feature(commander) change json structure: [path, files] -> {path: "", files: []}

This commit is contained in:
coderaiser 2013-12-02 11:04:46 +00:00
parent a3cfc0a7ea
commit c28bae15cc
3 changed files with 15 additions and 15 deletions

View file

@ -113,7 +113,7 @@
*/
function fillJSON(pParams) {
var name, stat, mode, isDir, size, uid,
p, i, n, file, path, json,
p, i, n, file, path, json, files,
ret = Util.checkObjTrue(pParams, ['files', 'stats', 'path']);
if (ret) {
@ -123,9 +123,11 @@
/* данные о файлах в формате JSON*/
file = {};
path = getDirPath(p.path);
json = [{
path : path
}];
json = {
path : path,
files : []
},
files = json.files;
for (i = 0; i < n; i++ ) {
/* Переводим права доступа в 8-ричную систему */
@ -142,19 +144,18 @@
/* Если папка - выводим пиктограмму папки *
* В противоположном случае - файла */
file = {
'name' : p.files[i],
'name' : name,
'size' : size,
'uid' : uid,
'mode' : mode
};
json.push(file);
files.push(file);
}
json = changeOrder(json);
files = changeOrder(files);
Util.exec(p.callback, null, json);
}
}
@ -163,11 +164,10 @@
files = [],
dirs = [],
current = [],
path = json[0],
sorted = [path];
sorted = [];
n = json.length;
for (i = 1; i < n; i++) {
for (i = 0; i < n; i++) {
current = json[i];
if (current.size === "dir")