mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
changed if( -> if (
This commit is contained in:
parent
6bf2d02e61
commit
c7dd643e18
5 changed files with 226 additions and 212 deletions
48
cloudcmd.js
48
cloudcmd.js
|
|
@ -53,7 +53,7 @@
|
|||
* меняем в index.html обычные css на
|
||||
* минифицированый
|
||||
*/
|
||||
if(Minify.allowed.css){
|
||||
if (Minify.allowed.css){
|
||||
var lPath = '/' + Util.removeStr(Minify.MinFolder, DIR),
|
||||
lReplace = '<link rel=stylesheet href="/css/reset.css">';
|
||||
lData = Util.removeStr(lData, lReplace)
|
||||
|
|
@ -65,10 +65,10 @@
|
|||
fm : lAdditional
|
||||
});
|
||||
|
||||
if(!Config.appcache)
|
||||
if (!Config.appcache)
|
||||
lData = Util.removeStr(lData, ' manifest="/cloudcmd.appcache"');
|
||||
|
||||
if(!Config.show_keys_panel){
|
||||
if (!Config.show_keys_panel){
|
||||
var lKeysPanel = '<div id=keyspanel';
|
||||
lData = lData.replace(lKeysPanel, lKeysPanel +' class=hidden');
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
lFiles[0][lFONT_REMOTE] = lFONT_LOCAL;
|
||||
lFiles[1][lJQUERY_REMOTE] = lJQUERY_LOCAL;
|
||||
|
||||
if(Config.minification.css)
|
||||
if (Config.minification.css)
|
||||
lFiles.push('node_modules/minify/min/all.min.css');
|
||||
|
||||
AppCache.addFiles(lFiles);
|
||||
|
|
@ -141,7 +141,7 @@
|
|||
}
|
||||
|
||||
function init(){
|
||||
if(update)
|
||||
if (update)
|
||||
update.get();
|
||||
|
||||
/* Determining server.js directory
|
||||
|
|
@ -151,14 +151,14 @@
|
|||
*/
|
||||
var lServerDir = path.dirname(process.argv[1]) + '/';
|
||||
|
||||
if( DIR !== lServerDir ){
|
||||
if ( DIR !== lServerDir ){
|
||||
Util.log('current dir: ' + DIR);
|
||||
process.chdir(lServerDir);
|
||||
}
|
||||
Util.log('server dir: ' + lServerDir);
|
||||
Util.log('reading configuration file config.json...');
|
||||
|
||||
if(Config){
|
||||
if (Config){
|
||||
Util.log('config.json readed');
|
||||
|
||||
/* if command line parameter testing resolved
|
||||
|
|
@ -178,7 +178,7 @@
|
|||
writeLogsToFile();
|
||||
}
|
||||
|
||||
if(Config.server)
|
||||
if (Config.server)
|
||||
fs.watch(CONFIG_PATH, function(){
|
||||
/* every catch up - calling twice */
|
||||
setTimeout(function() {
|
||||
|
|
@ -194,17 +194,17 @@
|
|||
},
|
||||
lFiles = [FILE_TMPL, PATH_TMPL];
|
||||
|
||||
if(Config.ssl)
|
||||
if (Config.ssl)
|
||||
lFiles.push(CA, KEY, CERT);
|
||||
|
||||
main.readFiles(lFiles, function(pErrors, pFiles){
|
||||
if(pErrors)
|
||||
if (pErrors)
|
||||
Util.log(pErrors);
|
||||
else{
|
||||
FileTemplate = pFiles[FILE_TMPL].toString();
|
||||
PathTemplate = pFiles[PATH_TMPL].toString();
|
||||
|
||||
if(Config.ssl)
|
||||
if (Config.ssl)
|
||||
lParams.ssl = {
|
||||
ca : pFiles[CA],
|
||||
key : pFiles[KEY],
|
||||
|
|
@ -221,13 +221,13 @@
|
|||
|
||||
function readConfig(pCallBack){
|
||||
fs.readFile(CONFIG_PATH, function(pError, pData){
|
||||
if(!pError){
|
||||
if (!pError){
|
||||
Util.log('config: readed');
|
||||
|
||||
var lStr = pData.toString(),
|
||||
lReadedConf = Util.parseJSON(lStr);
|
||||
|
||||
if(!Config.minification)
|
||||
if (!Config.minification)
|
||||
main.config = Config = lReadedConf;
|
||||
|
||||
Util.tryCatchLog(function(){
|
||||
|
|
@ -250,19 +250,19 @@
|
|||
function route(pParams){
|
||||
var lRet = main.checkParams(pParams);
|
||||
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var p = pParams;
|
||||
|
||||
if( Util.strCmp(p.name, ['/auth', '/auth/github']) ){
|
||||
if ( Util.strCmp(p.name, ['/auth', '/auth/github']) ){
|
||||
Util.log('* Routing' +
|
||||
'-> ' + p.name);
|
||||
|
||||
pParams.name = main.HTMLDIR + p.name + '.html';
|
||||
lRet = main.sendFile( pParams );
|
||||
}
|
||||
else if( Util.isContainStrAtBegin(p.name, FS) || Util.strCmp( p.name, '/') ){
|
||||
else if ( Util.isContainStrAtBegin(p.name, FS) || Util.strCmp( p.name, '/') ){
|
||||
|
||||
if( Util.isContainStrAtBegin(p.name, FS + 'no-js/') ){
|
||||
if ( Util.isContainStrAtBegin(p.name, FS + 'no-js/') ){
|
||||
var lURL = Util.removeStr(pParams.name, 'no-js/');
|
||||
return main.redirect(pParams, lURL);
|
||||
}
|
||||
|
|
@ -279,13 +279,13 @@
|
|||
|
||||
function sendCommanderContent(pParams){
|
||||
var lRet = main.checkParams(pParams);
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var p = pParams;
|
||||
p.name = Util.removeStrOneTime(p.name, CloudFunc.FS) || main.SLASH;
|
||||
|
||||
fs.stat(p.name, function(pError, pStat){
|
||||
if(!pError)
|
||||
if( pStat.isDirectory() )
|
||||
if (!pError)
|
||||
if ( pStat.isDirectory() )
|
||||
processCommanderContent(pParams);
|
||||
else
|
||||
main.sendFile(p);
|
||||
|
|
@ -301,12 +301,12 @@
|
|||
function processCommanderContent(pParams){
|
||||
var lRet = main.checkParams(pParams);
|
||||
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var p = pParams;
|
||||
main.commander.getDirContent(p.name, function(pError, pJSON){
|
||||
if(!pError){
|
||||
if (!pError){
|
||||
var lQuery = main.getQuery(p.request);
|
||||
if( Util.isContainStr(lQuery, 'json') ){
|
||||
if ( Util.isContainStr(lQuery, 'json') ){
|
||||
p.data = Util.stringifyJSON(pJSON);
|
||||
p.name +='.json';
|
||||
main.sendResponse(p);
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
else{ /* get back html*/
|
||||
p.name = Minify.allowed.html ? Minify.getName(INDEX) : INDEX;
|
||||
fs.readFile(p.name, function(pError, pData){
|
||||
if(!pError){
|
||||
if (!pError){
|
||||
var lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate),
|
||||
lList = '<ul id=left class=panel>' + lPanel + '</ul>' +
|
||||
'<ul id=right class=panel>' + lPanel + '</ul>';
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
DOM.hide(lErrorImage);
|
||||
|
||||
var lCurrent;
|
||||
if(pPosition && pPosition.top)
|
||||
if (pPosition && pPosition.top)
|
||||
lCurrent = DOM.getRefreshButton().parentElement;
|
||||
else{
|
||||
var lFile = DOM.getCurrentFile();
|
||||
|
|
@ -56,7 +56,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
/* show loading icon if it not showed */
|
||||
|
||||
var lParent = lLoadingImage.parentElement;
|
||||
if(!lParent || (lParent && lParent !== lCurrent))
|
||||
if (!lParent || (lParent && lParent !== lCurrent))
|
||||
lCurrent.appendChild(lLoadingImage);
|
||||
|
||||
lRet_b = DOM.show(lLoadingImage); /* показываем загрузку*/
|
||||
|
|
@ -83,11 +83,11 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lText = (lStatus === 404 ? lResponce : lStatusText);
|
||||
|
||||
/* если файла не существует*/
|
||||
if( Util.isContainStr(lText, 'Error: ENOENT, ') )
|
||||
if ( Util.isContainStr(lText, 'Error: ENOENT, ') )
|
||||
lText = lText.replace('Error: ENOENT, n','N');
|
||||
|
||||
/* если не хватает прав для чтения файла*/
|
||||
else if( Util.isContainStr(lText, 'Error: EACCES,') )
|
||||
else if ( Util.isContainStr(lText, 'Error: EACCES,') )
|
||||
lText = lText.replace('Error: EACCES, p','P');
|
||||
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lErrorImage.title = lText;
|
||||
|
||||
var lParent = lLoadingImage.parentElement;
|
||||
if(lParent)
|
||||
if (lParent)
|
||||
lParent.appendChild(lErrorImage);
|
||||
|
||||
DOM.hide(lLoadingImage);
|
||||
|
|
@ -154,17 +154,17 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
|
||||
function sendRequest(pParams){
|
||||
var lRet = Util.checkObjTrue(pParams, ['method']);
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var p = pParams;
|
||||
|
||||
Images.showLoad( p.imgPosition );
|
||||
CloudCmd.getConfig(function(pConfig){
|
||||
var lData;
|
||||
|
||||
if( Util.isString(p.url) )
|
||||
if ( Util.isString(p.url) )
|
||||
p.url = decodeURI(p.url);
|
||||
|
||||
if( p.data && !Util.isString(p.data))
|
||||
if ( p.data && !Util.isString(p.data))
|
||||
lData = Util.stringifyJSON(p.data);
|
||||
else
|
||||
lData = p.data;
|
||||
|
|
@ -197,11 +197,11 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.addClass = function(pElement, pClass){
|
||||
var lRet;
|
||||
|
||||
if(pElement){
|
||||
if (pElement){
|
||||
var lClassList = pElement.classList;
|
||||
lRet = !this.isContainClass(pElement, pClass);
|
||||
|
||||
if( lRet )
|
||||
if ( lRet )
|
||||
lClassList.add(pClass);
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lRet,
|
||||
lClassList = pElement && pElement.classList;
|
||||
|
||||
if( lClassList )
|
||||
if ( lClassList )
|
||||
lRet = lClassList.contains(pClass);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -371,7 +371,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
|
||||
lEvent.initEvent(pEventName, true, true);
|
||||
|
||||
if(pKeyCode)
|
||||
if (pKeyCode)
|
||||
lEvent.keyCode = pKeyCode;
|
||||
|
||||
lEvent.isDefaultPrevented = function(){
|
||||
|
|
@ -470,15 +470,15 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
|
||||
lEventProcess = lEventProcess.bind(lElement);
|
||||
|
||||
if(lRet){
|
||||
if(Util.isString(pType) )
|
||||
if (lRet){
|
||||
if (Util.isString(pType) )
|
||||
lEventProcess(
|
||||
pType,
|
||||
pListener,
|
||||
pUseCapture
|
||||
);
|
||||
else if(Util.isObject(pType)){
|
||||
if(pListener)
|
||||
else if (Util.isObject(pType)){
|
||||
if (pListener)
|
||||
pElement = pListener;
|
||||
|
||||
for(lEvent in pType)
|
||||
|
|
@ -515,7 +515,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.remove = function(pItem){
|
||||
var lRet = this;
|
||||
|
||||
if(CacheAllowed)
|
||||
if (CacheAllowed)
|
||||
localStorage.removeItem(pItem);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -528,7 +528,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.set = function(pName, pData){
|
||||
var lRet = this;
|
||||
|
||||
if(CacheAllowed && pName && pData)
|
||||
if (CacheAllowed && pName && pData)
|
||||
localStorage.setItem(pName,pData);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -538,7 +538,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.get = function(pName){
|
||||
var lRet;
|
||||
|
||||
if(CacheAllowed)
|
||||
if (CacheAllowed)
|
||||
lRet = localStorage.getItem(pName);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -548,7 +548,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.getAll = function(){
|
||||
var lRet = null;
|
||||
|
||||
if(CacheAllowed)
|
||||
if (CacheAllowed)
|
||||
lRet = localStorage;
|
||||
|
||||
return lRet;
|
||||
|
|
@ -558,7 +558,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.clear = function(){
|
||||
var lRet = this;
|
||||
|
||||
if(CacheAllowed)
|
||||
if (CacheAllowed)
|
||||
localStorage.clear();
|
||||
|
||||
return lRet;
|
||||
|
|
@ -576,7 +576,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.getIdBySrc = function(pSrc){
|
||||
var lRet = Util.isString(pSrc);
|
||||
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var lNum = pSrc.lastIndexOf('/') + 1,
|
||||
lSub = pSrc.substr(pSrc, lNum),
|
||||
lID = Util.removeStrOneTime(pSrc, lSub );
|
||||
|
|
@ -598,11 +598,11 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
*/
|
||||
this.ajax = function(pParams){
|
||||
var lRet = Util.checkObjTrue(pParams, ['url', 'success']);
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var p = pParams,
|
||||
lType = p.type || p.method || 'GET';
|
||||
|
||||
if(!XMLHTTP)
|
||||
if (!XMLHTTP)
|
||||
XMLHTTP = new XMLHttpRequest();
|
||||
|
||||
XMLHTTP.open(lType, pParams.url, true);
|
||||
|
|
@ -617,10 +617,10 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lData = lJqXHR.response;
|
||||
|
||||
/* If it's json - parse it as json */
|
||||
if(lType && Util.isContainStr(lType, 'application/json') )
|
||||
if (lType && Util.isContainStr(lType, 'application/json') )
|
||||
lData = Util.parseJSON(lJqXHR.response) || lJqXHR.response;
|
||||
|
||||
if( Util.isFunction(p.success) )
|
||||
if ( Util.isFunction(p.success) )
|
||||
p.success(lData, lJqXHR.statusText, lJqXHR);
|
||||
}
|
||||
/* file not found or connection lost */
|
||||
|
|
@ -628,7 +628,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
/* if html given or something like thet
|
||||
* getBack just status of result
|
||||
*/
|
||||
if(lType && lType.indexOf('text/plain') !== 0)
|
||||
if (lType && lType.indexOf('text/plain') !== 0)
|
||||
lJqXHR.responseText = lJqXHR.statusText;
|
||||
|
||||
Util.exec(p.error, lJqXHR);
|
||||
|
|
@ -649,20 +649,20 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.anyLoadOnLoad = function(pParams_a, pFunc){
|
||||
var lRet = this;
|
||||
|
||||
if( Util.isArray(pParams_a) ) {
|
||||
if ( Util.isArray(pParams_a) ) {
|
||||
var lParam = pParams_a.pop(),
|
||||
lFunc = function(){
|
||||
Loader.anyLoadOnLoad(pParams_a, pFunc);
|
||||
};
|
||||
|
||||
if( Util.isString(lParam) )
|
||||
if ( Util.isString(lParam) )
|
||||
lParam = { src : lParam };
|
||||
else if( Util.isArray(lParam) ){
|
||||
else if ( Util.isArray(lParam) ){
|
||||
|
||||
this.anyLoadInParallel(lParam, lFunc);
|
||||
}
|
||||
|
||||
if(lParam && !lParam.func){
|
||||
if (lParam && !lParam.func){
|
||||
lParam.func = lFunc;
|
||||
|
||||
this.anyload(lParam);
|
||||
|
|
@ -689,21 +689,21 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lDoneFunc = function (pCallBack){
|
||||
Util.exec(pCallBack);
|
||||
|
||||
if( !lDone.pop() )
|
||||
if ( !lDone.pop() )
|
||||
Util.exec(pFunc);
|
||||
};
|
||||
|
||||
if( !Util.isArray(pParams_a) ){
|
||||
if ( !Util.isArray(pParams_a) ){
|
||||
pParams_a = [pParams_a];
|
||||
}
|
||||
|
||||
for(var i = 0, n = pParams_a.length; i < n; i++){
|
||||
var lParam = pParams_a.pop();
|
||||
|
||||
if(lParam){
|
||||
if (lParam){
|
||||
lDone.push(i);
|
||||
|
||||
if(Util.isString(lParam) )
|
||||
if (Util.isString(lParam) )
|
||||
lParam = { src : lParam };
|
||||
|
||||
var lFunc = lParam.func;
|
||||
|
|
@ -736,13 +736,13 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
*/
|
||||
this.anyload = function(pParams_o){
|
||||
|
||||
if( !pParams_o ) return;
|
||||
if ( !pParams_o ) return;
|
||||
|
||||
/* if a couple of params was
|
||||
* processing every of params
|
||||
* and quit
|
||||
*/
|
||||
if( Util.isArray(pParams_o) ){
|
||||
if ( Util.isArray(pParams_o) ){
|
||||
var lElements_a = [];
|
||||
for(var i = 0, n = pParams_o.length; i < n ; i++)
|
||||
lElements_a[i] = this.anyload(pParams_o[i]);
|
||||
|
|
@ -767,14 +767,14 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lFunc = lFunc.onload;
|
||||
}
|
||||
/* убираем путь к файлу, оставляя только название файла */
|
||||
if(!lID && lSrc)
|
||||
if (!lID && lSrc)
|
||||
lID = this.getIdBySrc(lSrc);
|
||||
|
||||
var lElement = DOMTree.getById(lID);
|
||||
|
||||
/* если скрипт еще не загружен */
|
||||
if(!lElement){
|
||||
if(!lName && lSrc){
|
||||
if (!lElement){
|
||||
if (!lName && lSrc){
|
||||
|
||||
var lDot = lSrc.lastIndexOf('.'),
|
||||
lExt = lSrc.substr(lDot);
|
||||
|
|
@ -792,17 +792,17 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
}
|
||||
lElement = document.createElement(lName);
|
||||
|
||||
if(lID)
|
||||
if (lID)
|
||||
lElement.id = lID;
|
||||
|
||||
if(lClass)
|
||||
if (lClass)
|
||||
lElement.className = lClass;
|
||||
|
||||
/* if working with external css
|
||||
* using href in any other case
|
||||
* using src
|
||||
*/
|
||||
if(lName === 'link'){
|
||||
if (lName === 'link'){
|
||||
lElement.href = lSrc;
|
||||
lElement.rel = 'stylesheet';
|
||||
}else
|
||||
|
|
@ -838,16 +838,16 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
Events.add('load', lLoad, lElement);
|
||||
Events.addError(lError, lElement);
|
||||
|
||||
if(lStyle)
|
||||
if (lStyle)
|
||||
lElement.style.cssText = lStyle;
|
||||
|
||||
if(lAsync || lAsync === undefined)
|
||||
if (lAsync || lAsync === undefined)
|
||||
lElement.async = true;
|
||||
|
||||
if(!lNotAppend)
|
||||
if (!lNotAppend)
|
||||
lParent.appendChild(lElement);
|
||||
|
||||
if(lInner)
|
||||
if (lInner)
|
||||
lElement.innerHTML = lInner;
|
||||
}
|
||||
/* если js-файл уже загружен
|
||||
|
|
@ -866,7 +866,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
* @param pFunc
|
||||
*/
|
||||
this.jsload = function(pSrc, pFunc){
|
||||
if( Util.isArray(pSrc) ){
|
||||
if ( Util.isArray(pSrc) ){
|
||||
for(var i=0; i < pSrc.length; i++)
|
||||
pSrc[i].name = 'script';
|
||||
|
||||
|
|
@ -912,7 +912,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
* все параметры опциональны
|
||||
*/
|
||||
this.cssLoad = function(pParams_o){
|
||||
if( Util.isArray(pParams_o) ){
|
||||
if ( Util.isArray(pParams_o) ){
|
||||
for(var i = 0, n = pParams_o.length; i < n; i++){
|
||||
pParams_o[i].name = 'link';
|
||||
pParams_o[i].parent = pParams_o.parent || document.head;
|
||||
|
|
@ -921,7 +921,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
return this.anyload(pParams_o);
|
||||
}
|
||||
|
||||
else if( Util.isString(pParams_o) )
|
||||
else if ( Util.isString(pParams_o) )
|
||||
pParams_o = { src: pParams_o };
|
||||
|
||||
pParams_o.name = 'link';
|
||||
|
|
@ -932,12 +932,47 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
|
||||
/**
|
||||
* load jquery from google cdn or local copy
|
||||
* @param pParams
|
||||
*/
|
||||
this.jquery = function(pParams){
|
||||
if (!pParams)
|
||||
pParams = {};
|
||||
/* загружаем jquery: */
|
||||
Loader.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{
|
||||
onload : Util.retExec(pParams.onload),
|
||||
onerror : Util.retExec(pParams.onerror)
|
||||
});
|
||||
};
|
||||
|
||||
},
|
||||
CmdProto = function(){
|
||||
var Cmd = this,
|
||||
CURRENT_FILE = 'current-file',
|
||||
SELECTED_FILE = 'selected-file',
|
||||
Title;
|
||||
|
||||
/**
|
||||
* private function thet unset currentfile
|
||||
*
|
||||
* @pCurrentFile
|
||||
*/
|
||||
function unsetCurrentFile(pCurrentFile){
|
||||
var lRet = DOM.isCurrentFile(pCurrentFile);
|
||||
|
||||
if (lRet)
|
||||
DOM.removeClass(pCurrentFile, CURRENT_FILE);
|
||||
|
||||
return lRet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load jquery from google cdn or local copy
|
||||
* @param pCallBack
|
||||
*/
|
||||
this.jqueryLoad = function(pCallBack){
|
||||
/* загружаем jquery: */
|
||||
Loader.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{
|
||||
onload: Util.retExec(pCallBack),
|
||||
Loader.jsqueryLoad({
|
||||
onload: pCallBack,
|
||||
|
||||
onerror: function(){
|
||||
Loader.jsload('/lib/client/jquery.js');
|
||||
|
|
@ -964,27 +999,6 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.socketLoad = function(pCallBack){
|
||||
Loader.jsload('/lib/client/socket.js', Util.retExec(pCallBack) );
|
||||
};
|
||||
},
|
||||
CmdProto = function(){
|
||||
var Cmd = this,
|
||||
CURRENT_FILE = 'current-file',
|
||||
SELECTED_FILE = 'selected-file',
|
||||
Title;
|
||||
|
||||
/**
|
||||
* private function thet unset currentfile
|
||||
*
|
||||
* @pCurrentFile
|
||||
*/
|
||||
function unsetCurrentFile(pCurrentFile){
|
||||
var lRet = DOM.isCurrentFile(pCurrentFile);
|
||||
|
||||
if(lRet)
|
||||
DOM.removeClass(pCurrentFile, CURRENT_FILE);
|
||||
|
||||
return lRet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* create new folder
|
||||
|
|
@ -1006,12 +1020,12 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lMsg = 'New ' + pTypeName || 'File',
|
||||
lType = Util.isString(pType) ? pType : '';
|
||||
|
||||
if(lName === '..')
|
||||
if (lName === '..')
|
||||
lName = '';
|
||||
|
||||
lName = prompt(lMsg, lName);
|
||||
|
||||
if(lName)
|
||||
if (lName)
|
||||
RESTfull.save(lDir + lName + lType, null, CloudCmd.refresh);
|
||||
};
|
||||
|
||||
|
|
@ -1031,11 +1045,11 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lSelected = this.getSelectedNames(lFiles),
|
||||
i, n = lSelected && lSelected.length;
|
||||
|
||||
if(n > 1){
|
||||
if (n > 1){
|
||||
for(i = 0; i < 5 && i < n; i++)
|
||||
lName += '\n' + lSelected[i];
|
||||
|
||||
if(n >= 5)
|
||||
if (n >= 5)
|
||||
lName += '\n...';
|
||||
|
||||
lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ;
|
||||
|
|
@ -1044,14 +1058,14 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lType, lIsDir;
|
||||
|
||||
/* dom element passed and it is not event */
|
||||
if( pCurrentFile && !pCurrentFile.pType)
|
||||
if ( pCurrentFile && !pCurrentFile.pType)
|
||||
lCurrent = pCurrentFile;
|
||||
else
|
||||
lCurrent = this.getCurrentFile();
|
||||
|
||||
lIsDir = this.isCurrentIsDir(lCurrent);
|
||||
|
||||
if(lIsDir){
|
||||
if (lIsDir){
|
||||
lQuery = '?dir';
|
||||
lType ='directory';
|
||||
}
|
||||
|
|
@ -1064,23 +1078,23 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lMsg = lMsgAsk + lMsgSel + lType + lName + '?';
|
||||
}
|
||||
|
||||
if(lName !== '..')
|
||||
if (lName !== '..')
|
||||
lRet = confirm(lMsg);
|
||||
else
|
||||
alert('No files selected!');
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var lUrl;
|
||||
|
||||
if(lCurrent)
|
||||
if (lCurrent)
|
||||
lUrl = this.getCurrentPath(lCurrent);
|
||||
else{
|
||||
lUrl = this.getCurrentDirPath();
|
||||
lCurrent = lFiles[0];
|
||||
}
|
||||
|
||||
if(lCurrent || lSelected)
|
||||
if (lCurrent || lSelected)
|
||||
RESTfull.delete(lUrl, lSelected, function(){
|
||||
if(n > 1)
|
||||
if (n > 1)
|
||||
DOM.deleteSelected(lFiles);
|
||||
else
|
||||
DOM.deleteCurrent(lCurrent);
|
||||
|
|
@ -1126,7 +1140,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lPath = this.getByClass('path', lPanel)[0],
|
||||
lRet;
|
||||
|
||||
if(lPath)
|
||||
if (lPath)
|
||||
lRet = lPath.textContent;
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1140,7 +1154,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lPath = this.getByClass('path', lPanel)[0],
|
||||
lRet;
|
||||
|
||||
if(lPath)
|
||||
if (lPath)
|
||||
lRet = lPath.textContent;
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1194,7 +1208,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lName = this.getCurrentName(lCurrent);
|
||||
/* если это папка - возвращаем слово dir вместо размера*/
|
||||
|
||||
if(lName !== '..')
|
||||
if (lName !== '..')
|
||||
RESTfull.read(lLink, function(pSize){
|
||||
DOM.setCurrentSize(pSize, lCurrent);
|
||||
Util.exec(pCallBack, lCurrent);
|
||||
|
|
@ -1245,16 +1259,16 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
Images.showError(jqXHR);
|
||||
};
|
||||
|
||||
if( Util.isFunction(lParams) )
|
||||
if ( Util.isFunction(lParams) )
|
||||
lParams.success = Util.retExec(pParams);
|
||||
|
||||
lParams.error = lError;
|
||||
|
||||
|
||||
if( this.isCurrentIsDir(lCurrentFile) )
|
||||
if ( this.isCurrentIsDir(lCurrentFile) )
|
||||
lPath += '?json';
|
||||
|
||||
if(!lParams.url)
|
||||
if (!lParams.url)
|
||||
lParams.url = CloudFunc.FS + lPath;
|
||||
|
||||
lRet = this.ajax(lParams);
|
||||
|
|
@ -1274,11 +1288,11 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(),
|
||||
lFunc = function(pData){
|
||||
var lName = DOM.getCurrentName(lCurrentFile);
|
||||
if( Util.isObject(pData) ){
|
||||
if ( Util.isObject(pData) ){
|
||||
pData = Util.stringifyJSON(pData);
|
||||
|
||||
var lExt = '.json';
|
||||
if( !Util.checkExtension(lName, lExt) )
|
||||
if ( !Util.checkExtension(lName, lExt) )
|
||||
lName += lExt;
|
||||
}
|
||||
|
||||
|
|
@ -1288,7 +1302,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
});
|
||||
};
|
||||
|
||||
if( !Util.isObject(pCallBack) )
|
||||
if ( !Util.isObject(pCallBack) )
|
||||
lParams = lFunc;
|
||||
else
|
||||
lParams = {
|
||||
|
|
@ -1319,14 +1333,14 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lRet,
|
||||
lCurrentFileWas = this.getCurrentFile();
|
||||
|
||||
if(pCurrentFile){
|
||||
if (pCurrentFile){
|
||||
if (pCurrentFile.className === 'path')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
if (pCurrentFile.className === 'fm-header')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
if(lCurrentFileWas)
|
||||
if (lCurrentFileWas)
|
||||
unsetCurrentFile(lCurrentFileWas);
|
||||
|
||||
this.addClass(pCurrentFile, CURRENT_FILE);
|
||||
|
|
@ -1348,7 +1362,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lCurrent = pCurrent || this.getCurrentFile(),
|
||||
lRet = this.addClass(pCurrent, SELECTED_FILE);
|
||||
|
||||
if(!lRet)
|
||||
if (!lRet)
|
||||
this.unsetSelectedFile(lCurrent);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1371,7 +1385,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.setHistory = function(pData, pTitle, pUrl){
|
||||
var lRet = window.history;
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
history.pushState(pData, pTitle, pUrl);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1393,14 +1407,14 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
*/
|
||||
|
||||
this.setTitle = function(pName){
|
||||
if(!Title)
|
||||
if (!Title)
|
||||
Title = DOMTree.getByTag('title')[0] ||
|
||||
Loader.anyload({
|
||||
name:'title',
|
||||
parentElement: document.head,
|
||||
innerHTML: pName
|
||||
});
|
||||
if(Title)
|
||||
if (Title)
|
||||
Title.textContent = pName;
|
||||
|
||||
return Title;
|
||||
|
|
@ -1414,7 +1428,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.isCurrentFile = function(pCurrent){
|
||||
var lRet;
|
||||
|
||||
if( pCurrent )
|
||||
if ( pCurrent )
|
||||
lRet = this.isContainClass(pCurrent, CURRENT_FILE);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1428,7 +1442,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.isSelected = function(pSelected){
|
||||
var lRet;
|
||||
|
||||
if( pSelected )
|
||||
if ( pSelected )
|
||||
lRet = this.isContainClass(pSelected, SELECTED_FILE);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1486,7 +1500,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lCurrent = pCurrentFile || this.getCurrentFile(),
|
||||
lLink = this.getCurrentLink( lCurrent );
|
||||
|
||||
if( Util.isObject(lLink) )
|
||||
if ( Util.isObject(lLink) )
|
||||
lLink = lLink.title || lLink.textContent;
|
||||
|
||||
return lLink;
|
||||
|
|
@ -1496,11 +1510,11 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lSelected = pSelected || this.getSelectedFiles(),
|
||||
lRet = lSelected ? [] : null;
|
||||
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
var lFirst = lSelected[0],
|
||||
lName = this.getCurrentName( lFirst );
|
||||
|
||||
if(lName === '..')
|
||||
if (lName === '..')
|
||||
this.unsetSelectedFile( lFirst );
|
||||
|
||||
for(var i = 0, n = lSelected.length; i < n;i++)
|
||||
|
|
@ -1538,7 +1552,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lPanel = this.getCurrentFile().parentElement;
|
||||
|
||||
/* if {active : false} getting passive panel */
|
||||
if(pActive && !pActive.active){
|
||||
if (pActive && !pActive.active){
|
||||
var lId = lPanel.id === 'left' ? 'right' : 'left';
|
||||
lPanel = this.getById(lId);
|
||||
}
|
||||
|
|
@ -1547,11 +1561,11 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
* then always work with passive
|
||||
* panel
|
||||
*/
|
||||
if(window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH)
|
||||
if (window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH)
|
||||
lPanel = this.getById('left');
|
||||
|
||||
|
||||
if(!lPanel)
|
||||
if (!lPanel)
|
||||
Util.log('Error can not find Active Panel');
|
||||
|
||||
return lPanel;
|
||||
|
|
@ -1575,7 +1589,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lRet = true,
|
||||
lPanel = this.getPanel(pActive);
|
||||
|
||||
if(lPanel)
|
||||
if (lPanel)
|
||||
this.show(lPanel);
|
||||
else
|
||||
lRet = false;
|
||||
|
|
@ -1590,7 +1604,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lRet = false,
|
||||
lPanel = this.getPanel(pActive);
|
||||
|
||||
if(lPanel)
|
||||
if (lPanel)
|
||||
lRet = this.hide(lPanel);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1614,7 +1628,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
',scrollbars=1,resizable=1';
|
||||
|
||||
var lWind = window.open(pUrl, 'Cloud Commander Auth', lOptions);
|
||||
if(!lWind)
|
||||
if (!lWind)
|
||||
Util.log('Pupup blocked!');
|
||||
};
|
||||
|
||||
|
|
@ -1636,7 +1650,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
var lRet_b = true,
|
||||
lClassList = pElement.classList;
|
||||
|
||||
if(pElement && lClassList)
|
||||
if (pElement && lClassList)
|
||||
lClassList.remove(pClass);
|
||||
|
||||
else
|
||||
|
|
@ -1654,14 +1668,14 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lParent = lCurrent && lCurrent.parentElement,
|
||||
lName = this.getCurrentName(lCurrent);
|
||||
|
||||
if(lCurrent && lParent && lName !== '..'){
|
||||
if (lCurrent && lParent && lName !== '..'){
|
||||
var lNext = pNextFile || lCurrent.nextSibling,
|
||||
lPrevious = pPreviousFile || lCurrent.previousSibling;
|
||||
|
||||
if(!pNotSet)
|
||||
if(lNext)
|
||||
if (!pNotSet)
|
||||
if (lNext)
|
||||
this.setCurrentFile(lNext);
|
||||
else if(lPrevious)
|
||||
else if (lPrevious)
|
||||
this.setCurrentFile(lPrevious);
|
||||
|
||||
lParent.removeChild(lCurrent);
|
||||
|
|
@ -1677,7 +1691,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.deleteSelected = function(pSelected){
|
||||
var lSelected = pSelected || this.getSelectedFiles();
|
||||
|
||||
if(lSelected){
|
||||
if (lSelected){
|
||||
var n = lSelected.length,
|
||||
lLast = n-1,
|
||||
lNext = lSelected[lLast].nextSibling,
|
||||
|
|
@ -1699,7 +1713,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
* @pCurrent
|
||||
*/
|
||||
this.renameCurrent = function(pCurrentFile){
|
||||
if( !Cmd.isCurrentFile(pCurrentFile) )
|
||||
if ( !Cmd.isCurrentFile(pCurrentFile) )
|
||||
pCurrentFile = null;
|
||||
|
||||
var lCurrent = pCurrentFile || Cmd.getCurrentFile(),
|
||||
|
|
@ -1707,7 +1721,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lTo = prompt('Rename', lFrom) || lFrom,
|
||||
lDirPath = Cmd.getCurrentDirPath();
|
||||
|
||||
if( !Util.strCmp(lFrom, lTo) ){
|
||||
if ( !Util.strCmp(lFrom, lTo) ){
|
||||
var lFiles = {
|
||||
from : lDirPath + lFrom,
|
||||
to : lDirPath + lTo
|
||||
|
|
@ -1725,7 +1739,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
* @pCurrent
|
||||
*/
|
||||
this.moveCurrent = function(pCurrentFile){
|
||||
if( !this.isCurrentFile(pCurrentFile) )
|
||||
if ( !this.isCurrentFile(pCurrentFile) )
|
||||
pCurrentFile = null;
|
||||
|
||||
var lCurrent = pCurrentFile || this.getCurrentFile(),
|
||||
|
|
@ -1735,7 +1749,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
|
||||
lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath );
|
||||
|
||||
if( lToPath && !Util.strCmp(lFromPath, lToPath) ){
|
||||
if ( lToPath && !Util.strCmp(lFromPath, lToPath) ){
|
||||
var lFiles = {
|
||||
from : lFromPath,
|
||||
to : lToPath
|
||||
|
|
@ -1759,7 +1773,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
* @pCurrent
|
||||
*/
|
||||
this.copyCurrent = function(pCurrentFile){
|
||||
if( !this.isCurrentFile(pCurrentFile) )
|
||||
if ( !this.isCurrentFile(pCurrentFile) )
|
||||
pCurrentFile = null;
|
||||
|
||||
var lCurrent = pCurrentFile || this.getCurrentFile(),
|
||||
|
|
@ -1768,7 +1782,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
lToPath = this.getNotCurrentDirPath() + lName;
|
||||
lToPath = prompt( 'Copy file "' + lName + '" to', lToPath );
|
||||
|
||||
if( lToPath && !Util.strCmp(lFromPath, lToPath) ){
|
||||
if ( lToPath && !Util.strCmp(lFromPath, lToPath) ){
|
||||
var lFiles = {
|
||||
from : lFromPath,
|
||||
to : lToPath
|
||||
|
|
@ -1792,7 +1806,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.scrollIntoViewIfNeeded = function(pElement){
|
||||
var lRet = pElement && pElement.scrollIntoViewIfNeeded;
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
pElement.scrollIntoViewIfNeeded();
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1802,7 +1816,7 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
this.scrollByPages = function(pElement, pPages){
|
||||
var lRet = pElement && pElement.scrollByPages && pPages;
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
pElement.scrollByPages(pPages);
|
||||
|
||||
return lRet;
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
DOM.jqueryLoad
|
||||
]);
|
||||
|
||||
var key_event = function(pEvent){
|
||||
var lKeyListener = function(pEvent){
|
||||
var lKEY = CloudCmd.KEY,
|
||||
lKeyCode = pEvent.keyCode;
|
||||
/* если клавиши можно обрабатывать */
|
||||
|
|
@ -307,7 +307,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
};
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
DOM.Events.addKey( key_event );
|
||||
DOM.Events.addKey( lKeyListener );
|
||||
};
|
||||
|
||||
CloudCmd.Menu = Menu;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ var CloudCmd, Util, DOM, $;
|
|||
]);
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
var lKeyHandler = function(pEvent){
|
||||
var lKeyListener = function(pEvent){
|
||||
var lRet = true,
|
||||
lKEY = CloudCmd.KEY,
|
||||
lKeyCode = pEvent.keyCode,
|
||||
|
|
@ -128,7 +128,7 @@ var CloudCmd, Util, DOM, $;
|
|||
return lRet;
|
||||
};
|
||||
|
||||
DOM.Events.addKey(lKeyHandler);
|
||||
DOM.Events.addKey( lKeyListener );
|
||||
};
|
||||
|
||||
CloudCmd.Terminal.JqueryTerminal = JqueryTerminal;
|
||||
|
|
|
|||
118
lib/util.js
118
lib/util.js
|
|
@ -17,7 +17,7 @@ Util = exports || {};
|
|||
Util.bind = function(pFunction, pContext){
|
||||
var lRet;
|
||||
|
||||
if( Util.isFunction(pFunction) )
|
||||
if ( Util.isFunction(pFunction) )
|
||||
lRet = pFunction.bind(pContext);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -61,11 +61,11 @@ Util = exports || {};
|
|||
/* если pExt - расширение pName */
|
||||
lRet = lExtSub === pExt.length;
|
||||
|
||||
}else if(Util.isObject(pExt) && pExt.length){
|
||||
}else if (Util.isObject(pExt) && pExt.length){
|
||||
for(var i=0; i < pName.length; i++){
|
||||
lRet = Util.checkExtension(pName, pExt[i]);
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -84,14 +84,14 @@ Util = exports || {};
|
|||
Util.checkObj = function(pObj, pPropArr, pTrueArr){
|
||||
var lRet,
|
||||
i, n;
|
||||
if( pObj ){
|
||||
if ( pObj ){
|
||||
lRet = Util.isArray(pPropArr);
|
||||
if(lRet){
|
||||
if (lRet){
|
||||
n = pPropArr.length;
|
||||
for(i = 0; i < n; i++){
|
||||
for (i = 0; i < n; i++){
|
||||
var lProp = pPropArr[i];
|
||||
lRet = pObj.hasOwnProperty( lProp );
|
||||
if(!lRet){
|
||||
if (!lRet){
|
||||
Util.logError(lProp + ' not in Obj!');
|
||||
Util.log(pObj);
|
||||
break;
|
||||
|
|
@ -99,7 +99,7 @@ Util = exports || {};
|
|||
}
|
||||
}
|
||||
|
||||
if( lRet && Util.isArray(pTrueArr) )
|
||||
if ( lRet && Util.isArray(pTrueArr) )
|
||||
lRet = Util.checkObjTrue( pObj, pTrueArr );
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ Util = exports || {};
|
|||
Util.checkObjTrue = function(pObj, pTrueArr){
|
||||
var lRet, lTrueArr,
|
||||
i, n;
|
||||
if( pObj ){
|
||||
if ( pObj ){
|
||||
lTrueArr = Util.isArray(pTrueArr) ? pTrueArr : [pTrueArr];
|
||||
|
||||
n = lTrueArr.length;
|
||||
|
|
@ -124,7 +124,7 @@ Util = exports || {};
|
|||
var lProp = lTrueArr[i];
|
||||
lRet = pObj[lProp];
|
||||
|
||||
if( !lRet){
|
||||
if ( !lRet){
|
||||
Util.logError(lProp + ' not true!');
|
||||
Util.log(pObj);
|
||||
break;
|
||||
|
|
@ -145,19 +145,19 @@ Util = exports || {};
|
|||
Util.copyObj = function(pFromObj, pToObj, pProps){
|
||||
var lRet;
|
||||
|
||||
if( !pToObj )
|
||||
if ( !pToObj )
|
||||
lRet = pToObj = {};
|
||||
|
||||
function copy(pI){
|
||||
var lName = pProps ? pProps[pI] : pI,
|
||||
lValue = pFromObj[lName];
|
||||
|
||||
if(lValue)
|
||||
if (lValue)
|
||||
pToObj[lName] = pFromObj[lName];
|
||||
}
|
||||
|
||||
if( Util.isObject(pFromObj) ){
|
||||
if(!pProps)
|
||||
if ( Util.isObject(pFromObj) ){
|
||||
if (!pProps)
|
||||
Util.forIn(pFromObj, copy);
|
||||
else
|
||||
Util.fori(pProps.length, copy);
|
||||
|
|
@ -171,7 +171,7 @@ Util = exports || {};
|
|||
Util.convertArrToObj = function(pArrKeys, pArrVal){
|
||||
var i, n, lName, lRet;
|
||||
|
||||
if(pArrKeys && pArrVal){
|
||||
if (pArrKeys && pArrVal){
|
||||
for(i = 0, n = pArrKeys; i < n; i++){
|
||||
lName = pArrKeys[i];
|
||||
lRet[lName] = pArrVal[i];
|
||||
|
|
@ -190,11 +190,11 @@ Util = exports || {};
|
|||
Util.extend = function(pTarget, PObj){
|
||||
var i, n, lObj, lRet = Util.isObject(pTarget) ? pTarget : {};
|
||||
|
||||
if( Util.isArray(PObj) )
|
||||
if ( Util.isArray(PObj) )
|
||||
for(i = 0, n = PObj.length; i < n; i++)
|
||||
lRet = Util.extend(pTarget, PObj[i]);
|
||||
|
||||
else if(PObj){
|
||||
else if (PObj){
|
||||
lObj = Util.isFunction(PObj) ? new PObj() : PObj;
|
||||
|
||||
for(i in lObj)
|
||||
|
|
@ -224,9 +224,9 @@ Util = exports || {};
|
|||
* @param pFunc
|
||||
*/
|
||||
Util.for = function(pI, pN, pFunc){
|
||||
if(Util.isFunction(pFunc))
|
||||
if (Util.isFunction(pFunc))
|
||||
for(var i = pI, n = pN; i < n; i++){
|
||||
if(pFunc(i))
|
||||
if (pFunc(i))
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
|
@ -236,9 +236,9 @@ Util = exports || {};
|
|||
* @param pFunc
|
||||
*/
|
||||
Util.forIn = function(pObj, pFunc){
|
||||
if(Util.isFunction(pFunc))
|
||||
if (Util.isFunction(pFunc))
|
||||
for(var lName in pObj)
|
||||
if(pFunc(lName))
|
||||
if (pFunc(lName))
|
||||
break;
|
||||
};
|
||||
|
||||
|
|
@ -287,15 +287,15 @@ Util = exports || {};
|
|||
Util.strCmp = function (pStr1, pStr2){
|
||||
var lRet = Util.isString(pStr1);
|
||||
|
||||
if(lRet){
|
||||
if( Util.isArray(pStr2) )
|
||||
if (lRet){
|
||||
if ( Util.isArray(pStr2) )
|
||||
for(var i = 0, n = pStr2.length; i < n; i++){
|
||||
lRet = Util.strCmp( pStr1, pStr2[i] );
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
break;
|
||||
}
|
||||
else if( Util.isString(pStr2) )
|
||||
else if ( Util.isString(pStr2) )
|
||||
lRet = Util.isContainStr(pStr1, pStr2) &&
|
||||
pStr1.length === pStr2.length;
|
||||
}
|
||||
|
|
@ -314,15 +314,15 @@ Util = exports || {};
|
|||
var lRet = Util.isString(pStr1);
|
||||
|
||||
|
||||
if( lRet ){
|
||||
if( Util.isArray(pStr2) )
|
||||
if ( lRet ){
|
||||
if ( Util.isArray(pStr2) )
|
||||
for(var i = 0, n = pStr2.length; i < n; i++){
|
||||
lRet = Util.isContainStr( pStr1, pStr2[i] );
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
break;
|
||||
}
|
||||
else if( Util.isString(pStr2) )
|
||||
else if ( Util.isString(pStr2) )
|
||||
lRet = pStr1.indexOf(pStr2) >= 0;
|
||||
}
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ Util = exports || {};
|
|||
Util.isContainStrAtBegin = function(pStr1, pStr2){
|
||||
var lRet;
|
||||
|
||||
if( Util.isString(pStr1) && Util.isString(pStr2) ){
|
||||
if ( Util.isString(pStr1) && Util.isString(pStr2) ){
|
||||
var lLength = pStr2.length,
|
||||
lSubStr = pStr1.substring(0, lLength);
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ Util = exports || {};
|
|||
var lConsole = Scope.console,
|
||||
lDate = '[' + Util.getDate() + '] ';
|
||||
|
||||
if(lConsole && pArg)
|
||||
if (lConsole && pArg)
|
||||
lConsole.log(lDate, pArg);
|
||||
|
||||
return pArg;
|
||||
|
|
@ -369,9 +369,9 @@ Util = exports || {};
|
|||
var lConsole = Scope.console,
|
||||
lDate = '[' + Util.getDate() + '] ';
|
||||
|
||||
if(lConsole && pArg){
|
||||
if (lConsole && pArg){
|
||||
var lMsg = pArg.message;
|
||||
if( lMsg )
|
||||
if ( lMsg )
|
||||
lDate += pArg.message + ' ';
|
||||
|
||||
lConsole.error(lDate, pArg);
|
||||
|
|
@ -386,14 +386,14 @@ Util = exports || {};
|
|||
* @param pData - not necessarily
|
||||
*/
|
||||
Util.loadOnLoad = function(pFunc_a, pData){
|
||||
if( Util.isArray(pFunc_a) && pFunc_a.length) {
|
||||
if ( Util.isArray(pFunc_a) && pFunc_a.length) {
|
||||
var lFunc_a = pFunc_a.slice(),
|
||||
lFunc = lFunc_a.pop(),
|
||||
lCallBack = function(pData){
|
||||
return Util.loadOnLoad(lFunc_a, pData);
|
||||
};
|
||||
|
||||
if( !Util.isUndefined(pData) )
|
||||
if ( !Util.isUndefined(pData) )
|
||||
pData = {
|
||||
data : pData,
|
||||
callback : lCallBack
|
||||
|
|
@ -411,10 +411,10 @@ Util = exports || {};
|
|||
Util.removeStr = function(pStr, pSubStr){
|
||||
var lRet = Util.isString(pStr) && pSubStr;
|
||||
|
||||
if( lRet ){
|
||||
if ( lRet ){
|
||||
var n = pSubStr.length;
|
||||
|
||||
if( Util.isArray(pSubStr) )
|
||||
if ( Util.isArray(pSubStr) )
|
||||
Util.fori(n, function(i){
|
||||
lRet = pStr = Util.replaceStr(pStr, pSubStr[i], '');
|
||||
});
|
||||
|
|
@ -435,10 +435,10 @@ Util = exports || {};
|
|||
Util.removeStrOneTime = function(pStr, pSubStr){
|
||||
var lRet = Util.isString(pStr) && pSubStr;
|
||||
|
||||
if( lRet ){
|
||||
if ( lRet ){
|
||||
var n = pSubStr.length;
|
||||
|
||||
if( Util.isArray(pSubStr) )
|
||||
if ( Util.isArray(pSubStr) )
|
||||
Util.fori(n, function(i){
|
||||
lRet = pStr = pStr.replace(pSubStr[i], '');
|
||||
});
|
||||
|
|
@ -461,7 +461,7 @@ Util = exports || {};
|
|||
Util.replaceStr = function(pStr, pFrom, pTo){
|
||||
var lRet = pStr;
|
||||
|
||||
if(pStr && pFrom){
|
||||
if (pStr && pFrom){
|
||||
pFrom = Util.escapeRegExp(pFrom);
|
||||
lRet = pStr.replace(new RegExp(pFrom, 'g'), pTo);
|
||||
}
|
||||
|
|
@ -473,7 +473,7 @@ Util = exports || {};
|
|||
Util.escapeRegExp = function(pStr) {
|
||||
var lRet = pStr;
|
||||
|
||||
if( Util.isString(pStr) )
|
||||
if ( Util.isString(pStr) )
|
||||
lRet = pStr.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
||||
|
||||
return lRet;
|
||||
|
|
@ -497,7 +497,7 @@ Util = exports || {};
|
|||
* @pSymbols
|
||||
*/
|
||||
Util.ownRender = function(pTempl, pView, pSymbols){
|
||||
if(!pSymbols)
|
||||
if (!pSymbols)
|
||||
pSymbols = ['{', '}'];
|
||||
|
||||
var lRet = pTempl,
|
||||
|
|
@ -544,7 +544,7 @@ Util = exports || {};
|
|||
Util.exec(pParams.callback);
|
||||
|
||||
var lNum = done.pop (pParams.number);
|
||||
if(!lNum){
|
||||
if (!lNum){
|
||||
Util.exec(pCallback);
|
||||
}
|
||||
}
|
||||
|
|
@ -634,7 +634,7 @@ Util = exports || {};
|
|||
*/
|
||||
Util.retExec = function(pCallBack, pArg){
|
||||
return function(pArgument){
|
||||
if( !Util.isUndefined(pArg) )
|
||||
if ( !Util.isUndefined(pArg) )
|
||||
pArgument = pArg;
|
||||
Util.exec(pCallBack, pArgument);
|
||||
};
|
||||
|
|
@ -685,12 +685,12 @@ Util = exports || {};
|
|||
Util.setValue = function(pArgs){
|
||||
var lRet = false;
|
||||
|
||||
if( Util.isObject(pArgs) ){
|
||||
if ( Util.isObject(pArgs) ){
|
||||
var lObj = pArgs.object,
|
||||
lProp = pArgs.property,
|
||||
lVal = pArgs.lVal;
|
||||
|
||||
if(lObj){
|
||||
if (lObj){
|
||||
lObj[lProp] = lVal;
|
||||
lRet = true;
|
||||
}
|
||||
|
|
@ -708,7 +708,7 @@ Util = exports || {};
|
|||
lFunc = pArgs.func,
|
||||
lTime = pArgs.time || 1000,
|
||||
lCallBack = function(pArgument){
|
||||
if(!lDone){
|
||||
if (!lDone){
|
||||
lDone = Util.exec(pArgs.callback, pArgument);
|
||||
}
|
||||
};
|
||||
|
|
@ -716,7 +716,7 @@ Util = exports || {};
|
|||
var lTimeoutFunc = function(){
|
||||
setTimeout(function(){
|
||||
Util.exec(lFunc, lCallBack);
|
||||
if(!lDone)
|
||||
if (!lDone)
|
||||
lTimeoutFunc();
|
||||
}, lTime);
|
||||
};
|
||||
|
|
@ -752,7 +752,7 @@ Util = exports || {};
|
|||
Util.tryCatchDebug = function(pTryFunc){
|
||||
var lRet = Util.tryCatch(pTryFunc);
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
Util.debug();
|
||||
|
||||
return lRet;
|
||||
|
|
@ -783,7 +783,7 @@ Util = exports || {};
|
|||
|
||||
lRet = Util.tryCatch(pTryFunc);
|
||||
|
||||
if(lRet)
|
||||
if (lRet)
|
||||
Util.exec(pCallBack, lRet);
|
||||
|
||||
return lRet;
|
||||
|
|
@ -797,8 +797,8 @@ Util = exports || {};
|
|||
Util.exec = function(pCallBack, pArg, pArg1){
|
||||
var lRet;
|
||||
|
||||
if(pCallBack){
|
||||
if( Util.isFunction(pCallBack) )
|
||||
if (pCallBack){
|
||||
if ( Util.isFunction(pCallBack) )
|
||||
lRet = pCallBack(pArg, pArg1);
|
||||
else {
|
||||
var lCallBack = pCallBack.callback || pCallBack.success;
|
||||
|
|
@ -816,7 +816,7 @@ Util = exports || {};
|
|||
Util.execIfExist = function(pObj, pName, pArg){
|
||||
var lRet;
|
||||
|
||||
if(pObj){
|
||||
if (pObj){
|
||||
var lFunc = Util.bind(pObj[pName], pObj);
|
||||
lRet = Util.exec(lFunc, pArg);
|
||||
}
|
||||
|
|
@ -833,7 +833,7 @@ Util = exports || {};
|
|||
Util.ifExec = function(pCondition, pCallBack, pFunc){
|
||||
var lRet;
|
||||
|
||||
if(pCondition)
|
||||
if (pCondition)
|
||||
Util.exec(pCallBack, pCondition);
|
||||
else
|
||||
Util.exec(pFunc, pCallBack);
|
||||
|
|
@ -849,7 +849,7 @@ Util = exports || {};
|
|||
Util.getExtension = function(pFileName){
|
||||
var lRet, lDot;
|
||||
|
||||
if( Util.isString(pFileName) ){
|
||||
if ( Util.isString(pFileName) ){
|
||||
lDot = pFileName.lastIndexOf('.');
|
||||
lRet = pFileName.substr(lDot);
|
||||
}
|
||||
|
|
@ -865,10 +865,10 @@ Util = exports || {};
|
|||
Util.getNamesFromObjArray = function(pArr){
|
||||
var lRet = [];
|
||||
|
||||
if(pArr && !Util.isArray(pArr))
|
||||
if (pArr && !Util.isArray(pArr))
|
||||
pArr = pArr.data;
|
||||
|
||||
if(pArr)
|
||||
if (pArr)
|
||||
Util.fori(pArr.length, function(i){
|
||||
lRet[i] = pArr[i].name || pArr[i];
|
||||
});
|
||||
|
|
@ -884,9 +884,9 @@ Util = exports || {};
|
|||
Util.findObjByNameInArr = function(pArr, pObjName){
|
||||
var lRet;
|
||||
|
||||
if(pArr){
|
||||
if (pArr){
|
||||
for(var i = 0, n = pArr.length; i < n; i++ )
|
||||
if(pArr[i].name === pObjName) break;
|
||||
if (pArr[i].name === pObjName) break;
|
||||
|
||||
lRet = pArr[i].data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue