facebookStreamSetting = new function () { this.actionLinkText = ""; this.actionLinkHref = ""; } facebookApp = new function facebookApp() { this.apiKey = "3847b507a3950eb86e8c4b1411d6ec05"; this.autoPublish = false; this.init = function() { if (this.apiKey != "") { FB.init(this.apiKey, "/xd_receiver.htm"); FB_RequireFeatures(["XFBML", "Connect", "Api"], null); } } this.login = function() { if (this.apiKey != "") { FB.ensureInit(function (){ FB.Connect.ifUserConnected(siteLogin, null); }) ; } } this.fbLogin = function() { if (this.apiKey != "") { FB.ensureInit(function (){ FB.Connect.ifUserConnected(facebookLogin, null); }) ; } } // this.fbLogin = function() { // if (this.apiKey != "") { // FB.ensureInit(function() { // FB.Connect.requireSession(siteLogin) ; // } // ); // } // } this.afterConnect = function(result, exception) { if (this.apiKey != "") { $.get('/ws/fb/connect.aspx', { action: 'connect', t: new Date().getTime() }, function(data) { afterConnectCallback(data); }); } } this.disconnect = function() { if (this.apiKey != "") { $.facebox("Sending disconnect request..."); $.get('/ws/fb/connect.aspx', { action: 'disconnect', t: new Date().getTime() }, function(data) { disconnectCallback(data); }); } } function disconnectCallback() { jQuery(document).trigger('close.facebox'); location.reload(); } function afterConnectCallback(data) { var connectedNode = $('connect', data); if (connectedNode != null ) { if (connectedNode.attr('status') == '1') location.reload(); } jQuery(document).trigger('close.facebox'); } function siteLogin () { var playerId = parseInt(getCookie("playerId")); if (isNaN(playerId)) playerId = 0; if (!(playerId != 0)) { var fbUser = FB.Connect.get_loggedInUser(); if (fbUser != null) { $.facebox('Please wait while logging in'); $.get('/ws/fb/login.aspx', { t: new Date().getTime()}, function(data) { loginCallback(data); }); //window.location = '/login/register.aspx?retUrl=' + escape(window.location.pathname); } } } function facebookLogin () { var playerId = parseInt(getCookie("playerId")); if (isNaN(playerId)) playerId = 0; if (!(playerId != 0)) { var fbUser = FB.Connect.get_loggedInUser(); if (fbUser != null) { $.facebox('Please wait while logging in'); $.get('/ws/fb/facebookLogin.aspx', {t: new Date().getTime()}, function(data) { facebookLoginCallback(data); }); } } } this.logout = function logout() { if (this.apiKey != "") { var fbUser = FB.Connect.get_loggedInUser(); if (fbUser != null) { FB.Connect.logoutAndRedirect('/login/logout.aspx'); } else { window.location = '/login/logout.aspx'; } } else{ window.location = '/login/logout.aspx'; } } function facebookLoginCallback(data){ var playerId = parseInt(getCookie("playerId")); if (isNaN(playerId)) playerId = 0; if (playerId > 0){ this.afterConnect(); } else{ window.location = '/login/facebookRegister.aspx?retUrl=' + escape(window.location.pathname); } } function loginCallback(data) { var playerId = parseInt(getCookie("playerId")); if (isNaN(playerId)) playerId = 0; if (playerId > 0){ var redirectTo = $('redirectTo', data); if (redirectTo != null) { if (!IsNullOrEmpty(redirectTo.text())) { window.location = unescape(redirectTo.text()) ; return ; } } location.reload() ; } else{ jQuery(document).trigger('close.facebox'); } } }