2Elm.Native.Utils = function(elm) {
5 elm.Native = elm.Native || {};
6 if (elm.Native.Utils) return elm.Native.Utils;
9 if (x === y) return true;
10 if (typeof x === "object") {
12 for (var i in x) { ++c; if (!eq(x[i],y[i])) return false; }
13 return c === Object.keys(y).length;
15 if (typeof x === 'function') {
16 throw new Error('Equality error: general function equality is ' +
17 'undecidable, and therefore, unsupported');
22 var EQ = 0, LT = -1, GT = 1, ord = ['EQ','LT','GT'];
23 function compare(x,y) { return { ctor: ord[cmp(x,y)] } }
26 if (typeof x !== 'object') return x === y ? EQ : x < y ? LT : GT;
28 if (x.ctor === "::" || x.ctor === "[]") {
30 if (x.ctor === "[]" && y.ctor === "[]") return EQ;
31 if (x.ctor !== y.ctor) return x.ctor === '[]' ? LT : GT;
32 ord = cmp(x._0, y._0);
33 if (ord !== EQ) return ord;
39 if (x.ctor.slice(0,6) === '_Tuple') {
40 var n = x.ctor.slice(6) - 0;
41 var err = 'cannot compare tuples with more than 6 elements.';
42 if (n === 0) return EQ;
43 if (n >= 1) { ord = cmp(x._0, y._0); if (ord !== EQ) return ord;
44 if (n >= 2) { ord = cmp(x._1, y._1); if (ord !== EQ) return ord;
45 if (n >= 3) { ord = cmp(x._2, y._2); if (ord !== EQ) return ord;
46 if (n >= 4) { ord = cmp(x._3, y._3); if (ord !== EQ) return ord;
47 if (n >= 5) { ord = cmp(x._4, y._4); if (ord !== EQ) return ord;
48 if (n >= 6) { ord = cmp(x._5, y._5); if (ord !== EQ) return ord;
49 if (n >= 7) throw new Error('Comparison error: ' + err); } } } } } }
52 throw new Error('Comparison error: comparison is only defined on ints, ' +
53 'floats, times, chars, strings, lists of comparable values, ' +
54 'and tuples of comparable values.')
58 var Tuple0 = { ctor: "_Tuple0" };
59 function Tuple2(x,y) { return { ctor:"_Tuple2", _0:x, _1:y } }
62 function guid(_) { return count++ }
66 for (var i in r) { o[i] = r[i]; }
70 function remove(x,r) {
74 o._[x] = o._[x].slice(1);
75 if (o._[x].length === 0) { delete o._[x]; }
82 function replace(kvs,r) {
84 for (var i = kvs.length; i--; ) {
91 function insert(x,v,r) {
93 if (x in o) o._[x] = [o[x]].concat(x in o._ ? o._[x].slice(0) : []);
98 function max(a,b) { return a > b ? a : b }
99 function min(a,b) { return a < b ? a : b }
103 var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r+b) : -mod(-a,-b));
105 return m === b ? 0 : m;
108 function htmlHeight(width, html) {
109 var t = document.createElement('div');
111 if (width > 0) { t.style.width = width + "px"; }
112 t.style.visibility = "hidden";
113 t.style.styleFloat = "left";
114 t.style.cssFloat = "left";
116 elm.node.appendChild(t);
117 var style = window.getComputedStyle(t, null);
118 var w = Math.ceil(style.getPropertyValue("width").slice(0,-2) - 0);
119 var h = Math.ceil(style.getPropertyValue("height").slice(0,-2) - 0);
120 elm.node.removeChild(t);
124 function adjustOffset() {
126 var offsetX = 0, offsetY = 0;
127 if (node.offsetParent) {
129 offsetX += node.offsetLeft;
130 offsetY += node.offsetTop;
131 } while (node = node.offsetParent);
133 elm.node.offsetX = offsetX;
134 elm.node.offsetY = offsetY;
137 if (elm.display === ElmRuntime.Display.COMPONENT) {
138 elm.addListener(elm.inputs, elm.node, 'mouseover', adjustOffset);
141 return elm.Native.Utils = {
155 htmlHeight: F2(htmlHeight),
156 toFloat: function(x){return x}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list