mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
added skydrive module
This commit is contained in:
parent
fadbb74ff3
commit
e83d9ed711
1 changed files with 78 additions and 0 deletions
78
lib/client/storage/_skydrive.js
Normal file
78
lib/client/storage/_skydrive.js
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
//http://isdk.dev.live.com/ISDK.aspx?category=scenarioGroup_skyDrive&index=0
|
||||
var CloudCommander, Util, DOM, WL;
|
||||
|
||||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
var SkyDrive = {};
|
||||
|
||||
/* PRIVATE FUNCTIONS */
|
||||
|
||||
/**
|
||||
* load google api library
|
||||
*/
|
||||
function load(pCallBack){
|
||||
console.time('SkyDrive');
|
||||
var lUrl = '//js.live.net/v5.0/wl.js';
|
||||
|
||||
DOM.jsload(lUrl, function(){
|
||||
console.timeEnd('SkyDrive load');
|
||||
DOM.Images.hideLoad();
|
||||
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function auth(pCallBack){
|
||||
CloudCmd.getModules(function(pModules){
|
||||
var lStorage = Util.findObjByNameInArr(pModules, 'storage'),
|
||||
lSkyDrive = Util.findObjByNameInArr(lStorage, 'SkyDrive'),
|
||||
lSkyDriveKey = lSkyDrive && lSkyDrive.id;
|
||||
|
||||
WL.init({
|
||||
client_id: lSkyDriveKey,
|
||||
redirect_uri: CloudCmd.HOST,
|
||||
});
|
||||
|
||||
WL.login({
|
||||
scope: ["wl.skydrive wl.signin"]
|
||||
}).then(
|
||||
function(response) {
|
||||
Util.log(response);
|
||||
},
|
||||
function(response) {
|
||||
Util.log("Failed to authenticate.");
|
||||
});
|
||||
|
||||
WL.Event.subscribe("auth.login", onLogin);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function onLogin(session) {
|
||||
var strGreeting = "";
|
||||
WL.api({
|
||||
path: "me",
|
||||
method: "GET"
|
||||
},
|
||||
|
||||
function (response) {
|
||||
if (!response.error) {
|
||||
strGreeting = "Hi, " + response.first_name + "!";
|
||||
Util.log(strGreeting);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SkyDrive.init = function(pCallBack){
|
||||
Util.loadOnLoad([
|
||||
Util.retExec(pCallBack),
|
||||
auth,
|
||||
load
|
||||
]);
|
||||
};
|
||||
|
||||
CloudCmd.SkyDrive = SkyDrive;
|
||||
|
||||
})(CloudCommander, Util, DOM);
|
||||
Loading…
Add table
Add a link
Reference in a new issue