Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save choonkeat/472346 to your computer and use it in GitHub Desktop.

Select an option

Save choonkeat/472346 to your computer and use it in GitHub Desktop.
Index: trunk/FBConnect/FBConnectHooks.php
===================================================================
--- trunk/FBConnect/FBConnectHooks.php (revision 206)
+++ trunk/FBConnect/FBConnectHooks.php (working copy)
@@ -%ld,%ld +%ld,%ld @@
// Don't include jQuery if it's already in use on the site
#$out->includeJQuery();
// Temporary workaround until until MW is bundled with jQuery 1.4.2:
- $out->addScriptFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
+ $out->addInlineScript('!window.jQuery && document.write(unescape("%3Cscript src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"%3E%3C/script%3E"))');
// Add the script file specified by $url
if(!empty($fbExtensionScript)){
@@ -%ld,%ld +%ld,%ld @@
// Don't include jQuery if it's already in use on the site
if (!empty($fbIncludeJquery)){
- $out->addScriptFile("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
+ $out->addInlineScript('!window.jQuery && document.write(unescape("%3Cscript src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"%3E%3C/script%3E"))');
}
// Add the script file specified by $url
Index: trunk/FBConnect/fbconnect.min.js
===================================================================
--- trunk/FBConnect/fbconnect.min.js (revision 206)
+++ trunk/FBConnect/fbconnect.min.js (working copy)
@@ -%ld,%ld +%ld,%ld @@
-window.fbAsyncInit=function(){FB.init({appId:window.fbAppId,session:window.fbSession,status:true,cookie:true,xfbml:window.fbUseMarkup});FB.Event.subscribe("auth.logout",function(){if(confirm("Not logged in.\n\nYou have been loggout out of Facebook. Press OK to log in via Facebook Connect again, or press Cancel to stay on the current page."))window.location=window.wgArticlePath.replace(/\$1/,"Special:Connect")})};
-$(document).ready(function(){$("#pt-fbconnect,#pt-fblink,#pt-fbconvert").addClass("mw-fblink");$("#pt-fblogout").click(function(){confirm("You are logging out of both this site and Facebook.")&&FB.logout(function(){window.location=window.fbLogoutURL})})});function sendToConnectOnLogin(){window.location.href=wgServer+wgScript+"?title=Special:Connect&returnto="+wgPageName+"&returntoquery="+wgPagequery};
\ No newline at end of file
+
+window.fbAsyncInit=function(){FB.init({appId:window.fbAppId,session:window.fbSession,status:true,cookie:true,xfbml:window.fbUseMarkup});var log=function(){log.history=log.history||[];log.history.push(arguments);if(window.console){try{console.log.apply(window,Array.prototype.slice.call(arguments));}catch(e){console.log(arguments);}}};var events=['auth.login','auth.logout','auth.sessionChange','auth.statusChange','xfbml.render','edge.create','comments.add','fb.log'];var len=events.length;for(var x=0;x<len;x++){(function(evt){log("hooking up",evt);FB.Event.subscribe(evt,function(response){log("["+evt+"]",(response&&response.status),response);});})(events[x]);}
+FB.getLoginStatus(function(response){log("getLoginStatus",response);FB.Event.subscribe('auth.logout',function(response){var login=confirm("Not logged in.\n\nYou have been loggout out of "+"Facebook. Press OK to log in via Facebook Connect "+"again, or press Cancel to stay on the current page.");if(login){}});});};$(document).ready(function(){$('#pt-fbconnect,#pt-fblink,#pt-fbconvert').addClass('mw-fblink');$('#pt-fblogout').click(function(){var logout=confirm("You are logging out of both this site and Facebook.");if(logout){FB.logout(function(response){window.location=window.fbLogoutURL;});}});});function sendToConnectOnLogin(){var destUrl=wgServer+wgScript+"?title=Special:Connect&returnto="+wgPageName+"&returntoquery="+wgPagequery;window.location.href=destUrl;}
\ No newline at end of file
Index: trunk/FBConnect/fbconnect.js
===================================================================
--- trunk/FBConnect/fbconnect.js (revision 206)
+++ trunk/FBConnect/fbconnect.js (working copy)
@@ -%ld,%ld +%ld,%ld @@
xfbml : window.fbUseMarkup // Whether XFBML should be automatically parsed
});
+/* FIRST, IMPROVE DEBUGGING */
+ // http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
+ var log = function() {
+ log.history = log.history || []; // store logs to an array for reference
+ log.history.push(arguments);
+ if (window.console) {
+ try {
+ console.log.apply(window,Array.prototype.slice.call(arguments));
+ } catch(e) {
+ console.log(arguments);
+ }
+ }
+ };
+ var events = [
+ 'auth.login', // -- fired when the user logs in
+ 'auth.logout', // -- fired when the user logs out
+ 'auth.sessionChange', // -- fired when the session changes
+ 'auth.statusChange', // -- fired when the status changes
+ 'xfbml.render', // -- fired when a call to FB.XFBML.parse() completes
+ 'edge.create', // -- fired when the user likes something (fb:like)
+ 'comments.add', // -- fired when the user adds a comment (fb:comments)
+ 'fb.log'];
+ var len = events.length;
+ for (var x = 0; x < len; x++) {
+ (function(evt) {
+ log("hooking up", evt);
+ FB.Event.subscribe(evt, function(response) { log("[" + evt + "]", (response && response.status), response); });
+ })(events[x]);
+ }
+
+
+/* NEXT, "FB.getLoginStatus" seem to trigger spurious "auth.logout" events.
+ So, let us perform a "FB.getLoginStatus" to get the facts right first
+ before hooking up our "auth.logout" handler */
+ FB.getLoginStatus(function(response) {
+ log("getLoginStatus", response);
+
// NOTE: Auth.login doesn't appear to work anymore.
// The onlogin attribute of the fb:login-buttons is being used instead.
-
+
// Register a function for when the user logs out of Facebook
FB.Event.subscribe('auth.logout', function(response) {
// TODO: Internationalize
@@ -%ld,%ld +%ld,%ld @@
window.location = window.wgArticlePath.replace(/\$1/, "Special:Connect");
}
});
+
+ });
};
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment