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") {
19 stack.push({ 'x': x[i], 'y': y[i] });
21 if (c !== Object.keys(y).length) {
24 } else if (typeof x === 'function') {
25 throw new Error('Equality error: general function equality is ' +
26 'undecidable, and therefore, unsupported');
34 // code in Generate/JavaScript.hs depends on the particular
35 // integer values assigned to LT, EQ, and GT
36 var LT = -1, EQ = 0, GT = 1, ord = ['LT','EQ','GT'];
37 function compare(x,y) { return { ctor: ord[cmp(x,y)+1] } }
40 if (typeof x !== 'object'){
41 return x === y ? EQ : x < y ? LT : GT;
46 return a === b ? EQ : a < b ? LT : GT;
48 else if (x.ctor === "::" || x.ctor === "[]") {
50 if (x.ctor === "[]" && y.ctor === "[]") return EQ;
51 if (x.ctor !== y.ctor) return x.ctor === '[]' ? LT : GT;
52 ord = cmp(x._0, y._0);
53 if (ord !== EQ) return ord;
58 else if (x.ctor.slice(0,6) === '_Tuple') {
59 var n = x.ctor.slice(6) - 0;
60 var err = 'cannot compare tuples with more than 6 elements.';
61 if (n === 0) return EQ;
62 if (n >= 1) { ord = cmp(x._0, y._0); if (ord !== EQ) return ord;
63 if (n >= 2) { ord = cmp(x._1, y._1); if (ord !== EQ) return ord;
64 if (n >= 3) { ord = cmp(x._2, y._2); if (ord !== EQ) return ord;
65 if (n >= 4) { ord = cmp(x._3, y._3); if (ord !== EQ) return ord;
66 if (n >= 5) { ord = cmp(x._4, y._4); if (ord !== EQ) return ord;
67 if (n >= 6) { ord = cmp(x._5, y._5); if (ord !== EQ) return ord;
68 if (n >= 7) throw new Error('Comparison error: ' + err); } } } } } }
72 throw new Error('Comparison error: comparison is only defined on ints, ' +
73 'floats, times, chars, strings, lists of comparable values, ' +
74 'and tuples of comparable values.');
79 var Tuple0 = { ctor: "_Tuple0" };
80 function Tuple2(x,y) { return { ctor:"_Tuple2", _0:x, _1:y } }
83 var x = new String(c);
89 var t = new String(str);
94 function makeText(text) {
108 if (href) text = '<a href="' + href + '">' + text + '</a>';
109 if (style) text = '<span style="' + style + '">' + text + '</span>';
115 function guid(_) { return count++ }
119 for (var i in r) { o[i] = r[i]; }
123 function remove(x,r) {
127 o._[x] = o._[x].slice(1);
128 if (o._[x].length === 0) { delete o._[x]; }
135 function replace(kvs,r) {
137 for (var i = kvs.length; i--; ) {
139 o[kvsi[0]] = kvsi[1];
144 function insert(x,v,r) {
146 if (x in o) o._[x] = [o[x]].concat(x in o._ ? o._[x].slice(0) : []);
151 function max(a,b) { return a > b ? a : b }
152 function min(a,b) { return a < b ? a : b }
156 throw new Error("Cannot perform mod 0. Division by zero error.");
159 var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r+b) : -mod(-a,-b));
161 return m === b ? 0 : m;
164 function htmlHeight(width, rawHtml) {
166 var html = rawHtml.html;
167 var t = document.createElement('div');
169 if (width > 0) { t.style.width = width + "px"; }
170 t.style.visibility = "hidden";
171 t.style.styleFloat = "left";
172 t.style.cssFloat = "left";
174 document.body.appendChild(t);
176 // insert interpolated values
177 var args = rawHtml.args;
178 var guid = rawHtml.guid;
179 for (var i = args.length; i--; ) {
181 var span = document.getElementById('md-' + guid + '-' + i);
183 span.style.width = arg.props.width + 'px';
184 span.style.height = arg.props.height + 'px';
186 span.innerHTML = arg;
191 var style = window.getComputedStyle(t, null);
192 var w = Math.ceil(style.getPropertyValue("width").slice(0,-2) - 0);
193 var h = Math.ceil(style.getPropertyValue("height").slice(0,-2) - 0);
194 document.body.removeChild(t);
201 if (e.pageX || e.pageY) {
204 } else if (e.clientX || e.clientY) {
205 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
206 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
209 if (elm.display === ElmRuntime.Display.COMPONENT) {
210 var rect = elm.node.getBoundingClientRect();
211 var relx = rect.left + document.body.scrollLeft + document.documentElement.scrollLeft;
212 var rely = rect.top + document.body.scrollTop + document.documentElement.scrollTop;
213 // TODO: figure out if there is a way to avoid rounding here
214 posx = posx - Math.round(relx) - elm.node.clientLeft;
215 posy = posy - Math.round(rely) - elm.node.clientTop;
217 return Tuple2(posx, posy);
220 function isJSArray(a) {
221 return a instanceof Array;
224 return elm.Native.Utils.values = {
241 htmlHeight: F2(htmlHeight),
243 isJSArray: isJSArray,
244 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