1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 02:42:47 +00:00

[lib] modified new dir/file

This commit is contained in:
llj
2015-02-07 16:50:33 +08:00
committed by Daniel Pan
parent 1e3a18f6c9
commit 13d5730684
6 changed files with 148 additions and 82 deletions

View File

@@ -53,7 +53,6 @@ define([
case 'cp_file': return siteRoot + 'ajax/repo/' + options.repo_id + '/file/cp/';
case 'new_dir': return siteRoot + 'ajax/repo/' + options.repo_id + '/dir/new/';
case 'new_file': return siteRoot + 'ajax/repo/' + options.repo_id + '/file/new/';
case 'repo_new_file': return siteRoot + 'repo/' + options.repo_id + '/files/';
case 'del_dirents': return siteRoot + 'ajax/repo/' + options.repo_id + '/dirents/delete/';
case 'mv_dirents': return siteRoot + 'ajax/repo/' + options.repo_id + '/dirents/move/';
case 'cp_dirents': return siteRoot + 'ajax/repo/' + options.repo_id + '/dirents/copy/';
@@ -207,7 +206,7 @@ define([
});
},
HTMLescape: function(html){
HTMLescape: function(html) {
return document.createElement('div')
.appendChild(document.createTextNode(html))
.parentNode
@@ -223,7 +222,35 @@ define([
result += '/' + array[i];
}
return result;
}
},
fileSizeFormat: function (bytes, precision) {
var kilobyte = 1024;
var megabyte = kilobyte * 1024;
var gigabyte = megabyte * 1024;
var terabyte = gigabyte * 1024;
var precision = precision || 0;
if ((bytes >= 0) && (bytes < kilobyte)) {
return bytes + ' B';
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
return (bytes / kilobyte).toFixed(precision) + ' KB';
} else if ((bytes >= megabyte) && (bytes < gigabyte)) {
return (bytes / megabyte).toFixed(precision) + ' MB';
} else if ((bytes >= gigabyte) && (bytes < terabyte)) {
return (bytes / gigabyte).toFixed(precision) + ' GB';
} else if (bytes >= terabyte) {
return (bytes / terabyte).toFixed(precision) + ' TB';
} else {
return bytes + ' B';
}
}
}
});