initial commit
This commit is contained in:
commit
c64f2ce09b
1 changed files with 21 additions and 0 deletions
21
randomComment.js
Normal file
21
randomComment.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
var li = document.getElementsByTagName("li");
|
||||||
|
console.log("Found ", li.length, " li tags");
|
||||||
|
var comments = [];
|
||||||
|
|
||||||
|
for (var l = 0; l < li.length - 1; l++) {
|
||||||
|
if (li[l].classList.contains("comment")) {
|
||||||
|
if (li[l].classList.contains("comment-author-bernie") == false) {
|
||||||
|
comments.push(li[l]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Found ", comments.length, " comments not by Bernie");
|
||||||
|
|
||||||
|
console.log("Choosing winner...");
|
||||||
|
var winner = comments[Math.floor(Math.random() * comments.length)];
|
||||||
|
|
||||||
|
winner.querySelector("article").style.background = "gray";
|
||||||
|
winner.scrollIntoViewIfNeeded();
|
||||||
|
|
||||||
|
// alert("The winner is: ", winnerName);
|
Loading…
Reference in a new issue