mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added path template
This commit is contained in:
parent
34d7a1b89e
commit
4fb7815583
4 changed files with 41 additions and 34 deletions
12
cloudcmd.js
12
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 = '<ul id=left class=panel>' + lPanel + '</ul>' +
|
||||
'<ul id=right class=panel>' + lPanel + '</ul>';
|
||||
|
||||
|
|
|
|||
7
html/path.html
Normal file
7
html/path.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<li class=path>
|
||||
<span class="path-icon clear-cache" id=clear-cache title="clear cache (Ctrl+D)"> </span>
|
||||
<span class="path-icon refresh-icon" title="refresh (Ctrl+R)">
|
||||
<a href="{link}"> + </a>
|
||||
</span>
|
||||
<span>{path}</span>
|
||||
</li>,
|
||||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
'<li class=path>'+
|
||||
'<span class="path-icon clear-cache"' +
|
||||
'id=clear-cache ' +
|
||||
'title="clear cache (Ctrl+D)">' +
|
||||
'</span>' +
|
||||
'<span class="path-icon ' + CloudFunc.REFRESHICON + '"' +
|
||||
' title="refresh (Ctrl+R)">' +
|
||||
'<a href="' + FS + lRefreshPath + '">' +
|
||||
'</a>' +
|
||||
'</span>' +
|
||||
'<span>' + lHtmlPath + '</span>' +
|
||||
'</li>',
|
||||
lFileTable = Util.render(pPathTemplate, {
|
||||
link: FS + lRefreshPath,
|
||||
path: lHtmlPath
|
||||
}),
|
||||
|
||||
fileTableTitles = ['name','size','owner','mode'];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue