From 4fb78155830cae29596e2389e85a5fc2da8b444d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Mar 2013 07:18:26 -0400 Subject: [PATCH] added path template --- cloudcmd.js | 12 ++++++++---- html/path.html | 7 +++++++ lib/client.js | 37 +++++++++++++++++++++---------------- lib/cloudfunc.js | 19 +++++-------------- 4 files changed, 41 insertions(+), 34 deletions(-) create mode 100644 html/path.html diff --git a/cloudcmd.js b/cloudcmd.js index 3ca5b066..9822e120 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -28,7 +28,9 @@ CERT = DIR + 'ssl/ssl.crt', TEMPLATEPATH= HTMLDIR + 'file.html', - Template, + PATHTEMPLATE_PATH = HTMLDIR + 'path.html', + + Template, PathTemplate, FS = CloudFunc.FS; /* reinit main dir os if we on @@ -187,7 +189,7 @@ route : route }; - var lFiles = [TEMPLATEPATH]; + var lFiles = [TEMPLATEPATH, PATHTEMPLATE_PATH]; if(Config.ssl) lFiles.push(CA, KEY, CERT); @@ -196,7 +198,9 @@ if(pErrors) Util.log(pErrors); else{ - Template = pFiles[TEMPLATEPATH].toString(); + Template = pFiles[TEMPLATEPATH].toString(); + PathTemplate = pFiles[PATHTEMPLATE_PATH].toString(); + if(Config.ssl) lParams.ssl = { ca : pFiles[CA], @@ -306,7 +310,7 @@ p.name = Minify.allowed.html ? Minify.getName(INDEX) : INDEX; fs.readFile(p.name, function(pError, pData){ if(!pError){ - var lPanel = CloudFunc.buildFromJSON(pJSON, Template), + var lPanel = CloudFunc.buildFromJSON(pJSON, Template, PathTemplate), lList = '' + ''; diff --git a/html/path.html b/html/path.html new file mode 100644 index 00000000..3c6a8054 --- /dev/null +++ b/html/path.html @@ -0,0 +1,7 @@ +
  • + + + + + + {path} +
  • , \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index d7928906..41c32ef7 100644 --- a/lib/client.js +++ b/lib/client.js @@ -7,7 +7,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; (function(Util, DOM){ 'use strict'; - var Config, Modules, FileTemplate; + var Config, Modules, FileTemplate, PathTemplate; /* Клиентский обьект, содержащий функциональную часть*/ var CloudCmd = { @@ -384,13 +384,14 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; function lGetSysFile(pCallBack){ Util.ifExec(pGlobal, pCallBack, function(pCallBack){ - DOM.ajax({ - url : pURL, - success : function(pLocal){ - pGlobal = pLocal; - Util.exec(pCallBack, pLocal); - } - }); + if(!pGlobal) + DOM.ajax({ + url : pURL, + success : function(pLocal){ + pGlobal = pLocal; + Util.exec(pCallBack, pLocal); + } + }); }); } @@ -402,7 +403,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; CloudCmd.getConfig = getSystemFile(Config, CloudCmd.JSONDIR + 'config.json'); CloudCmd.getModules = getSystemFile(Modules, CloudCmd.JSONDIR + 'modules.json'); CloudCmd.getFileTemplate = getSystemFile(FileTemplate, CloudCmd.HTMLDIR + 'file.html'); - + CloudCmd.getpPathTemplate = getSystemFile(PathTemplate, CloudCmd.HTMLDIR + 'path.html'); CloudCmd.execFromModule = function(pModuleName, pFuncName, pParams){ var lObject = CloudCmd[pModuleName]; @@ -586,8 +587,10 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; lJSON = Util.parseJSON(lJSON); CloudCmd.getFileTemplate(function(pTemplate){ - CloudCmd._createFileTable(lPanel, lJSON, pTemplate); - CloudCmd._changeLinks(lPanel); + CloudCmd.getpPathTemplate(function(pPathTemplate){ + CloudCmd._createFileTable(lPanel, lJSON, pTemplate, pPathTemplate); + CloudCmd._changeLinks(lPanel); + }); }); } else @@ -604,9 +607,11 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; success : function(pData){ CloudCmd.getFileTemplate(function(pTemplate){ - CloudCmd._createFileTable(lPanel, pData, pTemplate); - CloudCmd._changeLinks(lPanel); - }); + CloudCmd.getpPathTemplate(function(pPathTemplate){ + CloudCmd._createFileTable(lPanel, lJSON, pTemplate, pPathTemplate); + CloudCmd._changeLinks(lPanel); + }); + }); /* переводим таблицу файлов в строку, для * * сохранения в localStorage */ @@ -626,7 +631,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; * @param pEleme - родительский элемент * @param pJSON - данные о файлах */ - CloudCmd._createFileTable = function(pElem, pJSON, pTemplate){ + CloudCmd._createFileTable = function(pElem, pJSON, pTemplate, pPathTemplate){ var lElem = DOM.getById(pElem), /* getting current element if was refresh */ lPath = DOM.getByClass('path', lElem), @@ -641,7 +646,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; while(i--) lElem.removeChild(lElem.lastChild); /* заполняем панель новыми элементами */ - lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate); + lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate); var lFound; /* searching current file */ diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 18cd7330..47c5be37 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -295,7 +295,7 @@ var CloudFunc, exports, Util; * [{path:'путь',size:'dir'}, * {name:'имя',size:'размер',mode:'права доступа'}] */ - CloudFunc.buildFromJSON = function(pJSON, pTemplate) + CloudFunc.buildFromJSON = function(pJSON, pTemplate, pPathTemplate) { var files = pJSON, /* сохраняем путь каталога в котором мы сейчас находимся*/ @@ -313,19 +313,10 @@ var CloudFunc, exports, Util; */ lRefreshPath = CloudFunc.removeLastSlash(lPath), - lFileTable = - '
  • '+ - '' + - '' + - '' + - '' + - '' + - '' + - '' + lHtmlPath + '' + - '
  • ', + lFileTable = Util.render(pPathTemplate, { + link: FS + lRefreshPath, + path: lHtmlPath + }), fileTableTitles = ['name','size','owner','mode'];