Williammer
5/31/2014 - 2:59 PM

jsPattern.callback@makeHamburger.html

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>