Commits

Anonymous committed 288a04a

Manual folder instead of symlink

Comments (0)

Files changed (8)

lib

-/home/firefly/web/js/lib
+var FF = (function() {
+	var FF = {};
+	var _included = {};
+	
+	var HEAD;
+	
+	FF.Core = {};
+	FF.Dom = {};
+	
+	FF.Dom.instanceOf = function(x, y) {
+		return typeof(x) === 'object' && x !== null && x instanceof y;
+	};
+	FF.Dom.isArray = function(x) {
+		return FF.Dom.instanceOf(x, Array);
+	};
+	
+	FF.$ = function(s) {
+		return document.getElementById(s);
+	};
+	
+	FF.Core.include = function() {
+		var folder='', files=0, done=0, perfs=[];
+		if (!HEAD) HEAD = document.getElementsByTagName('head')[0];
+		
+		function include(file) {
+			if (!((folder + '/' + file) in _included)) {
+				var el = document.createElement('script');
+				el.type = 'application/javascript';
+				el.src = folder + '/' + file;
+				HEAD.appendChild(el);
+				
+				files--;
+				el.onload = function() {
+					done++;
+					
+					if (files == done) {
+						for (var i=0; i<perfs.length; i++) {
+							perfs[i].call(this);
+						}
+					}
+				};
+			}
+		}
+		
+		for (var i=0; i<arguments.length; i++) {
+			if (typeof(arguments[i]) == 'string') {
+				if (arguments[i].match(/\.js$/)) {
+					include(arguments[i]);
+				} else {
+					folder = arguments[i];
+				}
+			} else if (FF.Dom.isArray(arguments[i])) {
+				for (var j=0; j<arguments[i].length; j++) {
+					include(arguments[i][j]);
+				}
+			} else if (typeof(arguments[i]) == 'function') {
+				perfs.push(arguments[i]);
+			} else {
+				throw new TypeError("Unsupported argument '" + arguments[i] + "'");
+			}
+		}
+		
+		files = -files;
+	};
+	
+	return FF;
+})();
+(function() {
+	FF.Debug = {};
+	var callbacks = [];
+	var on = true;
+	
+	FF.Debug.print = function() {
+		if (on) {
+			for (var i=0; i<callbacks.length; i++) {
+				for (var j=0; j<arguments.length; j++) {
+					callbacks[i]('' + arguments[j]);
+				}
+			}
+		}
+	};
+	FF.Debug.printobj = function(obj) {
+		var propVals = [];
+		for (var k in obj) {
+			if (obj.hasOwnProperty(k)) {
+				propVals.push(k + ":'" + obj[k] + "'");
+			}
+		}
+		FF.Debug.print("{" + propVals.join(", ") + "}");
+	};
+	FF.Debug.setEnabled = function(isOn) {
+		on = isOn;
+	};
+	FF.Debug.on = function() { FF.Debug.setEnabled(true); };
+	FF.Debug.off = function() { FF.Debug.setEnabled(false); };
+	
+	FF.Debug.connect = function(cb) {
+		if (callbacks.indexOf(cb) == -1) {
+			callbacks.push(cb);
+		}
+	};
+	FF.Debug.disconnect = function(cb) {
+		callbacks = callbacks.sans(cb);
+	};
+	
+	FF.Debug.createElement = function() {
+		var D = FF.Dom;
+		
+		var list = D.create('ul', {style: "font-family: monospace; font-size: 10pt; " +
+				"white-space: pre; padding-left: 0; max-height: 185px; overflow: auto;"});
+		list.style.display = 'none';
+		var shown = false;
+		
+		var el = D.create('div', {style: "position: absolute; bottom: 0; left: 0; " +
+				"width: 100%; border-top: 1px solid #999"}, [
+			list,
+			D.create('span', {style: "cursor: pointer;", onclick: function() {
+				shown = !shown;
+				list.style.display = shown ? 'block' : 'none';
+			}}, ["***"])
+		]);
+		
+		FF.Debug.connect(function(str) {
+			list.appendChild(D.create('li', {}, [str]));
+		});
+		
+		return el;
+	};
+})();
+
+var Debug = FF.Debug;
+FF.Dom.create = function(name, attrs, chs, cb) {
+	if (FF.Dom.isArray(attrs)) {
+		attrs = {};
+		chs = attrs;
+	}
+	if (!FF.Dom.isArray(chs)) {
+		chs = [];
+	}
+	
+	var el = document.createElement(name);
+	
+	for (var key in attrs) {
+		el[key] = attrs[key];
+	}
+	
+	for (var i=0; i<chs.length; i++) {
+		if (typeof(chs[i]) == 'string') {
+			el.appendChild(FF.Dom.text(chs[i]));
+		} else {
+			el.appendChild(chs[i]);
+		}
+	}
+	
+	if (typeof(cb) == 'function') {
+		cb.call(el, attrs, chs);
+	}
+	
+	return el;
+};
+
+FF.Dom.text = function(str) {
+	return document.createTextNode(str);
+};

