Browse Source

HUE-8687 [frontend] Fix sprintf in ko

jdesjean 6 years ago
parent
commit
5321892898

+ 2 - 2
desktop/core/src/desktop/js/ko/bindings/ko.bytesize.js

@@ -44,12 +44,12 @@ ko.bindingHandlers.bytesize = (function() {
 
 
       // Special case small numbers (including 0), because they're exact.
       // Special case small numbers (including 0), because they're exact.
       if (bytes < 1024) {
       if (bytes < 1024) {
-        return sprintf('%d B', bytes);
+        return sprintf.sprintf('%d B', bytes);
       }
       }
 
 
       let index = Math.floor(that.getBaseLog(bytes, 1024));
       let index = Math.floor(that.getBaseLog(bytes, 1024));
       index = Math.min(that.units.length - 1, index);
       index = Math.min(that.units.length - 1, index);
-      return sprintf('%.1f %s', bytes / Math.pow(1024, index), that.units[index]);
+      return sprintf.sprintf('%.1f %s', bytes / Math.pow(1024, index), that.units[index]);
     }
     }
   });
   });
 })();
 })();

+ 6 - 6
desktop/core/src/desktop/js/ko/bindings/ko.duration.js

@@ -35,16 +35,16 @@ ko.bindingHandlers.duration = (function() {
     humanTime: function(value) {
     humanTime: function(value) {
       value = value * 1;
       value = value * 1;
       if (value < Math.pow(10, 3)) {
       if (value < Math.pow(10, 3)) {
-        return sprintf('%i ns', value);
+        return sprintf.sprintf('%i ns', value);
       } else if (value - Math.pow(10, 6) < -Math.pow(10, 3) / 2) {
       } else if (value - Math.pow(10, 6) < -Math.pow(10, 3) / 2) {
         // Make sure rounding doesn't cause numbers to have more than 4 significant digits.
         // Make sure rounding doesn't cause numbers to have more than 4 significant digits.
         value = (value * 1.0) / Math.pow(10, 3);
         value = (value * 1.0) / Math.pow(10, 3);
         const sprint = value > 100 ? '%i us' : '%.1f us';
         const sprint = value > 100 ? '%i us' : '%.1f us';
-        return sprintf(sprint, value);
+        return sprintf.sprintf(sprint, value);
       } else if (value - Math.pow(10, 9) < -Math.pow(10, 6) / 2) {
       } else if (value - Math.pow(10, 9) < -Math.pow(10, 6) / 2) {
         value = (value * 1.0) / Math.pow(10, 6);
         value = (value * 1.0) / Math.pow(10, 6);
         const sprint = value > 100 ? '%i ms' : '%.1f ms';
         const sprint = value > 100 ? '%i ms' : '%.1f ms';
-        return sprintf(sprint, value);
+        return sprintf.sprintf(sprint, value);
       } else {
       } else {
         // get the ms value
         // get the ms value
         const SECOND = 1;
         const SECOND = 1;
@@ -54,19 +54,19 @@ ko.bindingHandlers.duration = (function() {
         let buffer = '';
         let buffer = '';
 
 
         if (value > HOUR) {
         if (value > HOUR) {
-          buffer += sprintf('%i h', value / HOUR);
+          buffer += sprintf.sprintf('%i h', value / HOUR);
           value = value % HOUR;
           value = value % HOUR;
         }
         }
 
 
         if (buffer.length < 4 && value > MINUTE) {
         if (buffer.length < 4 && value > MINUTE) {
           const sprint = buffer.length ? ' %i m' : '%i m';
           const sprint = buffer.length ? ' %i m' : '%i m';
-          buffer += sprintf(sprint, value / MINUTE);
+          buffer += sprintf.sprintf(sprint, value / MINUTE);
           value = value % MINUTE;
           value = value % MINUTE;
         }
         }
 
 
         if (buffer.length < 4 && value > SECOND) {
         if (buffer.length < 4 && value > SECOND) {
           const sprint = buffer.length ? ' %i s' : '%.1f s';
           const sprint = buffer.length ? ' %i s' : '%.1f s';
-          buffer += sprintf(sprint, (value * 1.0) / SECOND);
+          buffer += sprintf.sprintf(sprint, (value * 1.0) / SECOND);
         }
         }
         return buffer;
         return buffer;
       }
       }

+ 2 - 2
desktop/core/src/desktop/js/ko/bindings/ko.simplesize.js

@@ -44,12 +44,12 @@ ko.bindingHandlers.simplesize = (function() {
 
 
       // Special case small numbers (including 0), because they're exact.
       // Special case small numbers (including 0), because they're exact.
       if (bytes < 1000) {
       if (bytes < 1000) {
-        return sprintf('%d', bytes);
+        return sprintf.sprintf('%d', bytes);
       }
       }
 
 
       let index = Math.floor(that.getBaseLog(bytes, 1000));
       let index = Math.floor(that.getBaseLog(bytes, 1000));
       index = Math.min(that.units.length - 1, index);
       index = Math.min(that.units.length - 1, index);
-      return sprintf('%.1f %s', bytes / Math.pow(1000, index), that.units[index]);
+      return sprintf.sprintf('%.1f %s', bytes / Math.pow(1000, index), that.units[index]);
     }
     }
   });
   });
 })();
 })();