From 640197a52e39eb799d990853cf16be4617179dde Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 13 Nov 2012 04:30:23 -0500 Subject: [PATCH] minor changes --- client.js | 34 ++++++++++++++++++++++++++++------ lib/client/dom.js | 11 ----------- lib/client/storage/_github.js | 35 +++++++++++++++++++++-------------- lib/util.js | 12 ++++++++++++ modules.json | 3 +-- 5 files changed, 62 insertions(+), 33 deletions(-) diff --git a/client.js b/client.js index d901202a..8f322972 100644 --- a/client.js +++ b/client.js @@ -375,6 +375,13 @@ CloudClient._currentToParent = function(pDirName){ * инициализации */ CloudClient.init = function(){ + var lFunc = function(){ + Util.loadOnLoad([ + initModules, + baseInit + ]); + }; + getByClass = DOM.getByClass; getById = DOM.getById; @@ -385,13 +392,13 @@ CloudClient.init = function(){ this.OLD_BROWSER = true; DOM.jsload(CloudClient.LIBDIRCLIENT + 'ie.js', function(){ - DOM.jqueryLoad( baseInit ); + DOM.jqueryLoad( lFunc ); }); - } - else baseInit(); + }else + lFunc(); }; -function initModules(){ +function initModules(pCallBack){ loadModule({ /* привязываем клавиши к функциям */ @@ -408,11 +415,13 @@ function initModules(){ if( Util.isArray(pModules) ) for(var i = 0, n = pModules.length; i < n ; i++) loadModule(pModules[i]); + + Util.exec(pCallBack); } }); } -function baseInit(){ +function baseInit(pCallBack){ if(applicationCache){ var lFunc = applicationCache.onupdateready; @@ -480,10 +489,23 @@ function baseInit(){ '}' }); - initModules(); + Util.exec(pCallBack || initModules); cloudcmd.KeyBinding(); } +CloudClient.loadConfig = function(pCallBack){ + if(!cloudcmd.Config) + return DOM.ajax({ + url:'/config.json', + success: function(pConfig){ + cloudcmd.Config = pConfig; + + Util.exec(pCallBack, pConfig); + } + }); +}; + + /* функция меняет ссыки на ajax-овые */ CloudClient._changeLinks = function(pPanelID){ /* назначаем кнопку очистить кэш и показываем её */ diff --git a/lib/client/dom.js b/lib/client/dom.js index dbd79a4e..d8ae4c79 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -145,17 +145,6 @@ var CloudCommander, $, Util, DOM; return lID; }, - DOM.loadOnload = function(pFunc_a){ - if( Util.isArray(pFunc_a) ) { - var lFunc_f = pFunc_a.pop(); - - if(typeof lFunc_f === 'function') - lFunc_f(); - - return DOM.loadOnload(pFunc_a); - } - else return Util.exec(pFunc_a); - }; DOM.anyLoadOnLoad = function(pParams_a, pFunc){ if( Util.isArray(pParams_a) ) { diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 057693a7..325b9be2 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -6,10 +6,8 @@ var CloudCommander, Util, DOM, $, Github; var cloudcmd = CloudCommander, - CLIENT_ID = '435c670f44320e287ad6', - //'891c251b925e4e967fa9', - CLIENT_SECRET = 'a8b49e8c8c1a6253b149d224149a076270d8d614', - //'afe9bed1e810c5dc44c4c2a953fc6efb1e5b0545', + CLIENT_ID, // = '891c251b925e4e967fa9', + CLIENT_SECRET,// = 'afe9bed1e810c5dc44c4c2a953fc6efb1e5b0545', GithubStore = {}; cloudcmd.Storage = {}; @@ -19,7 +17,7 @@ var CloudCommander, Util, DOM, $, Github; /** * function loads github.js */ - function load(){ + function load(pCallBack){ console.time('github load'); var lDir = './lib/client/storage/github/'; @@ -31,16 +29,23 @@ var CloudCommander, Util, DOM, $, Github; function(){ console.timeEnd('github load'); DOM.Images.hideLoad(); - init(); + + Util.exec(pCallBack); }); } - function callback(pError, pDate){ - if(pError) - console.log(pError); - - if(pDate) - console.log(pDate); + function setConfig(pCallBack){ + cloudcmd.loadConfig(function(){ + var lConfig = cloudcmd.Config; + CLIENT_ID = lConfig.oauth_client_id; + CLIENT_SECRET = lConfig.oauth_client_secret; + + Util.exec(pCallBack); + }); + } + + function callback(pError, pData){ + console.log(pError || pData); } /* PUBLICK FUNCTIONS */ @@ -87,8 +92,10 @@ var CloudCommander, Util, DOM, $, Github; }; cloudcmd.Storage.Keys = function(){ - DOM.jqueryLoad( load ); + DOM.jqueryLoad(function(){ + Util.loadOnLoad([ init, load, setConfig ]); + }); }; - cloudcmd.Storage.Github = GithubStore; + cloudcmd.Storage.Github = GithubStore; })(); diff --git a/lib/util.js b/lib/util.js index ea1c1559..ede2fd25 100644 --- a/lib/util.js +++ b/lib/util.js @@ -58,6 +58,18 @@ var Util, exports; return lRet; }; + Util.loadOnLoad = function(pFunc_a){ + if( Util.isArray(pFunc_a) ) { + var lFunc = pFunc_a.pop(); + + Util.exec(lFunc, function(){ + return Util.loadOnLoad(pFunc_a); + }); + } + else + return Util.exec(pFunc_a); + }; + /** * function remove substring from string * @param pStr diff --git a/modules.json b/modules.json index f3b987cc..b1ae657a 100644 --- a/modules.json +++ b/modules.json @@ -3,6 +3,5 @@ "viewer", "storage/_github", "terminal", - "menu", - "config" + "menu" ] \ No newline at end of file