Last active
December 10, 2015 01:19
-
-
Save DanGe42/4357372 to your computer and use it in GitHub Desktop.
A naive way of doing something
This file contains 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
var toArray = function(orig) { | |
var arr = []; | |
for (var i = 0; i < orig.length; i++) { | |
arr.push(orig[i]); | |
} | |
return arr; | |
} | |
var find_child_by_class = function(root, klass) { | |
var queue = toArray(root.children); | |
var head = null; | |
while (queue.length > 0) { | |
head = queue.shift(); | |
if (head.className === klass) { | |
return head; | |
} else { | |
queue = queue.concat(toArray(head.children)); | |
} | |
} | |
return null; | |
} | |
setInterval(function() { | |
// Nah, you can easily figure out what goes here | |
}, 15000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment