Last active
April 22, 2016 00:03
-
-
Save mgroves/55c2a08fc26e3f082bee84528f1cf153 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$(document).ready(function () { | |
var commentDiv = $("#latestComments"); | |
if (!commentDiv || commentDiv.length <= 0) | |
return; | |
var url = "https://disqus.com/api/3.0/forums/listPosts.json?forum=[your forum name]&limit=10&related=thread&order=desc&api_key=[put your own API key here]"; | |
$.get(url, function (res, code) { | |
var html = ""; | |
if (res.code === 0) { | |
if (res.response.length <= 0) { | |
html += "There are no comments."; | |
} else { | |
html += "<ul class=\"list-group\">"; | |
for (var i = 0, len = res.response.length; i < len; i++) { | |
var post = res.response[i]; | |
html += "<li class=\"list-group-item\"><strong>"; | |
html += post.author.name; | |
html += "</strong> on <a href=\"" + post.url + "\">"; | |
html += post.thread.clean_title; | |
html += "</a></li>"; | |
} | |
html += "</ul>"; | |
} | |
} else { | |
html = "Unable to load latest comments."; | |
} | |
commentDiv.html(html); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment