Skip to content

Instantly share code, notes, and snippets.

@thearchduke
Created November 5, 2016 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thearchduke/69f685ed5a0de260eb8233ec670951a2 to your computer and use it in GitHub Desktop.
Save thearchduke/69f685ed5a0de260eb8233ec670951a2 to your computer and use it in GitHub Desktop.
$.ajax({
url: "evening.html",
}).done(function(data) {
var post = $(data);
window.graph.nodes.push({
"id": "front-page post",
"user": "front-page post"
})
post.find('.comment').each(function() {
var cmt = $(this);
var user = cmt.find('div > div > cite').text();
var text = cmt.find('p').text();
var id = cmt.find('div:nth-of-type(2)').attr('id');
var numAs = 0;
window.graph.nodes.push({
"id": id,
"user": user,
"text": text,
});
cmt.find('div > p > a').each(function() {
var anchor = $(this)
if (anchor.attr("href").includes("#comment-")) {
window.graph.links.push({
"source": id,
"target": anchor.attr("href").split("#")[1]
});
numAs++;
}
})
if (numAs == 0) {
window.graph.links.push({
"source": id,
"target": "front-page post"
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment