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 var stack = [{'x': l, 'y': r}]
10 while (stack.length > 0) {
11 var front = stack.pop();
14 if (x === y) continue;
15 if (typeof x === "object") {
21 stack.push({ 'x': x[i], 'y': y[i] });
28 stack.push({'x': x.ctor, 'y': y.ctor});
30 if (c !== Object.keys(y).length) {
33 } else if (typeof x === 'function') {
34 throw new Error('Equality error: general function equality is ' +
35 'undecidable, and therefore, unsupported');
43 // code in Generate/JavaScript.hs depends on the particular
44 // integer values assigned to LT, EQ, and GT
45 var LT = -1, EQ = 0, GT = 1, ord = ['LT','EQ','GT'];
46 function compare(x,y) { return { ctor: ord[cmp(x,y)+1] } }
49 if (typeof x !== 'object'){
50 return x === y ? EQ : x < y ? LT : GT;
55 return a === b ? EQ : a < b ? LT : GT;
57 else if (x.ctor === "::" || x.ctor === "[]") {
59 if (x.ctor === "[]" && y.ctor === "[]") return EQ;
60 if (x.ctor !== y.ctor) return x.ctor === '[]' ? LT : GT;
61 ord = cmp(x._0, y._0);
62 if (ord !== EQ) return ord;
67 else if (x.ctor.slice(0,6) === '_Tuple') {
68 var n = x.ctor.slice(6) - 0;
69 var err = 'cannot compare tuples with more than 6 elements.';
70 if (n === 0) return EQ;
71 if (n >= 1) { ord = cmp(x._0, y._0); if (ord !== EQ) return ord;
72 if (n >= 2) { ord = cmp(x._1, y._1); if (ord !== EQ) return ord;
73 if (n >= 3) { ord = cmp(x._2, y._2); if (ord !== EQ) return ord;
74 if (n >= 4) { ord = cmp(x._3, y._3); if (ord !== EQ) return ord;
75 if (n >= 5) { ord = cmp(x._4, y._4); if (ord !== EQ) return ord;
76 if (n >= 6) { ord = cmp(x._5, y._5); if (ord !== EQ) return ord;
77 if (n >= 7) throw new Error('Comparison error: ' + err); } } } } } }
81 throw new Error('Comparison error: comparison is only defined on ints, ' +
82 'floats, times, chars, strings, lists of comparable values, ' +
83 'and tuples of comparable values.');
88 var Tuple0 = { ctor: "_Tuple0" };
89 function Tuple2(x,y) { return { ctor:"_Tuple2", _0:x, _1:y } }
92 var x = new String(c);
98 var t = new String(str);
103 function makeText(text) {
117 if (href) text = '<a href="' + href + '">' + text + '</a>';
118 if (style) text = '<span style="' + style + '">' + text + '</span>';
124 function guid(_) { return count++ }
128 for (var i in r) { o[i] = r[i]; }
132 function remove(x,r) {
136 o._[x] = o._[x].slice(1);
137 if (o._[x].length === 0) { delete o._[x]; }
144 function replace(kvs,r) {
146 for (var i = kvs.length; i--; ) {
148 o[kvsi[0]] = kvsi[1];
153 function insert(x,v,r) {
155 if (x in o) o._[x] = [o[x]].concat(x in o._ ? o._[x].slice(0) : []);
160 function max(a,b) { return a > b ? a : b }
161 function min(a,b) { return a < b ? a : b }
165 throw new Error("Cannot perform mod 0. Division by zero error.");
168 var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r+b) : -mod(-a,-b));
170 return m === b ? 0 : m;
173 function htmlHeight(width, rawHtml) {
175 var html = rawHtml.html;
176 var t = document.createElement('div');
178 if (width > 0) { t.style.width = width + "px"; }
179 t.style.visibility = "hidden";
180 t.style.styleFloat = "left";
181 t.style.cssFloat = "left";
183 document.body.appendChild(t);
185 // insert interpolated values
186 var args = rawHtml.args;
187 var guid = rawHtml.guid;
188 for (var i = args.length; i--; ) {
190 var span = document.getElementById('md-' + guid + '-' + i);
192 span.style.width = arg.props.width + 'px';
193 span.style.height = arg.props.height + 'px';
195 span.innerHTML = arg;
200 var style = window.getComputedStyle(t, null);
201 var w = Math.ceil(style.getPropertyValue("width").slice(0,-2) - 0);
202 var h = Math.ceil(style.getPropertyValue("height").slice(0,-2) - 0);
203 document.body.removeChild(t);
210 if (e.pageX || e.pageY) {
213 } else if (e.clientX || e.clientY) {
214 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
215 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
218 if (elm.display === ElmRuntime.Display.COMPONENT) {
219 var rect = elm.node.getBoundingClientRect();
220 var relx = rect.left + document.body.scrollLeft + document.documentElement.scrollLeft;
221 var rely = rect.top + document.body.scrollTop + document.documentElement.scrollTop;
222 // TODO: figure out if there is a way to avoid rounding here
223 posx = posx - Math.round(relx) - elm.node.clientLeft;
224 posy = posy - Math.round(rely) - elm.node.clientTop;
226 return Tuple2(posx, posy);
229 function isJSArray(a) {
230 return a instanceof Array;
233 return elm.Native.Utils.values = {
250 htmlHeight: F2(htmlHeight),
252 isJSArray: isJSArray,
253 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