Skip to content

Instantly share code, notes, and snippets.

@tastycode
Created August 30, 2011 05:08
Show Gist options
  • Save tastycode/1180227 to your computer and use it in GitHub Desktop.
Save tastycode/1180227 to your computer and use it in GitHub Desktop.
fb_comment_layer
/*
Facebook Comment Layer
Adds a facebook comment feed to any page
*/
(function() {
//adapted from jQuerify bookmarklet loader
//http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
var el=document.createElement('div');
var body=document.getElementsByTagName('body')[0];
var otherlib=false;
if (typeof($)=='function') otherlib=true;
function getScript(url,success){
var script=document.createElement('script');
script.src=url;
var head=document.getElementsByTagName('head')[0],
done=false;
// Attach handlers for all browsers
script.onload=script.onreadystatechange = function(){
if ( !done && (!this.readyState
|| this.readyState == 'loaded'
|| this.readyState == 'complete') ) {
done=true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
}
getScript('http://code.jquery.com/jquery-latest.min.js',function() {
if (typeof jQuery=='undefined') {
msg='Sorry, but jQuery wasn\'t able to load';
} else {
//fetch facebook API
getScript("http://connect.facebook.net/en_US/all.js#xfbml=1",function() {
//once DOM loaded, add in FB elements
jQuery(function() {
//create fixed comment container
var fb_foot_container = jQuery("<div></div>",{
css: {
position:'fixed',
background: '#efefef',
bottom: 0,
left: 0,
width: '100%'
}
});
//standard fb:comments implementation adopted from
//https://developers.facebook.com/docs/reference/plugins/comments/
var fb_root = jQuery("<div></div>",{id:"fb-root"});
var fb_fbml_comments = jQuery("<fb:comments></fb:comments>");
jQuery('body').append(fb_foot_container);
jQuery(fb_fbml_comments).attr({href:window.location.toString(),num_posts:6,width:jQuery(fb_foot_container).width()});
fb_foot_container.append(fb_root);
fb_foot_container.append(fb_fbml_comments);
//parse all fbml
FB.XFBML.parse();
});
});
}
});
}());
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(5(){4 J=9.z(\'8\');4 f=9.y(\'f\')[0];4 r=w;d(A($)==\'5\')r=p;5 e(x,s){4 2=9.z(\'2\');2.I=x;4 a=9.y(\'a\')[0],g=w;2.l=2.n=5(){d(!g&&(!c.b||c.b==\'H\'||c.b==\'G\')){g=p;s();2.l=2.n=L;a.O(2)}};a.N(2)}e(\'q://M.u.P/u-C.B.m\',5(){d(A 3==\'F\'){E=\'D, K 3 15\\\'t 1b 1c 1a\'}19{e("q://Q.18.1e/1g/1i.m#1h=1",5(){3(5(){4 7=3("<8></8>",{1f:{1j:\'1d\',16:\'#V\',W:0,U:0,i:\'T%\'}});4 o=3("<8></8>",{R:"h-S"});4 k=3("<h:v></h:v>");3(\'f\').j(7);3(k).X({Y:13.14.12(),11:6,i:3(7).i()});7.j(o);7.j(k);Z.10.17()})})}})}());',62,82,'||script|jQuery|var|function||fb_foot_container|div|document|head|readyState|this|if|getScript|body|done|fb|width|append|fb_fbml_comments|onload|js|onreadystatechange|fb_root|true|http|otherlib|success||jquery|comments|false|url|getElementsByTagName|createElement|typeof|min|latest|Sorry|msg|undefined|complete|loaded|src|el|but|null|code|appendChild|removeChild|com|connect|id|root|100|left|efefef|bottom|attr|href|FB|XFBML|num_posts|toString|window|location|wasn|background|parse|facebook|else|load|able|to|fixed|net|css|en_US|xfbml|all|position'.split('|'),0,{}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment