From 913fc2f7cec07f0eb212a4cb94c6faf0db4de7bb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 24 May 2014 12:06:13 -0400 Subject: [PATCH] feature(cloudfunc) buildFromJSON: change params --- cloudcmd.js | 10 +++++++++- lib/client.js | 12 +++++++++++- lib/cloudfunc.js | 22 ++++++++++++---------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 35d6215e..14c040e1 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -275,7 +275,15 @@ var panel, data; if (!error) { - panel = CloudFunc.buildFromJSON(json, FileTemplate, PathTemplate, LinkTemplate), + panel = CloudFunc.buildFromJSON({ + data: json, + template: { + file: FileTemplate, + path: PathTemplate, + link: LinkTemplate + } + }), + data = indexProcessing({ panel : panel, data : template, diff --git a/lib/client.js b/lib/client.js index 6178a5c1..c73cc00b 100644 --- a/lib/client.js +++ b/lib/client.js @@ -256,6 +256,7 @@ var Util, DOM, CloudFunc; Listeners.init(); /* загружаем Google Analytics */ Listeners.analytics(); + Listeners.changeLinks(LEFT); Listeners.changeLinks(RIGHT); @@ -419,7 +420,16 @@ var Util, DOM, CloudFunc; while(i--) panel.removeChild(panel.lastChild); - panel.innerHTML = CloudFunc.buildFromJSON(json, templFile, templPath, templLink); + panel.innerHTML = CloudFunc.buildFromJSON({ + data : json, + id : panel.id, + template : { + file : templFile, + path : templPath, + link : templLink + } + }); + files = DOM.getFiles(panel); /* searching current file */ diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index ba4a122e..53e998dd 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -363,15 +363,18 @@ var Util; /** * Функция строит таблицу файлв из JSON-информации о файлах - * @param json - информация о файлах + * @param params - информация о файлах * - * {name:'имя',size:'размер',mode:'права доступа'}] */ - this.buildFromJSON = function(json, template, pathTemplate, linkTemplate) { + this.buildFromJSON = function(params) { var file, i, n, type, attribute, size, owner, mode, /* ссылка на верхний каталог*/ dotDot, link, linkResult, + template = params.template, + templateFile = template.file, + templateLink = template.link, + json = params.data, files = json.files, /* сохраняем путь каталога в котором мы сейчас находимся*/ path = json.path, @@ -388,13 +391,13 @@ var Util; */ refreshPath = CloudFunc.rmLastSlash(path), - fileTable = Util.render(pathTemplate, { + fileTable = Util.render(template.path, { link : FS + refreshPath, fullPath : path, path : htmlPath }), - header = Util.render(template, { + header = Util.render(templateFile, { tag : 'div', attribute : '', className : 'fm-header', @@ -422,13 +425,13 @@ var Util; link = FS + dotDot; - linkResult = Util.render(linkTemplate, { + linkResult = Util.render(template.link, { link : link, name : '..' }); /* Сохраняем путь к каталогу верхнего уровня*/ - fileTable += Util.render(template, { + fileTable += Util.render(template.file, { tag : 'li', attribute : 'draggable="true" ', className : '', @@ -458,14 +461,13 @@ var Util; owner = file.owner || 'root'; mode = CloudFunc.getSymbolicPermissions(file.mode); - linkResult = Util.render(linkTemplate, { + linkResult = Util.render(templateLink, { link : link, name : file.name, attribute : attribute }); - - fileTable += Util.render(template,{ + fileTable += Util.render(templateFile, { tag : 'li', attribute : 'draggable="true" ', className : '',