Created
February 4, 2013 19:52
-
-
Save chrisramsay/4709143 to your computer and use it in GitHub Desktop.
js-prettify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var prettifyPath = "//jp-cdn.appspot.com/js/prettify/"; | |
var prettifyJS = prettifyPath + "prettify.js"; | |
var prettifyCSS = prettifyPath + "prettify.css"; | |
var jqueryJS = "//jp-cdn.appspot.com//js/jquery.js"; | |
function jQueryExists() { return typeof jQuery !== 'undefined'; } | |
//get jquery | |
if(jQueryExists()) | |
gotJQuery(); | |
else { | |
document.write('<script src="'+jqueryJS+'"></script>'); | |
var interval = setInterval(function() { | |
if (jQueryExists()) { | |
clearInterval(interval); | |
gotJQuery(); | |
} | |
}, 100); | |
} | |
//got jquery | |
function gotJQuery() { | |
$("head").append('<link href="'+prettifyCSS+'" rel="stylesheet"></link>'); | |
jQuery.ajaxSetup({ cache: false }); | |
$.getScript(prettifyJS, gotPrettify); | |
} | |
//prettify! | |
function gotPrettify(){ | |
$(document).ready(window.prettyPrint); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment