From 8c96ad58c717e1b13d7af4de2df0bc1df207fb0a Mon Sep 17 00:00:00 2001 From: Ashley Teoh Date: Tue, 17 Apr 2018 11:41:09 -0400 Subject: [PATCH] cleanup --- notebook/static/base/js/utils.js | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) 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,25 +1041,19 @@ define([ var format_filesize = function(filesize) { if (filesize) { - return (convertFileSize(filesize)); + 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 convertFileSize = function(filesize){ - 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]; - - } - // javascript stores text as utf16 and string indices use "code units", // which stores high-codepoint characters as "surrogate pairs",