mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(commander) add changeOrder
This commit is contained in:
parent
41e124ad4c
commit
9df2503db5
2 changed files with 34 additions and 0 deletions
1
HELP.md
1
HELP.md
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue