Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Forked from anonymous/kodfejtok_sample.js
Created April 15, 2012 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ajnasz/2392589 to your computer and use it in GitHub Desktop.
Save Ajnasz/2392589 to your computer and use it in GitHub Desktop.
(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