From a4ef905bbd0bbec5d011ab62dc018af70d14038d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 15:04:45 +0000 Subject: [PATCH] feature(link) add --- cloudcmd.js | 8 +++++--- html/link.html | 1 + lib/client.js | 10 ++++++---- lib/cloudfunc.js | 7 +++---- 4 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 html/link.html diff --git a/cloudcmd.js b/cloudcmd.js index da518df0..3ace7ec0 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -30,8 +30,9 @@ FILE_TMPL = HTMLDIR + 'file.html', PATH_TMPL = HTMLDIR + 'path.html', + LINK_TMPL = HTMLDIR + 'path.html', - FileTemplate, PathTemplate, + FileTemplate, PathTemplate, LinkTemplate, FS = CloudFunc.FS; /* reinit main dir os if we on Win32 should be backslashes */ @@ -139,7 +140,7 @@ route : route }, - lFiles = [FILE_TMPL, PATH_TMPL]; + lFiles = [FILE_TMPL, PATH_TMPL, LINK_TMPL]; if (Config.ssl) lFiles.push(KEY, CERT); @@ -150,6 +151,7 @@ else { FileTemplate = pFiles[FILE_TMPL]; PathTemplate = pFiles[PATH_TMPL]; + LinkTemplate = pFiles[LINK_TMPL]; if (Config.ssl) lParams.ssl = { @@ -257,7 +259,7 @@ main.sendError(p, error); else { p.name = INDEX_PATH, - lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), + lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate), lList = '' + ''; diff --git a/html/link.html b/html/link.html new file mode 100644 index 00000000..c06af763 --- /dev/null +++ b/html/link.html @@ -0,0 +1 @@ +{{ name }} \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index 2bf7c051..6ebd8917 100644 --- a/lib/client.js +++ b/lib/client.js @@ -11,7 +11,7 @@ var Util, DOM, CloudFunc, CloudCmd; function CloudCmdProto(Util, DOM) { var Key, Config, Modules, Extensions, - FileTemplate, PathTemplate, Listeners, + FileTemplate, PathTemplate, LinkTemplate, Listeners, CloudCmd = this; Storage = DOM.Storage; @@ -284,6 +284,7 @@ var Util, DOM, CloudFunc, CloudCmd; this.getExt = getSystemFile(Extensions, CloudCmd.JSONDIR + 'ext.json'); this.getFileTemplate = getSystemFile(FileTemplate, CloudCmd.HTMLDIR + 'file.html'); this.getPathTemplate = getSystemFile(PathTemplate, CloudCmd.HTMLDIR + 'path.html'); + this.getLinkTemplate = getSystemFile(PathTemplate, CloudCmd.HTMLDIR + 'link.html'); this.execFromModule = function(pModuleName, pFuncName, pParams) { var lObject = CloudCmd[pModuleName]; @@ -401,17 +402,18 @@ var Util, DOM, CloudFunc, CloudCmd; lWasRefresh_b = lPath[0].textContent === pJSON.path, lFuncs = [ CloudCmd.getFileTemplate, - CloudCmd.getPathTemplate + CloudCmd.getPathTemplate, + CloudCmd.getLinkTemplate ]; - Util.asyncCall(lFuncs, function(pTemplate, pPathTemplate) { + Util.asyncCall(lFuncs, function(pTemplate, pPathTemplate, pLinkTemplate) { /* очищаем панель */ var i = lElem.childNodes.length; while(i--) lElem.removeChild(lElem.lastChild); - lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate); + lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate, pLinkTemplate); /* если нажали на ссылку на верхний каталог*/ var lFound; diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index a073a04f..f3b16e70 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -317,9 +317,8 @@ var Util; * [{path:'путь',size:'dir'}, * {name:'имя',size:'размер',mode:'права доступа'}] */ - this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate) { + this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate, pLinkTemplate) { var lFile, i, n, type, link, target, size, owner, mode, - linkTemplate = '{{ name }}', linkResult, files = pJSON.files, /* сохраняем путь каталога в котором мы сейчас находимся*/ @@ -367,7 +366,7 @@ var Util; lLink = FS + lDotDot; - linkResult = Util.render(linkTemplate, { + linkResult = Util.render(pLinkTemplate, { link : lLink, name : '..', target : '' @@ -395,7 +394,7 @@ var Util; mode = CloudFunc.getSymbolicPermissions(lFile.mode); - linkResult = Util.render(linkTemplate, { + linkResult = Util.render(pLinkTemplate, { link : link, name : lFile.name, target : target