diff --git a/lib/client.js b/lib/client.js index 9a94064f..3e7c61ab 100644 --- a/lib/client.js +++ b/lib/client.js @@ -97,15 +97,18 @@ var loadModule = function(pParams){ if( !Util.isContainStr(lPath, '.js') ) lPath += '.js'; - cloudcmd[lName] = function(pArg){ - - lPath = Util.exec(lDoBefore) || lPath; - - return DOM.jsload(cloudcmd.LIBDIRCLIENT + lPath, lFunc || - function(){ - cloudcmd[lName].Keys(pArg); - }); - }; + if(!cloudcmd[lName]) + cloudcmd[lName] = function(pArg){ + + Util.exec(lDoBefore); + + return DOM.jsload(cloudcmd.LIBDIRCLIENT + lPath, lFunc || + function(){ + cloudcmd[lName].Keys(pArg); + }); + }; + else + cloudcmd[lName + lPath]; }; CloudClient.GoogleAnalytics = function(){ @@ -344,9 +347,6 @@ function initModules(pCallBack){ DOM.ajax({ url:'/modules.json', success: function(pModules){ - const DROPBOX = 'storage/_dropbox', - GITHUB = 'storage/_github'; - var lShowLoadFunc = Util.retFunc( DOM.Images.showLoad ), lDisableMenuFunc = function(){ var lFunc = document.oncontextmenu; @@ -355,32 +355,13 @@ function initModules(pCallBack){ return cloudcmd.Menu.ENABLED || false; }; }, - lStorage = function(){ - const lKEY = cloudcmd.KEY; - - var lRet = false; - - switch(event.keyCode){ - case lKEY.G: - lRet = GITHUB; - break; - - case lKEY.D: - lRet = DROPBOX; - break; - } - - return lRet && (lRet + '.js'); - }, lDoBefore = { 'editor/_codemirror' : lShowLoadFunc, 'menu' : lDisableMenuFunc, 'viewer' : lShowLoadFunc }; - - lDoBefore[GITHUB] = - lDoBefore[DROPBOX] = lStorage; + lDisableMenuFunc(); diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 3091625a..caddda62 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -78,7 +78,10 @@ var CloudCommander, Util, DOM; Util.exec(cloudcmd.Config); } - else if( (lKeyCode === KEY.G || lKeyCode === KEY.D) && event.altKey){ + else if(lKeyCode === KEY.G && event.altKey) + Util.exec(cloudcmd.Storage); + + else if(lKeyCode === KEY.D && event.altKey){ Util.exec(cloudcmd.Storage); event.preventDefault(); } @@ -117,7 +120,7 @@ var CloudCommander, Util, DOM; DOM.removeCurrent(lCurrentFile); /* if f3 or shift+f3 or alt+f3 pressed */ - else if(lKeyCode === KEY.F3){ + else if(lKeyCode === KEY.F3){ var lEditor = cloudcmd[event.shiftKey ? 'Viewer' : 'Editor']; diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index d930dbda..4fc5e26e 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -1,23 +1,24 @@ -var CloudCommander, DOM, Dropbox; //o7d6llji052vijk +var CloudCommander, Util, DOM, Dropbox; /* module for work with github */ (function(){ "use strict"; - var cloudcmd = CloudCommander, - CLIENT_ID, - DropBoxStore = {}, - options = { - linkType: "direct", - success: function(files) { - console.log("Here's the file link:" + files[0].link); - }, - cancel: function() { - console.log('Chose something'); - } - }; - + const cloudcmd = CloudCommander; + var CLIENT_ID, + Storage = cloudcmd.Storage, + DropBoxStore = {}, + options = { + linkType: "direct", + success: function(files) { + console.log("Here's the file link:" + files[0].link); + }, + cancel: function() { + console.log('Chose something'); + } + }; + /* PRIVATE FUNCTIONS */ /** @@ -42,9 +43,9 @@ var CloudCommander, DOM, Dropbox; //o7d6llji052vijk Dropbox.choose(options); }; - cloudcmd.Storage.Keys = function(){ + Storage.Keys = function(){ load(); }; - cloudcmd.Storage.DropBoxStore = DropBoxStore; + Storage.DropBoxStore = DropBoxStore; })(); diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 86e8f093..aa0d9178 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -4,17 +4,18 @@ var CloudCommander, Util, DOM, $, Github, cb; (function(){ "use strict"; - var cloudcmd = CloudCommander, - - APIURL = '/api/v1', - AuthURL = APIURL + '/auth', - GitHubIdURL = APIURL + '/github_id', - GitHub_ID, - Cache = DOM.Cache, - GithubLocal, - User, - GithubStore = {}; + const cloudcmd = CloudCommander, + Cache = DOM.Cache, + + APIURL = '/api/v1', + AuthURL = APIURL + '/auth', + GitHubIdURL = APIURL + '/github_id'; + var GitHub_ID, + GithubLocal, + User, + Storage = cloudcmd.Storage = {}, + GithubStore = {}; /* temporary callback function for work with github */ cb = function (err, data){ console.log(err || data);}; @@ -157,8 +158,8 @@ var CloudCommander, Util, DOM, $, Github, cb; User.show(null, lShowUserInfo); } - - cloudcmd.Storage.Keys = function(){ + + Storage.Keys = function(){ Util.loadOnLoad([ getUserData, init, @@ -167,5 +168,5 @@ var CloudCommander, Util, DOM, $, Github, cb; ]); }; - cloudcmd.Storage.GithubStore = GithubStore; + Storage.GithubStore = GithubStore; })();