friendica-github/view/theme/frio/js/dropzone-frio.js
Jakobus Schürz 3688196859 create workaround for not working php
Strings:getBytesFromShorthand

i created a js-function which converts integer, k, m and g to MB
Just remove this code, when we found out, why Strings is in some files
not working.
2023-03-19 18:52:45 +01:00

24 lines
400 B
JavaScript

function isInteger(value) {
return /^\d+$/.test(value);
}
function getMBytes(value) {
var res;
if (isInteger(value)) {
res = value;
} else {
eh = value.slice(-1);
am = Number(value.slice(0, -1));
switch (eh) {
case 'k':
res = am * 1024;
break;
case 'm':
res = am * 1024 * 1024;
break;
case 'g':
res = am * 1024 * 1024 * 1024;
}
}
return res / 1000000;
}