Skip to content

Instantly share code, notes, and snippets.

@dhg
Created December 15, 2011 23:49
Show Gist options
  • Save dhg/1483546 to your computer and use it in GitHub Desktop.
Save dhg/1483546 to your computer and use it in GitHub Desktop.
Test
$(document).ready(function() {
//Global Vars -----------------------------------------------------
var posts = $('.posts'),
afterString,
subdomain = readParams('r'),
loader = $('.wash'),
loadMore = $('.loadmore-button'),
activePost = 0,
post,
subredditHint = $('.subreddit-hint p'),
hintIndex = 0,
lock = false,
commandDown = false;
//Initial Load -------------------------------------------------------------------------------
window.scrollTo(0,0);
// If viewType cookied, set it
if($.cookie("viewType")) {
$('body')
.removeClass('fullview')
.removeClass('listview')
.addClass($.cookie("viewType"));
}
//Initial JSON load
loadJSON();
//JSON -------------------------------------------------------------------------------
// Load data
function loadJSON() {
$.getJSON("http://www.reddit.com/"+subdomain+".json?limit=25&after="+afterString+"&jsonp=?", null, function(data) {
$.each(data.data.children, function(i, post) {
renderPost(post.data);
afterString = post.data.name;
});
}).complete(function() {
post = $('.post');
classifyImages();
loader.fadeOut(100);
loadMore.removeClass('loading');
lock = false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment