mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
minor changes
This commit is contained in:
parent
f7ae641970
commit
4e77f783b8
5 changed files with 37 additions and 41 deletions
|
|
@ -494,7 +494,7 @@ function baseInit(pCallBack){
|
|||
'}'
|
||||
});
|
||||
|
||||
Util.exec(pCallBack || initModules);
|
||||
Util.exec(pCallBack);
|
||||
cloudcmd.KeyBinding();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var CloudCommander, $, Util, DOM;
|
||||
var CloudCommander, $, Util, DOM, CloudFunc;
|
||||
|
||||
(function(){
|
||||
"use strict";
|
||||
|
|
@ -20,7 +20,7 @@ var CloudCommander, $, Util, DOM;
|
|||
* функции для отображения
|
||||
* картинок
|
||||
*/
|
||||
Images_o = {
|
||||
Images_o = {
|
||||
/* Функция создаёт картинку загрузки*/
|
||||
loading : function(){
|
||||
var lE = DOM.getById('loading-image');
|
||||
|
|
@ -104,48 +104,38 @@ var CloudCommander, $, Util, DOM;
|
|||
XMLHTTP.send(null);
|
||||
|
||||
var lSuccess_f = pParams.success;
|
||||
if(typeof lSuccess_f !== 'function')
|
||||
console.log('error in DOM.ajax onSuccess:', pParams);
|
||||
if( !Util.isFunction(lSuccess_f) )
|
||||
console.log('error in DOM.ajax onSuccess:', pParams);
|
||||
|
||||
XMLHTTP.onreadystatechange = function(pEvent){
|
||||
if (XMLHTTP.readyState === 4 /* Complete */){
|
||||
var lJqXHR = pEvent.target;
|
||||
var lContentType = XMLHTTP.getResponseHeader('content-type');
|
||||
var lJqXHR = pEvent.target,
|
||||
lType = XMLHTTP.getResponseHeader('content-type');
|
||||
|
||||
if (XMLHTTP.status === 200 /* OK */){
|
||||
var lData = lJqXHR.response;
|
||||
|
||||
/* If it's json - parse it as json */
|
||||
if(lContentType &&
|
||||
lContentType.indexOf('application/json') === 0){
|
||||
try{
|
||||
lData = JSON.parse(lJqXHR.response);
|
||||
}
|
||||
catch(pError) {
|
||||
/* if could not parse */
|
||||
console.log('Error: could not parse' +
|
||||
'json from server from url: ' +
|
||||
pParams.url);
|
||||
|
||||
lData = lJqXHR.response;
|
||||
}
|
||||
}
|
||||
if(lType && Util.isContainStr(lType, 'application/json') ){
|
||||
var lResult = Util.tryCatch(function(){
|
||||
lData = JSON.parse(lJqXHR.response);
|
||||
});
|
||||
|
||||
if( Util.log(lResult) )
|
||||
lData = lJqXHR.response;
|
||||
}
|
||||
|
||||
lSuccess_f(lData, lJqXHR.statusText, lJqXHR);
|
||||
}
|
||||
else/* file not found or connection lost */{
|
||||
var lError_f = pParams.error;
|
||||
|
||||
/* if html given or something like it
|
||||
* getBack just status of result
|
||||
*/
|
||||
if(lContentType &&
|
||||
lContentType.indexOf('text/plain') !== 0){
|
||||
if(lType &&
|
||||
lType.indexOf('text/plain') !== 0){
|
||||
lJqXHR.responseText = lJqXHR.statusText;
|
||||
}
|
||||
|
||||
if(typeof lError_f === 'function')
|
||||
lError_f(lJqXHR);
|
||||
Util.exec(pParams.error, lJqXHR);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -184,7 +174,8 @@ var CloudCommander, $, Util, DOM;
|
|||
|
||||
DOM.anyload(lParam);
|
||||
|
||||
}else Util.exec(pFunc);
|
||||
}else
|
||||
Util.exec(pFunc);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -382,11 +373,7 @@ var CloudCommander, $, Util, DOM;
|
|||
DOM.jqueryLoad = function(pCallBack){
|
||||
/* загружаем jquery: */
|
||||
DOM.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js',{
|
||||
onload: function(){
|
||||
$ = window.jQuery;
|
||||
if(typeof pCallBack === 'function')
|
||||
pCallBack();
|
||||
},
|
||||
onload: Util.retExec(pCallBack),
|
||||
|
||||
onerror: function(){
|
||||
DOM.jsload('lib/client/jquery.js');
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ var CloudCommander, Util, DOM, $;
|
|||
|
||||
$(window).unbind('resize');
|
||||
|
||||
Util.exec(pCallBack);
|
||||
Util.exec(pCallBack.callback || pCallBack);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -105,13 +105,11 @@ var CloudCommander, Util, DOM, $;
|
|||
*/
|
||||
cloudcmd.Terminal.Keys = function(){
|
||||
/* loading js and css*/
|
||||
DOM.jqueryLoad(function(){
|
||||
Util.loadOnLoad([
|
||||
DOM.jqueryLoad( Util.retLoadOnLoad([
|
||||
JqueryTerminal.show,
|
||||
load,
|
||||
DOM.socketLoad
|
||||
]);
|
||||
});
|
||||
]) );
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
DOM.addKeyListener(function(){
|
||||
|
|
|
|||
13
lib/util.js
13
lib/util.js
|
|
@ -65,7 +65,7 @@ var Util, exports;
|
|||
*/
|
||||
Util.loadOnLoad = function(pFunc_a, pData){
|
||||
if( Util.isArray(pFunc_a) && pFunc_a.length) {
|
||||
var lFunc_a = pFunc_a.slice,
|
||||
var lFunc_a = pFunc_a.slice(),
|
||||
lFunc = lFunc_a.pop(),
|
||||
lCallBack = function(pData){
|
||||
return Util.loadOnLoad(lFunc_a, pData);
|
||||
|
|
@ -150,6 +150,17 @@ var Util, exports;
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* return load functions thrue callbacks one-by-one
|
||||
* @param pFunc_a {Array} - array of functions
|
||||
* @param pData - not necessarily
|
||||
*/
|
||||
Util.retLoadOnLoad = function(pFunc_a, pData){
|
||||
return function(){
|
||||
Util.loadOnLoad(pFunc_a, pData);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* set value to property of object, if object exist
|
||||
* @param pArgs {object, property, value}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cloudcmd",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.7-20",
|
||||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
||||
"description": "Two-panels file manager, totally writed on js.",
|
||||
"homepage": "https://github.com/coderaiser/cloudcmd",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue