-
-
Save Ajnasz/2392589 to your computer and use it in GitHub Desktop.
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
(function(app) { | |
var blockNodes, complexComputation, | |
findNodes, hiddenNodes, hide; | |
complexComputation = function () { | |
/* do some complex stuff and return a node */ | |
}; | |
findNodes = function(callback) { | |
var nodes = [], node; | |
node = complexComputation(); | |
// call if callback is callable | |
if (typeof callback === "function") callback(node); | |
nodes.push(node); | |
return nodes; | |
}; | |
// a callback function | |
hide = function(node) { | |
node.style.display = "none"; | |
}; | |
// find the nodes and hide them as you go | |
hiddenNodes = findNodes(hide); | |
blockNodes = findNodes(function(node) { | |
node.style.display = 'block'; | |
}); | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment