Created
March 15, 2012 21:36
-
-
Save assembler/2047145 to your computer and use it in GitHub Desktop.
Render gists on tumblr
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
<!-- GIST Renderer --> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<link rel="stylesheet" href="https://gist.github.com/stylesheets/gist/embed.css"/> | |
<script type="text/javascript"> | |
var cachedWrite = document.write, | |
body = $('body'), | |
gists = $("a[href*='gist.github.com'][href$='#embed']").get(), | |
embedNextGist = function() { | |
if (gists.length == 0) { | |
document.write = cachedWrite; | |
} | |
else { | |
var gist = gists.shift(), | |
src = $(gist).attr('href').split('#')[0]; | |
document.write = function(styleLink) { | |
document.write = function(gistDiv) { | |
$(gist).replaceWith(gistDiv); | |
embedNextGist(); | |
}; | |
}; | |
body.append('<scr' + 'ipt src="' + src + '.js"></scr' + 'ipt>'); | |
} | |
}; | |
embedNextGist(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment