2Elm.Native.Utils.make = function(elm) {
4 elm.Native = elm.Native || {};
5 elm.Native.Utils = elm.Native.Utils || {};
6 if (elm.Native.Utils.values) return elm.Native.Utils.values;
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 // code in Generate/JavaScript.hs depends on the particular
23 // integer values assigned to LT, EQ, and GT
24 var LT = -1, EQ = 0, GT = 1, ord = ['LT','EQ','GT'];
25 function compare(x,y) { return { ctor: ord[cmp(x,y)+1] } }
28 if (typeof x !== 'object' || x instanceof String){
29 return x === y ? EQ : x < y ? LT : GT;
32 if (x.ctor === "::" || x.ctor === "[]") {
34 if (x.ctor === "[]" && y.ctor === "[]") return EQ;
35 if (x.ctor !== y.ctor) return x.ctor === '[]' ? LT : GT;
36 ord = cmp(x._0, y._0);
37 if (ord !== EQ) return ord;
43 if (x.ctor.slice(0,6) === '_Tuple') {
44 var n = x.ctor.slice(6) - 0;
45 var err = 'cannot compare tuples with more than 6 elements.';
46 if (n === 0) return EQ;
47 if (n >= 1) { ord = cmp(x._0, y._0); if (ord !== EQ) return ord;
48 if (n >= 2) { ord = cmp(x._1, y._1); if (ord !== EQ) return ord;
49 if (n >= 3) { ord = cmp(x._2, y._2); if (ord !== EQ) return ord;
50 if (n >= 4) { ord = cmp(x._3, y._3); if (ord !== EQ) return ord;
51 if (n >= 5) { ord = cmp(x._4, y._4); if (ord !== EQ) return ord;
52 if (n >= 6) { ord = cmp(x._5, y._5); if (ord !== EQ) return ord;
53 if (n >= 7) throw new Error('Comparison error: ' + err); } } } } } }
56 throw new Error('Comparison error: comparison is only defined on ints, ' +
57 'floats, times, chars, strings, lists of comparable values, ' +
58 'and tuples of comparable values.')
62 var Tuple0 = { ctor: "_Tuple0" };
63 function Tuple2(x,y) { return { ctor:"_Tuple2", _0:x, _1:y } }
66 var x = new String(c);
72 var t = new String(str);
77 function makeText(text) {
91 if (href) text = '<a href="' + href + '">' + text + '</a>';
92 if (style) text = '<span style="' + style + '">' + text + '</span>';
98 function guid(_) { return count++ }
102 for (var i in r) { o[i] = r[i]; }
106 function remove(x,r) {
110 o._[x] = o._[x].slice(1);
111 if (o._[x].length === 0) { delete o._[x]; }
118 function replace(kvs,r) {
120 for (var i = kvs.length; i--; ) {
122 o[kvsi[0]] = kvsi[1];
127 function insert(x,v,r) {
129 if (x in o) o._[x] = [o[x]].concat(x in o._ ? o._[x].slice(0) : []);
134 function max(a,b) { return a > b ? a : b }
135 function min(a,b) { return a < b ? a : b }
139 throw new Error("Cannot perform mod 0. Division by zero error.");
142 var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r+b) : -mod(-a,-b));
144 return m === b ? 0 : m;
147 function htmlHeight(width, rawHtml) {
149 var html = rawHtml.html;
150 var t = document.createElement('div');
152 if (width > 0) { t.style.width = width + "px"; }
153 t.style.visibility = "hidden";
154 t.style.styleFloat = "left";
155 t.style.cssFloat = "left";
157 document.body.appendChild(t);
159 // insert interpolated values
160 var args = rawHtml.args;
161 var guid = rawHtml.guid;
162 for (var i = args.length; i--; ) {
164 var span = document.getElementById('md-' + guid + '-' + i);
166 span.style.width = arg.props.width + 'px';
167 span.style.height = arg.props.height + 'px';
169 span.innerHTML = arg;
174 var style = window.getComputedStyle(t, null);
175 var w = Math.ceil(style.getPropertyValue("width").slice(0,-2) - 0);
176 var h = Math.ceil(style.getPropertyValue("height").slice(0,-2) - 0);
177 document.body.removeChild(t);
184 if (e.pageX || e.pageY) {
187 } else if (e.clientX || e.clientY) {
188 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
189 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
192 if (elm.display === ElmRuntime.Display.COMPONENT) {
193 var rect = elm.node.getBoundingClientRect();
194 var relx = rect.left + document.body.scrollLeft + document.documentElement.scrollLeft;
195 var rely = rect.top + document.body.scrollTop + document.documentElement.scrollTop;
196 // TODO: figure out if there is a way to avoid rounding here
197 posx = posx - Math.round(relx) - elm.node.clientLeft;
198 posy = posy - Math.round(rely) - elm.node.clientTop;
200 return Tuple2(posx, posy);
203 return elm.Native.Utils.values = {
220 htmlHeight: F2(htmlHeight),
222 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