[pve-devel] [PATCH 2/8] format_size: optionally specify decimal place

Stefan Priebe s.priebe at profihost.ag
Wed Apr 24 10:45:18 CEST 2013


Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
---
 www/manager/Utils.js |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/www/manager/Utils.js b/www/manager/Utils.js
index 97c62b1..38d890f 100644
--- a/www/manager/Utils.js
+++ b/www/manager/Utils.js
@@ -502,7 +502,7 @@ Ext.define('PVE.Utils', { statics: {
 	return task;
     },
 
-    format_size: function(size) {
+    format_size: function(size, sl) {
 	/*jslint confusion: true */
 
 	if (size < 1024) {
@@ -512,24 +512,24 @@ Ext.define('PVE.Utils', { statics: {
 	var kb = size / 1024;
 
 	if (kb < 1024) {
-	    return kb.toFixed(0) + "KB";
+	    return kb.toFixed(!Ext.isNumeric(sl) ? 0 : sl) + "KB";
 	}
 
 	var mb = size / (1024*1024);
 
 	if (mb < 1024) {
-	    return mb.toFixed(0) + "MB";
+	    return mb.toFixed(!Ext.isNumeric(sl) ? 0 : sl) + "MB";
 	}
 
 	var gb = mb / 1024;
 
 	if (gb < 1024) {
-	    return gb.toFixed(2) + "GB";
+	    return gb.toFixed(!Ext.isNumeric(sl) ? 2 : sl) + "GB";
 	}
 
 	var tb =  gb / 1024;
 
-	return tb.toFixed(2) + "TB";
+	return tb.toFixed(!Ext.isNumeric(sl) ? 2 : sl) + "TB";
 
     },
 
-- 
1.7.10.4




More information about the pve-devel mailing list