style(legacy): format (#2039)
This commit is contained in:
parent
7082c9693d
commit
1550d44ac5
122 changed files with 18369 additions and 15819 deletions
|
@ -1,88 +1,100 @@
|
|||
|
||||
$(document).ready(function() {
|
||||
$("#facebook-login").click(function() {
|
||||
AIRTIME.facebook.promptForFacebookPage();
|
||||
});
|
||||
$(document).ready(function () {
|
||||
$("#facebook-login").click(function () {
|
||||
AIRTIME.facebook.promptForFacebookPage();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
window.fbAsyncInit = function() {
|
||||
FB.init({
|
||||
appId : FACEBOOK_APP_ID,
|
||||
xfbml : true,
|
||||
version : 'v2.4'
|
||||
});
|
||||
window.fbAsyncInit = function () {
|
||||
FB.init({
|
||||
appId: FACEBOOK_APP_ID,
|
||||
xfbml: true,
|
||||
version: "v2.4",
|
||||
});
|
||||
};
|
||||
|
||||
var AIRTIME = (function(AIRTIME) {
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
//Module initialization
|
||||
if (AIRTIME.facebook === undefined) {
|
||||
AIRTIME.facebook = {};
|
||||
}
|
||||
|
||||
//Module initialization
|
||||
if (AIRTIME.facebook === undefined) {
|
||||
AIRTIME.facebook = {};
|
||||
var mod = AIRTIME.facebook;
|
||||
|
||||
(function (d, s, id) {
|
||||
var js,
|
||||
fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) {
|
||||
return;
|
||||
}
|
||||
js = d.createElement(s);
|
||||
js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
})(document, "script", "facebook-jssdk");
|
||||
|
||||
var mod = AIRTIME.facebook;
|
||||
|
||||
(function (d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) {
|
||||
return;
|
||||
mod.promptForFacebookPage = function () {
|
||||
FB.login(
|
||||
function (response) {
|
||||
if (response.authResponse) {
|
||||
mod.getPagesOwnedByUser(
|
||||
response.authResponse.userID,
|
||||
response.authResponse.accessToken
|
||||
);
|
||||
mod.addPageTab();
|
||||
} else {
|
||||
console.log("Authorization failed.");
|
||||
}
|
||||
js = d.createElement(s);
|
||||
js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
},
|
||||
{ scope: "manage_pages" }
|
||||
);
|
||||
};
|
||||
|
||||
mod.promptForFacebookPage = function() {
|
||||
FB.login(function (response) {
|
||||
if (response.authResponse) {
|
||||
mod.getPagesOwnedByUser(response.authResponse.userID, response.authResponse.accessToken);
|
||||
mod.addPageTab();
|
||||
mod.getPagesOwnedByUser = function (userId, accessToken) {
|
||||
FB.api(
|
||||
"/" + userId + "/accounts",
|
||||
function (response) {
|
||||
console.log(response);
|
||||
},
|
||||
{ access_token: accessToken }
|
||||
);
|
||||
};
|
||||
|
||||
} else {
|
||||
console.log('Authorization failed.');
|
||||
mod.addPageTab = function () {
|
||||
FB.ui(
|
||||
{ method: "pagetab" },
|
||||
function (resp) {
|
||||
console.log("response:");
|
||||
console.log(resp);
|
||||
var pageIdList = [];
|
||||
var tabs = resp["tabs_added"];
|
||||
|
||||
if (tabs != undefined && Object.keys(tabs).length > 0) {
|
||||
for (var pageId in tabs) {
|
||||
pageIdList.push(pageId);
|
||||
}
|
||||
|
||||
//POST these back to Airtime, which will then proxy it over to our social app. (multiple requests from Airtime)
|
||||
$.post(
|
||||
"facebook-tab-success",
|
||||
{ pages: JSON.stringify(pageIdList) },
|
||||
function () {
|
||||
alert("Successfully added to your Facebook page!");
|
||||
}
|
||||
}, {scope: 'manage_pages'});
|
||||
}
|
||||
)
|
||||
.done(function () {})
|
||||
.fail(function () {
|
||||
alert(
|
||||
"Sorry, an error occurred and we were unable to add the widget to your Facebook page."
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
app_id: FACEBOOK_APP_ID,
|
||||
//redirect_uri: 'https://localhost'
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
mod.getPagesOwnedByUser = function(userId, accessToken) {
|
||||
FB.api('/' + userId + '/accounts', function (response) {
|
||||
console.log(response);
|
||||
}, {access_token: accessToken});
|
||||
}
|
||||
|
||||
mod.addPageTab = function() {
|
||||
FB.ui(
|
||||
{ method: 'pagetab' },
|
||||
function (resp) {
|
||||
console.log("response:");
|
||||
console.log(resp);
|
||||
var pageIdList = [];
|
||||
var tabs = resp["tabs_added"];
|
||||
|
||||
if ((tabs != undefined) && (Object.keys(tabs).length > 0)) {
|
||||
for (var pageId in tabs) {
|
||||
pageIdList.push(pageId);
|
||||
}
|
||||
|
||||
//POST these back to Airtime, which will then proxy it over to our social app. (multiple requests from Airtime)
|
||||
$.post('facebook-tab-success', { "pages" : JSON.stringify(pageIdList) }, function() {
|
||||
alert("Successfully added to your Facebook page!");
|
||||
}).done(function() {
|
||||
|
||||
}).fail(function() {
|
||||
alert("Sorry, an error occurred and we were unable to add the widget to your Facebook page.");
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
app_id: FACEBOOK_APP_ID,
|
||||
//redirect_uri: 'https://localhost'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue