function sinceCount(obj){//科學計數顯示
var num = (obj.next().find(".myJqmeterTarget").text()||0).toString(),result = '';
while(num.length > 3){
result = ','+num.slice(-3) + result;
num = num.slice(0,num.length - 3);
}
if(num){result = num+result;}
obj.next().find(".myJqmeterTarget").text(result);
}
存在小数点的情况
function sinceCount(num){
var num = num.toString();
var arr = num.split(".");
num = arr[0];
var result = "";
while (num.length > 3) {
result = "," + num.slice(-3) + result;
num = num.slice(0,num.length-3);
}
if(num){result = num+result};
if(!!arr[1]){
result+="."arr[1];
}
return result;
}
//计算数据大小单位
function bytesToSize(bytes) {
if (bytes === 0) return '0 B';
let k = 1024, // or 1024
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
}