git-svn-id: https://msi/svn/firstRepo/WebClient/branches/Manut_2.2.3@24 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2015-01-20 12:30:56 +00:00
parent 160ed036a6
commit 1b92a374cc
28 changed files with 1003 additions and 910 deletions
+15 -3
View File
@@ -155,6 +155,19 @@ var openFB = (function () {
function logout() {
tokenStore['fbtoken'] = undefined;
}
function createHttpReq(callbackFn){
var request;
if (window.XDomainRequest) {
request = new window.XDomainRequest();
request.onload = callbackFn;
}
else {
request = new XMLHttpRequest();
request.onreadystatechange = callbackFn;
}
return request;
}
/**
* Lets you make any Facebook Graph API request.
@@ -169,14 +182,13 @@ var openFB = (function () {
var method = obj.method || 'GET',
params = obj.params || {},
xhr = new XMLHttpRequest(),
url;
params['access_token'] = tokenStore['fbtoken'];
url = 'https://graph.facebook.com' + obj.path + '?' + toQueryString(params);
xhr.onreadystatechange = function () {
var xhr = createHttpReq( function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
if (obj.success) obj.success(JSON.parse(xhr.responseText));
@@ -185,7 +197,7 @@ var openFB = (function () {
if (obj.error) obj.error(error);
}
}
};
});
xhr.open(method, url, true);
xhr.send();