Skip to content

Instantly share code, notes, and snippets.

@acdha
Created November 4, 2010 13:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdha/662454 to your computer and use it in GitHub Desktop.
Save acdha/662454 to your computer and use it in GitHub Desktop.
Bookmarklet to embed and run Google's BidiChecker on the current page
javascript:(function(){(function(target,msg){var loader=function(){if(arguments.callee._executed)return;arguments.callee._executed=true;bidichecker.runGui(bidichecker.checkPage(document.dir=="rtl"));};var s=document.createElement('script');s.type="text/javascript";s.setAttribute('src',"//bidichecker.googlecode.com/svn/trunk/lib/bidichecker_packaged.js");if(s.addEventListener){s.addEventListener("load",loader,false);}else if("onreadystatechange" in s){s.onreadystatechange=function(){if(this.readyState=='complete'||this.readyState=='loaded'){loader();}};}else{window.setTimeout(loader(),2500);}document.getElementsByTagName('head')[0].appendChild(s);})();})();
/*
To avoid polluting the global namespace this uses an anonymous
function which is called with either the URL for an external
JavaScript file or a function. In either case jQuery will be loaded
from the Google CDN before your code is executed so it's free to
depend on jQuery without checking for it and can do things like
jQuery.getScript() to load other components (e.g. jQuery UI),
stylesheets, etc.
*/
(function (target, msg) {
var loader = function() {
// Avoid executing this function twice:
if (arguments.callee._executed) return;
arguments.callee._executed = true;
bidichecker.runGui(bidichecker.checkPage(document.dir == "rtl"));
};
var s = document.createElement('script');
s.type = "text/javascript";
s.setAttribute('src', "//bidichecker.googlecode.com/svn/trunk/lib/bidichecker_packaged.js");
if (s.addEventListener) { // Mozilla / WebKit
s.addEventListener("load", loader, false);
} else if ("onreadystatechange" in s) { // IE
s.onreadystatechange = function () {
if (this.readyState == 'complete' || this.readyState == 'loaded') { loader(); }
};
} else {
// Chances are if your browser is this old this won't even work but just in case:
window.setTimeout(loader(), 2500);
}
document.getElementsByTagName('head')[0].appendChild(s);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment