From 5c9afe7171dcc8d739aea9a82a64fca6617efb49 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 24 Apr 2014 03:04:13 -0400 Subject: [PATCH] refactor(gdrive) load --- lib/client/storage/_gdrive.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/client/storage/_gdrive.js b/lib/client/storage/_gdrive.js index 5cfbc176..2ea26b6c 100644 --- a/lib/client/storage/_gdrive.js +++ b/lib/client/storage/_gdrive.js @@ -11,23 +11,23 @@ var CloudCmd, Util, DOM, gapi; /** * load google api library */ - function load(pCallBack){ + function load(callback){ /* https://code.google.com/p/google-api-javascript-client/ */ var lUrl = 'https://apis.google.com/js/client.js'; DOM.jsload(lUrl, function(){ - CloudCmd.getModules(function(pModules){ - var lStorage = Util.findObjByNameInArr(pModules, 'storage'), - lGDrive = Util.findObjByNameInArr(lStorage, 'GDrive'), - GDriveId = lGDrive && lGDrive.id; + CloudCmd.getModules(function(modules){ + var storage = Util.findObjByNameInArr(modules, 'storage'), + gDrive = Util.findObjByNameInArr(storage, 'GDrive'), + gDriveId = gDrive && gDrive.id, /* https://developers.google.com/drive/credentials */ - - var lCLIENT_ID = GDriveId + '.apps.googleusercontent.com', - lSCOPES = 'https://www.googleapis.com/auth/drive', + + clientId = gDriveId + '.apps.googleusercontent.com', + scopes = 'https://www.googleapis.com/auth/drive', lParams = { - 'client_id' : lCLIENT_ID, - 'scope' : lSCOPES, + 'client_id' : clientId, + 'scope' : scopes, 'immediate' : false }; @@ -35,9 +35,7 @@ var CloudCmd, Util, DOM, gapi; gapi.auth.authorize(lParams, function(pAuthResult){ if (pAuthResult && !pAuthResult.error) - gapi.client.load('drive', 'v2', function() { - Util.exec(pCallBack); - }); + gapi.client.load('drive', 'v2', Util.retExec(callback)); }); }, 1500); @@ -56,8 +54,8 @@ var CloudCmd, Util, DOM, gapi; var lContent = pParams.data, lName = pParams.name, boundary = '-------314159265358979323846', - delimiter = "\r\n--" + boundary + "\r\n", - close_delim = "\r\n--" + boundary + "--", + delimiter = '\r\n--' + boundary + '\r\n', + close_delim = '\r\n--' + boundary + '--', contentType = pParams.type || 'application/octet-stream', metadata = {