Skip to content

Instantly share code, notes, and snippets.

@dawalama
Created February 5, 2014 23:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dawalama/8835144 to your computer and use it in GitHub Desktop.
Save dawalama/8835144 to your computer and use it in GitHub Desktop.
<script>
if(!window.location.query) {
window.location.query = function(){
var map = {};
if ("" != this.search) {
var groups = this.search.substr(1).split("&"), i;
for (i in groups) {
i = groups[i].split("=");
map[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
}
}
return map;
};
}
queries = window.location.query();
var head= document.getElementsByTagName('head');
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'http://maydaylevisxwax.tumblr.com/api/read/json?num=50&start=0&tagged=' + queries['tag'];
head[0].appendChild(script);
</script>
<script type="text/javascript">
function parseTumblrApiResponse() {
// The variable "tumblr_api_read" is now set.
console.log(tumblr_api_read);
for (var i=0; i < tumblr_api_read.posts.length; i++) {
post = tumblr_api_read.posts[i];
if (post.type == 'photo') {
document.writeln('<li>' + post.id + ' (' + post['date-gmt'] + ')' + ' - Image<div><img src="' + post['photo-url-250'] + '" alt="0"></img></div></li>');
} else if (post.type == 'regular') {
document.write( '<li>' + post.id + ' (' + post['date-gmt'] + ')' + ' - Text' );
document.write('<div class="textPost">' + post['regular-body'] + '</div></li>');
} else if (post.type == 'video') {
document.write('<li>' + post.id + ' (' + post['date-gmt'] + ')' + ' - Video' );
document.write('<div>' + post['video-player-250'] + '</div></li>');
}
}
}
</script>
<body onLoad='parseTumblrApiResponse();'>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment