From c28bae15cc18b3c1ed811d075a30e1e232ff7585 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 11:04:46 +0000 Subject: [PATCH] feature(commander) change json structure: [path, files] -> {path: "", files: []} --- lib/client.js | 2 +- lib/cloudfunc.js | 6 +++--- lib/server/commander.js | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/client.js b/lib/client.js index 771ba0ba..95990829 100644 --- a/lib/client.js +++ b/lib/client.js @@ -398,7 +398,7 @@ var Util, DOM, CloudFunc, CloudCmd; lDir = DOM.getCurrentDirName(), lName = DOM.getCurrentName(lCurrent), - lWasRefresh_b = lPath[0].textContent === pJSON[0].path, + lWasRefresh_b = lPath[0].textContent === pJSON.path, lFuncs = [ CloudCmd.getFileTemplate, CloudCmd.getPathTemplate diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 4181905b..b87324b3 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -334,9 +334,9 @@ var Util; * {name:'имя',size:'размер',mode:'права доступа'}] */ this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate) { - var files = pJSON, + var files = pJSON.files, /* сохраняем путь каталога в котором мы сейчас находимся*/ - lPath = files[0].path, + lPath = pJSON.path, /* * Строим путь каталога в котором мы находимся @@ -387,7 +387,7 @@ var Util; }); } - for(var i = 1, n = files.length; i < n; i++) { + for(var i = 0, n = files.length; i < n; i++) { var lFile = files[i]; lFileTable += Util.render(pTemplate,{ diff --git a/lib/server/commander.js b/lib/server/commander.js index 832034d6..b1c54a66 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -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")