1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
function fbAsyncInit() {
var fbInitiated = false;
FB.init({
appId : regData.facebookApiID,
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true,
authResponse: true
});
var fbStatusChange = function(response) {
fbInitiated = true;
fbShowTabs();
if (response.status === 'connected') {
fbShowData();
} else if (response.status === 'not_authorized') {
fbShowData();
} else {
fbHideData();
}
}
// run once with current status and whenever the status changes
FB.getLoginStatus(fbStatusChange, true);
if (!fbInitiated) {
fbHideTabs();
fbHideData();
}
FB.Event.subscribe('auth.statusChange', fbStatusChange);
};
function fbShowTabs() {
if (regData.loginFacebookEnable)
OAT.Dom.show("lf_tab_2");
if (regData.facebookEnable)
OAT.Dom.show("rf_tab_2");
}
function fbHideTabs() {
OAT.Dom.hide("lf_tab_2");
OAT.Dom.hide("rf_tab_2");
}
function fbShowData() {
fbHideData();
var x = function(response) {
facebookData = response;
var lfLabel = $('lf_facebookData');
var rfLabel = $('rf_facebookData');
if (lfLabel || rfLabel) {
if (lfLabel) {
lfLabel.innerHTML = '<img src="https://graph.facebook.com/' + response.id + '/picture" style="margin-right:5px"/>' + response.name;
if (lfTab.selectedIndex == 2)
$('lf_login').disabled = false;
}
if (rfLabel) {
rfLabel.innerHTML = '<img src="https://graph.facebook.com/' + response.id + '/picture" style="margin-right:5px"/>' + response.name;
if (rfTab.selectedIndex == 2)
$('rf_signup').disabled = false;
var tbl = $('rf_table_2');
addProfileRowInput(tbl, 'Login Name', 'rf_uid_2', {value: (response.name).replace(' ', ''), width: '150px'});
addProfileRowInput(tbl, 'E-Mail', 'rf_email_2', {value: response.email, width: '300px'});
rfCheckUpdate(2);
}
}
}
FB.api('/me', x);
}
function fbHideData() {
facebookData = null;
var label = $('lf_facebookData');
if (label) {
label.innerHTML = '';
if (lfTab.selectedIndex == 2)
$('lf_login').disabled = true;
}
var label = $('rf_facebookData');
if (label) {
label.innerHTML = '';
if (rfTab.selectedIndex == 2)
$('rf_signup').disabled = true;
OAT.Dom.unlink('tr_rf_uid_2');
OAT.Dom.unlink('tr_rf_email_2');
}
}
|