feature(cloudfunc) buildFromJSON: change params

This commit is contained in:
coderaiser 2014-05-24 12:06:13 -04:00
parent 1cbd959a46
commit 913fc2f7ce
3 changed files with 32 additions and 12 deletions

View file

@ -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,

View file

@ -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 */

View file

@ -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 : '',