From 7c5b85c1d4ba1e4c3eb19af66fb4d9bc48e9362d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 16 Jan 2013 05:03:40 -0500 Subject: [PATCH] refactored --- config.json | 2 +- lib/client.js | 12 ++++++------ lib/client/menu.js | 10 ++++++++-- lib/client/storage/_dropbox.js | 17 +++++++---------- lib/client/storage/_vk.js | 20 ++++++++++++++++---- lib/util.js | 5 +---- modules.json | 1 + 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/config.json b/config.json index 6e9dd506..2daffa62 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,7 @@ "appcache" : false, "cache" : {"allowed" : false}, "minification" : { - "js" : true, + "js" : false, "css" : true, "html" : true, "img" : true diff --git a/lib/client.js b/lib/client.js index a36065c3..f5917bef 100644 --- a/lib/client.js +++ b/lib/client.js @@ -259,9 +259,10 @@ function initModules(pCallBack){ }, lNames = {}; - lNames[lStorage + '_dropbox'] = 'DropBox', - lNames[lStorage + '_github' ] = 'GitHub', - lNames[lStorage + '_gdrive' ] = 'GDrive', + lNames[lStorage + '_dropbox'] = 'DropBox', + lNames[lStorage + '_github' ] = 'GitHub', + lNames[lStorage + '_gdrive' ] = 'GDrive', + lNames[lStorage + '_vk' ] = 'VK', lDisableMenuFunc(); @@ -320,7 +321,7 @@ function baseInit(pCallBack){ }; } - /* загружаем общие функции для клиента и сервера */ + /* загружаем общие функции для клиента и сервера */ DOM.jsload(CloudCmd.LIBDIR + 'cloudfunc.js',function(){ DOM.addListener("popstate", function(pEvent) { var lPath = pEvent.state; @@ -478,8 +479,7 @@ CloudCmd._changeLinks = function(pPanelID){ lUrl = CloudCmd.HOST; - for(var i = 0, n = a.length; i < n ; i++) - { + for(var i = 0, n = a.length; i < n ; i++){ /* убираем адрес хоста*/ var link = a[i].href.replace(lUrl,''); diff --git a/lib/client/menu.js b/lib/client/menu.js index 10fad938..3c344926 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -113,7 +113,7 @@ var CloudCommander, Util, DOM, $; callback: function(key, options) { var m = "clicked: " + key; - console.log(m, options); + Util.log(m, options); KeyBinding.set(); }, @@ -123,7 +123,13 @@ var CloudCommander, Util, DOM, $; 'View' : Util.retExec(showEditor, true), 'Edit' : Util.retExec(showEditor, false), 'Delete' : Util.retExec(DOM.promptRemoveCurrent), - 'Upload to' : getUploadToItem( ['GitHub', 'GDrive', 'DropBox'] ), + 'Upload to' : getUploadToItem( + [ + 'DropBox', + 'GDrive', + 'GitHub', + 'VK' + ]), 'Download' : function(key, opt){ DOM.Images.showLoad(); diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 49d4e32d..cc3fec7e 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -7,7 +7,7 @@ var CloudCommander, Util, DOM, Dropbox, cb, Client; var DropBoxStore = {}; /* temporary callback function for work with github */ - cb = function (err, data){ console.log(err || data);}; + cb = function (err, data){ Util.log(err || data);}; /* PRIVATE FUNCTIONS */ @@ -34,15 +34,12 @@ var CloudCommander, Util, DOM, Dropbox, cb, Client; } function getUserData(pCallBack){ - var lName, - lShowUserInfo = function(pError, pData){ - if(!pError){ - lName = pData.name; - console.log('Hello ' + lName + ' :)!'); - } - }; + Client.getUserInfo(function(pError, pData){ + var lHello = 'Hello ' + pData.name + ' :)!', + lMsg = pError ? pError : lHello; - Client.getUserInfo(lShowUserInfo); + Util.log(lMsg); + }); Util.exec(pCallBack); } @@ -87,7 +84,7 @@ var CloudCommander, Util, DOM, Dropbox, cb, Client; Client.writeFile(lName, lContent, function(pError, pData){ DOM.Images.hideLoad(); - console.log(pError || pData); + Util.log(pError || pData); Util.exec(pCallBack); }); } diff --git a/lib/client/storage/_vk.js b/lib/client/storage/_vk.js index 75ea1597..b8b15b9c 100644 --- a/lib/client/storage/_vk.js +++ b/lib/client/storage/_vk.js @@ -31,12 +31,24 @@ var CloudCommander, Util, DOM, VK; } - function auth(){ + function auth(pCallBack){ CloudCmd.getConfig(function(pConfig){ + var lDOCUMENTS_ACCESS = 131072; + VK.init({ apiId: pConfig.vk_id}); - VK.Auth.login(function(pResponse){ - console.log(pResponse); - }, 131072); /* Доступ к документам пользователя */ + + VK.Auth.login(function(){ + var lNAME = 1281; + VK.Api.call('getVariable', {key: lNAME}, function(r) { + var lName = r.response; + + if(lName) + Util.log ('Hello, ' + lName + ':)'); + }); + + Util.exec(pCallBack); + + }, lDOCUMENTS_ACCESS); /* Доступ к документам пользователя */ }); } diff --git a/lib/util.js b/lib/util.js index 9a31b81f..7dd605ed 100644 --- a/lib/util.js +++ b/lib/util.js @@ -97,11 +97,8 @@ Util = exports || {}; lConsole = Scope.console, lDate = '[' + Util.getDate() + '] '; - if(!Util.isString(lArg)) - lArg = JSON.stringify(lArg); - if(lConsole && pArg) - lConsole.log(lDate + lArg); + lConsole.log(lDate, lArg); return pArg; }; diff --git a/modules.json b/modules.json index 30766d4f..d7c68ff6 100644 --- a/modules.json +++ b/modules.json @@ -6,5 +6,6 @@ "storage/_dropbox", "storage/_dropbox_chooser", "storage/_gdrive", + "storage/_vk", "terminal" ] \ No newline at end of file