Commit 57483b5b by Dányi Bence

one: human-readable filesizes

parent b7dc0d0a
...@@ -138,6 +138,13 @@ $(function() { ...@@ -138,6 +138,13 @@ $(function() {
} }
function addFile(d) { function addFile(d) {
function convert(n){
var suffix = 'B KB MB GB'.split(' ');
for(var i=0;n>1024;i++){
n/=1024;
}
return n.toFixed(2)+' '+suffix[i];
}
var viewData; var viewData;
if(d.TYPE === 'D') { if(d.TYPE === 'D') {
viewData = { viewData = {
...@@ -155,12 +162,13 @@ $(function() { ...@@ -155,12 +162,13 @@ $(function() {
viewData = { viewData = {
originalName: d.NAME, originalName: d.NAME,
name: d.NAME.length > 30 ? (d.NAME.substr(0, 27) + '...') : d.NAME, name: d.NAME.length > 30 ? (d.NAME.substr(0, 27) + '...') : d.NAME,
size: d.SIZE + 'K', size: convert(d.SIZE),
type: 'fájl', type: 'fájl',
mTime: d.MTIME, mTime: d.MTIME,
getTypeClass: 'name filetype-text', getTypeClass: 'name filetype-text',
clickHandler: function(item, event) {} clickHandler: function(item, event) {}
}; };
console.log(viewData);
} }
self.files.push(viewData); self.files.push(viewData);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment