mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 10:09:04 +00:00
moved out set current file from cloudfunc to client.js
This commit is contained in:
parent
ed4f497122
commit
9fb3f12495
4 changed files with 44 additions and 46 deletions
|
|
@ -37,6 +37,8 @@ would be on top.
|
|||
* Fixed bug with saving json to localStorage, it's always
|
||||
writed root directory.
|
||||
|
||||
* Moved out set current file from cloudfunc to client.js
|
||||
|
||||
|
||||
2012.03.01, Version 0.1.9
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
(function(Util, DOM){
|
||||
'use strict';
|
||||
|
||||
var Config, Modules;
|
||||
var Config, Modules, FileTemplate;
|
||||
|
||||
/* Клиентский обьект, содержащий функциональную часть*/
|
||||
var CloudCmd = {
|
||||
|
|
@ -44,6 +44,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
LIBDIR : '/lib/',
|
||||
LIBDIRCLIENT : '/lib/client/',
|
||||
JSONDIR : '/json/',
|
||||
HTMLDIR : '/html/',
|
||||
/* height of Cloud Commander
|
||||
* seting up in init()
|
||||
*/
|
||||
|
|
@ -378,26 +379,30 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
CloudCmd.KeyBinding();
|
||||
}
|
||||
|
||||
CloudCmd.getConfig = function(pCallBack){
|
||||
Util.ifExec(Config, pCallBack, function(pCallBack){
|
||||
DOM.ajax({
|
||||
url : CloudCmd.JSONDIR + 'config.json',
|
||||
success : function(pConfig){
|
||||
Config = pConfig;
|
||||
Util.exec(pCallBack, pConfig);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
CloudCmd.getModules = function(pCallBack){
|
||||
Util.ifExec(Modules, pCallBack, function(pCallBack){
|
||||
DOM.ajax({
|
||||
url : CloudCmd.JSONDIR + 'modules.json',
|
||||
success : Util.retExec(pCallBack)
|
||||
function getSystemFile(pGlobal, pURL){
|
||||
|
||||
function lGetSysFile(pCallBack){
|
||||
Util.ifExec(pGlobal, pCallBack, function(pCallBack){
|
||||
DOM.ajax({
|
||||
url : pURL,
|
||||
success : function(pLocal){
|
||||
pGlobal = pLocal;
|
||||
Util.exec(pCallBack, pLocal);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return lGetSysFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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.execFromModule = function(pModuleName, pFuncName, pParams){
|
||||
var lObject = CloudCmd[pModuleName];
|
||||
|
|
@ -579,7 +584,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
if (lJSON){
|
||||
/* переводим из текста в JSON */
|
||||
lJSON = Util.parseJSON(lJSON);
|
||||
CloudCmd._createFileTable(lPanel, lJSON, true);
|
||||
CloudCmd._createFileTable(lPanel, lJSON);
|
||||
CloudCmd._changeLinks(lPanel);
|
||||
}
|
||||
else
|
||||
|
|
@ -595,7 +600,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
},
|
||||
|
||||
success : function(pData){
|
||||
CloudCmd._createFileTable(lPanel, pData, true);
|
||||
CloudCmd._createFileTable(lPanel, pData);
|
||||
CloudCmd._changeLinks(lPanel);
|
||||
|
||||
/* переводим таблицу файлов в строку, для *
|
||||
|
|
@ -616,7 +621,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
* @param pEleme - родительский элемент
|
||||
* @param pJSON - данные о файлах
|
||||
*/
|
||||
CloudCmd._createFileTable = function(pElem, pJSON, pSetCurrent){
|
||||
CloudCmd._createFileTable = function(pElem, pJSON){
|
||||
var lElem = DOM.getById(pElem),
|
||||
/* getting current element if was refresh */
|
||||
lPath = DOM.getByClass('path', lElem),
|
||||
|
|
@ -635,11 +640,12 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
lElem.removeChild(lElem.lastChild);
|
||||
|
||||
/* заполняем панель новыми элементами */
|
||||
lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pSetCurrent);
|
||||
lElem.innerHTML = CloudFunc.buildFromJSON(pJSON);
|
||||
|
||||
var lFound;
|
||||
/* searching current file */
|
||||
if(lWasRefresh_b){
|
||||
var lFound, n = lElem.childNodes.length;
|
||||
var n = lElem.childNodes.length;
|
||||
for(i = 2; i < n ; i++){
|
||||
var lVarCurrent = lElem.childNodes[i],
|
||||
lVarName = DOM.getCurrentName(lVarCurrent);
|
||||
|
|
@ -651,12 +657,12 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!lFound) /* .. */
|
||||
lCurrent = lElem.childNodes[2];
|
||||
|
||||
DOM.setCurrentFile(lCurrent);
|
||||
}
|
||||
if(!lFound) /* .. */
|
||||
lCurrent = lElem.childNodes[2];
|
||||
|
||||
DOM.setCurrentFile(lCurrent);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ var CloudFunc, exports, Util;
|
|||
}
|
||||
|
||||
/* оставляем последние 3 символа*/
|
||||
pPerm_s = pPerm_s.length> 5 ?pPerm_s.substr(3) : pPerm_s.substr(2);
|
||||
pPerm_s = pPerm_s.length > 5 ? pPerm_s.substr(3) : pPerm_s.substr(2);
|
||||
|
||||
/* Рекомендации гугла советуют вместо string[3]
|
||||
* использовать string.charAt(3)
|
||||
|
|
@ -165,6 +165,7 @@ var CloudFunc, exports, Util;
|
|||
/* добавляем 2 цыфры до 5 */
|
||||
return '00' + lOwner + lGroup + lAll;
|
||||
};
|
||||
|
||||
/** Функция получает короткие размеры
|
||||
* конвертируя байт в килобайты, мегабойты,
|
||||
* гигайбайты и терабайты
|
||||
|
|
@ -294,7 +295,7 @@ var CloudFunc, exports, Util;
|
|||
* [{path:'путь',size:'dir'},
|
||||
* {name:'имя',size:'размер',mode:'права доступа'}]
|
||||
*/
|
||||
CloudFunc.buildFromJSON = function(pJSON, pSetCurrent)
|
||||
CloudFunc.buildFromJSON = function(pJSON)
|
||||
{
|
||||
var files = pJSON,
|
||||
/* сохраняем путь каталога в котором мы сейчас находимся*/
|
||||
|
|
@ -311,7 +312,6 @@ var CloudFunc, exports, Util;
|
|||
* если он есть
|
||||
*/
|
||||
lRefreshPath = CloudFunc.removeLastSlash(lPath),
|
||||
lFS_s = CloudFunc.FS,
|
||||
|
||||
lFileTable =
|
||||
'<li class=path>'+
|
||||
|
|
@ -321,7 +321,7 @@ var CloudFunc, exports, Util;
|
|||
'</span>' +
|
||||
'<span class="path-icon ' + CloudFunc.REFRESHICON + '"' +
|
||||
' title="refresh (Ctrl+R)">' +
|
||||
'<a href="' + lFS_s + lRefreshPath + '">' +
|
||||
'<a href="' + FS + lRefreshPath + '">' +
|
||||
'</a>' +
|
||||
'</span>' +
|
||||
'<span>' + lHtmlPath + '</span>' +
|
||||
|
|
@ -345,8 +345,7 @@ var CloudFunc, exports, Util;
|
|||
if(lDotDot === '')
|
||||
lDotDot = '/';
|
||||
|
||||
lLink = lFS_s + lDotDot;
|
||||
|
||||
lLink = FS + lDotDot;
|
||||
|
||||
/* Сохраняем путь к каталогу верхнего уровня*/
|
||||
lFileTable += '<li draggable class>' +
|
||||
|
|
@ -373,7 +372,7 @@ var CloudFunc, exports, Util;
|
|||
'">';
|
||||
lFileTable += '</span>';
|
||||
lFileTable += '<span draggable class=name>' +
|
||||
'<a href="' + lFS_s + lPath + files[i].name +
|
||||
'<a href="' + FS + lPath + files[i].name +
|
||||
'"' +
|
||||
/* открываем файлы */
|
||||
/*в новой вкладке */
|
||||
|
|
@ -405,15 +404,6 @@ var CloudFunc, exports, Util;
|
|||
lFileTable += '</li>';
|
||||
}
|
||||
|
||||
/* если клавиши назначены и
|
||||
* мы в корневом каталоге и
|
||||
* верхний файл еще не выделен -
|
||||
* выделяем верхний файл
|
||||
*/
|
||||
if(pSetCurrent)
|
||||
lFileTable = lFileTable.replace('<li draggable class>',
|
||||
'<li draggable class=current-file>');
|
||||
|
||||
return lFileTable;
|
||||
};
|
||||
})();
|
||||
|
|
@ -23,4 +23,4 @@
|
|||
"node": ">=0.4.x"
|
||||
},
|
||||
"main": "cloudcmd.js"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue