feature(commander) add changeOrder

This commit is contained in:
coderaiser 2013-11-29 14:55:50 +00:00
parent 41e124ad4c
commit 9df2503db5
2 changed files with 34 additions and 0 deletions

View file

@ -394,3 +394,4 @@ Special Thanks
- [Elec-ua](https://github.com/elec-ua)
- [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations;
- config [template](html/config.html) and [style](css/config.css);
- change order of directories and files in [commander](lib/server/commander.js "Commander")

View file

@ -156,6 +156,39 @@
}
}
function changeOrder(json) {
var file, i, n,
files = [],
dirs = [],
current = [],
path = json[0],
sorted = [path];
n = json.length;
for (i = 1; i < n; i++) {
current = json[i];
if (current.size === "dir")
dirs.push(current);
else
files.push(current);
}
n = dirs.length;
for (i = 0; i < n; i++) {
current = dirs[i];
sorted.push(current);
}
n = files.length;
for (i = 0; i < n; i++) {
current = files[i];
sorted.push(current);
}
return sorted;
}
function getDirPath(pPath) {
var lRet = pPath;