Last active
July 27, 2017 15:30
Revisions
-
armandocanals revised this gist
Jul 15, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,4 @@ function getElementsByClassName(className) { return matches; } getElementsByClassName('some-class'); -
armandocanals renamed this gist
Jul 15, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
armandocanals revised this gist
Oct 15, 2013 . 1 changed file with 16 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,23 @@ function getElementsByClassName(className) { var elements = document.body, matches = []; function traverse(node) { for(var i = 0; i < node.childNodes.length; i++) { if(node.childNodes[i].childNodes.length > 0) { traverse(node.childNodes[i]); } if(node.childNodes[i].getAttribute && node.childNodes[i].getAttribute('class')) { if(node.childNodes[i].getAttribute('class').split(" ").indexOf(className) >= 0) { matches.push(node.childNodes[i]); } } } } traverse(elements); return matches; } getElementsByClassName('central-featured-lang'); -
armandocanals revised this gist
Oct 15, 2013 . 1 changed file with 14 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,23 @@ function getElementsByClassName(className) { var elements = document.body.children, elArr = Array.prototype.slice.apply(elements), results = []; function inspect(node, results) { if(node.getAttribute && node.getAttribute('class')) { if(node.getAttribute('class').split(" ").indexOf(className) >= 0) { results.push(node); } }; }; elArr.forEach(function(x) { inspect(x, results); for(var i = 0; i < x.childNodes.length; i++) { var node = x.childNodes[i]; inspect(node, results); } }); return results; -
armandocanals revised this gist
Oct 15, 2013 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,19 +3,19 @@ function getElementsByClassName(className) { elArr = Array.prototype.slice.apply(elements), results = [], tree = []; elArr.forEach(function(x) { tree.push(x) for(var i = 0; i < x.childNodes.length; i++) { tree.push(x.childNodes[i]); } }); tree.forEach(function(item) { if(item.getAttribute && item.getAttribute('class')) { if(item.getAttribute('class').indexOf(className) >= 0) { results.push(item); } }; }); return results; -
armandocanals created this gist
Oct 14, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ function getElementsByClassName(className) { var elements = document.body.children, elArr = Array.prototype.slice.apply(elements), results = [], tree = []; elArr.forEach(function(x, idx) { tree.push(x) for(var i = 0; i < x.childNodes.length; i++) { tree.push(x.childNodes[i]); } }) tree.forEach(function(item,index) { if(item.getAttribute && item.getAttribute('class')) { if(item.getAttribute('class').indexOf(className) >= 0) { results.push(item); } }; }) return results; } getElementsByClassName('central-featured-lang');