lib/functional.js

+	// If not built-in.
+if (!Array.prototype.indexOf) {
+	Array.prototype.indexOf = function(x) {
+		for (var i=0; i<this.length; i++) {
+			if (this[i] == x) {
+				return i;
+			}
+		}
+		return -1;
+	};
+}
+if (!Array.prototype.lastIndexOf) {
+	Array.prototype.lastIndexOf = function(x) {
+		for (var i=this.length-1; i>0; i++) {
+			if (this[i] == x) {
+				return i;
+			}
+		}
+		return -1;
+	};
+}
+if (!Array.prototype.map) {
+	Array.prototype.map = function(f) {
+		var o = new Array(this.length);
+		for (var i=0; i<this.length; i++) {
+			o[i] = f(this[i], i, this);
+		}
+		return o;
+	};
+}
+if (!Array.prototype.filter) {
+	Array.prototype.filter = function(f) {
+		var o = [];
+		for (var i=0; i<this.length; i++) {
+			if (f(this[i], i, this)) {
+				o.push(this[i]);
+			}
+		}
+		return o;
+	};
+}
+if (!Array.prototype.forEach) {
+	Array.prototype.forEach = function(f) {
+		for (var i=0; i<this.length; i++) {
+			if (typeof(this[i]) !== 'undefined') {
+				f(this[i], i, this);
+			}
+		}
+	};
+}
+if (!Array.prototype.every) {
+	Array.prototype.every = function(f) {
+		for (var i=0; i<this.length; i++) {
+			if (!f(this[i], i, this)) {
+				return false;
+			}
+		}
+		return true;
+	};
+}
+if (!Array.prototype.some) {
+	Array.prototype.some = function(f) {
+		for (var i=0; i<this.length; i++) {
+			if (f(this[i], i, this)) {
+				return true;
+			}
+		}
+		return false;
+	};
+}
+if (!Array.prototype.reduce) {
+	Array.prototype.reduce = function(f) {
+		if (this.length == 1) {
+			return this[0];
+		} else {
+			return f(this[0], this.slice(1).reduce(f));
+		}
+	};
+}
+if (!Array.prototype.reduceRight) {
+	Array.prototype.reduceRight = function(f) {
+		if (this.length == 1) {
+			return this[0];
+		} else {
+			return f(this.slice(0, this.length-1).reduceRight(f),
+					this[this.length-1]);
+		}
+	};
+}
+
+	// Custom.
+if (!Array.prototype.rotate) {
+	Array.prototype.rotate = function(n) {
+		if (n === 0)
+			return this.copy();
+		
+		if (typeof(n) == 'undefined') {
+			n = 1;
+		} else {
+			n %= this.length;
+		}
+		return this.slice(this.length-n, this.length).
+				concat(this.slice(0, this.length-n));
+	};
+}
+if (!Array.prototype.copy) {
+	Array.prototype.copy = function() {
+		return this.slice(0);
+	};
+}
+if (!Array.prototype.multiply) {
+	Array.prototype.multiply = function(n) {
+		if (typeof(n) == 'undefined') n = 1;
+		var o = [];
+		
+		for (var i=0; i<n; i++) {
+			o.push(this.copy());
+		}
+		return o;
+	};
+}
+if (!Array.prototype.square) {
+	Array.prototype.square = function() {
+		return this.multiply(this.length);
+	};
+}
+if (!Array.prototype.mapDeep) {
+	Array.prototype.mapDeep = function(cb) {
+		var o = [];
+		for (var i=0; i<this.length; i++) {
+			if (typeof(this[i]) == 'object' && this[i] != null &&
+					this[i] instanceof Array) {
+				o.push(this[i].mapDeep(cb));
+			} else {
+				o.push(cb(this[i], i, this));
+			}
+		}
+		return o;
+	};
+}
+if (!Array.prototype.zip) {
+	Array.prototype.zip = function(other, cb) {
+		if (typeof(cb) == 'undefined') {
+			cb = function(a, b) {return [a, b]};
+		}
+		
+		if (typeof(other) != 'object' || other == null || !(other
+				instanceof Array) || this.length != other.length) {
+			throw new TypeError();
+		} else {
+			var o = new Array(this.length);
+			for (var i=0; i<this.length; i++) {
+				o[i] = cb(this[i], other[i], i, this, other);
+			}
+			return o;
+		}
+	};
+}
+if (!Array.prototype.inner) {
+	Array.prototype.inner = function(other, cb, cb2) {
+		if (typeof(cb) == 'undefined') {
+			cb = function(a, b) {return a*b};
+		}
+		if (typeof(cb2) == 'undefined') {
+			cb2 = function(a, b) {return a+b};
+		}
+		
+		return this.zip(other, cb).reduce(cb2);
+	};
+}
+if (!Array.prototype.outer) {
+	Array.prototype.outer = function(other, cb) {
+		if (typeof(other) != 'object' || other == null ||
+				!(other instanceof Array)) {
+			throw new TypeError();
+		} else {
+			var o = new Array(this.length);
+			for (var i=0; i<this.length; i++) {
+				o[i] = new Array(other.length);
+				for (var j=0; j<other.length; j++) {
+					o[i][j] = cb(this[i], other[j], i, j, this, other);
+				}
+			}
+			return o;
+		}
+	};
+}
+if (!Array.prototype.wrap) {
+	Array.prototype.wrap = function(n) {
+		if (typeof(n) == 'undefined') n = 1;
+		var c = this.copy(), o = [];
+		while (c.length > 0) {
+			var t = [];
+			for (var i=0; i<n && c.length>0; i++)
+				t.push(c.shift());
+			o.push(t);
+		}
+		return o;
+	};
+}
+if (!Array.prototype.permute) {
+	Array.prototype.permute = function() {
+		var ks = [], vs = [];
+		for (var i=0; i<this.length; i++) {
+			if (ks.indexOf(this[i]) >= 0) {
+				vs[ks.indexOf(this[i])]++;
+			} else {
+				ks.push(this[i]);
+				vs.push(1);
+			}
+		}
+		
+		function internalPermute(keys, vals) {
+			if (keys.length == 1) {
+				var o = [];
+				for (var i=0; i<vals[0]; i++) {
+					o.push(keys[0]);
+				}
+				return [o];
+			} else {
+				var o = [];
+				for (var i=0; i<keys.length; i++) {
+					var vali = vals.copy();
+					var keyi = keys.copy();
+					if (vals[i] == 1) {
+						vali.splice(i, 1);
+						keyi.splice(i, 1);
+					} else {
+						vali[i]--;
+					}
+					var perms = internalPermute(keyi, vali);
+					o = o.concat(perms.map(function(a) {
+						return [keys[i]].concat(a);
+					}));
+				}
+				return o;
+			}
+		};
+		
+		return internalPermute(ks, vs);
+	};
+}
+if (!Array.prototype.padBefore) {
+	Array.prototype.padBefore = function(pad, n) {
+		var o = [];
+		for (var i=0; i<this.length; i++) {
+			if (typeof(this[i]) != 'object' || this[i] == null ||
+					!(this[i] instanceof Array)) {
+				throw new TypeError();
+			} else {
+				var p = Array.range(n - this[i].length).map(function() {
+					return pad;
+				});
+				o.push(p.concat(this[i]));
+			}
+		}
+		return o;
+	}
+}
+if (!Array.prototype.interchange) {
+	Array.prototype.interchange = function(v, n) {
+		var i = 0;
+		return this.copy().map(function(a) {
+			if (a == v) {
+				return n[i++];
+			} else {
+				return a;
+			}
+		});
+	};
+}
+if (!Array.prototype.interchangeDeep) {
+	Array.prototype.interchangeDeep = function(v, n) {
+		var i = 0;
+		return this.copy().mapDeep(function(a) {
+			if (a == v) {
+				return n[i++];
+			} else {
+				return a;
+			}
+		});
+	};
+}
+if (!Array.prototype.count) {
+	Array.prototype.count = function(e) {
+		return this.filter(function(a) {return a==e}).length;
+	};
+}
+if (!Array.prototype.asSet) {
+	Array.prototype.asSet = function() {
+		var o = [];
+		for (var i=0; i<this.length; i++) {
+			if (o.realIndexOf(this[i]) == -1)
+				o.push(this[i]);
+		}
+		return o;
+	};
+}
+if (!Array.prototype.union) {
+	Array.prototype.union = function(other) {
+		return this.concat(other).asSet();
+	};
+}
+if (!Array.prototype.intersect) {
+	Array.prototype.intersect = function(other) {
+		var o = [];
+		for (var i=0; i<this.length; i++) {
+			if (other.indexOf(this[i]) != -1)
+				o.push(this[i]);
+		}
+		return o;
+	};
+}
+if (!Array.prototype.sans) {
+	Array.prototype.sans = function(arr) {
+		return this.filter(function(a) {
+			return arr.realIndexOf(a) == -1;
+		});
+	};
+}
+if (!Array.prototype.similarTo) {
+	Array.prototype.similarTo = function(other) {
+		if (this.length != other.length) {
+			return false;
+		} else {
+			for (var i=0; i<this.length; i++) {
+				if (typeof(this[i]) == 'object' && this[i] != null &&
+						this[i] instanceof Array) {
+					if (!this[i].similarTo(other[i]))
+						return false;
+				} else {
+					if (this[i] != other[i])
+						return false;
+				}
+			}
+			return true;
+		}
+	};
+}
+if (!Array.prototype.realIndexOf) {
+	Array.prototype.realIndexOf = function(el) {
+		if (typeof(el) == 'object' && el != null && el instanceof Array) {
+			for (var i=0; i<this.length; i++) {
+				if (this[i].similarTo(el))
+					return i;
+			}
+			return -1;
+		} else {
+			return this.indexOf(el);
+		}
+	};
+}
+if (!Array.prototype.flatten) {
+	Array.prototype.flatten = function() {
+		return this.reduce(function(a, b) {return a.concat(b)});
+	};
+}
+if (!Array.prototype.stitch) {
+	Array.prototype.stitch = function(other) {
+		var o = this.copy();
+		for (var i=0; i<other.length; i++) {
+			if (this.length <= i)
+				break;
+			
+			o[i] = o[i].concat(other[i]);
+		}
+		return o;
+	};
+}
+if (!Array.prototype.stitchFold) {
+	Array.prototype.stitchFold = function() {
+		return this.reduce(function(a, b) {return a.stitch(b)});
+	};
+}
+if (!Array.prototype.nIndexOf) {
+	Array.prototype.nIndexOf = function(other) {
+		if (other.length > this.length) {
+			return [-1];
+		} else {
+			if (typeof(this[0]) != 'object' && this[0] != null &&
+					!(this[0] instanceof Array)) {
+				var n = 0;
+				for (var i=0; i<this.length; i++) {
+					if (this[i] == other[n]) {
+						n++;
+						if (n == other.length) {
+							return [i-n+1];
+						}
+					} else {
+						n = 0;
+					}
+				}
+				return [-1];
+			} else {
+				var t;
+		outer:	for (var i=0; i<this.length; i++) {
+					if ((t = this[i].nIndexOf(other[0]))[0] >= 0) {
+							// See if done.
+						for (var j=1; j<other.length; j++) {
+							if (!this[i+j].slice(t[0], t[0] + other[j].length).
+									similarTo(other[j])) {
+								continue outer;
+							}
+							return [i].concat(t);
+						}
+					}
+				}
+				return [-1];
+			}
+		}
+	}
+}
+
+if (!Array.range) {
+	Array.range = function(a, b) {
+		if (!b) {
+			b = a;
+			a = 1;
+		}
+		
+		var out = [];
+		for (var i=a; i<=b; i++) {
+			out.push(i);
+		}
+		return out;
+	};
+}
+if (!Array.indices) {
+	Array.indices = function() {
+		var o = [];
+		for (var i=0; i<arguments.length; i++) {
+			for (var j=0; j<arguments[i]; j++) {
+				o.push(i);
+			}
+		}
+		return o;
+	};
+}
+if (!Array.radixNumbers) {
+	Array.radixNumbers = function(r, n) {
+		var o = [];
+		for (var i=0; i<n; i++) {
+			o.push((i).toString(r).split('').map(function(a) {
+				return parseInt(a);
+			}));
+		}
+		return o;
+	};
+}
+
+if (!Function.prototype.iterate) {
+	Function.prototype.iterate = function(x, n) {
+		if (n == 0) {
+			return [];
+		} else if (n < 0) {
+			throw new TypeError();
+		} else {
+			var o = [x];
+			for (var i=1; i<n; i++) {
+				o.push(this(o[i-1]));
+			}
+			return o;
+		}
+	};
+}
+
+if (!Math.add) {
+	Math.add = function(a, b) {return a+b};
+}
+if (!Math.multiply) {
+	Math.multiply = function(a, b) {return a*b};
+}
+if (!Math.subtract) {
+	Math.subtract = function(a, b) {return a-b};
+}
+if (!Math.divide) {
+	Math.divide = function(a, b) {return a/b};
+}
+if (!Math.square) {
+	Math.square = function(a) {return a*a};
+}
+if (!Math.getMultiplier) {
+	Math.getMultiplier = function(a) {
+		return function(b) {return a*b}
+	};
+}
+if (!Math.pow) {
+	Math.pow = function(a, b) {return Math.pow(a, b)};
+}
+(function() {
+	FF.Random = function(f) {
+		this.func = f;
+	};
+	FF.Random.prototype.nextInt = function(min, max) {
+		min = min || 0;
+		max = max || (1 << 32) - 1;
+		return this.func() % (min+max) - min;
+	};
+	FF.Random.prototype.nextFloat = function() {
+		return (this.func() / 0x1FFFFFFF) % 1;
+	};
+	
+	(function() {
+		FF.Random.MersenneTwister = function(seed) {
+			this.MT = new Array(624);
+			this.index = 0;
+			
+			var twister = this;
+			FF.Random.call(this, function() { return twister.extract(); });
+			this.init(seed);
+		};
+		FF.Random.MersenneTwister.prototype.init = function(seed) {
+			this.MT[0] = seed;
+			for (var i=1; i<624; i++) {
+				this.MT[i] = (1812433253 * (this.MT[i-1] ^ (this.MT[i-1] >> 30)) + 1) & 0xFFFFFFFF;
+			}
+		};
+		FF.Random.MersenneTwister.prototype.extract = function() {
+			if (this.index == 0) {
+				this.generate();
+			}
+			
+			var y = this.MT[this.index];
+			y = y ^ (y >> 11);
+			y = y ^ ((y << 7) & 2636928640);
+			y = y ^ ((y << 15) & 4022730752);
+			y = y ^ (y >> 18);
+			
+			this.index = (this.index + 1) % 624;
+			return y;
+		};
+		FF.Random.MersenneTwister.prototype.generate = function() {
+			for (var i=0; i<624; i++) {
+				var y = (this.MT[i] & (1 << 31)) + (this.MT[(i+1) % 624] & 0x7FFFFFFF);
+				this.MT[i] = this.MT[(i + 397) % 624] ^ (y >> 1);
+				
+				if (y % 2 == 1) {
+					this.MT[i] = this.MT[i] ^ 2567483615;
+				}
+			}
+		};
+		for (var k in FF.Random.prototype) {
+			FF.Random.MersenneTwister.prototype[k] = FF.Random.prototype[k];
+		}
+	})();
+	
+})();
+(function() {
+	var conds = [];
+	
+	function checkConds() {
+		for (var i=0; i<conds.length; i++) {
+			if (conds[i][0]()) {
+				conds[i][1].call(conds[i][2]);
+				conds.splice(i, 1);
+				i--;
+			}
+		}
+		
+		if (conds.length > 0) {
+			setTimeout(checkConds, 50);
+		}
+	}
+	
+	FF.Utils = {};
+	
+	FF.Utils.when = function(condArg, func, thisObj, thisObj2) {
+		var cond = condArg;
+		if (typeof(cond) === 'object') {
+			cond = function() {return condArg.value;};
+			if (typeof(func) === 'string') {
+				var key = func;
+				func = thisObj;
+				thisObj = thisObj2;
+				cond = function() {return condArg[key];};
+			} else {
+				cond = function() {return condArg.value;};
+			}
+		}
+		
+		conds.push([cond, func, thisObj]);
+		
+		if (conds.length == 1) {
+			checkConds();
+		}
+	};
+	
+	FF.Utils.urlParameters = function(s) {
+		var s = s || window.location;
+		
+		var args = {};
+		s.toString().replace(/[^?]*\??/, '').split(/&/).forEach(function(a) {
+			if (a.match(/\w+=/)) {
+				var key = a.replace(/=.*$/, '');
+				var value = a.replace(/[^=]*=/, '');
+				args[key] = unescape(value);
+			}
+		});
+		
+		return args;
+	}
+})();
+/home/firefly/web/js/lib