diff --git a/src/resources/index.html b/src/resources/index.html index a209793..0ed94f3 100644 --- a/src/resources/index.html +++ b/src/resources/index.html @@ -222,7 +222,7 @@
Artifacts
diff --git a/src/resources/js/app.js b/src/resources/js/app.js index 78fc86c..13eb2b1 100644 --- a/src/resources/js/app.js +++ b/src/resources/js/app.js @@ -3,35 +3,12 @@ * https://laminar.ohwg.net */ -// usage: {{ file.size | prettyBytes }} -// source: https://gist.github.com/james2doyle/4aba55c22f084800c199 -Vue.filter('prettyBytes', function (num) { - // jacked from: https://github.com/sindresorhus/pretty-bytes - if (typeof num !== 'number' || isNaN(num)) { - throw new TypeError('Expected a number'); - } - - var exponent; - var unit; - var neg = num < 0; - var units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - - if (neg) { - num = -num; - } - - if (num < 1) { - return (neg ? '-' : '') + num + ' B'; - } - - exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1); - num = (num / Math.pow(1000, exponent)).toFixed(2) * 1; - unit = units[exponent]; - - return (neg ? '-' : '') + num + ' ' + unit; +Vue.filter('iecFileSize', function(bytes) { + var exp = Math.floor(Math.log(bytes) / Math.log(1024)); + return (bytes / Math.pow(1024, exp)).toFixed(1) + ' ' + + ['B', 'KiB', 'MiB', 'GiB', 'TiB'][exp]; }); - const wsp = function(path) { return new WebSocket((location.protocol === 'https:'?'wss://':'ws://') + location.host + path);