Skip to content

Instantly share code, notes, and snippets.

@Williammer
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Williammer/b7c4d4d2d0e3ed9975b6 to your computer and use it in GitHub Desktop.
Save Williammer/b7c4d4d2d0e3ed9975b6 to your computer and use it in GitHub Desktop.
jsPattern.callback@makeHamburger.html
<iframe width="100%" height="300" src="http://jsfiddle.net/Williammer/Yp9gf/1/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
<script>
/** javaScript **/
var findNodes = function (callback, callback_obj) {
var i = 10,
nodes = [],
found;
// check if callback is callable
if(typeof callback === 'string'){
callback = callback_obj[callback];
}
if (typeof callback !== "function") {
callback = false;
}
while (i) {
i -= 1;
found = i%2? document.createElement('li'): false;
found.className = 'li_'+i;
found.innerHTML = 'li_'+i;
//found = document.createElement('li');
// now callback:
if (callback) {
callback.call(callback_obj, found);
//callback(found);
}
nodes.push(found);
}
return nodes;
};
var handleNode = {
settleNode: function(node) {
if(node){
var pt = document.getElementById('plat');
pt.appendChild(node);
}
}
};
findNodes('settleNode', handleNode);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment