Skip to content

Instantly share code, notes, and snippets.

@mcwhittemore
Created April 10, 2014 10:04
Show Gist options
  • Save mcwhittemore/10364108 to your computer and use it in GitHub Desktop.
Save mcwhittemore/10364108 to your computer and use it in GitHub Desktop.
var contentBox = $(".box")[0];
if(contentBox==undefined){
throw new Error("Can't find paste element");
}
else{
var $content = $(contentBox);
var header = $content.find(".box-header")[0];
header.innerHTML = "<h3 style='text-align: center;'>Comments</h3>";
var box = $content.find(".box-body")[0];
box.innerHTML = "";
listComments(1, 10, box);
}
function listComments(page, maxPage, box){
$.get(window.location.pathname+"?page="+page).done(function(body){
var comments = $("<div>"+body+"</div>").find(".commit_comment");
for(var i=0; i<comments.length; i++){
box.appendChild(comments[i]);
}
if(page<maxPage){
listComments(page+1, maxPage, box);
}
}).fail(function(){console.log("FAIL");});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment