minor changes

This commit is contained in:
coderaiser 2012-10-26 05:43:37 -04:00
parent 13870902f9
commit cf8d196b84
2 changed files with 58 additions and 10 deletions

View file

@ -1,4 +1,4 @@
var CloudCommander;
var CloudCommander, $;
var CloudCommander, Github;
/* object contains terminal jqconsole */
@ -7,7 +7,10 @@ var CloudCommander, Github;
"use strict";
var cloudcmd = CloudCommander,
Util = cloudcmd.Util;
Util = cloudcmd.Util,
CLIENT_ID = '891c251b925e4e967fa9',
CLIENT_SECRET = 'afe9bed1e810c5dc44c4c2a953fc6efb1e5b0545';
cloudcmd.Storage = {};
@ -59,21 +62,34 @@ var CloudCommander, Github;
};
function init(){
var lTokin = window.location.search;
if ( Util.isContainStr(lTokin, '?code=') )
lTokin = lTokin.replace('?code=','');
GithubStore.Login(lTokin);
var lCode = window.location.search;
if ( Util.isContainStr(lCode, '?code=') ){
lCode = lCode.replace('?code=','');
$.post("https://github.com/login/oauth/access_token",{
client_id : CLIENT_ID,
client_secret : CLIENT_SECRET,
code : lCode,
state : ''
},
function(pDate){
//GithubStore.Login(lToken);
console.log(pDate);
}, "json");
}
else
cloudcmd.Auth();
}
cloudcmd.Auth = function(){
window.location =
'https://github.com/login/oauth/authorize?client_id=' +
'891c251b925e4e967fa9';
CLIENT_ID + '&&scope=repo,user,gist';
};
cloudcmd.Storage.Keys = function(){
load();
Util.jqueryLoad( load );
};
cloudcmd.Storage.Github = GithubStore;

View file

@ -25,7 +25,39 @@ var CloudFunc = {
SHORTNAMELENGTH : 16
};
/*1
/* STRINGS */
/**
* function check is strings are equal
* @param pStr1
* @param pStr2
*/
CloudFunc.strCmp = function (pStr1, pStr2){
return this.isContainStr(pStr1, pStr2) &&
pStr1.length == pStr2.length;
};
/**
* function returns is pStr1 contains pStr2
* @param pStr1
* @param pStr2
*/
CloudFunc.isContainStr = function(pStr1, pStr2){
return pStr1 &&
pStr2 &&
pStr1.indexOf(pStr2) >= 0;
};
/**
* function remove substring from string
* @param pStr
* @param pSubStr
*/
CloudFunc.removeStr = function(pStr, pSubStr){
return pStr.replace(pSubStr,'');
};
/*
* Функция убирает последний слеш,
* если он - последний символ строки
*/