diff --git a/HELP.md b/HELP.md index 53605e79..7a4790dd 100644 --- a/HELP.md +++ b/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") diff --git a/lib/server/commander.js b/lib/server/commander.js index d0c24b5e..95bffc31 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -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;