diff --git a/notebook/static/base/js/utils.js b/notebook/static/base/js/utils.js index a1074e6b4..588e6edd0 100644 --- a/notebook/static/base/js/utils.js +++ b/notebook/static/base/js/utils.js @@ -1041,26 +1041,20 @@ define([ var format_filesize = function(filesize) { if (filesize) { - return (convertFileSize(filesize)); - } - } - - var convertFileSize = function(filesize){ - var units = ['B', 'kB', 'MB', 'GB', 'TB']; - var base = 1000; - if (Math.abs(filesize) < base){ - return filesize + " B"; + var units = ['B', 'kB', 'MB', 'GB', 'TB']; + var base = 1000; + if (Math.abs(filesize) < base){ + return filesize + " B"; + } + var u = -1; + do { + filesize /= base; + u++; + } while(Math.abs(filesize) >= base && u < units.length - 1); + return filesize.toFixed(1) + " " + units[u]; } - var u = -1; - do{ - filesize /= base; - u++; - } while(Math.abs(filesize) >= base && u < units.length - 1); - return filesize.toFixed(1) + " " + units[u]; - } - // javascript stores text as utf16 and string indices use "code units", // which stores high-codepoint characters as "surrogate pairs", // which occupy two indices in the javascript string.