1 dump('entering util/exec.js\n');
3 if (typeof util == 'undefined') var util = {};
4 util.exec = function() {
5 //JSAN.use('util.error'); this.error = new util.error();
10 util.exec.prototype = {
11 // This executes a series of functions, but tries to give other events/functions a chance to
12 // execute between each one.
13 'chain' : function () {
16 for (var i = 0; i < arguments.length; i++) {
17 var arg = arguments[i];
18 switch(arg.constructor.name) {
23 for (var j = 0; j < arg.length; j++) {
24 if (typeof arg[j] == 'function') args.push( arg[j] );
29 if (typeof arg[j] == 'function') args.push( arg[j] );
34 if (args.length > 0) setTimeout(
38 if (args.length > 1 ) obj.chain( args.slice(1) );
40 dump('util.exec.chain error: ' + js2JSON(E) + '\n');
41 var keep_going = false;
42 if (typeof obj.on_error == 'function') {
43 keep_going = obj.on_error(E);
46 dump('chain not broken\n');
48 if (args.length > 1 ) obj.chain( args.slice(1) );
51 dump('another error: ' + js2JSON(E) + '\n');
54 dump('chain broken\n');
62 dump('exiting util/exec.js\n');