Skip to content

Instantly share code, notes, and snippets.

@AgelxNash
Created June 20, 2014 21:42
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 AgelxNash/0ba65897eada74e1d42c to your computer and use it in GitHub Desktop.
Save AgelxNash/0ba65897eada74e1d42c to your computer and use it in GitHub Desktop.
<pre class="gist" data-id="7377194"></pre>
$('pre.gist').each(function(){
var placeholder = $(this);
var filename = placeholder.data('file');
$.ajax({
url: 'https://api.github.com/gists/'+$(this).data('id'),
type: 'GET',
dataType: 'jsonp'
}).success( function(gistdata) {
if(filename != null && typeof gistdata.data.files[filename] !== "undefined"){
var content = gistdata.data.files[filename].content;
}else{
var content = gistdata.data.files[Object.keys(gistdata.data.files)[0]].content;
}
placeholder.removeClass('prettyprinted');
placeholder.text(content);
prettyPrint();
}).error( function(e) {
// ajax error
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment