function statusChangeCallback(response) {
if (response.status === 'connected') {
FB.api('me', {fields: 'username'}, function(res) { });
$.mbsmessage(t_lang('Please wait...'));
data='fb_token='+response.authResponse.accessToken;
data+='&is_ajax_request=yes';
$.ajax({
data:data,
url:'/member/fblogin/',
dataType:'JSON',
type:'POST',
async:false,
success:function(data) { // Do an AJAX call]
$(document).trigger('close.mbsmessage');
if(data.status=="1")
{
window.location.reload();
//$("#responseModal").hide();
}
else if(data.status=="0")
{
$.facebox("
"+data.msg+"
");
}
else if(typeof data !== 'undefined' && data.length > 0){
if(data.msg){
$.facebox(""+data.msg+"
");
}
}
}
});
}
}
function Login()
{
FB.login(function(response) {
console.log(response);
statusChangeCallback(response);
}, {scope: 'public_profile,email'});
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '724551240982624',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.1' // use version 2.0
});
}; (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'));
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log(response);
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
var photo;
FB.api('/me/picture?type=normal', function(response) {
if(response){
console.log(response);
}
});
}
function openPopup(url)
{
var height = 580;
var width = 500;
var left=100;
var top=100;
var simpleauth = window.open(url, 'simpleauth', 'location=yes,status=yes,resizable=true,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
if(!simpleauth && !navigator.userAgent.match('iPad')){
alert('Cannot Open popup as it is disabled from your browser is disabled. Change settings and try again.');
}
else
simpleauth.window.focus();
}