3065,6,153,9,1267,8,89,14,562,31,365,53,301,53,298,49,234,44,304,67,598,84,361,49,626,43,232,47,858,43,818,52,230,56,356,50,444,33,560,39,1186,48,27332,42,134,42,127,41,131,44,637,30,1409,48,824,48,454,52,381,58,1053,38,114,40,386,39,416,50,1094,50,1037,45,699,48,517,49,777,47,961,60,672,39,319,50,797,48,336,56,169,32,2113,51,309,50,118,54,184,50,179,47,789,56,129,60,207,58,202,58,355,50,118,54,125,52,199,52,199,50,167,50,197,55,191,27,218,34,1501,47,2303,50,1108,105,293,99,378,82,858,98,311,74,533,87,260,102,146,106,232,98,148,94,59,98,274,100,363,91,577,77,290,95,437,80,641,91,775,101,193,69,593,77,1192,74,1572,78,3586,56,2045,38,1460,55,2332,52,1399,56,1993,30,279,33,570,77,466,66,374,63,604,75,350,83,454,55,951,54,126,56,138,56,142,59,899,60,132,55,600,64,668,71,221,76,334,58,357,59,421,58,223,49,650,67,407,61,547,65,391,57,191,59,246,46,446,46,323,71,319,65,1381,46,190,54,387,52,151,56,80,56,196,67,242,73,188,67,1065,76,599,82,225,80,1216,89,227,92,344,92,299,89,257,90,227,93,343,93,397,90,347,78,224,80,934,92,552,92,269,89,471,93,566,93,268,90,570,82,902,93,238,93,227,90,241,94,235,94,227,91,240,71,202,80,154,76,485,65,404,67,498,71,441,65,141,67,493,59,668,79,529,61,315,72,165,63,492,67,538,65,113,61,144,79,222,81,593,63,2124,67,95,51,762,65,471,83,472,69,141,84,587,67,479,80,373,78,326,73,263,74,794,63,702,67,266,79,351,65,407,69,440,63,144,75,159,74,403,65,1070,55,628,70,170,66,502,71,177,67,230,86,721,69,321,86,707,69,320,76,319,65,382,87,703,99,620,85,132,97,1296,85,1239,105,693,79,88,78,471,79,171,74,472,92,304,83,627,100,420,93,440,89,481,80,524,68,854,100,431,87,683,84,306,86,447,109,354,82,515,97,1909,78,571,70,252,62,141,64,312,53,581,76,242,58,351,68,100,68,804,69,272,65,407,69,440,63,144,65,612,55,938,70,158,66,490,71,282,86,514,69,321,74,1296,70,365,67,265,65,437,65,398,69,435,76,504,57,482,63,207,81,281,65,468,64,884,59,305,55,650,71,164,77,505,59,406,70,352,66,560,65,398,69,431,63,207,65,266,64,884,59,305,71,164,77,503,59,406,55,617,70,352,66,560,64,402,68,443,62,144,64,589,53,502,70,186,85,701,68,321,85,691,68,320,75,504,64,614,67,419,71,458,65,144,67,746,59,505,73,141,88,751,71,321,90,728,75,327,90,742,75,314,78,504,67,823,64,402,68,443,62,144,64,1584,53,502,70,186,85,701,68,321,85,691,68,320,75,504,64,640,66,453,70,490,64,142,66,427,57,498,70,141,74,141,76,198,88,928,70,432,78,485,64,361,76,717,80,349,72,268,83,942,74,367,76,424,64,501,62,453,66,432,70,465,64,144,66,510,57,504,72,142,70,280,87,790,70,327,66,358,70,432,74,465,68,144,70,716,65,508,76,171,74,280,91,790,74,327,91,787,74,320,70,518,42,1005,55,436,59,407,53,533,53,367,55,421,61,619,55,726,44,820,55,387,60,428,44,345,34,265,46,266,38,267,27,331,19,341,37,1010,48,670,25,402,46,431,56,542,32,960,21,571,25,327,27,715,24,98,33,1185,19,2535,76,471,69,431,69,216,73,441,45,279,40,996,29,120,46,333,35,216,38,218,34,577,40,733,42,165,35,743,38,165,40,165,36,950,36,647,36,643,35,632,41,559,35,546,23,2288,31,174,50,206,55,513,48,781,55,75,65,412,55,209,41,1041,24,333,40,333,52,298,43,290,24,741,23,1114,36,280,43,494,21,389,28,273,28,233 _info {"project":"math-div","branch":"master","version":190,"versionDate":"2024-05-07T09:22:58.000Z","fromVersion":0,"reset":true,"checksumDocs":"431-270370"} docs.txt http://khan.github.io/math-input/ Math42 als Website, super zum Lösen von Formeln... https://www.mathway.com/BasicMath Editoren: http://www.imatheq.com/corpsite/index.html https://www.mathcha.io/ MathJax MathQuill https://developer.mozilla.org/de/docs/Web/MathML https://github.com/Jam3/math-as-code http://asciimath.org/ https://runarberg.github.io/mathup/ https://silentmatt.com/javascript-expression-evaluator/ http://arthanzel.github.io/evaluatex/ guppy https://www.mathpapa.com/ https://www.symbolab.com/ ----- ### CAS ### Problemfälle: * b: "12^(-6)=1/12^6" ----- nerdamer sehr groß 800K non-minified javascript-cas last updated 2014 coffeequate http://matthewja.com/Coffeequate last updated 2016 algebra.js gibt keine wirkliche equals() funktion archiviert, last updated 2017 man kann nur durch integer oder fractions teilen, nicht durch expressions mathsteps, socratic by google "step-by-step solutions for a subset of high school algebra", including polyomials with basic fractions and radicals." finde die app nicht im app store algebrite fails with (x+2)(y+2) (needs *) simplify very expensive for negative exponents? https://github.com/Khan/KAS -> 2018 https://www-fourier.ujf-grenoble.fr/~parisse/giac.html init.ls (function(){ return function(){ return window.MathDiv = inc("mathDiv/mathDiv"); }; })(); mathDiv/_t.ls (function(){ return { oopsWrong: { de: "Ups, deine Lösung war falsch.", en: "Oops, your answer was incorrect.", fr: "Oups… ta réponse n'était pas correcte.", es: "¡Ups! Tu respuesta es incorrecta.", pt: "Ops! Sua resposta está incorreta." }, tryAgain: { de: "Nochmal probieren", en: "Try again", fr: "Essaie encore", es: "Volver a intentar", pt: "Tentar de novo" }, solve: { de: "Lösen", en: "Solve", fr: "Voir la solution", es: "Ver solución", pt: "Ver solução" }, check: { de: "Prüfen", en: "Check", fr: "Vérifier", es: "Verificar", pt: "Verificar" } }; })(); mathDiv/adjustLayout/adjust.ls (function(){ return function(o){ return function(){ var m; m = inc("mergeNeighbours/mergeNeighbours"); m(o, "mn"); m(o, "mspace"); m(o, "mtext"); inc("removeMnMoverSpace/remove")(o); inc("adjustSizes/adjust")(o); inc("adjustBracketSize/adjust")(o); inc("adjustCenter/adjust")(o); inc("adjustWidth/adjust")(o); return inc("adjustMSupSpacing/adjust")(o); }; }; })(); mathDiv/adjustLayout/adjustBlinkerWidths/decrease.ls (function(){ return function(o){ var i$, ref$, len$, msqrt, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll(".msqrt")).length; i$ < len$; ++i$) { msqrt = ref$[i$]; msqrt.blinkerEnd.css({ width: "0px" }); results$.push(msqrt.mrow.blinkerEnd.css({ width: "0px" })); } return results$; }; })(); mathDiv/adjustLayout/adjustBlinkerWidths/increase.ls (function(){ return function(o){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll(".msqrt, .mroot")).length; i$ < len$; ++i$) { el = ref$[i$]; el.blinkerEnd.css({ width: "5px" }); results$.push(el.mrow.blinkerEnd.css({ width: "15px" })); } return results$; }; })(); mathDiv/adjustLayout/adjustBracketSize/adjust.ls (function(){ return function(o){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll(".mfenced").reverse()).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(el.scale()); } return results$; }; })(); mathDiv/adjustLayout/adjustCenter/adjust.ls (function(){ return function(o){ var i$, ref$, len$, el, results$ = []; inc("adjustChildrenElements/adjust")(o, o.div); for (i$ = 0, len$ = (ref$ = o.div.findAll(".center")).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(inc("adjustChildrenElements/adjust")(o, el)); } return results$; }; })(); mathDiv/adjustLayout/adjustCenter/adjustChildrenElements/adjust.ls (function(){ return function(o, div){ var maxCenter, i$, ref$, len$, el, center, results$ = []; maxCenter = 0; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.getCenter) { center = el.getCenter(); maxCenter = Math.max(maxCenter, center); } } inc("showDebugCenterDiv/show")(o, div); for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.getCenter) { center = el.getCenter(); el.css({ marginTop: maxCenter - center + "px" }); results$.push(inc("showDebugCenterDiv/show")(o, el)); } } return results$; }; })(); mathDiv/adjustLayout/adjustCenter/adjustChildrenElements/showDebugCenterDiv/show.ls (function(){ return function(o, el){ var center, ref$; if (o.debug && el.getCenter) { center = el.getCenter(); if (!el.debugCenterDiv) { el.append(el.debugCenterDiv = Div({ position: "absolute", left: 0, height: "1px", width: "1px", backgroundColor: "red" })); } return (ref$ = el.debugCenterDiv) != null ? ref$.css({ top: center + "px" }) : void 8; } }; })(); mathDiv/adjustLayout/adjustMSupSpacing/adjust.ls (function(){ return function(o){ var i$, ref$, len$, msup, defaultValue, ref1$, ref2$, ref3$, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll(".msup")).length; i$ < len$; ++i$) { msup = ref$[i$]; defaultValue = "-3px"; results$.push(msup.wrapper.mrow2.parent().css({ marginLeft: (ref1$ = _.last(msup.wrapper.mrow1.getElements())) != null && ref1$.hasClass("mfenced") ? "-1px" : (ref2$ = _.last(msup.wrapper.mrow1.getElements())) != null && ref2$.hasClass("mgap") ? "-1px" : (ref3$ = _.first(msup.wrapper.mrow2.getElements())) != null && ref3$.hasClass("mgap") ? "-1px" : defaultValue })); } return results$; }; })(); mathDiv/adjustLayout/adjustSizes/adjust.ls (function(){ return function(o){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll(".adjustSize")).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(el.adjustSize()); } return results$; }; })(); mathDiv/adjustLayout/adjustWidth/adjust-wip.ls (function(){ return function(o){ var startDiv, endDiv, distanceToEdge, offsetRight, ref$, diff; startDiv = o.div.startDiv; endDiv = o.div.endDiv; distanceToEdge = body.width() - endDiv.offset().right; if (distanceToEdge - 40 < 0) { o.maxWidth == null && (o.maxWidth = body.width() - startDiv.offset().left - 30); o.div.css({ overflowX: "auto", justifyContent: "flex-start", pointerEvents: "auto", maxWidth: o.mode !== "calculator" ? o.maxWidth + "px" : void 8 }); } else { o.div.css({ overflowX: "", maxWidth: "" }); inc("/mathDiv/calcSourceDiv/setCenterAttribute/set")(o); } offsetRight = ((ref$ = o.cursorElement) != null ? ref$.offset().left : void 8) - o.div.offset().left; if (offsetRight == null || _.isNaN(offsetRight)) { offsetRight = 0; } diff = offsetRight - o.div.offsetWidth; if (diff + 10 > 0) { return o.div.scrollLeft += diff + 13; } }; })(); mathDiv/adjustLayout/adjustWidth/adjust.ls (function(){ return function(o){ var end, start, w, offsetRight, ref$, diff; end = o.div.endDiv; start = o.div.startDiv; w = end && start ? (end != null ? end.offset().left : void 8) - (start != null ? start.offset().left : void 8) : 0; if (w + 40 > body.width()) { o.div.css({ overflowX: "auto", justifyContent: "flex-start", pointerEvents: "auto", maxWidth: o.mode !== "calculator" ? body.width() - 40 + "px" : void 8 }); } else { o.div.css({ overflowX: "", maxWidth: "" }); inc("/mathDiv/calcSourceDiv/setCenterAttribute/set")(o); } offsetRight = ((ref$ = o.cursorElement) != null ? ref$.offset().left : void 8) - o.div.offset().left; if (offsetRight == null || _.isNaN(offsetRight)) { offsetRight = 0; } diff = offsetRight - o.div.offsetWidth; if (diff + 10 > 0) { return o.div.scrollLeft += diff + 13; } }; })(); mathDiv/adjustLayout/mergeNeighbours/merge/merge.ls (function(){ return function(o, el1, el2){ var el1Last; el1Last = _.last(el1.findAll(".char")); if (o.cursorElement === el2.firstChild) { el1Last.startCursor(); } el1Last.after(el2.findAll(".char")); return el2.remove(); }; })(); mathDiv/adjustLayout/mergeNeighbours/mergeNeighbours.ls (function(){ return function(o, tagName){ var i$, ref$, len$, el, el2, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll("." + tagName)).length; i$ < len$; ++i$) { el = ref$[i$]; el2 = el.nextSibling; if (el2 != null && el2.hasClass(tagName)) { inc("merge/merge")(o, el, el2); results$.push(inc(THISFILE)(o, tagName)); } } return results$; }; })(); mathDiv/adjustLayout/removeMnMoverSpace/remove.ls (function(){ return function(o){ var i$, ref$, len$, el, el2, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll(".mover")).length; i$ < len$; ++i$) { el = ref$[i$]; el2 = el.previousSibling; if (el2 != null && el2.hasClass("mn")) { el2.css({ paddingRight: 0 }); if ((ref1$ = el.findFirst(".mn")) != null) { ref1$.css({ paddingLeft: 0 }); } results$.push(el.wrapper.over.firstChild.css({ left: 0 })); } } return results$; }; })(); mathDiv/calcCorrectValue/calc.ls (function(){ return function(o){ return function(){ var gapValues, res$, i$, ref$, len$, gap, s, t; res$ = []; for (i$ = 0, len$ = (ref$ = o.gaps).length; i$ < len$; ++i$) { gap = ref$[i$]; res$.push(gap.value || gap.getValue()); } gapValues = res$; o.value = _.replaceAll(o.value, //, ""); o.value = _.replaceAll(o.value, "", ""); s = ""; for (i$ = 0, len$ = (ref$ = o.value.split(/(.*?<\/gap>)/)).length; i$ < len$; ++i$) { t = ref$[i$]; if (_.startsWith(t, "/, ""); o.value = _.replaceAll(o.value, "", ""); o.value = _.replaceAll(o.value, //, ""); gapIndex = -1; for (i$ = 0, len$ = (ref$ = o.value.split(/(.*?<\/gap>)/)).length; i$ < len$; ++i$) { t = ref$[i$]; if (_.startsWith(t, "")) { gapIndex++; solutions2 = []; for (j$ = 0, len1$ = (ref1$ = gapSolutions[gapIndex]).length; j$ < len1$; ++j$) { sol = ref1$[j$]; for (k$ = 0, len2$ = solutions.length; k$ < len2$; ++k$) { s = solutions[k$]; solutions2.push(s + sol); } } solutions = solutions2; } else { for (j$ = 0, len1$ = solutions.length; j$ < len1$; ++j$) { i = j$; solutions[i] += t; } } } return solutions; function fn$(c){ return _.replaceAll(c.mathData.asciimath, /\s+/g, ""); } }; }; })(); mathDiv/calcSourceDiv/_external/ascii2mathml.js // Transpiled using https://babeljs.io/repl "use strict"; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; !function (e) { if ("object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module) module.exports = e();else if ("function" == typeof define && define.amd) define([], e);else { ("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).ascii2mathml = e(); } }(function () { return function e(t, n, r) { function i(l, c) { if (!n[l]) { if (!t[l]) { var s = "function" == typeof require && require;if (!c && s) return s(l, !0);if (o) return o(l, !0);var a = new Error("Cannot find module '" + l + "'");throw a.code = "MODULE_NOT_FOUND", a; }var u = n[l] = { exports: {} };t[l][0].call(u.exports, function (e) { var n = t[l][1][e];return i(n || e); }, u, u.exports, e, t, n, r); }return n[l].exports; }for (var o = "function" == typeof require && require, l = 0; l < r.length; l++) { i(r[l]); }return i; }({ 1: [function (e, t, n) { "use strict"; Object.defineProperty(n, "__esModule", { value: !0 }), n.default = function e(t, n) { if ("object" == (typeof t === "undefined" ? "undefined" : _typeof(t))) return function (n, r) { var i = Object.assign({}, t, r);return e(n, i); };n = "object" == (typeof n === "undefined" ? "undefined" : _typeof(n)) ? n : {};n.annotate = n.annotate || !1;n.bare = n.bare || !1;n.display = n.display || "inline";n.standalone = n.standalone || !1;n.dir = n.dir || "ltr";n.decimalMark = n.decimalMark || ".";n.colSep = n.colSep || ",";n.rowSep = n.rowSep || ";";"," === n.decimalMark && "," === n.colSep && (n.colSep = ";");";" === n.colSep && ";" === n.rowSep && (n.rowSep = ";;");if (n.bare) { if (n.standalone) throw new Error("Can't output a valid HTML without a root element");if (n.display && "inline" !== n.display.toLowerCase()) throw new Error("Can't display block without root element.");if (n.dir && "ltr" !== n.dir.toLowerCase()) throw new Error("Can't have right-to-left direction without root element."); }var r = (0, o.default)(n);var i = void 0;var l = n.bare ? function (e) { return e; } : function (e) { return "" + e + ""; };if (n.annotate) { var _e = r(t.trim(), ""), _n = _e === o.default.getlastel(_e) ? _e : "" + _e + "";i = l("" + _n + '' + t + ""); } else i = l(r(t.trim(), ""));n.standalone && (i = "" + t + "" + i + "");return i; };var r, i = e("./lib/parser"), o = (r = i) && r.__esModule ? r : { default: r }; }, { "./lib/parser": 3 }], 2: [function (e, t, n) { "use strict"; Object.defineProperty(n, "__esModule", { value: !0 });var r = {}, i = "[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u218B\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u767E\u5343\u4E07\u5104\u5146\u4EAC\u5793\uD855\uDF71\u79ED\u7A63\u6E9D\u6F97\u6B63\u8F09\u5272\u5206\u5398\u6BDB\u7CF8\u5FFD\u5FAE\u7E4A\u6C99\u5875\u57C3\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]", o = new RegExp(i);Object.defineProperties(r, { digitRange: { value: i }, digitRE: { value: o }, isdigit: { value: function value(e) { return e.match(o); } } });var l = [],//JP: removed"sin", "cos", "tan", "asin", "acos", "atan", "csc", "sec", "cot", "sinh", "cosh", "tanh", "log", "ln", "det", "dim", "lim", "mod", "gcd", "lcm", "min", "max"], // // JP: removed the greek short forms Gamma: "\u0393", Delta: "\u0394", Theta: "\u0398", Lambda: "\u039B", Xi: "\u039E", Pi: "\u03A0", Sigma: "\u03A3", Phi: "\u03A6", Psi: "\u03A8", Omega: "\u03A9", alpha: "\u03B1", beta: "\u03B2", gamma: "\u03B3", delta: "\u03B4", epsilon: "\u025B", zeta: "\u03B6", eta: "\u03B7", theta: "\u03B8", iota: "\u03B9", kappa: "\u03BA", lambda: "\u03BB", mu: "\u03BC", nu: "\u03BD", xi: "\u03BE", pi: "\u03C0", rho: "\u03C1", sigma: "\u03C3", tau: "\u03C4", upsilon: "\u03C5", phi: "\u03C6", chi: "\u03C7", psi: "\u03C8", omega: "\u03C9", oo: "\u221E", "O/": "\u2205", CC: "\u2102", NN: "\u2115", QQ: "\u211A", RR: "\u211D", ZZ: "\u2124" c = {};l.forEach(function (e) { c[e] = e; }), Object.defineProperty(c, "contains", { value: function value(e) { return void 0 !== c[e]; } }), Object.defineProperty(c, "funs", { value: l }), Object.defineProperty(c, "isfun", { value: function value(e) { return l.indexOf(e) >= 0; } });var s = { "*": "\xb7", "**": "\u2217", "***": "\u22C6", "//": "/", "|": "|", ":": ":", "'": "\u2032", "''": "\u2033", "'''": "\u2034", "''''": "\u2057", "-:": "\xf7", "|><": "\u22C9", "><|": "\u22CA", "|><|": "\u22C8", "@": "\u2218", "!": "!", sum: "\u2211", prod: "\u220F", "^^": "\u2227", "^^^": "\u22C0", int: "\u222B", oint: "\u222E", dint: "\u222C", "+-": "\xb1", del: "\u2202", grad: "\u2207", aleph: "\u2135", "/_": "\u2220", diamond: "\u22C4", square: "\u25A1", "|__": "\u230A", "__|": "\u230B", "|~": "\u2308", "~|": "\u2309", "=": "=", "!=": "\u2260", "<": "<", ">": ">", "<=": "\u2264", ">=": "\u2265", "-<=": "\u2AAF", ">-=": "\u2AB0", sub: "\u2282", sup: "\u2283", sube: "\u2286", supe: "\u2287", "-=": "\u2261", "==": "\u2261", "~=": "\u2245", "~~": "\u2248", prop: "\u221D", "->": "\u2192", "=>": "\u21D2", "<=>": "\u21D4", "|->": "\u21A6", ">->": "\u21A3", "->>": "\u21A0", ">->>": "\u2916", uarr: "\u2191", darr: "\u2193", lArr: "\u21D0", rArr: "\u21D2", hArr: "\u21D4", iff: "\u21D4", ",": ",", ":.": "\u2234", "...": "\u2026", cdots: "\u22EF", ddots: "\u22F1", vdots: "\u22EE", if: "if", otherwise: "otherwise", and: "and", or: "or", not: "\xac", AA: "\u2200", EE: "\u2203", "_|_": "\u22A5", TT: "\u22A4", "|--": "\u22A2", "|==": "\u22A8" };Object.defineProperty(s, "contains", { value: function value(e) { return void 0 !== s[e]; // JP: this is the original code, we remove certain conversion rules for simplicity, >-, -<, <- xx, o+, ox, o., vv, vvv, nn, nnn, uu, uuu // } });var s = { "*": "\xb7", "**": "\u2217", "***": "\u22C6", "//": "/", "|": "|", ":": ":", "'": "\u2032", "''": "\u2033", "'''": "\u2034", "''''": "\u2057", xx: "\xd7", "-:": "\xf7", "|><": "\u22C9", "><|": "\u22CA", "|><|": "\u22C8", "@": "\u2218", "o+": "\u2295", ox: "\u2297", "o.": "\u2299", "!": "!", sum: "\u2211", prod: "\u220F", "^^": "\u2227", "^^^": "\u22C0", vv: "\u2228", vvv: "\u22C1", nn: "\u2229", nnn: "\u22C2", uu: "\u222A", uuu: "\u22C3", int: "\u222B", oint: "\u222E", dint: "\u222C", "+-": "\xb1", del: "\u2202", grad: "\u2207", aleph: "\u2135", "/_": "\u2220", diamond: "\u22C4", square: "\u25A1", "|__": "\u230A", "__|": "\u230B", "|~": "\u2308", "~|": "\u2309", "=": "=", "!=": "\u2260", "<": "<", ">": ">", "<=": "\u2264", ">=": "\u2265", "-<": "\u227A", "-<=": "\u2AAF", ">-": "\u227B", ">-=": "\u2AB0", in: "\u2208", "!in": "\u2209", sub: "\u2282", sup: "\u2283", sube: "\u2286", supe: "\u2287", "-=": "\u2261", "==": "\u2261", "~=": "\u2245", "~~": "\u2248", prop: "\u221D", "<-": "\u2190", "->": "\u2192", "=>": "\u21D2", "<=>": "\u21D4", "|->": "\u21A6", ">->": "\u21A3", "->>": "\u21A0", ">->>": "\u2916", uarr: "\u2191", darr: "\u2193", larr: "\u2190", rarr: "\u2192", harr: "\u2194", lArr: "\u21D0", rArr: "\u21D2", hArr: "\u21D4", iff: "\u21D4", ",": ",", ":.": "\u2234", "...": "\u2026", cdots: "\u22EF", ddots: "\u22F1", vdots: "\u22EE", if: "if", otherwise: "otherwise", and: "and", or: "or", not: "\xac", AA: "\u2200", EE: "\u2203", "_|_": "\u22A5", TT: "\u22A4", "|--": "\u22A2", "|==": "\u22A8" };Object.defineProperty(s, "contains", { value: function value(e) { // return void 0 !== s[e]; // MV: also removed larr: "\u2190", rarr: "\u2192", harr: "\u2194" to allow larrow, rarrow and lrarrow over-tags } }), Object.defineProperty(s, "get", { value: function value(e) { return s[e] || e; } }), Object.defineProperty(s, "regexp", { value: new RegExp("(" + Object.keys(s).sort(function (e, t) { return t.length - e.length; }).map(function (e) { return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }).join("|") + "|[+-<=>|~\xAC\xB1\xD7\xF7\u03D0\u03D1\u03D2\u03D5\u03F0\u03F1\u03F4\u03F5\u03F6\u0606\u0607\u0608\u2016\u2032\u2033\u2034\u2040\u2044\u2052\u2061-\u2064\u207A-\u207E\u208A-\u208E\u2605\u2606\u2660\u2661\u2662\u2663\u266D\u266E\u266F\uFB29\uFF61-\uFF68\uFF0B\uFF1C\uFF1D\uFF1E\uFF3C\uFF3E\uFF5C\uFF5E\uFFE2\uFFE9\uFFEA\uFFEB\uFFEC\u2200-\u22FF\u2A00-\u2AFF\u27C0-\u27E5\u2980-\u2982\u2999-\u29FF\u2301-\u23FF\u25A0-\u25FF\u2B00-\u2BFF\u2190-\u21FF\u27F0-\u27FF\u2900-\u297F\u20D0-\u20EF])") });var a = { open: { "(:": "\u27E8", "{:": "" }, close: { ":)": "\u27E9", ":}": "" }, complex: { abs: { open: "|", close: "|" }, floor: { open: "\u230A", close: "\u230B" }, ceil: { open: "\u2308", close: "\u2309" }, norm: { open: "\u2225", close: "\u2225" } } };Object.defineProperty(a.open, "regexp", { value: /([[\u27e6\u27e8\u27ea\u27ec\u27ee\u2983\u2985\u2987\u2989\u298b\u298d\u298f\u2991\u2993\u2995\u2997]|[({]:?)/ }), Object.defineProperty(a.close, "regexp", { value: /([\]\u27e7\u27e9\u27eb\u27ed\u27ef\u2984\u2986\u2988\u298a\u298c\u298e\u2990\u2992\u2994\u2996\u2998]|:?[)}])/ }), Object.defineProperty(a.open, "get", { value: function value(e) { var t = a.open[e];return "string" == typeof t ? t : e; } }), Object.defineProperty(a.close, "get", { value: function value(e) { var t = a.close[e];return "string" == typeof t ? t : e; } }), Object.defineProperty(a.complex, "contains", { value: function value(e) { return Object.keys(a.complex).indexOf(e) >= 0; } }), Object.defineProperty(a.complex, "get", { value: function value(e) { return a.complex[e]; // JP removed these shortcuts for styling since it breaks when we write them in color tags for example rm: "normal", bf: "bold", it: "italic", bb: "double-struck", cc: "script", tt: "monospace", fr: "fraktur", sf: "sans-serif" } } }), Object.freeze(a.open), Object.freeze(a.close), Object.freeze(a.complex);var u = {};Object.defineProperty(u, "get", { value: function value(e) { return u[e]; } }), Object.defineProperty(u, "regexp", { value: new RegExp("(" + Object.keys(u).join("|") + ")") });var f = { hat: { type: "over", accent: "^" }, bar: { type: "over", accent: "\u203E" }, lrarrow: { type: "over", accent: "\u2194" }, ul: { type: "under", accent: "_" }, rarrow: { type: "over", accent: "\u2192" }, larrow: { type: "over", accent: "\u2190" }, dot: { type: "over", accent: "\u22C5" }, ddot: { type: "over", accent: "\u22C5\u22C5" }, tilde: { type: "over", accent: "\u02DC" }, cancel: { type: "enclose", attrs: { notation: "updiagonalstrike" } } };Object.defineProperty(f, "contains", { value: function value(e) { return Object.keys(f).indexOf(e) >= 0; } }), Object.defineProperty(f, "get", { value: function value(e) { return f[e]; } }), Object.defineProperty(f, "regexp", { value: new RegExp("(" + Object.keys(f).join("|") + ")") }), n.numbers = r, n.identifiers = c, n.operators = s, n.groupings = a, n.fonts = u, n.accents = f; }, {}], 3: [function (e, t, n) { "use strict"; Object.defineProperty(n, "__esModule", { value: !0 });var r, i = e("./syntax"), o = (r = i) && r.__esModule ? r : { default: r }, l = e("./lexicon");function c(e) { return function t(n, r) { if ("object" == (typeof n === "undefined" ? "undefined" : _typeof(n))) return function (e) { return t(e, n); };if ("object" != (typeof r === "undefined" ? "undefined" : _typeof(r))) return "<" + e + ">" + n + "";{ var _t = Object.keys(r).map(function (e) { return e + "=\"" + r[e] + "\""; }).join(" ");return "<" + e + " " + _t + ">" + n + ""; } }; }var s = c("mi"), a = c("mn"), u = c("mo"), f = c("mfrac"), m = c("msup"), p = c("msub"), d = c("msubsup"), h = c("munder"), g = c("mover"), b = c("munderover"), x = c("menclose"), y = c("mrow"), v = c("msqrt"), O = c("mroot"), j = c("mfenced"), w = c("mtable"), $ = c("mtr"), _ = c("mtd");function k(e) { var t = "." === e.decimalMark ? "\\." : e.decimalMark, n = new RegExp("^" + l.numbers.digitRange + "+(" + t + l.numbers.digitRange + "+)?"), r = R(e.colSep), i = R(e.rowSep), k = R("\n");function R(e) { return function (t) { var n = [], r = 0, i = 0;for (var _o = 0; _o < t.length; _o += 1) { var _c = t.slice(_o), _s = t[_o];_c.startsWith(e) && !t.slice(0, _o).match(/\\(\\{2})*$/) ? 0 === r && (n.push(t.slice(i, _o)), i = _o + e.length) : _s.match(l.groupings.open.regexp) ? r += 1 : _s.match(l.groupings.close.regexp) && (r -= 1); }return n.push(t.slice(i)), n; }; }var L = function e(t, n, r, i) { var _ref, _ref2; if (!t) return n;if (t.match(/^\s/)) { if (t.match(/^\s+(\/[^\/]|^[^\^]|_[^_|])/)) return e(t.trim(), n, !0);var _r = t.match(/^ +/), _i = _r ? _r[0].length : 0;if (_i > 1) { var _r2 = "";return e(t.trim(), n + _r2, !0); }return e(t.trim(), n, !0); } var _C = C(t, i), _C2 = _slicedToArray(_C, 2), o = _C2[0], l = _C2[1]; return (l && l.trimLeft().startsWith("/") || l.trimLeft().startsWith("./")) && !l.trimLeft().match(/^\.?\/\//) && (_ref = function e(t, n) { var r = n.trim().startsWith("./"), i = n.trim().slice(r ? 2 : 1);var o = void 0, l = void 0, c = void 0;if (i.startsWith(" ")) { var _e2 = i.trim().split(" ");o = M(_e2[0]), c = i.trimLeft().slice(_e2[0].length + 1); } else { ; var _C3 = C(i); var _C4 = _slicedToArray(_C3, 2); o = _C4[0]; c = _C4[1]; }o = o || y("");l = f(S(t) + S(o), r && { bevelled: !0 });if (c && c.trim().startsWith("/") || c.trim().startsWith("./")) return e(l, c);return [l, c]; }(o, l), _ref2 = _slicedToArray(_ref, 2), o = _ref2[0], l = _ref2[1], _ref), e(l, n + o, !1); };function M(e) { if (0 === e.trim().length) return "";var t = L(e, "", !1, !0);return t === P(t) ? t : y(t); }function C(t, P, R) { var _ref5, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12; if (!t) return ["", ""];var L = void 0, N = void 0, z = t[0], A = t.slice(1), q = z + (A.match(/^[A-Za-z]+/) || "");if (t.startsWith("sqrt")) { var _e3 = C(t.slice(4).trim(), P);L = v(_e3[0] ? S(_e3[0]) : y("")), N = _e3[1]; } else if (t.startsWith("root")) { var _e4 = C(t.slice(4).trimLeft(), P), _n2 = _e4[0] ? S(_e4[0]) : y(""), _r3 = C(_e4[1].trimLeft(), P), _i2 = _r3[0] ? S(_r3[0]) : y("");L = O(_i2 + _n2), N = _r3[1]; } else if ("\\" === z && t.length > 1) { if (t[1].match(/[(\[]/)) { var _e5 = function (e) { var t = e[0], n = "(" === t ? ")" : "[" === t ? "]" : e[0], r = 0, i = 0;for (var _o2 = 0; _o2 < e.length; _o2 += 1) { var _l = e[_o2];if (i += 1, _l === n) { if (0 === (r -= 1)) break; } else _l === t && (r += 1); }return i; }(A);L = u(t.slice(2, _e5)), N = t.slice(_e5 + 1); } else L = u(t[1]), N = t.slice(2); } else if (l.accents.contains(q)) { var _e6 = l.accents.get(q), _n3 = t.slice(q.length).trimLeft(), _r4 = _n3.match(/^\s*\(?([ij])\)?/), _i3 = C(_n3);switch (_e6.type) {case "over": _r4 ? (L = g(s("i" === _r4[1] ? "\u0131" : "\u0237") + u(_e6.accent, { accent: !0 })), N = _n3.slice(_r4[0].length)) : (L = g(S(_i3[0]) + u(_e6.accent, { accent: !0 })), N = _i3[1]);break;case "under": L = h(S(_i3[0]) + u(_e6.accent)), N = _i3[1];break;case "enclose": L = x(S(_i3[0]), _e6.attrs), N = _i3[1];break;default: throw new Error("Invalid config for accent " + q);} } else if (o.default.isfontCommand(t)) { var _e7 = o.default.splitfont(t);L = c(_e7.tagname)(_e7.text, _e7.font && { mathvariant: _e7.font }), N = _e7.rest; } else if (l.groupings.complex.contains(q)) { var _e8 = l.groupings.complex.get(q), _n4 = C(t.slice(q.length).trimLeft());L = j(S(_n4[0]), _e8), N = _n4[1]; } else if (o.default.isgroupStart(t) || o.default.isvertGroupStart(t)) { var _ref3 = o.default.isgroupStart(t) ? o.default.splitNextGroup(t) : o.default.splitNextVert(t), _ref4 = _slicedToArray(_ref3, 5), _n5 = _ref4[1], _c2 = _ref4[2], _s2 = _ref4[3], _a = _ref4[4]; N = l.groupings.open.get(_a);var _u = function () { var e = k(_c2);return e.length > 1 ? e : i(_c2); }();if (o.default.ismatrixInterior(_c2.trim(), e.colSep)) { _c2.trim().endsWith(e.colSep) && (_c2 = _c2.trimRight().slice(0, -1));var _t2 = function (e, t) { var n = function () { var t = r(e);return t.length > 1 ? t : k(e); }().map(function (e) { return e.trim().slice(1, -1); });return w(n.map(G).join(""), t); }(_c2, "{" === _n5 && "" === _s2 && { columnalign: "center left" });L = j(_t2, { open: _n5, close: _s2 }); } else if (_u.length > 1) { if (2 === _u.length && "(" === _n5 && ")" === _s2) { var _e9 = f(_u.map(M).join(""), { linethickness: 0 });L = j(_e9, { open: _n5, close: _s2 }); } else { var _e10 = _u.map(r);1 === W(_e10).length && W(_e10)[0].match(/^\s*$/) && (_e10 = _e10.slice(0, -1));var _t3 = _e10.map(function (e) { return $(e.map((t = _, n = M, function (e) { return t(n(e)); })).join(""));var t, n; }).join("");L = j(w(_t3), { open: _n5, close: _s2 }); } } else { var _t4 = r(_c2).map(M).join(""), _i4 = { open: _n5, close: _s2 };"," !== e.colSep && (_i4.separators = e.colSep), L = j(_t4, _i4); } } else if (!P && o.default.isgroupable(t, e)) { var _n6 = function t(n) { var r = new RegExp("(\\s|" + e.colSep + "|" + e.rowSep + "|$)");var i = n.match(r), l = n.slice(0, i.index), c = i[0], s = n.slice(i.index + 1);var a = l, u = c + s;if (!o.default.isgroupStart(s.trim()) && o.default.endsInFunc(l)) { var _e11 = t(s);a += c + _e11[0], u = _e11[1]; } else if (l.match(/root$/)) { var _e12 = t(s), _n7 = t(_e12[1].trimLeft());a += c + _e12[0] + " " + _n7[0], u = c + _n7[1]; }return [a, u]; }(t);L = M(_n6[0]), N = _n6[1]; } else if (l.numbers.isdigit(z)) { var _e13 = t.match(n)[0];L = a(_e13), N = A.slice(_e13.length - 1); } else if (t.match(/^#`[^`]+`/)) { var _e14 = t.match(/^#`([^`]+)`/)[1];L = a(_e14), N = t.slice(_e14.length + 3); } else if (t.match(new RegExp("^" + l.operators.regexp.source)) && !l.identifiers.contains(q)) { var _o$default$splitNextO = o.default.splitNextOperator(t), _o$default$splitNextO2 = _slicedToArray(_o$default$splitNextO, 2), _e15 = _o$default$splitNextO2[0], _n8 = _o$default$splitNextO2[1], _r5 = t.startsWith("'"), _i5 = E(["\u2202", "\u2207"], _e15), _l2 = E(["|"], _e15), _c3 = t.startsWith("| "), _s3 = {}; _r5 && (_s3.lspace = 0, _s3.rspace = 0), _i5 && (_s3.rspace = 0), _l2 && (_s3.stretchy = !0), _c3 && (_s3.lspace = "veryverythickmathspace", _s3.rspace = "veryverythickmathspace"), L = u(_e15, (U = _s3, !(0 === Object.keys(U).length) && _s3)), N = _n8; } else if (l.identifiers.contains(q)) { var _e16 = l.identifiers[q];L = _e16.match(/[\u0391-\u03A9\u2100-\u214F\u2200-\u22FF]/) ? s(_e16, { mathvariant: "normal" }) : s(_e16), N = A.slice(q.length - 1); } else "OBREAKO" === z && "/" === A[0] ? (L = s(l.identifiers["O/"], { mathvariant: "normal" }), N = A.slice(1)) : (L = s(z), N = A);var U;return N && N.trimLeft().match(/\.?[\^_]/) && (R && R.match(/m(sup|over)/) || !N.trim().startsWith("_") || !(N.trim().length <= 1) && N.trim()[1].match(/[|_]/) ? "mover" !== R && N.trim().startsWith("._") && (N.trim().length <= 2 || !N.trim()[2].match(/[|_]/)) ? (_ref5 = function (e, t) { var n = void 0, //JP: quick hack to break the O/ special syntax for defining empty sets r = C(t.trim().slice(2).trim(), !0, "munder"), i = r[0] ? S(r[0]) : y(""), o = r[1], l = o.match(/^(\.?\^)[^\^]/);if (l) { var _t5 = C(o.trim().slice(l[1].length).trim(), !0), _r6 = _t5[0] ? S(_t5[0]) : y("");n = b(e + i + _r6), o = _t5[1]; } else n = h(e + i);return [n, o]; }(L, N), _ref6 = _slicedToArray(_ref5, 2), L = _ref6[0], N = _ref6[1], _ref5) : R && R.match(/m(sub|under)/) || !N.trim().startsWith("^") || !(N.trim().length <= 1 || "^" !== N.trim()[1]) ? "munder" !== R && N.trim().startsWith(".^") && (N.trim().length <= 2 || "^" !== N.trim()[2]) && (_ref7 = function (e, t) { var n = void 0, r = C(t.trim().slice(2).trim(), !0, "mover"), i = r[0] ? S(r[0]) : y(""), o = r[1], l = o.match(/^(\.?_)[^_|]/);if (l) { var _t6 = C(o.trim().slice(l[1].length).trim(), !0), _r7 = _t6[0] ? S(_t6[0]) : y("");n = b(e + _r7 + i), o = _t6[1]; } else n = g(e + i);return [n, o]; }(L, N), _ref8 = _slicedToArray(_ref7, 2), L = _ref8[0], N = _ref8[1], _ref7) : (_ref9 = function (e, t) { var n = void 0, r = C(t.trim().slice(1).trim(), !0, "msup"), i = r[0] ? S(r[0]) : y(""), l = r[1];if (l.trim().startsWith("_") && (l.trim().length <= 1 || !l.trim()[1].match(/[|_]/))) { var _t7 = C(l.trim().slice(1).trim(), !0), _r8 = _t7[0] ? S(_t7[0]) : y(""), _c4 = o.default.shouldGoUnder(e) ? b : d;n = _c4(e + _r8 + i), l = _t7[1]; } else { var _t8 = o.default.shouldGoUnder(e) ? g : m;n = _t8(e + i); }return [n, l]; }(L, N), _ref10 = _slicedToArray(_ref9, 2), L = _ref10[0], N = _ref10[1], _ref9) : (_ref11 = function (e, t) { var n = void 0, r = C(t.trim().slice(1).trim(), !0, "msub"), i = r[0] ? S(r[0]) : y(""), l = r[1];if (l && l.trim().startsWith("^") && (l.trim().length <= 1 || "^" !== !l.trim()[1])) { var _t9 = C(l.trim().slice(1).trim(), !0), _r9 = _t9[0] ? S(_t9[0]) : y(""), _c5 = o.default.shouldGoUnder(e) ? b : d;n = _c5(e + i + _r9), l = _t9[1]; } else { var _t10 = o.default.shouldGoUnder(e) ? h : p;n = _t10(e + i); }return [n, l]; }(L, N), _ref12 = _slicedToArray(_ref11, 2), L = _ref12[0], N = _ref12[1], _ref11)), [L, N]; }function G(t, n) { if (n = "string" == typeof n ? n : "", !t || 0 === t.length) return $(n); var _ref13 = function t(n, r) { if (!n || 0 === n.length) return [_(r), ""];if (n[0] === e.colSep) return [_(r), n.slice(1).trim()]; var _C5 = C(n), _C6 = _slicedToArray(_C5, 2), i = _C6[0], o = _C6[1]; return t(o.trim(), r + i); }(t.trim(), ""), _ref14 = _slicedToArray(_ref13, 2), r = _ref14[0], i = _ref14[1]; return G(i.trim(), n + r); }return L; }function S(e) { var t = e.replace(/^]*>/, "").replace(/<\/mfenced>$/, "");return function (e) { var t = P(e);return [e.slice(0, e.lastIndexOf(t)), t]; }(t)[1] === t ? t : y(t); }function P(e) { var t = e.match(/<\/(m[a-z]+)>$/);if (!t) { var _t11 = e.match(//);if (_t11) { var _n9 = _t11.match[0].length;return e.slice(_n9); }return ""; }var n = t[1], r = e.length - (n.length + 3), i = 0;for (; r >= 0; r -= 1) { if (e.slice(r).startsWith("<" + n)) { if (0 === i) break;i -= 1; }e.slice(r - 2).startsWith("= 0; }function W(e) { return e.slice(-1)[0]; }k.getlastel = P, n.default = k; }, { "./lexicon": 2, "./syntax": 4 }], 4: [function (e, t, n) { "use strict"; Object.defineProperty(n, "__esModule", { value: !0 });var r = e("./lexicon");function i(e) { var t = new RegExp("^" + r.groupings.open.regexp.source);return e.match(t); }var o = new RegExp("(" + r.identifiers.funs.concat(Object.keys(r.accents)).concat(["sqrt"]).sort(function (e, t) { return e.length - t.length; }).join("|") + ")$");function l(e) { var t = new RegExp("^" + r.groupings.open.regexp.source), n = new RegExp("^" + r.groupings.close.regexp.source);var i = void 0, o = void 0, l = void 0, c = void 0, s = 0, a = 0;for (; a < e.length;) { var _r10 = e.slice(a), _u2 = _r10.match(t), _f = _r10.match(n);if (_u2) "number" != typeof i && (i = a, l = _u2[0]), s += 1, a += _u2[0].length;else if (_f) { if (0 === (s -= 1)) { o = a + ((c = _f[0]).length - 1);break; }a += _f[0].length; } else a += 1; }return l ? [0 === i ? "" : e.slice(0, i), r.groupings.open.get(l), e.slice(i + l.length, c ? o - (c.length - 1) : e.length), c ? r.groupings.close.get(c) : "", o ? e.slice(o + 1) : ""] : null; }function c(e) { function t(t, n, r) { return [0 === t ? "" : e.slice(0, t), r ? "\u2016" : "|", e.slice(t + (r ? 2 : 1), n), r ? "\u2016" : "|", e.slice(n + (r ? 2 : 1))]; }var n = e.indexOf("|"), r = n + 1, i = e.slice(n + 1), o = i.startsWith("|"), c = o ? /\|\|/ : /\|/;if (o && (i = i.slice(1), r += 1), -1 === i.indexOf("|")) return null;if (i.match(/^\.?[_\^]/)) return null;for (; i.length > 0;) { var _e17 = l(i), _u3 = _e17 ? _e17[0] : i, _f2 = _e17 ? _e17[4] : "", _m = c.exec(_u3);if (_m) return t(n, r + _m.index, o);r += _e17.slice(0, -1).map(s("length")).reduce(a), "" === _e17[1] ? r += 2 : "\u2329" === _e17[1] && (r += 1), "" === _e17[3] ? r += 2 : "\u232A" === _e17[3] && (r += 1), i = _f2; }return null; }function s(e) { return function (t) { return t[e]; }; }function a(e, t) { return e + t; }function u(e) { var t = new RegExp("^(" + r.fonts.regexp.source + " ?)?" + e);return function (e) { return t.exec(e); }; }var f = u("(`)[ -~àáâæãaéèêûùúîïíìôòóõœñçäüöÀÁÂÆÃAÉÈÊÛÙÚÎÏÍÌÔÒÓÕŒÑÇÄÜÖß°α-ωΑ-Ω]+`"), // JP: changed from \\w+ to include also Umlaute and other ascii chars, see https://catonmat.net/my-favorite-regex m = u('(")');var p = ["lim", "\u2211", "\u220F"];var d = { endsInFunc: function endsInFunc(e) { return e.match(o); }, isgroupStart: i, isgroupable: function isgroupable(e, t) { var n = new RegExp("^[0-9A-Za-z+\\-!]{2,}(\\s|" + t.colSep + "|" + t.rowSep + ")");return e.match(n); }, isvertGroupStart: function isvertGroupStart(e) { if (!e.startsWith("|")) return !1;var t = c(e);return t && "" === t[0]; }, splitNextGroup: l, splitNextVert: c, splitNextOperator: function splitNextOperator(e) { var t = new RegExp("^" + r.operators.regexp.source).exec(e)[0];return [r.operators.get(t), e.slice(t.length)]; }, ismatrixInterior: function ismatrixInterior(e, t) { return i(e) && function () { var n = l(e)[4];return n.trim().startsWith(t) || n.match(/^\s*\n/) && i(n.trim()); }(); }, isfontCommand: function isfontCommand(e) { return f(e) || m(e); }, splitfont: function splitfont(e) { var t = f(e) || m(e), n = t && t[2], i = t && t[3], o = '"' === i ? "mtext" : "`" === i ? "mi" : "", l = e.indexOf(i), c = l + 1 + e.slice(l + 1).indexOf(i), s = l > 0 ? r.fonts.get(n) : "";return { tagname: o, text: e.slice(l + 1, c), font: s, rest: e.slice(c + 1) }; }, shouldGoUnder: function shouldGoUnder(e) { return p.indexOf(e) >= 0; } };n.default = d; }, { "./lexicon": 2 }] }, {}, [1])(1); }); mathDiv/calcSourceDiv/addAlignment/add.ls (function(){ return function(v){ v = _.replaceAll(v, '||', '"||"'); v = v.replace(/([^|])\|([^|])/g, "$1\"|\"$2"); return v; }; })(); mathDiv/calcSourceDiv/addGapFences/add.ls (function(){ return function(v){ v = _.replaceAll(v, '', '⟪⟪"'); v = _.replaceAll(v, '', '"⟫⟫'); return v; }; })(); mathDiv/calcSourceDiv/addNewlines/add.ls (function(){ return function(v){ v = _.replaceAll(v, '
', '"
"'); v = _.replaceAll(v, '
', '"
"'); return v; }; })(); mathDiv/calcSourceDiv/addStyleFences/add.ls (function(){ var markColors, ref$, textColors, ref1$; markColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.markColors : void 8; textColors = (ref1$ = document.head.findFirst('#cssColorTags')) != null ? ref1$.textColors : void 8; return function(v){ var styles, c, i$, len$, s; styles = ["b", "i", "u"]; for (c in markColors) { styles.push("m-" + c); } for (c in textColors) { styles.push("t-" + c); } for (i$ = 0, len$ = styles.length; i$ < len$; ++i$) { s = styles[i$]; v = _.replaceAll(v, '<' + s + '>', '⟨"style_' + s + '"'); v = _.replaceAll(v, '', '"styleend_' + s + '"⟩'); } return v; }; })(); mathDiv/calcSourceDiv/calc.ls (function(){ return function(o){ return function(){ var a, res$, i$, ref$, len$, s, v, gaps; if (o.value.indexOf("") === 0) { res$ = []; for (i$ = 0, len$ = (ref$ = o.value.split("\n")).length; i$ < len$; ++i$) { s = ref$[i$]; res$.push(s.trim()); } a = res$; o.mathml = a.join(""); o.sourceDiv = Div().html(o.mathml).firstChild; return; } if (!window.ascii2mathml) { inc("_external/ascii2mathml.js"); window.ascii2mathml = ascii2mathml['default']; } v = o.value; inc("calcMatAttributes/calc")(o, v); inc("calcGapAttributes/calc")(o, v); v = _.replaceAll(v, //, ""); inc("setCenterAttribute/set")(o); v = inc("fixSpaces/fix")(v); v = _.replaceAll(v, //, ""); v = _.replaceAll(v, "", ""); ref$ = inc("pullGaps/pull")(v), v = ref$[0], gaps = ref$[1]; v = inc("addStyleFences/add")(v); v = inc("addNewlines/add")(v); v = inc("addAlignment/add")(v); v = inc("unescapeAngleBrackets/unescape")(v); o.mathml = ascii2mathml(v); o.mathml = inc("escapeSingleAngleBrackets/escape")(o.mathml); o.mathml = inc("fixChars/fix")(o.mathml); o.sourceDiv = Div().html(o.mathml).firstChild; inc("processGaps/process")(o, gaps); inc("processInverse/process")(o); inc("processFunctions/process")(o); inc("processStyles/process")(o); inc("removeStyleFences/remove")(o); inc("processNewlines/process")(o); inc("processAlignment/process")(o); inc("fixMnMoDot/fix")(o); return o.sourceDiv; }; }; })(); mathDiv/calcSourceDiv/calcGapAttributes/calc.ls (function(){ return function(o, v){ var matchesPerGap, i$, len$, i, matchedGap, matchedAttributes, gapAttributes, j$, ref$, len1$, attribute, key, value, results$ = []; o.gapAttributes = []; matchesPerGap = v.match(//g); if (!_.isEmpty(matchesPerGap)) { for (i$ = 0, len$ = matchesPerGap.length; i$ < len$; ++i$) { i = i$; matchedGap = matchesPerGap[i$]; matchedAttributes = matchedGap.match(//); if (_.includes(matchedAttributes[1], "=")) { gapAttributes = {}; for (j$ = 0, len1$ = (ref$ = matchedAttributes[1].trim().split(/\s+/)).length; j$ < len1$; ++j$) { attribute = ref$[j$]; key = attribute.split("=")[0]; value = attribute.split("=")[1]; value = value.substring(1, value.length - 1); gapAttributes[key] = value; } results$.push(o.gapAttributes[i] = gapAttributes); } } return results$; } }; })(); mathDiv/calcSourceDiv/calcMatAttributes/calc.ls (function(){ return function(o, v){ var attributes, ref$, i$, ref1$, len$, a, k, results$ = []; o.matAttributes = {}; attributes = (ref$ = v.match(//)) != null ? ref$[1] : void 8; if (attributes) { for (i$ = 0, len$ = (ref1$ = attributes.trim().split(" ")).length; i$ < len$; ++i$) { a = ref1$[i$]; k = a.split("=")[0]; v = a.split("=")[1]; v = v.substring(1, v.length - 1); results$.push(o.matAttributes[k] = v); } return results$; } }; })(); mathDiv/calcSourceDiv/detectNonAsciiChars/detect.ls (function(){ return function(v){ var nonAsciiChars; nonAsciiChars = v.match(/(?=[^äöüß÷€])[^\x00-\x7F]/g); if ((nonAsciiChars != null ? nonAsciiChars.length : void 8) > 0) { debug("Warning: You are using the following non-ascii characters in the mat-tag:\n" + nonAsciiChars.join(" ") + "\n" + "Please replace them by the proper mat-tag abbreviation!"); return debug(v); } }; })(); mathDiv/calcSourceDiv/escapeSingleAngleBrackets/escape.ls (function(){ return function(mathml){ var escape, openBracketCount, lastBracketIndex, singleBrackets, i$, len$, i, c, currentBracketIndex, lastI, newMathml; escape = function(c){ if (c === "<") { return "<"; } else if (c === ">") { return ">"; } else { return c; } }; openBracketCount = 0; lastBracketIndex = -1; singleBrackets = []; for (i$ = 0, len$ = mathml.length; i$ < len$; ++i$) { i = i$; c = mathml[i$]; if (c === "<" || c === ">") { currentBracketIndex = i; } if (c === "<") { openBracketCount++; } else if (c === ">") { openBracketCount--; } if (openBracketCount === -1) { openBracketCount++; singleBrackets.push(currentBracketIndex); } else if (openBracketCount === 2) { openBracketCount--; singleBrackets.push(lastBracketIndex); } if (c === "<" || c === ">") { lastBracketIndex = i; } } lastI = 0; newMathml = ""; for (i$ = 0, len$ = singleBrackets.length; i$ < len$; ++i$) { i = singleBrackets[i$]; newMathml += mathml.slice(lastI, i) + escape(mathml[i]); lastI = i + 1; } newMathml += mathml.slice(lastI); return newMathml; }; })(); mathDiv/calcSourceDiv/fixChars/fix.ls (function(){ return function(v){ v = _.replaceAll(v, "·", "*"); v = _.replaceAll(v, ":", "÷"); return v; }; })(); mathDiv/calcSourceDiv/fixMnMoDot/fix.ls (function(){ return function(o){ var i$, ref$, len$, mo, prev, results$ = []; for (i$ = 0, len$ = (ref$ = o.sourceDiv.findAll("mo")).length; i$ < len$; ++i$) { mo = ref$[i$]; if (mo.textContent === ".") { prev = mo.previousSibling; if ((prev != null ? prev.tagName.toLowerCase() : void 8) === "mn") { mo.remove(); results$.push(prev.textContent += "."); } } } return results$; }; })(); mathDiv/calcSourceDiv/fixSpaces/fix.ls (function(){ return function(v){ var v2, i$, ref$, len$, part; v2 = ""; for (i$ = 0, len$ = (ref$ = v.split(/(.*?<\/gap>)/)).length; i$ < len$; ++i$) { part = ref$[i$]; part = part.replace(/\s\s+/g, " "); if (!_.startsWith(part, "")) { part = part.replace(/\s* \s*/g, " "); part = part.replace(/(( )+)/g, "$1 "); part = part.replace(/ /g, " "); } v2 += part; } return v2; }; })(); mathDiv/calcSourceDiv/processAlignment/process.ls (function(){ return function(o){ var i$, ref$, len$, mtd, newMtds, currentMtd, j$, ref1$, len1$, el, k$, ref2$, len2$, c, m, results$ = []; for (i$ = 0, len$ = (ref$ = o.sourceDiv.findAll("mtd")).length; i$ < len$; ++i$) { mtd = ref$[i$]; if (!mtd.firstChild) { continue; } newMtds = []; currentMtd = []; for (j$ = 0, len1$ = (ref1$ = mtd.childrenAll()).length; j$ < len1$; ++j$) { el = ref1$[j$]; if (el.tagName === "mtext" && el.innerHTML === "||") { newMtds.push(currentMtd); currentMtd = []; } else if (el.tagName === "mrow") { for (k$ = 0, len2$ = (ref2$ = el.childrenAll()).length; k$ < len2$; ++k$) { c = ref2$[k$]; currentMtd.push(c); } } else { currentMtd.push(el); } } if (currentMtd.length > 0) { newMtds.push(currentMtd); } results$.push(mtd.replaceWith((fn$()))); } return results$; function fn$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = newMtds).length; i$ < len$; ++i$) { m = ref$[i$]; results$.push(document.createElement("mtd").html(m.length > 1 ? document.createElement("mrow").html(m) : m.length === 1 ? m[0] : void 8)); } return results$; } }; })(); mathDiv/calcSourceDiv/processFunctions/process.ls (function(){ return function(o){ var fnsPre, fnsPost, fns, i$, ref$, len$, el, fnArg, that, mfn, p, results$ = []; fnsPre = "sin cos tan asin acos atan log ln logbase".split(" "); fnsPost = "!".split(" "); fns = fnsPre.concat(fnsPost); for (i$ = 0, len$ = (ref$ = _.filter(o.sourceDiv.findAll("mi, mo"), fn$)).length; i$ < len$; ++i$) { el = ref$[i$]; fnArg = el.innerHTML === "logbase" ? (that = el.nextSibling) ? [that, that.nextSibling] : void 8 : in$(el.innerHTML, fnsPre) ? el.nextSibling : in$(el.innerHTML, fnsPost) ? el.previousSibling : void 8; if (!fnArg) { continue; } mfn = document.createElement("mfn"); el.replaceWith(mfn); mfn.append(el, fnArg); if (el.attr("inverse") === "true") { mfn.attr({ inverse: true }); } p = mfn.parent(); if (p.tagName === "mrow" && p.childrenAll().length === 1) { results$.push(p.replaceWith(mfn)); } } return results$; function fn$(t){ return in$(t.innerHTML, fns); } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/calcSourceDiv/processGaps/process.ls (function(){ return function(o, gaps){ var gapFences, i$, ref$, len$, gf, p, i, gapIndex, gap, mgap, results$ = []; gapFences = function(){ return _.filter(o.sourceDiv.findAll("mfenced"), function(el){ return el.attr("open") === "⟪"; }); }; for (i$ = 0, len$ = (ref$ = gapFences()).length; i$ < len$; ++i$) { gf = ref$[i$]; p = gf.parent(); if (p.attr("open") === "⟪") { p.empty(); p.append(gf.childrenAll()); } } for (i$ = 0, len$ = (ref$ = gapFences()).length; i$ < len$; ++i$) { i = i$; gf = ref$[i$]; gapIndex = gf.firstChild.text(); gap = gaps[gapIndex]; mgap = document.createElement("mgap"); mgap.attr({ gap: gap, index: i }); results$.push(gf.replaceWith(mgap)); } return results$; }; })(); mathDiv/calcSourceDiv/processInverse/process.ls (function(){ return function(o){ var inversable, i$, ref$, len$, el, results$ = []; inversable = ["asin", "acos", "atan"]; for (i$ = 0, len$ = (ref$ = _.filter(o.sourceDiv.findAll("mi"), fn$)).length; i$ < len$; ++i$) { el = ref$[i$]; el.innerHTML = el.innerHTML.substr(1); results$.push(el.attr({ inverse: true })); } return results$; function fn$(t){ return in$(t.innerHTML, inversable); } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/calcSourceDiv/processNewlines/process.ls (function(){ return function(o){ var createMtr, mtable, elements, i$, len$, i, el, mtr; if (_.some(o.sourceDiv.findAll("mtext"), function(t){ return t.innerHTML === "
"; })) { createMtr = function(){ return document.createElement("mtr").append(document.createElement("mtd")); }; mtable = document.createElement("mtable").attr({ tableType: "newline" }); elements = o.sourceDiv.childrenAll(); for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { i = i$; el = elements[i$]; if (i === 0) { mtr = createMtr(); } if (el.tagName === "mtext" && el.innerHTML === "
") { mtable.append(mtr); el.remove(); mtr = createMtr(); } else { mtr.findFirst("mtd").append(el); } if (i === elements.length - 1) { mtable.append(mtr); } } return o.sourceDiv.empty().append(mtable); } }; })(); mathDiv/calcSourceDiv/processStyles/process.ls (function(){ return function(o){ var process; o.styleFences = _.filter(o.sourceDiv.findAll("mfenced"), function(el){ return el.attr("open") === "⟨"; }); process = inc("processStyle/process"); process({ o: o, filter: function(style){ return style === "b"; }, modifier: function(child){ return child.attr({ bold: true }); } }); process({ o: o, filter: function(style){ return style === "i"; }, modifier: function(child){ return child.attr({ italic: true }); } }); process({ o: o, filter: function(style){ return style === "u"; }, modifier: function(child){ return child.attr({ underline: true }); } }); process({ o: o, filter: function(style){ return _.includes(style, "m-"); }, modifier: function(child, style){ return child.attr({ mcolor: style.replace("m-", "") }); } }); return process({ o: o, filter: function(style){ return _.includes(style, "t-"); }, modifier: function(child, style){ return child.attr({ tcolor: style.replace("t-", "") }); } }); }; })(); mathDiv/calcSourceDiv/processStyles/processStyle/process.ls (function(){ return function(p){ var i$, ref$, len$, mtext, lresult$, html, style, parent, j$, ref1$, len1$, child, results$ = []; for (i$ = 0, len$ = (ref$ = p.o.sourceDiv.findAll("mtext")).length; i$ < len$; ++i$) { mtext = ref$[i$]; lresult$ = []; html = mtext.innerHTML; if (html.indexOf("styleend") === 0) { continue; } style = html.replace("style_", ""); if (!p.filter(style)) { continue; } parent = mtext.parent(); parent.firstChild.remove(); parent.lastChild.remove(); for (j$ = 0, len1$ = (ref1$ = parent.childrenAll()).length; j$ < len1$; ++j$) { child = ref1$[j$]; lresult$.push(p.modifier(child, style)); } results$.push(lresult$); } return results$; }; })(); mathDiv/calcSourceDiv/pullGaps/pull.ls (function(){ return function(v){ var split, newV, gaps, i$, len$, i, s; split = v.split(/|<\/gap>/g); newV = ""; gaps = []; for (i$ = 0, len$ = split.length; i$ < len$; ++i$) { i = i$; s = split[i$]; if (i % 2 === 0) { newV += s; continue; } gaps[i] = s; newV += '⟪⟪"' + i + '"⟫⟫'; } return [newV, gaps]; }; })(); mathDiv/calcSourceDiv/removeStyleFences/remove.ls (function(){ return function(o){ var i$, ref$, len$, el, mrow, j$, ref1$, len1$, c, mcolor, tcolor, parentTag, results$ = []; for (i$ = 0, len$ = (ref$ = o.styleFences).length; i$ < len$; ++i$) { el = ref$[i$]; mrow = el.firstChild; for (j$ = 0, len1$ = (ref1$ = mrow.childrenAll()).length; j$ < len1$; ++j$) { c = ref1$[j$]; if (el.attr("bold")) { c.attr({ bold: true }); } if (el.attr("italic")) { c.attr({ italic: true }); } if (el.attr("underline")) { c.attr({ underline: true }); } if (mcolor = el.attr("mcolor")) { c.attr({ mcolor: mcolor }); } if (tcolor = el.attr("tcolor")) { c.attr({ tcolor: tcolor }); } } parentTag = el.parent().tagName.toLowerCase(); results$.push(el.replaceWith(parentTag === "math" || parentTag === "mrow" ? mrow.childrenAll() : mrow)); } return results$; }; })(); mathDiv/calcSourceDiv/setCenterAttribute/set.ls (function(){ return function(o){ var ref$, parent; if (((ref$ = o.matAttributes) != null ? ref$.center : void 8) === "true") { parent = o.div.closest(".gapComponent") || o.div.parent(); if (parent != null) { parent.css({ width: "100%" }); } return o.div.css({ display: "flex", justifyContent: "center", margin: "0.6em 0" }); } }; })(); mathDiv/calcSourceDiv/unescapeAngleBrackets/unescape.ls (function(){ return function(v){ var r; r = _.replaceAll; v = r(v, "<", "<"); v = r(v, "≤", "≤"); v = r(v, ">", ">"); v = r(v, "≥", "≥"); return v; }; })(); mathDiv/calcSpecialKeys/calc.ls (function(){ return function(o){ return function(){ var keys, template, keyboardKeys, calcDiv, queryChildren, i$, ref$, len$, gap, j$, ref1$, len1$, c, that, k; keys = {}; template = inc("/../app01/lib/gui/screenKeyboard/_templates/templates")[o.keyboardLayout]; keyboardKeys = template != null ? template.main.join("|") : void 8; calcDiv = function(v){ if (keyboardKeys != null) { if (inc("checkExistsInKeyboard/check")(v, keyboardKeys)) { return; } } return inc("calcSpecialKey/calc")(o, keys, v); }; queryChildren = function(el){ var s, i$, ref$, len$, v, c, results$ = []; if (el.tagName === "mfrac") { if (_.includes(el.asciimath, ";")) { calcDiv(";"); } if (_.includes(el.asciimath, "/")) { calcDiv("/"); } } else if (el.tagName === "msqrt") { calcDiv("sqrt"); } else if (el.tagName === "mroot") { calcDiv("root"); } else if (el.tagName === "msup") { calcDiv("^"); } else if (el.tagName === "msub") { s = el.asciimath.replace(/_(.*)/, "_`$1`"); calcDiv(s); return; } else if (el.tagName === "msubsup") { debug("msubsup write doesn't work yet"); } else if (el.tagName === "mfn") { for (i$ = 0, len$ = (ref$ = el.content).length; i$ < len$; ++i$) { v = ref$[i$]; if (_.isString(v)) { calcDiv(v); } else { queryChildren(v); } } } else if (el.tagName === "mfenced") { switch (el.attributes.open) { case "(": calcDiv("()"); break; case "{": calcDiv("{}"); break; case "[": calcDiv("[]"); break; case "|": calcDiv("abs"); } } else if (el.tagName === "mover") { calcDiv(el.content[1]); } else if (_.isString(el.content)) { calcDiv(el.content); return; } for (i$ = 0, len$ = (ref$ = _.ensureArray(el.content)).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(queryChildren(c)); } return results$; }; for (i$ = 0, len$ = (ref$ = o.div.findAll(".gap")).length; i$ < len$; ++i$) { gap = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = gap.mathChoices).length; j$ < len1$; ++j$) { c = ref1$[j$]; queryChildren(c.mathData); } } if (that = o.matLayout.specialKeys) { for (i$ = 0, len$ = (ref$ = that.split(" ")).length; i$ < len$; ++i$) { k = ref$[i$]; queryChildren(MathDiv(k).getMathData()); } } return keys; }; }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/_div/div.ls (function(){ return function(html){ return Div({ display: "flex", padding: "0.3em 0.4em", flex: "0 0 auto", minWidth: "2.5em" }).html(Div({ flex: "1 1 auto", whiteSpace: "nowrap", textAlign: "center", overflow: "hidden", textOverflow: "ellipsis", display: "flex", paddingTop: "0.1em" }).html(html)); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/abs/abs.ls (function(){ return function(o){ return inc("../_div/div")("Abs").tap(function(){ return o.onKey("abs"); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/arrow/arrow.ls (function(){ return function(o, v){ return inc("../_div/div")(Svg({ svg: path("/../app01/lib/svg/key/" + v + ".svg"), size: "1.2em" })).tap(function(){ return o.onKey(v); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/bar/bar.ls (function(){ return function(o){ return inc("../_div/div")(Svg({ svg: path("/../app01/lib/svg/key/bar.svg"), size: "1.2em" })).tap(function(){ return o.onKey("bar"); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/calc.ls (function(){ return function(o, keys, v){ var ref$; if (_.isFinite(_.parseInt(v))) { return; } if (_.includes("+-*÷:.", v)) { return; } return (ref$ = keys[v]) != null ? ref$ : keys[v] = v === "^" ? inc("sup/sup")(o) : _.includes(v, "_") ? inc("sub/sub")(o, v) : v === "/" ? inc("fraction/fraction")(o) : v === ";" ? inc("ncr/ncr")(o) : v === "sqrt" ? inc("sqrt/sqrt")(o) : v === "root" ? inc("root/root")(o) : v === "asin" || v === "acos" || v === "atan" ? inc("inverse/inverse")(o, v) : v === "()" || v === "{}" || v === "[]" ? inc("fenced/fenced")(o, v) : v === "abs" ? inc("abs/abs")(o) : v === "logbase" ? inc("logbase/logbase")(o) : v === "rarrow" || v === "larrow" || v === "lrarrow" ? inc("arrow/arrow")(o, v) : v === "bar" ? inc("bar/bar")(o) : inc("other/other")(o, v); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/fenced/fenced.ls (function(){ return function(o, v){ return inc("../_div/div")(v[0] + " " + v[1]).tap(function(){ return o.onKey(v); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/fraction/fraction.ls (function(){ return function(o){ return inc("../_div/div")(Svg({ svg: path("/../app01/lib/svg/key/fraction.svg"), width: '1.2em', height: '1.2em' })).tap(function(){ return o.onKey("fraction"); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/inverse/inverse.ls (function(){ return function(o, label){ return inc("../_div/div")(label.substr(1)).tap(function(){ return o.onKey(label); }).append(Div({ marginTop: "-0.5em", fontSize: "0.8em" }).html("-1")); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/logbase/logbase.ls (function(){ return function(o){ return inc("../_div/div")(Div({ display: "flex" }).html(Div({ display: "flex" }).html(Div({ marginRight: "-2px" }).html("log"), Svg({ svg: path("/../app01/lib/svg/key/logbase.svg"), width: "1.2em", height: "1.2em", color: Color.black }).css({ marginTop: "3px" })))).tap(function(){ return o.onKey("logbase"); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/ncr/ncr.ls (function(){ return function(o){ return inc("../_div/div")("nCr").tap(function(){ return o.onKey("ncr"); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/other/other.ls (function(){ return function(o, label){ return inc("../_div/div")(label).tap(function(){ return o.onKey(label); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/root/root.ls (function(){ return function(o){ return inc("../_div/div")(Svg({ svg: path("/../app01/lib/svg/key/root.svg"), width: '1.2em', height: '1.2em' })).tap(function(){ return o.onKey("root"); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/sqrt/sqrt.ls (function(){ return function(o){ return inc("../_div/div")(Svg({ svg: path("/../app01/lib/svg/key/sqrt.svg"), width: '1.2em', height: '1.2em' })).tap(function(){ return o.onKey("sqrt"); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/sub/sub.ls (function(){ return function(o, v){ return inc("../_div/div")(MathDiv({ value: v, enabled: false })).tap(function(){ return o.onKey(v.replace(/`/g, "")); }); }; })(); mathDiv/calcSpecialKeys/calcSpecialKey/sup/sup.ls (function(){ return function(o){ return inc("../_div/div")(Svg({ svg: path("/../app01/lib/svg/key/sup.svg"), width: '1.2em', height: '1.2em' })).tap(function(){ return o.onKey("sup"); }); }; })(); mathDiv/calcSpecialKeys/checkExistsInKeyboard/check.ls (function(){ return function(v, keyboardKeys){ var v2; v2 = v === ";" ? "ncr" : v === "π" ? "pi" : v; return _.includes(keyboardKeys != null ? keyboardKeys.split("|") : void 8, v2); }; })(); mathDiv/calcSyntax/calc.ls (function(){ return function(o){ return function(){ var value; value = o.getValue(); value = value.replace(/[0-9]+/g, "$"); value = value.replace(/÷/g, ":"); value = value.replace(/ +/g, ""); return value; }; }; })(); mathDiv/checkEquivalence/check.ls (function(){ return function(o){ var findVariables; if ((typeof deviceLog != 'undefined' && deviceLog !== null) && deviceLog['var']("useCheckEquivalenceNext")) { return inc("../checkEquivalenceNext/check")(o); } findVariables = function(div){ return _.uniqBy(_.map(div.findAll(".mi"), function(mi){ return mi.text().trim(); })); }; return function(p){ var solutionMathDivs, res$, i$, ref$, len$, sol, allVariables, div, results, solDiv, currentVs; res$ = []; for (i$ = 0, len$ = (ref$ = p.solutions).length; i$ < len$; ++i$) { sol = ref$[i$]; res$.push(MathDiv({ value: sol })); } solutionMathDivs = res$; if (p.value != null) { p.inputMathDiv = MathDiv({ value: p.value }); p.valueNoSpaces = _.replaceAll(p.value, /[ `]+/g, ""); } else { p.inputMathDiv = o.div; p.valueNoSpaces = o.getValue().replace(/ +/g, ""); } res$ = []; for (i$ = 0, len$ = (ref$ = _.concat(solutionMathDivs, p.inputMathDiv)).length; i$ < len$; ++i$) { div = ref$[i$]; res$.push(findVariables(div)); } allVariables = res$; allVariables = _.uniqBy(_.flatten(allVariables)); results = []; for (i$ = 0, len$ = solutionMathDivs.length; i$ < len$; ++i$) { solDiv = solutionMathDivs[i$]; currentVs = _.concat(findVariables(p.inputMathDiv), findVariables(solDiv)); if (currentVs.length === 0) { results.push(inc("evalWithoutScope/eval")(p, solDiv)); } else { results.push(inc("evalWithScope/eval")(p, solDiv, allVariables)); } } return _.some(results, function(r){ return _.every(r, function(c){ return c === true; }); }); }; }; })(); mathDiv/checkEquivalence/evalWithScope/eval.ls (function(){ var primes; primes = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191]; return function(p, solDiv, allVariables){ var intsPos, intsNeg, floatPos, floatNeg, epsilon, i$, len$, i, v, prime, ref$, prime1, rounds, results, vars, valueSol, valueInput, absSol, absInp, diff; intsPos = {}; intsNeg = {}; floatPos = {}; floatNeg = {}; epsilon = Math.pow(2, -25); for (i$ = 0, len$ = allVariables.length; i$ < len$; ++i$) { i = i$; v = allVariables[i$]; prime = (ref$ = primes[i]) != null ? ref$ : i + 1; prime1 = (ref$ = primes[i + 1]) != null ? ref$ : i + 2; intsPos[v] = prime; intsNeg[v] = prime * -1; floatPos[v] = parseFloat(prime + "." + prime1); floatNeg[v] = parseFloat(prime + "." + prime1) * -1; } rounds = [intsPos, intsNeg, floatPos, floatNeg]; results = []; for (i$ = 0, len$ = rounds.length; i$ < len$; ++i$) { i = i$; vars = rounds[i$]; valueSol = solDiv.eval(vars); valueInput = p.inputMathDiv.eval(vars); if (valueSol == null) { debug("gapValidateMode: value cannot evaluate the gap solution. Falling back to normal validation."); return [in$(p.valueNoSpaces, p.solutions)]; } else if (valueInput == null) { return [false]; } else if (_.isNaN(valueSol) && _.isNaN(valueInput)) { debug("Attention, this term cannot currently be evaluated by gapValidateMode: \"value\""); return [false]; } else if (Math.abs(valueSol) > 1e+100 && Math.abs(valueInput) > 1e+100 && Math.sign(valueSol) === Math.sign(valueInput)) { debug("gapValidateMode: value cannot evaluate the gap because of overflow. Falling back to normal validation."); return [in$(p.valueNoSpaces, p.solutions)]; } else if (!_.isFinite(valueSol)) { debug("mathDiv currently doesn't support very large numbers"); return [false]; } else { if (p.precision) { results.push(_.round(valueSol, p.precision) === _.round(valueInput, p.precision)); } else { absSol = Math.abs(valueSol); absInp = Math.abs(valueInput); diff = Math.abs(valueSol - valueInput); results.push(absSol === 0 || absInp === 0 ? diff < epsilon : diff / (absSol + absInp) < epsilon); } } } return results; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/checkEquivalence/evalWithoutScope/eval.ls (function(){ return function(p, solDiv){ var solution, valueSol, valueInput, epsilon, result, absSol, absInp, diff; solution = solDiv.text().trim(); valueSol = solDiv.eval(); valueInput = p.inputMathDiv.eval(); epsilon = Math.pow(2, -25); result = valueSol == null ? (debug("gapValidateMode: value cannot evaluate the gap solution '" + solution + "'. Falling back to normal validation."), in$(p.valueNoSpaces, p.solutions)) : valueInput == null ? false : _.isNaN(valueSol) || _.isNaN(valueInput) ? (debug("Attention, this term cannot currently be evaluated by gapValidateMode: \"value\""), false) : !_.isFinite(valueSol) ? (debug("mathDiv currently doesn't support very large numbers"), false) : p.precision ? _.round(valueSol, p.precision) === _.round(valueInput, p.precision) : (absSol = Math.abs(valueSol), absInp = Math.abs(valueInput), diff = Math.abs(valueSol - valueInput), absSol === 0 || absInp === 0 ? diff < epsilon : diff / (absSol + absInp) < epsilon); return [result]; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/findMatAtoms/extractMatTagString/extract.ls (function(){ return function(s){ var a, i$, len$, i; s = s.split("").join("/mat>§§"); a = s.split("§§"); for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { i = i$; s = a[i$]; if (!_.startsWith(s, "", "mmm>"); mEl = Div().html(s).firstChild; if (!_.isNaN(+mEl.textContent)) { return false; } if (mEl.firstChild.tagName === "GAP" && mEl.children.length === 1) { return false; } return true; }); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/findMatAtoms/find.ls (function(){ return function(levels, onDone){ var matAtoms, i$, len$, l, j$, ref$, len1$, t, k$, ref1$, len2$, atom, a, filteredMatAtoms; matAtoms = []; for (i$ = 0, len$ = levels.length; i$ < len$; ++i$) { l = levels[i$]; for (j$ = 0, len1$ = (ref$ = l.trainers).length; j$ < len1$; ++j$) { t = ref$[j$]; if (t.gapValidateMode === "value") { for (k$ = 0, len2$ = (ref1$ = t.atoms).length; k$ < len2$; ++k$) { atom = ref1$[k$]; if (_.includes(atom.b, "")) { matAtoms.push({ matString: atom.b, propertyName: "b", atom: atom, level: l }); } } } } } for (i$ = 0, len$ = matAtoms.length; i$ < len$; ++i$) { a = matAtoms[i$]; a.matTagString = inc("extractMatTagString/extract")(a.matString); a.matTagStrings = inc("getMatTagStrings/get")(a.matTagString); } filteredMatAtoms = inc("filterMatAtoms/filter")(matAtoms); return onDone(filteredMatAtoms); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/findMatAtoms/getMatTagStrings/get.ls (function(){ return function(matTagString){ var a, matTagStrings, res$, i$, len$, s; a = matTagString.split(""); res$ = []; for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { s = a[i$]; if (!_.endsWith(s, "/mat>")) { continue; } res$.push("" + s); } matTagStrings = res$; return matTagStrings; }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/list.ls (function(){ return function(page, atoms){ var list; return list = ListDiv({ data: _.slice(atoms, 0, 100000), row: function(d){ return inc("row/row")(d); }, nearScopeSize: 0.5, nearScopeDelay: 1000, debug: false, scopeRender: { enabled: true, debug: false, maxDurations: "200 5 5", nearScopeSize: 0 }, listPosition: app.lastListPosition, onScroll: function(){ return app.lastListPosition = list.getListPosition(); } }).css({ flex: "1 1 auto", width: "var(--centerWidth)", height: "var(--centerHeight)", fontSize: "16px" }); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/header/header.ls (function(){ return function(d){ return Div({ display: "flex", alignItems: "center", justifyContent: "flex-start", background: Color.grey[100] }).html(inc("levelIndex/levelIndex")(d), inc("propertyName/name")(d), inc("matTagString/matTagString")(d)); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/header/levelIndex/levelIndex.ls (function(){ return function(d){ return Div({ padding: "0.2em", borderRight: "1px solid " + Color.grey[200] }).html(d.level.levelIndex); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/header/matTagString/matTagString.ls (function(){ return function(d){ var div; div = Div({ flex: "1 1 auto", padding: "0.2em", borderRight: "1px solid " + Color.grey[200], textAlign: "Left", userSelect: "text" }); div.textContent = d.matTagString; return div; }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/header/propertyName/name.ls (function(){ return function(d){ return Div({ padding: "0.2em", borderRight: "1px solid " + Color.grey[200] }).html("." + d.propertyName); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/header/showData/show.ls (function(){ return function(d){ return debug(d); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/mathDivs/mathDiv/mathDiv.ls (function(){ return function(matTagString){ return Div({ width: "50%", background: "white", padding: "1em", paddingLeft: "3.5em", textAlign: "left", borderLeft: "1px solid " + Color.grey[100] }).html(MathDiv({ value: matTagString, enabled: false, debug: false })); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/mathDivs/mathDiv2/mathDiv2.ls (function(){ return function(matTagString){ var e; return Div({ width: "50%", background: "white", padding: "1em", paddingLeft: "3.5em", textAlign: "left" }).html((function(){ try { return inc("/mathDiv/mathDiv")({ value: matTagString, enabled: false }); } catch (e$) { e = e$; return Div({ background: "red", padding: "0.5em" }).html("ERROR"); } }())); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/mathDivs/mathDivs.ls (function(){ return function(d){ var i, matTagString; return Div({ borderTop: "1px solid " + Color.grey[100] }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = d.matTagStrings).length; i$ < len$; ++i$) { i = i$; matTagString = ref$[i$]; results$.push(Div({ flex: "1 1 auto", display: "flex", alignItems: "center", justifyContent: "flex-start", padding: "0.2em", borderTop: i > 0 ? "1px solid " + Color.grey[100] : void 8 }).html(inc("mathDiv2/mathDiv2")(matTagString), inc("mathDiv/mathDiv")(matTagString))); } return results$; }())); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/list/row/row.ls (function(){ return function(d){ var tap; tap = function(){ return inc("showData/show")(d); }; return Div({ display: "flex", borderBottom: "1px solid " + Color.grey[200], flexDirection: "column", alignItems: "stretch" }).html(inc("header/header")(d), inc("mathDivs/mathDivs")(d)); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/loadLevels/calcLevelPaths/calc.ls (function(){ return function(plan){ var levelPaths, i$, ref$, len$, t, j$, ref1$, len1$, b, k$, ref2$, len2$, l; levelPaths = []; for (i$ = 0, len$ = (ref$ = plan.topics).length; i$ < len$; ++i$) { t = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = t.blocks).length; j$ < len1$; ++j$) { b = ref1$[j$]; for (k$ = 0, len2$ = (ref2$ = b.levels).length; k$ < len2$; ++k$) { l = ref2$[k$]; levelPaths.push(l.path); } } } return levelPaths; }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/loadLevels/load.ls (function(){ return function(page, onDone){ var planPath, loadPlan, calcLevelPaths, loadLevels, finish; planPath = "/../" + page.plan + "/plan.ls"; loadPlan = function(){ return inc("/../app01/lib/util/loadPlan/load")({ path: planPath, fileApi: "files", onError: function(){ return debug("loadPlanError"); }, onLoaded: calcLevelPaths }); }; calcLevelPaths = function(plan){ var levelPaths; levelPaths = inc("calcLevelPaths/calc")(plan); return loadLevels(levelPaths); }; loadLevels = function(levelPaths){ return inc("loadLevels/load")(levelPaths, finish); }; finish = function(levels){ return onDone(levels); }; return loadPlan(); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/loadLevels/loadLevels/load.ls (function(){ return function(levelPaths, onDone){ var totalDone, levels, res$, i$, len$, i, p, loadLevels, onLevelLoaded; totalDone = 0; res$ = []; for (i$ = 0, len$ = levelPaths.length; i$ < len$; ++i$) { i = i$; p = levelPaths[i$]; res$.push({ levelIndex: i, path: p }); } levels = res$; loadLevels = function(){ var i$, ref$, len$, l, results$ = []; for (i$ = 0, len$ = (ref$ = levels).length; i$ < len$; ++i$) { l = ref$[i$]; results$.push(inc("loadLevel/load")(l, onLevelLoaded)); } return results$; }; onLevelLoaded = function(levelFull){ var l; l = _.find(levels, { path: levelFull.path }); levelFull.levelIndex = l.levelIndex; levels[l.levelIndex] = levelFull; totalDone++; if (totalDone === levels.length) { return onDone(levels); } }; return loadLevels(); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/loadLevels/loadLevels/loadLevel/load.ls (function(){ return function(l, onDone){ return inc("/../app01/lib/util/loadLevel/load")({ path: l.path, onLoaded: onDone, onError: function(){ return debug("Level load Error"); } }); }; })(); mathDiv/checkEquivalenceNext/_projectAtomWithMatTag_noMaster/page.ls (function(){ return function(page){ page.plan = "c-mat-8"; return { top: function(){ return inc("/../app01/addons/topbar2/topbar")({ back: true, title: page.plan }); }, start: function(){ var loadLevels, findMatAtoms, showList; loadLevels = function(){ return inc("loadLevels/load")(page, findMatAtoms); }; findMatAtoms = function(levels){ var matStrings; return matStrings = inc("findMatAtoms/find")(levels, showList); }; showList = function(atoms){ return page.html(inc("list/list")(page, atoms)); }; page.html(inc("/../app01/lib/gui/spinner/spinner")()); return loadLevels(); } }; }; })(); mathDiv/checkEquivalenceNext/_testPage_noMaster/cases/cases-multiVariable.ls (function(){ var cases; return cases = [ { solutions: ["x+y"], value: "x+y", equal: true }, { solutions: ["sqrt(x*y)"], value: "sqrt(x)*sqrt(y)", equal: true }, { solutions: ["sqrt(x/y)"], value: "sqrt(x)/sqrt(y)", equal: true }, { solutions: ["rootn(x^n)"], value: "x", equal: true }, { solutions: ["rootn(x^m)"], value: "x^(m/n)", equal: true }, { solutions: ["sqrt(x+y)"], value: "sqrt(x)+sqrt(y)", equal: false }, { solutions: ["sqrt(x-y)"], value: "sqrt(x-y)+0", equal: true }, { solutions: ["sqrt(-x)"], value: "sqrt(-x)+0y", equal: true }, { solutions: ["x^4*y^4"], value: "(x*y)^4", equal: true }, { solutions: ["x^n/y^n"], value: "(x/y)^n", equal: true }, { solutions: ["(-x)^n"], value: "-(x^n)", equal: false }, { solutions: ["x^(-n)"], value: "1/(x^n)", equal: true }, { solutions: ["x*x^n"], value: "x^(n+1)", equal: true }, { solutions: ["1*x^n"], value: "x^n", equal: true }, { solutions: ["-x^a"], value: "-x^a", equal: true }, { solutions: ["k*g(x_0)"], value: "k*g(x_0)", equal: true }, { solutions: ["k*g(x_0+h)"], value: "k*g(x_0+h)", equal: true }, { solutions: ["5xy-2xy^2"], value: "5xy-2xy^2", equal: true }, { solutions: ["4xy"], value: "4xy", equal: true } ]; })(); mathDiv/checkEquivalenceNext/_testPage_noMaster/cases/cases-noVariable.ls (function(){ var cases; return cases = [ { solutions: ["1"], value: "1", equal: true }, { solutions: ["1"], value: "-1", equal: false }, { solutions: ["3+1-5"], value: "-1", equal: true }, { solutions: ["(3+1)-5"], value: "-1", equal: true }, { solutions: ["(3+1)/5"], value: "3.2", equal: false }, { solutions: ["100:10"], value: "10", equal: true }, { solutions: ["1/5"], value: "5^(-1)", equal: true }, { solutions: ["`asin`(0.7)"], value: "44.427004", equal: true }, { solutions: ["`sin`(45)"], value: "sqrt(2)/2", equal: true }, { solutions: ["sqrt(-2)"], value: "sqrt(-3)", equal: false }, { solutions: ["10^888"], value: "10^88*10^800", equal: true }, { solutions: ["10^888"], value: "1+10^888", equal: false }, { solutions: ["`tan`(90)"], value: "`tan`(90)", equal: true }, { solutions: ["`tan`(90)"], value: "`tan`(90)+1", equal: false }, { solutions: ["`log`(1)"], value: "0", equal: true }, { solutions: ["0/0"], value: "0/0", equal: true }, { solutions: ["π"], value: "π", equal: true }, { solutions: ["∞"], value: "∞", equal: true }, { solutions: ["-∞"], value: "-∞", equal: true }, { solutions: ["6710000"], value: "6710000", equal: true }, { solutions: ["0.005"], value: "0.005", equal: true }, { solutions: ["5`m`"], value: "5`m`", equal: true }, { solutions: ["42`km`^2"], value: "42`km`^2", equal: true }, { solutions: ["9.40€-4€"], value: "9.40€-4€", equal: true }, { solutions: ["4`cm`"], value: "4`cm`", equal: true }, { solutions: ["2338`cm`^3"], value: "2338`cm`^3", equal: true }, { solutions: ["1000000"], value: "1000000", equal: true } ]; })(); mathDiv/checkEquivalenceNext/_testPage_noMaster/cases/cases-singleVariable.ls (function(){ var cases; return cases = [ { solutions: ["x"], value: "x", equal: true }, { solutions: ["-x"], value: "-x", equal: true }, { solutions: ["-x"], value: "-(x)", equal: true }, { solutions: ["x^2"], value: "-x^2", equal: false }, { solutions: ["x^2"], value: "x^2", equal: true }, { solutions: ["sqrt(-x)"], value: "-sqrt(x)", equal: false }, { solutions: ["(32*x)^(1/2)"], value: "sqrt(32*x)", equal: true }, { solutions: ["sqrt(x^2)"], value: "x", equal: false }, { solutions: ["x*x"], value: "x^2", equal: true }, { solutions: ["x^2*x^55"], value: "x^57", equal: true }, { solutions: ["x^600"], value: "x^600", equal: true }, { solutions: ["x^600"], value: "x^400*x^200", equal: true }, { solutions: ["(-x)^2"], value: "-(x^2)", equal: false }, { solutions: ["(-x)^3"], value: "-(x^3)", equal: true }, { solutions: ["x^0"], value: "1", equal: true }, { solutions: ["1*x^2"], value: "x^2", equal: true }, { solutions: ["a^(-888)"], value: "1+a^(-888)", equal: false }, { solutions: ["a^(-888)"], value: "a^(-888)", equal: true }, { solutions: ["a^(-888)"], value: "a^(-88)*a^(-800)", equal: true }, { solutions: ["a^(-888)"], value: "1+(a^(-88)*a^(-800))", equal: false }, { solutions: ["`cos`(17)*x"], value: "0.956*x", equal: true }, { solutions: ["`cos`(17.059)*x"], value: "0.956*x", equal: true }, { solutions: ["`cos`(17.05962)*x"], value: "0.956*x", equal: true }, { solutions: ["a^(-800)"], value: "0", equal: false }, { solutions: ["a^(-16)"], value: "0", equal: false }, { solutions: ["a^(-15)"], value: "0", equal: false }, { solutions: ["`log`(x)"], value: "`log`(x)", equal: true }, { solutions: ["(`ln`(x))/(`ln`(x))"], value: "1", equal: true }, { solutions: ["x/0"], value: "x/0", equal: true }, { solutions: ["sqrt(x)"], value: "sqrt(x)", equal: true }, { solutions: ["root2(x)"], value: "root2(x)", equal: true }, { solutions: ["root3(x)"], value: "root3(x)", equal: true }, { solutions: ["sqrt(x+2)"], value: "sqrt(x+2)", equal: true }, { solutions: ["sqrt(3*x)"], value: "sqrt(3*x)", equal: true }, { solutions: ["sqrt(x+x)"], value: "sqrt(x+x)", equal: true }, { solutions: ["sqrt(x^2)"], value: "sqrt(x^2)", equal: true }, { solutions: ["sqrt(x)*sqrt(x)"], value: "sqrt(x)*sqrt(x)", equal: true }, { solutions: ["x^(1/2)"], value: "x^(1/2)", equal: true }, { solutions: ["x^(1/3)"], value: "x^(1/3)", equal: true }, { solutions: ["x^(3/4)"], value: "x^(3/4)", equal: true }, { solutions: ["5x^4-1/(2sqrt(x))"], value: "5x^4-1/(2sqrt(x))", equal: true }, { solutions: ["sqrt(x)+root4(x)"], value: "sqrt(x)+root4(x)", equal: true }, { solutions: ["-1/(3root3(x^2))+1/(4root4(x^3))"], value: "-1/(3root3(x^2))+1/(4root4(x^3))", equal: true }, { solutions: ["sqrt(x)+abs(x)"], value: "sqrt(x)+abs(x)", equal: true }, { solutions: ["-0.035(x-22)^2+18)"], value: "-0.035(x-22)^2+18)", equal: true }, { solutions: ["x^2-44x+484"], value: "x^2-44x+484", equal: true }, { solutions: ["-0.035x^2+1.54x-16.94"], value: "-0.035x^2+1.54x-16.94", equal: true }, { solutions: ["πx"], value: "πx", equal: true }, { solutions: ["12*1.5^2+12*2*1.5*h+12h^2"], value: "12*1.5^2+12*2*1.5*h+12h^2", equal: true }, { solutions: ["-5+1/8*h"], value: "-5+1/8*h", equal: true }, { solutions: ["0.5/(4+h)"], value: "0.5/(4+h)", equal: true }, { solutions: ["(3x+3/2h+1)"], value: "(3x+3/2h+1)", equal: true }, { solutions: ["-5x^(-6)"], value: "-5x^(-6)", equal: true }, { solutions: ["-2x^(-3)+4x^3"], value: "-2x^(-3)+4x^3", equal: true }, { solutions: ["-4x^(-5)+2x"], value: "-4x^(-5)+2x", equal: true }, { solutions: ["4.70€-2e"], value: "4.70€-2e", equal: true } ]; })(); mathDiv/checkEquivalenceNext/_testPage_noMaster/page.ls (function(){ return function(page){ return { start: function(){ var casesNoVariable, casesSingleVariable, casesMultiVariable, allCases, createCellWide, createCellNarrow, createCellVeryNarrow, i, c, isEquivalent; casesNoVariable = inc("cases/cases-noVariable"); casesSingleVariable = inc("cases/cases-singleVariable"); casesMultiVariable = inc("cases/cases-multiVariable"); allCases = _.concat(casesNoVariable, casesSingleVariable, casesMultiVariable); createCellWide = function(html){ return Div({ width: "25%" }).html(html); }; createCellNarrow = function(html){ return Div().html(html); }; createCellVeryNarrow = function(html){ return Div({ width: "5%", fontStyle: "italic" }).html(html); }; return page.css({ padding: "1em" }).html(Div({ outline: "1px solid black" }).html(Div({ display: "flex", justifyContent: "space-around", padding: "0.5em 0", backgroundColor: Color.grey[200], borderBottom: "1px solid black" }).html(createCellVeryNarrow("#"), createCellWide("solution"), createCellWide("value"), Div({ display: "flex", justifyContent: "space-around", width: "18%" }).html(createCellNarrow("exp."), createCellNarrow("res."))), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = allCases).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; isEquivalent = MathDiv().checkEquivalence(c); results$.push(Div({ border: "1px solid " + Color.grey[300], backgroundColor: c.validationFallback ? Color.purple[200] : c.equal !== isEquivalent ? Color.red[300] : Color.white }).html(Div({ display: "flex", justifyContent: "space-around", padding: "0.5em 0" }).html(createCellVeryNarrow((i + 1) + ""), createCellWide("" + c.solutions[0] + ""), createCellWide("" + c.value + ""), Div({ display: "flex", justifyContent: "space-around", width: "18%" }).html(createCellNarrow(c.equal ? "=" : "≠"), createCellNarrow(isEquivalent ? "=" : "≠"))), c.comment ? Div({ fontSize: "0.8em", fontStyle: "italic", textAlign: "left", padding: "0.5em" }).html(c.comment) : void 8)); } return results$; }()))); } }; }; })(); mathDiv/checkEquivalenceNext/check.ls (function(){ return function(o){ var findVariables; findVariables = function(div){ return _.uniqBy(_.map(div.findAll(".mi"), function(mi){ return mi.text().trim(); })); }; return function(p){ var solutionMathDivs, res$, i$, ref$, len$, sol, allVariables, div, results, solDiv, currentVs; res$ = []; for (i$ = 0, len$ = (ref$ = p.solutions).length; i$ < len$; ++i$) { sol = ref$[i$]; res$.push(MathDiv({ value: sol })); } solutionMathDivs = res$; if (p.value != null) { p.inputMathDiv = MathDiv({ value: p.value }); p.valueNoSpaces = _.replaceAll(p.value, /[ `]+/g, ""); } else { p.inputMathDiv = o.div; p.valueNoSpaces = o.getValue().replace(/ +/g, ""); } res$ = []; for (i$ = 0, len$ = (ref$ = _.concat(solutionMathDivs, p.inputMathDiv)).length; i$ < len$; ++i$) { div = ref$[i$]; res$.push(findVariables(div)); } allVariables = res$; allVariables = _.uniqBy(_.flatten(allVariables)); results = []; for (i$ = 0, len$ = solutionMathDivs.length; i$ < len$; ++i$) { solDiv = solutionMathDivs[i$]; currentVs = _.concat(findVariables(p.inputMathDiv), findVariables(solDiv)); if (allVariables.length === 0) { results.push(inc("evalNoVariable/eval")(p, solDiv)); } else if (allVariables.length === 1) { results.push(inc("evalSingleVariable/eval")(p, solDiv, allVariables[0])); } else { results.push(inc("evalMultiVariable/eval")(p, solDiv, allVariables)); } } return _.some(results, function(r){ return _.every(r, function(c){ return c === true; }); }); }; }; })(); mathDiv/checkEquivalenceNext/evalMultiVariable/eval.ls (function(){ var primes; primes = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191]; return function(p, solDiv, allVariables){ var epsilon, intsPos, intsNeg, floatPos, floatNeg, i$, len$, i, v, prime, ref$, prime1, rounds, results, vars, valueSol, valueInput, absSol, absInp, diff; epsilon = Math.pow(2, -25); intsPos = {}; intsNeg = {}; floatPos = {}; floatNeg = {}; for (i$ = 0, len$ = allVariables.length; i$ < len$; ++i$) { i = i$; v = allVariables[i$]; prime = (ref$ = primes[i]) != null ? ref$ : i + 1; prime1 = (ref$ = primes[i + 1]) != null ? ref$ : i + 2; intsPos[v] = prime; intsNeg[v] = prime * -1; floatPos[v] = parseFloat(prime + "." + prime1); floatNeg[v] = parseFloat(prime + "." + prime1) * -1; } rounds = [intsPos, intsNeg, floatPos, floatNeg]; results = []; for (i$ = 0, len$ = rounds.length; i$ < len$; ++i$) { i = i$; vars = rounds[i$]; valueSol = solDiv.eval(vars); valueInput = p.inputMathDiv.eval(vars); if (valueSol == null) { p.validationFallback = true; debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."); return [in$(p.valueNoSpaces, p.solutions)]; } else if (valueInput == null) { return [false]; } else if (_.isNaN(valueSol) || _.isNaN(valueInput)) { p.validationFallback = true; debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."); return [in$(p.valueNoSpaces, p.solutions)]; } else if (!_.isFinite(valueSol) || !_.isFinite(valueInput)) { p.validationFallback = true; debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."); return [in$(p.valueNoSpaces, p.solutions)]; } else { if (p.precision) { results.push(_.round(valueSol, p.precision) === _.round(valueInput, p.precision)); } else { absSol = Math.abs(valueSol); absInp = Math.abs(valueInput); diff = Math.abs(valueSol - valueInput); results.push(absSol === 0 || absInp === 0 ? diff < epsilon : diff / (absSol + absInp) < epsilon); } } } return results; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/checkEquivalenceNext/evalNoVariable/eval.ls (function(){ return function(p, solDiv){ var solution, valueSol, valueInput, epsilon, result, absSol, absInp, diff; solution = solDiv.text().trim(); valueSol = solDiv.eval(); valueInput = p.inputMathDiv.eval(); epsilon = Math.pow(2, -25); result = valueSol == null ? (p.validationFallback = true, debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."), in$(p.valueNoSpaces, p.solutions)) : valueInput == null ? false : _.isNaN(valueSol) || _.isNaN(valueInput) ? (p.validationFallback = true, debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."), in$(p.valueNoSpaces, p.solutions)) : !_.isFinite(valueSol) || !_.isFinite(valueInput) ? (p.validationFallback = true, debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."), in$(p.valueNoSpaces, p.solutions)) : p.precision ? _.round(valueSol, p.precision) === _.round(valueInput, p.precision) : (absSol = Math.abs(valueSol), absInp = Math.abs(valueInput), diff = Math.abs(valueSol - valueInput), absSol === 0 || absInp === 0 ? diff < epsilon : diff / (absSol + absInp) < epsilon); return [result]; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/checkEquivalenceNext/evalSingleVariable/eval.ls (function(){ return function(p, solDiv, variable){ var epsilon, evalSol, evalInput, isDefined, rounds, testValues, res$, i$, len$, round, results, value, absSol, absInp, diff; epsilon = Math.pow(2, -25); evalSol = function(value){ var ref$; return solDiv.eval((ref$ = {}, ref$[variable + ""] = value, ref$)); }; evalInput = function(value){ var ref$; return p.inputMathDiv.eval((ref$ = {}, ref$[variable + ""] = value, ref$)); }; isDefined = function(value){ var sol, input; sol = evalSol(value); input = evalInput(value); return !_.isNaN(sol) && _.isFinite(sol) && !_.isNaN(input) && _.isFinite(input); }; rounds = [[3, -5, 105, -105], [-3, 5, -105, 105], [3.5, 5.7, 105.7, -105.7], [-3.5, 7.11, 107.11, -107.11]]; res$ = []; for (i$ = 0, len$ = rounds.length; i$ < len$; ++i$) { round = rounds[i$]; res$.push(_.find(round, isDefined)); } testValues = res$; if (_.compact(testValues).length < 4) { p.validationFallback = true; debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."); return [in$(p.valueNoSpaces, p.solutions)]; } results = []; for (i$ = 0, len$ = testValues.length; i$ < len$; ++i$) { value = testValues[i$]; if (evalSol(value) == null) { debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\"."); p.validationFallback = true; return [in$(p.valueNoSpaces, p.solutions)]; } else if (evalInput(value) == null) { return [false]; } else { if (p.precision) { results.push(_.round(evalSol(value), p.precision) === _.round(evalInput(value), p.precision)); } else { absSol = Math.abs(evalSol(value)); absInp = Math.abs(evalInput(value)); diff = Math.abs(evalSol(value) - evalInput(value)); results.push(absSol === 0 || absInp === 0 ? diff < epsilon : diff / (absSol + absInp) < epsilon); } } } return results; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/convertTag/convert.ls (function(){ return function(o){ o.value = o.convertTag.outerHTML; o.value = _.replaceAll(o.value, "<", "<"); o.value = _.replaceAll(o.value, ">", ">"); o.enabled = false; if (o.convertTag.attr("border") != null) { return o.div.css({ border: "1px solid red" }); } }; })(); mathDiv/createElements/create.ls (function(){ return function(o){ return function(){ var i$, ref$, len$, el; o.createElement = function(el){ if (_.isString(el)) { el = { tagName: el }; } return inc("element/element")(o, el); }; o.addCursorSupport = function(p){ p.o = o; return inc("element/_shared/cursor/addCursorSupport")(p); }; o.elements = []; for (i$ = 0, len$ = (ref$ = o.sourceDiv.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; o.elements.push(o.createElement(el)); } return o.div.html(o.div.startDiv = inc("start/start")(o), o.elements, o.div.endDiv = inc("end/end")(o)); }; }; })(); mathDiv/createElements/element/_shared/cursor/_initKeyframeAnimation/init.ls (function(){ var init; init = false; return function(){ var s; if (init) { return; } init = true; s = Style(); s.setAttribute("id", "mathDivCursor"); s.innerHTML = "\n .mathDivCursor {\n animation: 900ms mathDivCursor linear infinite;\n }\n\n @keyframes mathDivCursor {\n 0% {opacity: 1;}\n 40% {opacity: 1;}\n 50% {opacity: 0;}\n 90% {opacity: 0;}\n 100% {opacity: 1;}\n }\n"; return document.head.appendChild(s); }; })(); mathDiv/createElements/element/_shared/cursor/addCursorSupport.ls (function(){ return function(p){ var o, div, cursorType; o = p.o; div = p.div; cursorType = p.cursorType || "right"; inc("_initKeyframeAnimation/init")(); div.addClass("cursorSupport"); div.startCursor = inc("start")(o, div, cursorType); div.stopCursor = inc("stop")(o, div); div.insert = p.insert; div.back = p.back; div.left = p.left; return div.right = p.right; }; })(); mathDiv/createElements/element/_shared/cursor/cursor/cursor.ls (function(){ return function(cursorType){ return Div({ display: "flex", position: "absolute", top: 0, bottom: 0, width: "2px", pointerEvents: "none" }).css(cursorType === "left" ? { left: 0 } : cursorType === "right" ? { right: 0 } : cursorType === "middle" ? { left: "50%", marginLeft: "-1px" } : void 8).addClass("mathDivCursor").append(Div({ width: "2px", overflow: "hidden", backgroundColor: Color.grey[800], fontSize: "0.8em" }).html(" ")).onWindowBlur(function(){ return this.css({ visibility: "hidden" }); }).onWindowFocus(function(){ return this.css({ visibility: "visible" }); }); }; })(); mathDiv/createElements/element/_shared/cursor/cursorBorder/cursorBorder.ls (function(){ return function(){ return Div({ position: "absolute", left: 0, right: 0, top: 0, bottom: 0, border: "2px solid " + Color.grey[700], pointerEvents: "none" }).addClass("mathDivCursor").onWindowBlur(function(){ return this.css({ visibility: "hidden" }); }).onWindowFocus(function(){ return this.css({ visibility: "visible" }); }); }; })(); mathDiv/createElements/element/_shared/cursor/cursorBorderTableRow/cursorBorder.ls (function(){ return function(div){ var pos; pos = div.position(); return Div({ position: "absolute", left: pos.left + "px", top: pos.top + "px", height: div.offsetHeight + "px", width: div.offsetWidth + "px", border: "2px solid " + Color.grey[700], pointerEvents: "none" }).addClass("mathDivCursor").onWindowBlur(function(){ return this.css({ visibility: "hidden" }); }).onWindowFocus(function(){ return this.css({ visibility: "visible" }); }); }; })(); mathDiv/createElements/element/_shared/cursor/start.ls (function(){ return function(o, div, cursorType){ var start; return start = function(type){ var el, ref$; if (o.enabled === false) { return; } if (type === "last") { el = div.findLast(".cursorSupport"); if (el) { return el.startCursor(); } } if (type === "first") { el = div.findFirst(".cursorSupport"); if (el) { return el.startCursor(); } } if ((ref$ = o.cursorElement) != null) { ref$.stopCursor(); } o.cursorElement = div; if (!div.cursor) { if (div.hasClass("mtr") && cursorType === "border") { div.cursor = inc("cursorBorderTableRow/cursorBorder")(div); } else { div.cursor = cursorType === "border" ? inc("cursorBorder/cursorBorder")(div) : inc("cursor/cursor")(cursorType); } } if (div.hasClass("mtr") && cursorType === "border") { div.closest(".mtable").append(div.cursor); } else { div.append(div.cursor); } div.cursor.css({ visibility: document.hasFocus() ? "visible" : "hidden" }); if (!o.isStarted) { o.start(); } return div; }; }; })(); mathDiv/createElements/element/_shared/cursor/stop.ls (function(){ return function(o, div){ return function(){ o.cursorElement = null; div.cursor.remove(); return div; }; }; })(); mathDiv/createElements/element/_shared/getCenter/get.ls (function(){ return function(div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.offsetHeight / 2; }; }; })(); mathDiv/createElements/element/_shared/select/select.ls (function(){ return function(o, div){ return function(){ return div.addClass("select").css({ backgroundColor: Color.grey[300] }); }; }; })(); mathDiv/createElements/element/_shared/setAttrStyle/set.ls (function(){ var markColors, ref$, textColors, ref1$; markColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.markColors : void 8; textColors = (ref1$ = document.head.findFirst('#cssColorTags')) != null ? ref1$.textColors : void 8; return function(div, el){ var mcolor, tcolor; return div.css({ fontWeight: el != null && (typeof el.attr == 'function' && el.attr("bold")) ? "bold" : void 8, fontStyle: el != null && (typeof el.attr == 'function' && el.attr("italic")) ? "italic" : void 8, textDecoration: el != null && (typeof el.attr == 'function' && el.attr("underline")) ? "underline" : void 8, backgroundColor: (mcolor = el != null ? typeof el.attr == 'function' ? el.attr("mcolor") : void 8 : void 8) ? markColors[mcolor] : void 8, color: (tcolor = el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8) ? textColors[tcolor] : void 8 }); }; })(); mathDiv/createElements/element/_shared/unselect/unselect.ls (function(){ return function(o, div){ return function(){ return div.removeClass("select").css({ backgroundColor: "" }); }; }; })(); mathDiv/createElements/element/basic/_div/char/char.ls (function(){ return function(o, char, tagName){ var div; div = Div(); div.value = char; div.nearestTapEnabled = true; div.addClass("char").css({ display: "inline-block", textAlign: "center" }).html(char === "." ? twitch({ de: ",", en: ".", fr: ",", es: ".", pt: "," }) : char === "*" ? twitch({ de: "⋅", en: "×", fr: "×", es: "×", pt: "×" }) : char === "÷" || char === ":" ? twitch({ de: ":", en: "÷", fr: ":", es: "÷", pt: "÷" }) : char === " " ? " " : char === "-" ? "−" : char === "+" ? "+" : char); inc("cursor/cursor")(o, div, tagName); inc("tap/tap")(div); return div; }; })(); mathDiv/createElements/element/basic/_div/char/cursor/cursor.ls (function(){ return function(o, div, tagName){ return o.addCursorSupport({ div: div, insert: function(newElement){ return inc("insert/insert")(o, div, newElement, tagName); }, back: function(){ var p, prev; p = div.parent(); if (p.findAll(".char").length > 1) { div.previousSibling.startCursor(); return div.remove(); } else { prev = p.previousSibling; p.remove(); return prev.startCursor("last"); } }, left: function(type){ return div.previousSibling.startCursor(); }, right: function(type){ var p; p = div.parent(); if (div !== p.findLast(".char")) { return div.nextSibling.startCursor(); } else { return p.nextSibling.startCursor("first").right(); } } }); }; })(); mathDiv/createElements/element/basic/_div/char/cursor/insert/insert.ls (function(){ return function(o, div, newElement, tagName){ var ref$; if ((ref$ = div.nextSibling) != null && ref$.hasClass("char")) { inc("split/split")(o, div, tagName); } return div.parent().after(newElement); }; })(); mathDiv/createElements/element/basic/_div/char/cursor/insert/split/split.ls (function(){ return function(o, div, tagName){ var followUpChars, next, n, e; followUpChars = []; next = div.nextSibling; while (next) { followUpChars.push(next); n = next.nextSibling; next = n != null && n.hasClass("char") ? n : undefined; } e = o.createElement(tagName).append(followUpChars); return div.parent().after(e); }; })(); mathDiv/createElements/element/basic/_div/char/tap/tap.ls (function(){ return function(div){ var click; click = function(e){ var pageX, ref$, offset; pageX = e.pageX || ((ref$ = e.touches) != null ? ref$[0].pageX : void 8); offset = div.offset(); if (pageX < offset.left + div.offsetWidth / 2) { return div.previousSibling.startCursor(); } else { return div.startCursor(); } }; return div.charTap = click; }; })(); mathDiv/createElements/element/basic/_div/cursor/cursor.ls (function(){ return function(o, div){ return o.addCursorSupport({ div: div, cursorType: "border", insert: function(newElement){ return div.replaceWith(newElement); }, back: function(){ var prev; prev = div.previousSibling; div.remove(); return prev.startCursor("last"); }, left: function(){ return div.previousSibling.startCursor("last"); }, right: function(){ return div.nextSibling.startCursor("first"); } }); }; })(); mathDiv/createElements/element/basic/_div/debugTag/tag.ls (function(){ return function(tagName){ return Div({ position: "absolute", top: 0, left: 0, fontSize: "0.6em", backgroundColor: Color.grey[300], opacity: 0.5, height: "1em", zIndex: 2 }).html(tagName.substr(1, 2)); }; })(); mathDiv/createElements/element/basic/_div/div.ls (function(){ return function(o, tagName, chars, el){ var div, char; div = Div(); div.addClass("mathElement").addClass(tagName).css({ display: "inline-flex" }).html(o.debug ? inc("debugTag/tag")(tagName) : void 8, inc("start/start")(o), chars != null ? (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = chars).length; i$ < len$; ++i$) { char = ref$[i$]; results$.push(inc("char/char")(o, char, tagName)); } return results$; }()) : void 8); inc("../../_shared/getCenter/get")(div); inc("../../_shared/setAttrStyle/set")(div, el); inc("cursor/cursor")(o, div); inc("getMathData/get")(o, div, tagName, el); return div; }; })(); mathDiv/createElements/element/basic/_div/getMathData/eval/eval.ls (function(){ return function(tagName, s, scope){ var s2; s2 = s; if (tagName === "mo" && s === "±") { debug("Warning, ± is not allowed in gapValidateMode: \"value\""); return NaN; } if (tagName === "mi") { if (s === "π") { s = Math.PI; } else if (s === "e") { s = Math.E; } else { s = scope != null ? scope[s] : void 8; } } if (!s) { return NaN; } if (s === "÷") { return "/"; } else { return s; } }; })(); mathDiv/createElements/element/basic/_div/getMathData/get.ls (function(){ return function(o, div, tagName, el){ return div.getMathData = function(){ var chars, res$, i$, ref$, len$, char, s; res$ = []; for (i$ = 0, len$ = (ref$ = div.findAll(".char")).length; i$ < len$; ++i$) { char = ref$[i$]; res$.push(char.value); } chars = res$; s = chars.join(""); if ((el != null ? typeof el.attr == 'function' ? el.attr("inverse") : void 8 : void 8) === "true") { s = "a" + s; } return { tagName: tagName, content: s, asciimath: s, eval: function(scope){ return inc("eval/eval")(tagName, s, scope); } }; }; }; })(); mathDiv/createElements/element/basic/_div/start/cursor/cursor.ls (function(){ return function(o, div){ return o.addCursorSupport({ div: div, insert: function(newElement){ return div.parent().before(newElement); }, back: function(){ return div.parent().previousSibling.startCursor("last").back(); }, left: function(){ return div.parent().previousSibling.startCursor("last").left(); }, right: function(){ return div.nextSibling.startCursor(); } }); }; })(); mathDiv/createElements/element/basic/_div/start/start.ls (function(){ return function(o){ var div; div = Div(); div.addClass("start").css({ display: "inline-block", width: "0px" }).html(" "); inc("cursor/cursor")(o, div); return div; }; })(); mathDiv/createElements/element/basic/mi/inverse/inverse.ls (function(){ return function(o, el){ var chars; chars = el != null ? el.innerHTML : void 8; return inc("../../_div/div")(o, "mi", chars, el).css({ padding: "0 0.1em" }).append(Div({ marginTop: "-0.5em", fontSize: "0.8em" }).html("-1")); }; })(); mathDiv/createElements/element/basic/mi/mi.ls (function(){ return function(o, el){ var chars, inverse; chars = el != null ? el.innerHTML : void 8; inverse = (el != null ? typeof el.attr == 'function' ? el.attr("inverse") : void 8 : void 8) === "true"; if (inverse) { return inc("inverse/inverse")(o, el); } else { return inc("../_div/div")(o, "mi", chars, el).css(!o.matsci ? { padding: "0 0.1em" } : chars.length === 1 ? { fontStyle: "italic", letterSpacing: "0.1em" } : void 8); } }; })(); mathDiv/createElements/element/basic/mn/mn.ls (function(){ return function(o, el){ var chars, updateSpacing, div; chars = el != null ? el.innerHTML : void 8; updateSpacing = function(){ return inc("updateSpacings/update")(div); }; div = inc("../_div/div")(o, "mn", chars, el).onChildrenModified(updateSpacing).onDomAppendAndVisible(updateSpacing); return div; }; })(); mathDiv/createElements/element/basic/mn/updateSpacings/initCss/init.ls (function(){ return function(){ var id, s; id = "mathDivDigitGroupSeparator"; s = document.head.findFirst("#" + id); if (s) { return; } s = Style(); s.attr({ id: id }); s.innerHTML = "\n .digitGroup::after {\n content: \",\";\n pointer-events: \"none\";\n }\n"; return document.head.append(s); }; })(); mathDiv/createElements/element/basic/mn/updateSpacings/update.ls (function(){ inc("initCss/init")(); return function(div){ var chars, res$, i$, len$, char, calcDE, calcES, calcEN; if (div.closest(".mover") != null) { return; } chars = div.findAll(".char"); res$ = []; for (i$ = 0, len$ = chars.length; i$ < len$; ++i$) { char = chars[i$]; if (char.value !== ".") { res$.push(char); } else { break; } } chars = res$; calcDE = function(){ var i$, ref$, len$, i, char, results$ = []; for (i$ = 0, len$ = (ref$ = chars.reverse()).length; i$ < len$; ++i$) { i = i$; char = ref$[i$]; results$.push(char.css({ borderRight: i > 0 && i % 3 === 0 ? "0.23em solid transparent" : "0px solid transparent" })); } return results$; }; calcES = function(){ var i$, ref$, len$, i, char, results$ = []; for (i$ = 0, len$ = (ref$ = chars.reverse()).length; i$ < len$; ++i$) { i = i$; char = ref$[i$]; results$.push(char.css({ borderRight: chars.length > 4 && i > 0 && i % 3 === 0 ? "0.23em solid transparent" : "0px solid transparent" })); } return results$; }; calcEN = function(){ var i$, ref$, len$, i, char, results$ = []; for (i$ = 0, len$ = (ref$ = chars.reverse()).length; i$ < len$; ++i$) { i = i$; char = ref$[i$]; if (i > 0 && i % 3 === 0) { results$.push(char.addClass("digitGroup")); } else { results$.push(char.removeClass("digitGroup")); } } return results$; }; return twitch({ en: calcEN, es: calcES, de: calcDE, fr: calcDE, pt: calcDE })(); }; })(); mathDiv/createElements/element/basic/mo/mo.ls (function(){ return function(o, el){ var chars, div; chars = el != null ? el.textContent : void 8; return div = inc("../_div/div")(o, "mo", chars, el).css({ padding: "0 0.25em" }); }; })(); mathDiv/createElements/element/basic/mspace/mspace.ls (function(){ return function(o, el){ var width, total, chars, res$, i$, i; width = (el != null ? typeof el.attr == 'function' ? el.attr("width") : void 8 : void 8) || "0ex"; total = parseInt(width != null ? width.replace("ex", "") : void 8); res$ = []; for (i$ = 1; i$ <= total; ++i$) { i = i$; res$.push(" "); } chars = res$; return inc("../_div/div")(o, "mspace", chars, el); }; })(); mathDiv/createElements/element/basic/mtext/mtext.ls (function(){ return function(o, el){ var chars; chars = el != null ? el.innerHTML : void 8; return inc("../_div/div")(o, "mtext", chars, el); }; })(); mathDiv/createElements/element/basic/newline/newline.ls (function(){ return function(o, el){ return Div({ flex: "1 0 100%" }); }; })(); mathDiv/createElements/element/basic/unknown/unknown.ls (function(){ return function(o, el){ var div; div = Div(); return div.css({ display: "inline-block", backgroundColor: o.debug ? Color.red[500] : void 8 }).html("unknown: " + el.tagName); }; })(); mathDiv/createElements/element/combined/_shared/blinker/blinker.ls (function(){ return function(p){ var div; div = Div(); div.addClass("blinker").css({ width: "0px" }).html(" "); div.nearestTapEnabled = true; inc("cursor/cursor")(p, div); inc("../../../_shared/getCenter/get")(div); return div; }; })(); mathDiv/createElements/element/combined/_shared/blinker/cursor/cursor.ls (function(){ return function(p, div){ var o; o = p.o; return o.addCursorSupport({ div: div, cursorType: "middle", insert: p.insert, back: p.back, left: p.left, right: p.right }); }; })(); mathDiv/createElements/element/combined/_shared/bracket/bracket.ls (function(){ return function(o, el, v, parent){ var type, side, p, scale, div; type = v === "(" || v === ")" ? "round" : v === "[" || v === "]" ? "square" : v === "{" || v === "}" ? "curly" : v === "|" ? "abs" : "hide"; side = v === "(" || v === "[" || v === "{" || v === "(:" || v === "{:" ? "left" : v === ")" || v === "]" || v === "}" || v === ":)" || v === ":}" ? "right" : void 8; if (!type) { debug("unknown bracket type"); return; } p = {}; p.defaultHeight = +body.css("fontSize").replace("px", ""); p.currentHeight = null; scale = inc("scale/scale")(o, p); div = Div({ display: "inline-flex" }).html(p.bracket = type === "round" ? inc("brackets/round/round")(p, side) : type === "square" ? inc("brackets/square/square")(p, side) : type === "curly" ? inc("brackets/curly/curly")(p, side) : type === "abs" ? inc("brackets/abs/abs")(p) : type === "hide" ? inc("brackets/hide/hide")(p) : void 8); inc("../../../_shared/getCenter/get")(parent); inc("setFeedbackColor/set")(div, p); inc("setLineColor/set")(el, p.bracket); div.scale = scale; return div; }; })(); mathDiv/createElements/element/combined/_shared/bracket/brackets/abs/abs.ls (function(){ return function(p, side){ var setColor, div, svgs; setColor = function(color){ var i$, ref$, len$, svg, results$ = []; for (i$ = 0, len$ = (ref$ = svgs).length; i$ < len$; ++i$) { svg = ref$[i$]; results$.push(svg.setColor(color)); } return results$; }; div = Div({ display: "inline-flex", flexDirection: "column", minHeight: "0", width: "0.15em", height: p.defaultHeight + "px" }).html(svgs = [Svg({ svg: path("svgs/bar.svg") }).css({ height: "auto", width: "", flex: "1 1 auto", minHeight: "0", overflow: "hidden", margin: "-1px 0" })]); div.setColor = setColor; return div; }; })(); mathDiv/createElements/element/combined/_shared/bracket/brackets/abs/svgs/bar.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/curly.ls (function(){ return function(p, side){ var setColor, div, svgs; setColor = function(color){ var i$, ref$, len$, svg, results$ = []; for (i$ = 0, len$ = (ref$ = svgs).length; i$ < len$; ++i$) { svg = ref$[i$]; results$.push(svg.setColor(color)); } return results$; }; div = Div({ display: "inline-flex", flexDirection: "column", minHeight: "0", width: "0.4em", height: p.defaultHeight + "px", margin: side === "right" ? "0 0.15em 0 0" : "0 0 0 0.15em" }).html(svgs = [ Svg({ svg: path("svgs/" + side + "/top.svg") }).css({ height: "auto", width: "100%", flex: "0 2 0.5em", minHeight: "0" }), Svg({ svg: path("svgs/" + side + "/bar.svg") }).css({ height: "auto", width: "100%", flex: "1 4 500px", minHeight: "0", overflow: "hidden", margin: "-1px 0" }), Svg({ svg: path("svgs/" + side + "/middle.svg") }).css({ height: "auto", width: "100%", flex: "0 1.5 0.7em", minHeight: "0" }), Svg({ svg: path("svgs/" + side + "/bar.svg") }).css({ height: "auto", width: "100%", flex: "1 4 500px", minHeight: "0", overflow: "hidden", margin: "-1px 0" }), Svg({ svg: path("svgs/" + side + "/bottom.svg") }).css({ height: "auto", width: "100%", flex: "0 2 0.5em", minHeight: "0" }) ]); div.setColor = setColor; return div; }; })(); mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/left/bar.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/left/bottom.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/left/middle.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/left/top.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/right/bar.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/right/bottom.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/right/middle.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/curly/svgs/right/top.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/hide/hide.ls (function(){ return function(p, side){ var div; div = Div({ display: "inline-flex", flexDirection: "column", minHeight: "0", width: "1px", height: p.defaultHeight + "px" }); div.setColor = function(){}; return div; }; })(); mathDiv/createElements/element/combined/_shared/bracket/brackets/round/round.ls (function(){ return function(p, side){ var setColor, div, svgs; setColor = function(color){ var i$, ref$, len$, svg, results$ = []; for (i$ = 0, len$ = (ref$ = svgs).length; i$ < len$; ++i$) { svg = ref$[i$]; results$.push(svg.setColor(color)); } return results$; }; div = Div({ display: "inline-flex", flexDirection: "column", minHeight: "0", width: "0.25em", height: p.defaultHeight + "px", margin: side === "right" ? "0 0.1em -3px 0" : "0 0 -3px 0.1em" }).html(svgs = [ Svg({ svg: path("svgs/" + side + "/top.svg") }).css({ height: "auto", width: "100%", flex: "0 1 25px", minHeight: "0" }), Svg({ svg: path("svgs/" + side + "/middle.svg") }).css({ height: "auto", width: "100%", flex: "2 20 500px", minHeight: "0", overflow: "hidden", margin: "-1px 0" }), Svg({ svg: path("svgs/" + side + "/bottom.svg") }).css({ height: "auto", width: "100%", flex: "0 1 25px", minHeight: "0" }) ]); div.setColor = setColor; return div; }; })(); mathDiv/createElements/element/combined/_shared/bracket/brackets/round/svgs/left/bottom.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/round/svgs/left/middle.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/round/svgs/left/top.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/round/svgs/right/bottom.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/round/svgs/right/middle.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/round/svgs/right/top.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/square/square.ls (function(){ return function(p, side){ var setColor, div, svgs; setColor = function(color){ var i$, ref$, len$, svg, results$ = []; for (i$ = 0, len$ = (ref$ = svgs).length; i$ < len$; ++i$) { svg = ref$[i$]; results$.push(svg.setColor(color)); } return results$; }; div = Div({ display: "inline-flex", flexDirection: "column", minHeight: "0", width: "0.45em", height: p.defaultHeight + "px", margin: side === "right" ? "0 0.15em 0 0" : "0 0 0 0.15em" }).html(svgs = [ Svg({ svg: path("svgs/" + side + "/top.svg") }).css({ height: "auto", width: "100%", flex: "0 0 0.45em" }), Svg({ svg: path("svgs/" + side + "/middle.svg") }).css({ height: "auto", width: "100%", flex: "1 1 1000px", minHeight: "0", overflow: "hidden", margin: "-1px 0" }), Svg({ svg: path("svgs/" + side + "/bottom.svg") }).css({ height: "auto", width: "100%", flex: "0 0 0.45em" }) ]); div.setColor = setColor; return div; }; })(); mathDiv/createElements/element/combined/_shared/bracket/brackets/square/svgs/left/bottom.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/square/svgs/left/middle.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/square/svgs/left/top.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/square/svgs/right/bottom.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/square/svgs/right/middle.svg mathDiv/createElements/element/combined/_shared/bracket/brackets/square/svgs/right/top.svg mathDiv/createElements/element/combined/_shared/bracket/scale/scale.ls (function(){ return function(o, p){ return function(h){ var height; if (h !== p.currentHeight) { height = h - 5; p.bracket.css({ height: height + "px" }); return p.currentHeight = height; } }; }; })(); mathDiv/createElements/element/combined/_shared/bracket/setFeedbackColor/set.ls (function(){ return function(div, p){ div.addClass("feedbackColor"); return div.setFeedbackColor = function(c){ return p.bracket.setColor(c); }; }; })(); mathDiv/createElements/element/combined/_shared/bracket/setLineColor/set.ls (function(){ var textColors, ref$; textColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.textColors : void 8; return function(el, bracket){ var tcolor, ref$; tcolor = (el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8) || (el != null ? typeof el.closest == 'function' ? (ref$ = el.closest("[tcolor]")) != null ? ref$.attr("tcolor") : void 8 : void 8 : void 8); if (tcolor) { return bracket.setColor(textColors[tcolor]); } }; })(); mathDiv/createElements/element/combined/_shared/cursor/cursor.ls (function(){ return function(o, div){ return o.addCursorSupport({ div: div, cursorType: "border", insert: function(newElement){ return div.replaceWith(newElement); }, left: function(){ return div.blinkerStart.startCursor(); }, back: function(){ var prev; prev = div.previousSibling; div.remove(); return prev.startCursor("last"); }, right: function(){ return div.blinkerEnd.startCursor(); } }); }; })(); mathDiv/createElements/element/combined/mfenced/blinker/end/end.ls (function(){ return function(o, mfenced){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ var that; if (that = mfenced.closest(".mfn")) { return that.after(newElement); } else { return mfenced.after(newElement); } }; div.left = function(){ return mfenced.mrow.startCursor("last"); }; div.back = function(){ return mfenced.startCursor(); }; div.right = function(){ return mfenced.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/mfenced/blinker/start/start.ls (function(){ return function(o, mfenced){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mfenced.before(newElement); }; div.left = function(){ return mfenced.previousSibling.startCursor("last").left(); }; div.back = function(){ return mfenced.previousSibling.startCursor("last").back(); }; div.right = function(){ return mfenced.mrow.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/mfenced/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.mrow.getCenter(); }; }; })(); mathDiv/createElements/element/combined/mfenced/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var mrowMathData; mrowMathData = div.mrow.getMathData(); return { tagName: "mfenced", content: mrowMathData, attributes: { open: el.attr("open"), close: el.attr("close") }, asciimath: el.attr("open") + mrowMathData.asciimath + el.attr("close"), eval: function(scope){ var value; value = mrowMathData.eval(scope); if (el.attr("open") === "|" && value < 0) { return -value; } else { return value; } } }; }; }; })(); mathDiv/createElements/element/combined/mfenced/mfenced.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("mfenced center").css({ display: "inline-flex" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.open = inc("../_shared/bracket/bracket")(o, el, el.attr("open"), div), div.mrow = inc("mrow/mrow")(o, el), div.close = inc("../_shared/bracket/bracket")(o, el, el.attr("close"), div), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); div.scale = inc("scaleOpenClose/scale")(div); return div; }; })(); mathDiv/createElements/element/combined/mfenced/mrow/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var mfenced; mfenced = mrow.closest(".mfenced"); return mfenced.blinkerStart.startCursor(); }; mrow.back = function(){ var mfenced, prev; mfenced = mrow.closest(".mfenced"); prev = mfenced.previousSibling; mfenced.remove(); return prev.startCursor("last"); }; mrow.right = function(){ var mfenced; mfenced = mrow.closest(".mfenced"); return mfenced.blinkerEnd.startCursor(); }; mrow.blinkerStart.left = mrow.left; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/mfenced/mrow/mrow.ls (function(){ return function(o, el){ var el1, e, mrow; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); mrow.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow); return mrow; }; })(); mathDiv/createElements/element/combined/mfenced/scaleOpenClose/scale.ls (function(){ return function(div){ var scale; return scale = function(){ var h; h = div.mrow.offsetHeight; div.open.scale(h); return div.close.scale(h); }; }; })(); mathDiv/createElements/element/combined/mfn/blinker/end/end.ls (function(){ return function(o, mfn){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mfn.after(newElement); }; div.left = function(){ return mfn.wrapper.mrow1.startCursor("last"); }; div.back = function(){ if (mfn.notation === "post") { return mfn.startCursor(); } else { return mfn.wrapper.mrow1.startCursor("last").back(); } }; div.right = function(){ return mfn.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/mfn/blinker/start/start.ls (function(){ return function(o, mfn){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mfn.before(newElement); }; div.left = function(){ return mfn.previousSibling.startCursor("last").left(); }; div.back = function(){ return mfn.previousSibling.startCursor("last").back(); }; div.right = function(){ if (mfn.wrapper.contains(mfn.wrapper.base)) { return mfn.wrapper.base.mrow.startCursor("first"); } else { return mfn.wrapper.mrow1.startCursor("first"); } }; return div; }; })(); mathDiv/createElements/element/combined/mfn/calcNotation/calc.ls (function(){ return function(operator){ if (operator === "!") { return "post"; } else { return "pre"; } }; })(); mathDiv/createElements/element/combined/mfn/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/mfn/getMathData/factorial/factorial.ls (function(){ return function(n){ var val, i$, i; if (n > 170) { return NaN; } if (n < 0) { return NaN; } if (!_.isInteger(n)) { return NaN; } val = 1; for (i$ = 2; i$ <= n; ++i$) { i = i$; val *= i; } return val; }; })(); mathDiv/createElements/element/combined/mfn/getMathData/fixRoundingErrors/fix.ls (function(){ return function(v, op, trigMode){ var pi, v2, q, sols, ref$; pi = Math.PI; v2 = Math.abs(v); if (trigMode === "deg") { if (v2 >= 180) { q = Math.floor(v2 / 180); v2 -= 180 * q; } } else { if (v2 >= pi) { if (_.isInteger(v2 / pi)) { v2 = 0; } else if (_.isInteger(v2 / pi - 0.5)) { v2 = 0.5 * pi; } } } sols = { deg: { sin: { 0: 0 }, cos: { 90: 0 }, tan: { 0: 0, 90: NaN } }, rad: { sin: { 0: 0 }, cos: (ref$ = {}, ref$[0.5 * pi + ""] = 0, ref$), tan: (ref$ = { 0: 0 }, ref$[0.5 * pi + ""] = NaN, ref$) } }; return (ref$ = sols[trigMode][op]) != null ? ref$[v2] : void 8; }; })(); mathDiv/createElements/element/combined/mfn/getMathData/get.ls (function(){ return function(o, el, div){ var funs; funs = { log: Math.log10, logbase: inc("log/log"), ln: Math.log, sin: Math.sin, cos: Math.cos, tan: Math.tan, asin: Math.asin, acos: Math.acos, atan: Math.atan, "!": inc("factorial/factorial") }; return div.getMathData = function(){ var mrow1MathData, op, baseMathData, base, mrow1Content, mrow1FirstC, ref$, mrow1LastC, ref1$, ref2$, a, asciimath; mrow1MathData = div.wrapper.mrow1.getMathData(); op = div.operator; if (op === "logbase") { baseMathData = div.wrapper.base.mrow.getMathData(); base = baseMathData.asciimath; } if ((el != null ? el.attr("inverse") : void 8) === "true") { op = "a" + op; } mrow1Content = mrow1MathData.content; mrow1FirstC = (ref$ = _.first(mrow1Content)) != null ? ref$.asciimath : void 8; mrow1LastC = (ref1$ = _.last(mrow1Content)) != null ? ref1$.asciimath : void 8; if ((mrow1MathData.content.length > 0 || ((ref2$ = mrow1Content[0]) != null ? ref2$.tagName : void 8) === "mfrac") && !_.startsWith(mrow1FirstC, "(")) { a = "(" + mrow1MathData.asciimath + ")"; } else { a = mrow1MathData.asciimath; } if (op === "logbase") { asciimath = ("`" + op + "`") + ("(" + base + ")") + a; } else if (a) { if (div.notation === "post") { asciimath = a + ("`" + op + "`"); } else { asciimath = ("`" + op + "`") + a; } } else { asciimath = op; } asciimath = "(" + asciimath + ")"; return { tagName: "mfn", content: op === "logbase" ? [op, mrow1MathData, base] : [op, mrow1MathData], asciimath: asciimath, eval: function(scope){ var v, trigMode, r; v = mrow1MathData.eval(scope); trigMode = o.getTrigMode(); if (op === "sin" || op === "cos" || op === "tan") { r = inc("fixRoundingErrors/fix")(v, op, trigMode); if (r != null) { return r; } } if (funs[op] == null) { debug("mfn eval error, no operator found. how did you do that?"); return; } return r = (op === "sin" || op === "cos" || op === "tan") && trigMode === "deg" ? funs[op](v * (Math.PI / 180)) : (op === "asin" || op === "acos" || op === "atan") && trigMode === "deg" ? funs[op](v) * (180 / Math.PI) : op === "logbase" ? funs[op](v, baseMathData.eval(scope)) : funs[op](v); } }; }; }; })(); mathDiv/createElements/element/combined/mfn/getMathData/log/log.ls (function(){ return function(number, base){ return Math.log(number) / Math.log(base); }; })(); mathDiv/createElements/element/combined/mfn/mfn.ls (function(){ return function(o, el){ var operator, ref$, div; operator = (ref$ = el.firstChild) != null ? ref$.textContent : void 8; if (!operator) { debug("mfn error, no operator. how did you do that?"); } div = Div(); div.operator = operator; div.notation = inc("calcNotation/calc")(operator); div.addClass("mathElement").addClass("mfn center").css({ display: "inline-flex", alignItems: "flex-start", marginLeft: "3px" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el, div), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/mfn/wrapper/base/base.ls (function(){ return function(o, el){ var el1, e, mrow, div; el1 = el != null ? typeof el.childrenAll == 'function' ? el.childrenAll()[0] : void 8 : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); mrow.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow); div = Div({ fontSize: "0.7em", marginRight: "-3px", top: "0.6em" }).append(mrow); div.mrow = mrow; return div; }; })(); mathDiv/createElements/element/combined/mfn/wrapper/base/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var mfn; mfn = mrow.closest(".mfn"); return mfn.blinkerStart.startCursor(); }; mrow.back = function(){ var mfn; mfn = mrow.closest(".mfn"); mfn.previousSibling.startCursor("last"); return mfn.remove(); }; mrow.right = function(){ var mfn; mfn = mrow.closest(".mfn"); return mfn.findLast(".mrow").startCursor("first"); }; mrow.blinkerStart.left = mrow.left; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/mfn/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.offsetHeight / 2; }; }; })(); mathDiv/createElements/element/combined/mfn/wrapper/mrow1/cursorOverwrite/cursor.ls (function(){ return function(o, mrow1){ mrow1.left = function(){ var mfn; mfn = mrow1.closest(".mfn"); if (mfn.findFirst(".mrow") === mrow1) { return mfn.blinkerStart.startCursor(); } else { return mfn.findFirst(".mrow").startCursor("last"); } }; mrow1.back = function(){ var mfn; mfn = mrow1.closest(".mfn"); mfn.previousSibling.startCursor("last"); return mfn.remove(); }; mrow1.right = function(){ var mfn; mfn = mrow1.closest(".mfn"); return mfn.nextSibling.startCursor("first").right(); }; mrow1.blinkerStart.left = mrow1.left; return mrow1.blinkerEnd.right = mrow1.right; }; })(); mathDiv/createElements/element/combined/mfn/wrapper/mrow1/mrow1.ls (function(){ return function(o, el, mfn){ var mrow1, el2, e; if (mfn.operator === "logbase" && (el != null ? el.childrenAll().length : void 8) === 1) { mrow1 = o.createElement("mrow"); mrow1.hide(); return mrow1; } el2 = el != null ? el.lastChild : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow1); return mrow1; }; })(); mathDiv/createElements/element/combined/mfn/wrapper/operator/inverse/inverse.ls (function(){ return function(el){ var ref$; if ((ref$ = el.firstChild.textContent) === "asin" || ref$ === "acos" || ref$ === "atan") { el.firstChild.textContent = el.firstChild.textContent.substr(1); } return Div({ display: "flex" }).html(el.firstChild, Div({ display: "inline-block", fontSize: "0.7em", marginBottom: "0.6em", verticalAlign: "top" }).html("-1")); }; })(); mathDiv/createElements/element/combined/mfn/wrapper/operator/normal/normal.ls (function(){ return function(o, el, mfn){ if (mfn.operator === "logbase") { if (el.firstChild.nodeType === 3) { el.firstChild.nodeValue = "log"; } else { el.firstChild.replaceWith(document.createElement("mi").html("log")); } } return Div({ margin: mfn.notation === "post" ? "0 0.1em" : void 8 }).html(el.firstChild); }; })(); mathDiv/createElements/element/combined/mfn/wrapper/operator/operator.ls (function(){ return function(o, el, mfn){ var ref$; if (el.attr("inverse") === "true" || ((ref$ = el.textContent) === "asin" || ref$ === "acos" || ref$ === "atan")) { return inc("inverse/inverse")(el); } else { return inc("normal/normal")(o, el, mfn); } }; })(); mathDiv/createElements/element/combined/mfn/wrapper/showOpenClose/show.ls (function(){ return function(o, div, mfn){ var update; update = function(){ var elements, firstEl, show, h; elements = div.mrow1.getElements(); firstEl = _.first(elements); show = mfn.notation === "post" ? firstEl != null && firstEl.hasClass("mfenced") ? false : elements.length === 1 && ((firstEl != null && firstEl.hasClass("mn")) || (firstEl != null && firstEl.hasClass("mi"))) ? false : elements.length === 0 ? false : true : firstEl != null && firstEl.hasClass("mfenced") ? false : elements.length > 0 ? true : false; if (show) { div.open.show(); div.close.show(); h = div.mrow1.offsetHeight; div.open.scale(h); div.close.scale(h); } else { div.open.hide(); div.close.hide(); } return o.adjustLayout(); }; div.onChildrenModified(update); return div.onDomAppendAndVisible(update); }; })(); mathDiv/createElements/element/combined/mfn/wrapper/wrapper.ls (function(){ return function(o, el, mfn){ var div; div = Div(); div.css({ display: "flex", minWidth: "1em" }).append(div.operator = inc("operator/operator")(o, el, mfn)); div.open = inc("../../_shared/bracket/bracket")(o, el, "(", div); div.mrow1 = inc("mrow1/mrow1")(o, el, mfn); div.close = inc("../../_shared/bracket/bracket")(o, el, ")", div); if (mfn.notation === "post") { div.operator.before(div.mrow1); } else { div.operator.after(div.mrow1); } if (mfn.operator === "logbase") { div.base = inc("base/base")(o, el); div.operator.after(div.base); } div.mrow1.before(div.open); div.mrow1.after(div.close); inc("getCenter/get")(o, div); inc("showOpenClose/show")(o, div, mfn); return div; }; })(); mathDiv/createElements/element/combined/mfrac/adjustSize/adjust.ls (function(){ return function(div){ div.addClass("adjustSize"); div.adjustSize = function(){ if (inc("calcIsSubFrac/calc")(div)) { return div.css({ fontSize: "0.9em" }); } else { return div.css({ fontSize: "" }); } }; return div.onDomAppend(div.adjustSize); }; })(); mathDiv/createElements/element/combined/mfrac/adjustSize/calcIsSubFrac/calc.ls (function(){ return function(div){ var isSubFrac, parent; isSubFrac = false; parent = div.parent(); while (parent) { if (parent.hasClass("mfrac")) { isSubFrac = true; break; } else if (parent.hasClass("mathDiv")) { break; } parent = parent != null ? typeof parent.parent == 'function' ? parent.parent() : void 8 : void 8; } return isSubFrac; }; })(); mathDiv/createElements/element/combined/mfrac/blinker/end/end.ls (function(){ return function(o, mfrac){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mfrac.after(newElement); }; div.left = function(){ return mfrac.wrapper.mrow2.startCursor("last"); }; div.back = function(){ return mfrac.startCursor(); }; div.right = function(){ return mfrac.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/mfrac/blinker/start/start.ls (function(){ return function(o, mfrac){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mfrac.before(newElement); }; div.left = function(){ return mfrac.previousSibling.startCursor("last").left(); }; div.back = function(){ return mfrac.previousSibling.startCursor("last").back(); }; div.right = function(){ return mfrac.wrapper.mrow1.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/mfrac/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/mfrac/getMathData/evalFrac/eval.ls (function(){ return function(o, mrow1MathData, mrow2MathData, scope){ return "(" + mrow1MathData.eval(scope) + "/" + mrow2MathData.eval(scope) + ")"; }; })(); mathDiv/createElements/element/combined/mfrac/getMathData/evalNcr/eval.ls (function(){ return function(o, mrow1MathData, mrow2MathData, scope){ var n, k, result, i$, i; n = mrow1MathData.eval(scope); k = mrow2MathData.eval(scope); if (n < 0 || k < 0) { return; } if (!_.isInteger(n) || !_.isInteger(k)) { return; } if (n < k) { return; } if (k === 0) { return 1; } result = 1; for (i$ = 1; i$ <= k; ++i$) { i = i$; result *= (n - k + i) / i; } return _.round(result); }; })(); mathDiv/createElements/element/combined/mfrac/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var mrow1MathData, mrow2MathData, operator, asciimath, ref$; mrow1MathData = div.wrapper.mrow1.getMathData(); mrow2MathData = div.wrapper.mrow2.getMathData(); operator = (typeof el.attr == 'function' ? el.attr("linethickness") : void 8) === "0" ? ";" : "/"; asciimath = ""; if (mrow1MathData.content.length > 1) { asciimath += "(" + mrow1MathData.asciimath + ")"; } else { asciimath += mrow1MathData.asciimath; } asciimath += operator; if (mrow2MathData.content.length > 1 || (mrow2MathData.content.length === 1 && !((ref$ = mrow2MathData.content[0].tagName) === "mi" || ref$ === "mn"))) { asciimath += "(" + mrow2MathData.asciimath + ")"; } else { asciimath += mrow2MathData.asciimath; } return { tagName: "mfrac", content: [mrow1MathData, mrow2MathData], asciimath: asciimath, eval: function(scope){ if (operator === "/") { return inc("evalFrac/eval")(o, mrow1MathData, mrow2MathData, scope); } else { return inc("evalNcr/eval")(o, mrow1MathData, mrow2MathData, scope); } } }; }; }; })(); mathDiv/createElements/element/combined/mfrac/mfrac.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("mfrac center").css({ display: "inline-flex", alignItems: "flex-start", padding: "0 0.15em" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el, div), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("setFeedbackColor/set")(div); inc("adjustSize/adjust")(div); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); inc("setLineColor/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/mfrac/setFeedbackColor/set.ls (function(){ return function(div){ div.addClass("feedbackColor"); return div.setFeedbackColor = function(c){ return div.wrapper.line.css({ borderColor: c }); }; }; })(); mathDiv/createElements/element/combined/mfrac/setLineColor/set.ls (function(){ var textColors, ref$; textColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.textColors : void 8; return function(div, el){ var tcolor, ref$; tcolor = (el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8) || (el != null ? typeof el.closest == 'function' ? (ref$ = el.closest("[tcolor]")) != null ? ref$.attr("tcolor") : void 8 : void 8 : void 8); if (tcolor) { return div.wrapper.line.css({ borderColor: textColors[tcolor] }); } }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.mrow1.offsetHeight + (4 + div.line.offsetHeight) / 2; }; }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/line/line.ls (function(){ return function(el){ var isNcr, div; isNcr = el.attr("linethickness") === "0"; return div = Div().addClass("mfracLine").css({ display: "flex", margin: "2px 0", borderTop: isNcr ? "" : "1.5px solid black" }); }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/mrow1/cursorOverwrite/cursor.ls (function(){ return function(o, mrow1){ mrow1.left = function(){ var mfrac; mfrac = mrow1.closest(".mfrac"); return mfrac.blinkerStart.startCursor(); }; mrow1.back = function(){ var mfrac, mrow2Elements; mfrac = mrow1.closest(".mfrac"); mrow2Elements = mfrac.wrapper.mrow2.getElements(); if (mrow2Elements.length === 0) { mfrac.previousSibling.startCursor("last"); mfrac.remove(); } else { mfrac.after(mrow2Elements); mfrac.remove(); _.last(mrow2Elements).startCursor("last"); } return o.adjustLayout(); }; mrow1.right = function(){ var mfrac; mfrac = mrow1.closest(".mfrac"); return mfrac.wrapper.mrow2.startCursor("first"); }; mrow1.blinkerStart.left = mrow1.left; return mrow1.blinkerEnd.right = mrow1.right; }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/mrow1/mrow1.ls (function(){ return function(o, el){ var el1, e, mrow1; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow1); return mrow1; }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/mrow2/cursorOverwrite/cursor.ls (function(){ return function(o, mrow2){ mrow2.left = function(){ var mfrac; mfrac = mrow2.closest(".mfrac"); return mfrac.wrapper.mrow1.startCursor("last"); }; mrow2.back = function(){ var mfrac, mrow1Elements; mfrac = mrow2.closest(".mfrac"); mrow1Elements = mfrac.wrapper.mrow1.getElements(); if (mrow1Elements.length === 0) { mfrac.previousSibling.startCursor("last"); return mfrac.remove(); } else { mfrac.after(mrow1Elements); mfrac.remove(); return _.last(mrow1Elements).startCursor("last"); } }; mrow2.right = function(){ var mfrac; mfrac = mrow2.closest(".mfrac"); return mfrac.blinkerEnd.startCursor(); }; mrow2.blinkerStart.left = mrow2.left; return mrow2.blinkerEnd.right = mrow2.right; }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/mrow2/mrow2.ls (function(){ return function(o, el){ var el2, e, mrow2; el2 = el != null ? el.lastChild : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow2 = e; } else { mrow2 = o.createElement("mrow"); mrow2.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow2); return mrow2; }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/showOpenClose/show.ls (function(){ return function(o, el, div, mfn){ var update; if (el.attr("linethickness") !== "0") { div.open.hide(); div.close.hide(); return; } update = function(){ var h; h = div.offsetHeight; div.open.scale(h); div.close.scale(h); return o.adjustLayout(); }; div.onChildrenModified(update); return update(); }; })(); mathDiv/createElements/element/combined/mfrac/wrapper/wrapper.ls (function(){ return function(o, el, mfrac){ var div; div = Div(); div.css({ display: "flex" }).append(Div({ display: "flex", minWidth: "1em", flexDirection: "column", alignItems: "stretch", fontSize: "0.9em" }).append(div.mrow1 = inc("mrow1/mrow1")(o, el), div.line = inc("line/line")(el), div.mrow2 = inc("mrow2/mrow2")(o, el))); inc("getCenter/get")(o, div); return div; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/calcMathChoices/calc.ls (function(){ return function(o, div){ var choices, i$, len$, c, sourceDiv, elements, res$, j$, ref$, len1$, el, mrow, results$ = []; choices = inc("calcChoices/calc")(div); for (i$ = 0, len$ = choices.length; i$ < len$; ++i$) { c = choices[i$]; sourceDiv = inc("/mathDiv/calcSourceDiv/calc")({ value: c.text })(); res$ = []; for (j$ = 0, len1$ = (ref$ = sourceDiv.childrenAll()).length; j$ < len1$; ++j$) { el = ref$[j$]; res$.push(o.createElement(el)); } elements = res$; mrow = o.createElement("mrow"); mrow.setElements(elements); results$.push({ correct: c.correct, text: c.text, cleanText: _.replaceAll(c.text, /[ `]+/g, ""), mathData: mrow.getMathData(), mrow: mrow }); } return results$; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/calcMathChoices/calcChoices/calc.ls (function(){ return function(div){ var v, parts, defaultCorrect, choices, p; v = div.attr("gap"); v = _.replaceAll(v, /\s+/g, " "); parts = v.split(" "); defaultCorrect = !_.includes(v, "++"); return choices = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = parts).length; i$ < len$; ++i$) { p = ref$[i$]; if (p.substring(0, 2) === "++") { results$.push({ text: p.substring(2), correct: true }); } else if (p.substring(0, 2) === "--") { results$.push({ text: p.substring(2), correct: false }); } else { results$.push({ text: p, correct: defaultCorrect }); } } return results$; }()); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/calcSolutions/calc.ls (function(){ return function(div){ return _.map(_.filter(div.mathChoices, "correct"), function(c){ return c.cleanText; }); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/checkCorrect/calcSolution/calc.ls (function(){ return function(o, div, value, valueNoSpaces){ var defaultSolution, allGaps, isCorrect, otherSolutions, res$, i$, ref$, len$, g, mathSolutions, solution; defaultSolution = _.find(div.mathChoices, "correct"); allGaps = div.closest(".gapComponent").findAll(".gap"); if (o.uniqueSolutions && _.filter(div.mathChoices, "correct").length > 1) { isCorrect = function(s, sClean, sols){ if (div.gapValidateMode === "value") { return o.checkEquivalence({ value: s, solutions: sols }); } else { return _.includes(sols, sClean); } }; res$ = []; for (i$ = 0, len$ = (ref$ = _.filter(allGaps, "value")).length; i$ < len$; ++i$) { g = ref$[i$]; if (g !== div && g.choices.length > 1) { res$.push(g.value); } } otherSolutions = res$; mathSolutions = _.filter(div.mathChoices, { correct: true }); solution = _.find(mathSolutions, function(s){ return !isCorrect(s.text, s.cleanText, otherSolutions) && _.includes(s.cleanText, valueNoSpaces); }) || _.find(mathSolutions, function(s){ return !isCorrect(s.text, s.cleanText, otherSolutions); }) || defaultSolution; if (isCorrect(solution.text, solution.cleanText, otherSolutions)) { debug("Achtung, die uniqueSolutions-Gap kann nicht gelöst werden, da alle Lösungen schon in anderen Gaps stehen."); } return solution; } return defaultSolution; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/checkCorrect/check.ls (function(){ return function(o, value, div){ var valueNoSpaces, mathSolutions, asciimathSolutions, isCorrect, result; valueNoSpaces = _.replaceAll(value, /\s+/g, ""); div.value = valueNoSpaces; mathSolutions = _.filter(div.mathChoices, { correct: true }); asciimathSolutions = _.map(mathSolutions, function(c){ return _.replaceAll(c.mathData.asciimath, /\s+/g, ""); }); if (o.uniqueSolutions && _.filter(div.mathChoices, "correct").length > 1 && inc("checkSolutionExists/check")(o, div, value, valueNoSpaces)) { isCorrect = false; } else if (div.gapValidateMode === "literal") { isCorrect = in$(valueNoSpaces, asciimathSolutions); } else if (div.gapValidateMode === "value") { if (_.some(asciimathSolutions, function(s){ return _.includes(s, "="); }) || _.includes(value, "=")) { debug("Achtung: gapValidateMode: value funktioniert nicht für Gleichungen"); isCorrect = false; } else { isCorrect = o.checkEquivalence({ value: value, solutions: asciimathSolutions }); } } result = { isCorrect: isCorrect }; if (!isCorrect) { result.solution = inc("calcSolution/calc")(o, div, value, valueNoSpaces); } return result; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/createElements/element/combined/mgap/gapExtras/_shared/checkCorrect/checkSolutionExists/check.ls (function(){ return function(o, div, value, valueNoSpaces){ var allGaps, otherSolutions, res$, i$, ref$, len$, g, cleanDivValue, solutionExists; allGaps = div.closest(".gapComponent").findAll(".gap"); res$ = []; for (i$ = 0, len$ = (ref$ = _.filter(allGaps, "value")).length; i$ < len$; ++i$) { g = ref$[i$]; if (g !== div && g.choices.length > 1) { res$.push(_.replaceAll(g.value, /[ `]+/g, "")); } } otherSolutions = res$; cleanDivValue = _.replaceAll(div.value, /[ `]+/g, ""); return solutionExists = div.gapValidateMode === "value" ? o.checkEquivalence({ value: value, solutions: otherSolutions }) : _.some(otherSolutions, function(sol){ return _.isEqual(sol, cleanDivValue); }); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/getValue/get.ls (function(){ return function(o, div){ return div.mrow.getMathData().asciimath; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/start/start.ls (function(){ return function(o, div){ var ref$, ref1$; div.mrow.startCursor("first"); o.currentGap = div; o.div.currentGap = div; if ((ref$ = app.currentPage.levelPlayer) != null) { ref$.currentGap = div; } if ((ref1$ = o.slide) != null) { ref1$.gapClickStartDisabled = false; } if (o.mode === "write") { o.screenKeyboard.start(); } else if (o.mode === "buttons") { o.screenKeyboard.stop(); o.keyManager.stop(); div.showButtons(); } return div.isStarted = true; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/_shared/stopGap/stop.ls (function(){ return function(o, div){ return function(){ var ref$; div.isStarted = false; if ((ref$ = o.buttonsDiv) != null) { ref$.hide(); } return o.stop(); }; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/buttons/buttons.ls (function(){ return function(o, div){ var ref$; o.shuffleButtons = (ref$ = o.shuffleButtons) != null ? ref$ : true; if (o.combineButtons) { debug("combineButtons not supported yet in math-div"); } if (o.removeCorrectButton) { debug("removeCorrectButton not supported yet in math-div"); } div.submit = function(button, choice){ return inc("submit/submit")(o, div, button, choice); }; return div.showButtons = function(){ return inc("showButtons/show")(o, div); }; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/buttons/showButtons/button/button.ls (function(){ return function(o, gap, mathChoice, i){ var value, click, div; value = mathChoice.text; click = function(){ return gap.submit(div, mathChoice); }; div = Button({ label: MathDiv({ value: value, enabled: false }) }).css({ margin: "0.5em" }).tap(click); div.value = value; return div; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/buttons/showButtons/show.ls (function(){ return function(o, gap){ var buttonsDiv, mathChoices, i, mathChoice; if (o.mode !== "buttons") { return; } if (gap.isStarted) { return; } buttonsDiv = o.buttonsDiv; buttonsDiv.css({ pointerEvents: "" }); mathChoices = gap.mathChoices; if (o.shuffleButtons) { mathChoices = _.shuffle(mathChoices); } buttonsDiv.empty().append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = mathChoices).length; i$ < len$; ++i$) { i = i$; mathChoice = ref$[i$]; results$.push(inc("button/button")(o, gap, mathChoice, i)); } return results$; }())); buttonsDiv.hide(); return buttonsDiv.fadeIn(); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/buttons/submit/onCorrect/finishGap/finish.ls (function(){ return function(o, div, value){ var ref$, nextGap; div.gapIsCompleted = true; div.value = value; if ((ref$ = app.currentPage.levelPlayer) != null) { ref$.currentGap = undefined; } o.buttonsDiv.hide(); nextGap = _.find(o.gaps, function(g){ return !g.gapIsCompleted; }); if (!nextGap) { return o.finish(); } else { app.currentPage.scrollElementIntoView(nextGap, { padding: 50 }); return o.start(); } }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/buttons/submit/onCorrect/onCorrect.ls (function(){ return function(o, div, value, button){ var action; div.isStarted = false; div.css({ pointerEvents: "none" }); o.adjustLayout(); button.setState("correct"); o.slide.levelPlayer.progressBar.showGreen(); o.setColor(Color.green[500], div); action = { gap: div.gapIndex, value: value }; return o.onActionCorrect(action, function(){ return setTimeout(function(){ return inc("finishGap/finish")(o, div, value); }, 500); }); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/buttons/submit/onWrong/onWrong.ls (function(){ return function(o, div, value, button){ var action; button.setState("wrong"); o.slide.levelPlayer.progressBar.addElement().showRed(); if (typeof o.onActionMistake == 'function') { o.onActionMistake(action = { gap: div.gapIndex, value: value, solution: div.solutions[0] }); } o.setColor(Color.red[500], div); return setTimeout(function(){ o.buttonsDiv.css({ pointerEvents: "" }); button.setState("normal"); div.mrow.setElements(); return div.start(); }, 500); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/buttons/submit/submit.ls (function(){ return function(o, div, button, mathChoice){ var value, ref$, result; value = mathChoice.mathData.asciimath; div.mrow.setElements(mathChoice.mrow); o.adjustLayout(); o.stop(); o.buttonsDiv.css({ pointerEvents: "none" }); if ((ref$ = o.slide) != null) { ref$.gapClickStartDisabled = true; } result = inc("../../_shared/checkCorrect/check")(o, value, div); if (result.isCorrect) { return inc("onCorrect/onCorrect")(o, div, value, button); } else { return inc("onWrong/onWrong")(o, div, value, button); } }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/gapExtras.ls (function(){ return function(o, div){ var ref$, ref1$; div.gapValidateMode = (ref$ = (ref1$ = o.gapAttributes[div.attr("index")]) != null ? ref1$.gapValidateMode : void 8) != null ? ref$ : o.gapValidateMode; div.gapIsCompleted = false; o.uniqueSolutions == null && (o.uniqueSolutions = false); div.start = function(){ return inc("_shared/start/start")(o, div); }; div.startGap = div.start; div.stopGap = inc("_shared/stopGap/stop")(o, div); div.getValue = function(){ return inc("_shared/getValue/get")(o, div); }; div.mathChoices = inc("_shared/calcMathChoices/calc")(o, div); div.choices = div.mathChoices; div.solutions = inc("_shared/calcSolutions/calc")(div); div.mode = o.mode; div.mrow.setElements(); if (o.mode === "write") { return inc("write/write")(o, div); } else if (o.mode === "buttons") { return inc("buttons/buttons")(o, div); } }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/showWrongFeedback/diagonalLine/line.ls (function(){ return function(div){ var svg, container; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; return container = svg("svg").css({ position: "absolute", left: 0, top: 0, width: div.offsetWidth + "px", height: div.offsetHeight + "px" }).append(svg("line").attr({ x1: 0, y1: div.offsetHeight, x2: div.offsetWidth, y2: 0, "stroke-width": "1px", stroke: Color.red[500] })); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/showWrongFeedback/show.ls (function(){ return function(o, div, solution){ var currentElements, wrongMrow, solutionMrow, i$, ref$, len$, el; currentElements = div.mrow.getElements(); wrongMrow = o.createElement("mrow"); wrongMrow.setElements(currentElements); wrongMrow.css({ marginRight: "0.2em" }); solutionMrow = solution.mrow; solutionMrow.css({ color: Color.grey[550] }); for (i$ = 0, len$ = (ref$ = solutionMrow.findAll(".feedbackColor")).length; i$ < len$; ++i$) { el = ref$[i$]; el.setFeedbackColor(Color.grey[550]); } div.mrow.setElements([wrongMrow, solutionMrow]); return requestAnimationFrame(function(){ wrongMrow.append(inc("diagonalLine/line")(wrongMrow)); return o.adjustLayout(); }); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/submit/onCorrect/on.ls (function(){ return function(o, div, value, onSubmitted){ var action; div.css({ pointerEvents: "none" }); o.adjustLayout(); o.slide.levelPlayer.progressBar.showGreen(); o.setColor(Color.green[500], div); action = { gap: div.gapIndex, value: value }; return o.onActionCorrect(action, onSubmitted); }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/submit/onSubmitted/on.ls (function(){ return function(o, cancelCallback){ return function(){ var ref$, nextGap; if ((ref$ = app.currentPage.levelPlayer) != null) { ref$.currentGap = undefined; } nextGap = _.find(o.gaps, function(g){ return !g.gapIsCompleted; }); if (!nextGap) { return o.finish(cancelCallback); } else if (cancelCallback) { return cancelCallback(); } else { app.currentPage.scrollElementIntoView(nextGap, { padding: 50 }); return o.start(); } }; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/submit/onWrong/highlightEmptyMrows/highlight.ls (function(){ return function(div, c){ var border, i$, ref$, len$, mrow, results$ = []; border = !c ? "" : "1px solid " + c; for (i$ = 0, len$ = (ref$ = div.findAll(".mrow")).length; i$ < len$; ++i$) { mrow = ref$[i$]; if (mrow.blinkerEnd.previousSibling === mrow.blinkerStart) { results$.push(mrow.css({ border: border })); } } return results$; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/submit/onWrong/on.ls (function(){ return function(o, result, div, value, onSubmitted){ var solution, action; solution = result.solution; o.setColor(Color.red[500], div); inc("highlightEmptyMrows/highlight")(div, Color.red[500]); inc("topError/topError")(o, div, solution, onSubmitted); o.slide.levelPlayer.progressBar.addElement().showRed(); action = { gap: div.gapIndex, value: value, solution: solution.text }; if (typeof o.onActionMistake == 'function') { o.onActionMistake(action); } return div.value = solution.cleanText; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/submit/onWrong/topError/topError.ls (function(){ return function(o, gap, solution, onSubmitted){ var callback, isDone, solve, onSolveDone, retry, content, div; callback = function(){ o.slide.div.css({ pointerEvents: "" }); o.enable(); return onSubmitted(); }; isDone = false; solve = function(){ isDone = true; gap.showWrongFeedback(solution); o.slide.levelPlayer.progressBar.showGrey(); if (typeof o.onActionResolved == 'function') { o.onActionResolved({ gap: gap.gapIndex, solution: solution.text }); } gap.css({ pointerEvents: "none" }); o.slide.div.css({ pointerEvents: "none" }); o.disable(); return setTimeout(onSolveDone, 500); }; onSolveDone = function(){ var gaps, nextGap; gaps = o.slide.div.findAll(".gap"); nextGap = _.find(gaps, { gapIsCompleted: false }); if (!nextGap && !o.slide.finishButton) { o.slide.finishButton = true; } return callback(); }; retry = function(){ var ref$; if ((ref$ = o.slide) != null) { ref$.gapClickStartDisabled = false; } isDone = true; gap.css({ pointerEvents: "" }); gap.isStarted = true; gap.gapIsCompleted = false; gap.selectAll(); gap.start(); o.setColor(Color.black, gap); return inc("../highlightEmptyMrows/highlight")(gap); }; content = Div({ padding: "0.3em", textAlign: "center" }).html(Div().html(T("oopsWrong")), Div({ margin: "0.7em 0 0.4em" }).html(Button({ label: T("tryAgain"), icon: path("/../app01/lib/svg/icon/refresh.svg") }).tap(function(){ return div.close("retry"); }).css({ marginRight: "0.8em" }), Button({ label: T("solve"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).tap(function(){ return div.close("solve"); }))); div = inc("/../app01-trainers/shared/topMessage/topMessage")({ html: content, onClose: function(type){ if (type === "solve") { return solve(); } else { return retry(); } } }).addClass("hint").addClass("gapWriteMistakeHint"); div.isDone = function(){ return isDone; }; div.solveAndContinue = solve; div.retryAndContinue = retry; return div; }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/submit/submit.ls (function(){ return function(o, div, cancelCallback){ var value, onSubmitted, ref$, result; value = div.getMathData().asciimath; if (value === "") { return; } onSubmitted = inc("onSubmitted/on")(o, cancelCallback); o.stop(); div.isStarted = false; div.gapIsCompleted = true; if ((ref$ = o.slide) != null) { ref$.gapClickStartDisabled = true; } result = inc("../../_shared/checkCorrect/check")(o, value, div); if (result.isCorrect) { return inc("onCorrect/on")(o, div, value, onSubmitted); } else { return inc("onWrong/on")(o, result, div, value, onSubmitted); } }; })(); mathDiv/createElements/element/combined/mgap/gapExtras/write/write.ls (function(){ return function(o, div){ div.submit = function(cancelCallback){ return inc("submit/submit")(o, div, cancelCallback); }; return div.showWrongFeedback = function(solution){ return inc("showWrongFeedback/show")(o, div, solution); }; }; })(); mathDiv/createElements/element/combined/mgap/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.mrow.getCenter(); }; }; })(); mathDiv/createElements/element/combined/mgap/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var mrowMathData; mrowMathData = div.mrow.getMathData(); return { tagName: "mgap", content: mrowMathData, asciimath: mrowMathData.asciimath, eval: function(scope){ debug("gap eval"); return mrowMathData.eval(scope); } }; }; }; })(); mathDiv/createElements/element/combined/mgap/mgap.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("mgap gap center").css({ display: "inline-flex", alignItems: "flex-start", padding: "0em 2px", backgroundColor: Color.grey[100] }).append(div.mrow = inc("mrow/mrow")(o, el)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../../_shared/setAttrStyle/set")(div, el); inc("setGapAttributes/set")(div, el); div.selection = inc("selection/selection")(o, div); div.selectAll = inc("selectAll/selectAll")(div); inc("gapExtras/gapExtras")(o, div); return div; }; })(); mathDiv/createElements/element/combined/mgap/mrow/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){}; mrow.back = function(){}; mrow.right = function(){}; mrow.blinkerStart.left = mrow.left; mrow.blinkerStart.back = mrow.back; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/mgap/mrow/mrow.ls (function(){ return function(o, el){ var el1, e, mrow; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); mrow.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow); mrow.disableShowGreyIfEmpty = true; return mrow; }; })(); mathDiv/createElements/element/combined/mgap/selectAll/selectAll.ls (function(){ return function(div){ return function(){ return div.selection.selectAll(); }; }; })(); mathDiv/createElements/element/combined/mgap/selection/selection.ls (function(){ return function(o, div){ var selectedChars; selectedChars = function(){ return div.find(".select"); }; return { chars: selectedChars, unselect: function(){ var i$, ref$, len$, char, results$ = []; for (i$ = 0, len$ = (ref$ = selectedChars()).length; i$ < len$; ++i$) { char = ref$[i$]; results$.push(char.unselect()); } return results$; }, 'delete': function(){ var i$, ref$, len$, char; for (i$ = 0, len$ = (ref$ = selectedChars()).length; i$ < len$; ++i$) { char = ref$[i$]; char.remove(); } return o.adjustLayout(); }, selectAll: function(){ var i$, ref$, len$, char, results$ = []; for (i$ = 0, len$ = (ref$ = div.find(".mathElement")).length; i$ < len$; ++i$) { char = ref$[i$]; results$.push(typeof char.select == 'function' ? char.select() : void 8); } return results$; } }; }; })(); mathDiv/createElements/element/combined/mgap/setGapAttributes/set.ls (function(){ return function(div, el){ var i$, ref$, len$, a, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = el.attributes).length; i$ < len$; ++i$) { a = ref$[i$]; results$.push(div.attr((ref1$ = {}, ref1$[a.name + ""] = a.value, ref1$))); } return results$; }; })(); mathDiv/createElements/element/combined/mover/blinker/end/end.ls (function(){ return function(o, mover){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mover.after(newElement); }; div.left = function(){ return mover.wrapper.mrow1.startCursor("last"); }; div.back = function(){ return mover.startCursor(); }; div.right = function(){ return mover.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/mover/blinker/start/start.ls (function(){ return function(o, mover){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mover.before(newElement); }; div.left = function(){ return mover.previousSibling.startCursor("last").left(); }; div.back = function(){ return mover.previousSibling.startCursor("last").back(); }; div.right = function(){ return mover.wrapper.mrow1.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/mover/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/mover/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var w, mrow1MathData, asciimath; w = div.wrapper; mrow1MathData = w.mrow1.getMathData(); asciimath = div.overType; if (mrow1MathData.content.length > 1) { asciimath += "(" + mrow1MathData.asciimath + ")"; } else { asciimath += mrow1MathData.asciimath; } return { tagName: "mover", content: [mrow1MathData, div.overType], asciimath: asciimath, eval: function(){ var ref$; if ((ref$ = div.overType) === "larrow" || ref$ === "rarrow" || ref$ === "lrarrow") { return debug("gVM: \"value\" not supported with arrows"); } } }; }; }; })(); mathDiv/createElements/element/combined/mover/mover.ls (function(){ return function(o, el){ var div, overType, ref$; div = Div(); overType = el != null ? (ref$ = el.lastChild) != null ? ref$.textContent : void 8 : void 8; if (overType === "‾") { div.overType = "bar"; } else if (overType === "→") { div.overType = "rarrow"; } else if (overType === "↔") { div.overType = "lrarrow"; } else if (overType === "←") { div.overType = "larrow"; } else { debug("unknown over type"); } div.addClass("mathElement").addClass("mover center").css({ display: "inline-flex", alignItems: "flex-start" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el, div), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("setFeedbackColor/set")(div); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); inc("setLineColor/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/mover/setFeedbackColor/set.ls (function(){ return function(div){ div.addClass("feedbackColor"); return div.setFeedbackColor = function(c){ return div.wrapper.over.setColor(c); }; }; })(); mathDiv/createElements/element/combined/mover/setLineColor/set.ls (function(){ var textColors, ref$; textColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.textColors : void 8; return function(div, el){ var tcolor, ref$; tcolor = (el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8) || (el != null ? typeof el.closest == 'function' ? (ref$ = el.closest("[tcolor]")) != null ? ref$.attr("tcolor") : void 8 : void 8 : void 8); if (tcolor) { return div.wrapper.over.setColor(textColors[tcolor]); } }; })(); mathDiv/createElements/element/combined/mover/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ var ref$; if ((ref$ = div.overType) === "larrow" || ref$ === "rarrow" || ref$ === "lrarrow") { return div.mrow1.getCenter() + 3; } else { return div.mrow1.getCenter(); } }; }; })(); mathDiv/createElements/element/combined/mover/wrapper/mrow1/cursorOverwrite/cursor.ls (function(){ return function(o, mrow1){ mrow1.left = function(){ var mover; mover = mrow1.closest(".mover"); return mover.blinkerStart.startCursor(); }; mrow1.back = function(){ var mover, prev; mover = mrow1.closest(".mover"); prev = mover.previousSibling; mover.remove(); return prev.startCursor("last"); }; mrow1.right = function(){ var mover; mover = mrow1.closest(".mover"); return mover.blinkerEnd.startCursor(); }; mrow1.blinkerStart.left = mrow1.left; return mrow1.blinkerEnd.right = mrow1.right; }; })(); mathDiv/createElements/element/combined/mover/wrapper/mrow1/mrow1.ls (function(){ return function(o, el){ var el1, e, mrow1; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow1); return mrow1; }; })(); mathDiv/createElements/element/combined/mover/wrapper/over/arrow/arrow.ls (function(){ return function(div){ var getUpdateFunction, svg, setColor, wrapper, path, update; getUpdateFunction = function(overType){ var calcPath; calcPath = (function(){ switch (overType) { case "rarrow": return function(width){ return "M2,0 L" + (width - 3) + ",0 M" + (width - 5) + ",-3 L" + (width - 2) + ",0 L" + (width - 5) + ",3"; }; case "larrow": return function(width){ return "M5,-3 L2,0 L5,3 M2,0 L" + (width - 3) + ",0"; }; case "lrarrow": return function(width){ return "M5,-3 L2,0 L5,3 M2,0 L" + (width - 3) + ",0 M" + (width - 5) + ",-3 L" + (width - 2) + ",0 L" + (width - 5) + ",3"; }; } }()); return function(){ return path.attr("d", calcPath(div.width())); }; }; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; setColor = function(color){ return path.attr("stroke", color); }; wrapper = svg("svg").css({ pointerEvents: "none", position: "absolute", overflow: "visible", top: 4, left: 0, width: "100%", height: "100%", zIndex: 2 }); path = svg("path"); path.attr("stroke", "black"); path.attr("stroke-width", 1.5); path.attr("fill-opacity", 0); wrapper.append(path); update = getUpdateFunction(div.overType); div.onChildrenModified(update); div.onDomAppendAndVisible(update); wrapper.setColor = setColor; return wrapper; }; })(); mathDiv/createElements/element/combined/mover/wrapper/over/bar/bar.ls (function(){ return function(){ var setColor, div, bar; setColor = function(color){ return bar.css({ borderColor: color }); }; div = Div({ pointerEvents: "none", height: 0, zIndex: 2 }).append(bar = Div({ position: "absolute", top: "1px", left: "0.1em", right: "0.1em", height: "2px", borderTop: "1px solid black" })); div.setColor = setColor; return div; }; })(); mathDiv/createElements/element/combined/mover/wrapper/over/over.ls (function(){ return function(div, o, el){ var ref$; el.lastChild.remove(); if (div.overType === "bar") { return inc("bar/bar")(); } else if ((ref$ = div.overType) === "larrow" || ref$ === "rarrow" || ref$ === "lrarrow") { return inc("arrow/arrow")(div); } }; })(); mathDiv/createElements/element/combined/mover/wrapper/wrapper.ls (function(){ return function(o, el, parent){ var div, ref$; div = Div(); div.overType = parent.overType; div.css({ display: "flex", flexDirection: "column", alignItems: "stretch" }).css((ref$ = div.overType) === "larrow" || ref$ === "lrarrow" || ref$ === "rarrow" ? { paddingTop: "3px" } : void 8).append(div.over = inc("over/over")(div, o, el), div.mrow1 = inc("mrow1/mrow1")(o, el)); inc("getCenter/get")(o, div); return div; }; })(); mathDiv/createElements/element/combined/mroot/blinker/end/end.ls (function(){ return function(o, mroot){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mroot.after(newElement); }; div.left = function(){ return mroot.mrow.startCursor("last"); }; div.back = function(){ return mroot.startCursor(); }; div.right = function(){ return mroot.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/mroot/blinker/start/start.ls (function(){ return function(o, mroot){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mroot.before(newElement); }; div.left = function(){ return mroot.previousSibling.startCursor("last").left(); }; div.back = function(){ return mroot.previousSibling.startCursor("last").back(); }; div.right = function(){ return mroot.exp.mrow.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/mroot/exp/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var mroot; mroot = mrow.closest(".mroot"); return mroot.blinkerStart.startCursor(); }; mrow.back = function(){ var mroot, prev; mroot = mrow.closest(".mroot"); prev = mroot.previousSibling; mroot.remove(); return prev.startCursor("last"); }; mrow.right = function(){ var mroot; mroot = mrow.closest(".mroot"); return mroot.mrow.startCursor("first"); }; mrow.blinkerStart.left = mrow.left; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/mroot/exp/exp.ls (function(){ return function(o, el){ var el1, e, mrow, div; el1 = el != null ? typeof el.childrenAll == 'function' ? el.childrenAll()[1] : void 8 : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); mrow.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow); div = Div({ fontSize: "0.7em", marginTop: "-0.2em", alignSelf: "flex-start" }).append(mrow); div.mrow = mrow; return div; }; })(); mathDiv/createElements/element/combined/mroot/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ requestAnimationFrame(function(){ return div.icon.draw(); }); return div.mrow.getCenter() + 3; }; }; })(); mathDiv/createElements/element/combined/mroot/getMathData/customPow/customPow.ls (function(){ return function(base, exp){ var customPow; customPow = function(base, exp){ if (base < 0) { if (Math.abs(exp) < 1) { if (1 / exp % 2 === 0) { return NaN; } return -Math.pow(Math.abs(base), exp); } } return Math.pow(base, exp); }; return customPow(base, exp); }; })(); mathDiv/createElements/element/combined/mroot/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var mrowMathData, expMathData; mrowMathData = div.mrow.getMathData(); expMathData = div.exp.mrow.getMathData(); return { tagName: "mroot", content: [mrowMathData, expMathData], asciimath: "root(" + expMathData.asciimath + ")(" + mrowMathData.asciimath + ")", eval: function(scope){ return inc("customPow/customPow")(mrowMathData.eval(scope), 1 / expMathData.eval(scope)); } }; }; }; })(); mathDiv/createElements/element/combined/mroot/icon/draw/draw.ls (function(){ var textColors, ref$; textColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.textColors : void 8; return function(div, div2, el){ var w, h, w1, w2, w3, h2, h1, tcolor; w = div.offsetWidth; h = div.offsetHeight; if (div2.lastHeight === h) { return; } div2.lastHeight = h; w1 = w * 0.2; w2 = w * 0.5; w3 = w - 2; h2 = h * 0.48; h1 = h2; tcolor = textColors[el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8]; return div2.html("\n \n"); }; })(); mathDiv/createElements/element/combined/mroot/icon/icon.ls (function(){ return function(o, el){ var draw, div, div2; draw = function(){ return inc("draw/draw")(div, div2, el); }; div = Div({ alignSelf: "stretch" }).append("   ", div2 = Div({ position: "absolute", left: 0, top: "-2px", right: 0, bottom: 0 })); div.draw = draw; return div; }; })(); mathDiv/createElements/element/combined/mroot/mroot.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("mroot center").css({ display: "inline-flex", alignItems: "flex-start", paddingTop: "3px" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.exp = inc("exp/exp")(o, el), div.icon = inc("icon/icon")(o, el), div.mrow = inc("mrow/mrow")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("setFeedbackColor/set")(div); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); inc("setLineColor/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/mroot/mrow/borderTop/border.ls (function(){ return function(){ return Div({ position: "absolute", top: "-2px", left: "-2px", right: 0, height: "0.08em", backgroundColor: Color.black }); }; })(); mathDiv/createElements/element/combined/mroot/mrow/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var mroot; mroot = mrow.closest(".mroot"); return mroot.exp.mrow.startCursor("last"); }; mrow.back = function(){ var mroot, prev; mroot = mrow.closest(".mroot"); prev = mroot.previousSibling; mroot.remove(); return prev.startCursor("last"); }; mrow.right = function(){ var mroot; mroot = mrow.closest(".mroot"); return mroot.blinkerEnd.startCursor(); }; mrow.blinkerStart.left = mrow.left; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/mroot/mrow/mrow.ls (function(){ return function(o, el){ var el1, e, mrow, borderTop; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); mrow.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow); mrow.append(borderTop = inc("borderTop/border")()); mrow.borderTop = borderTop; return mrow; }; })(); mathDiv/createElements/element/combined/mroot/setFeedbackColor/set.ls (function(){ return function(div){ div.addClass("feedbackColor"); return div.setFeedbackColor = function(c){ return requestAnimationFrame(function(){ var ref$, ref1$; if ((ref$ = div.icon.findFirst("path")) != null) { ref$.attr({ stroke: c }); } return (ref1$ = div.mrow.borderTop) != null ? ref1$.css({ backgroundColor: c }) : void 8; }); }; }; })(); mathDiv/createElements/element/combined/mroot/setLineColor/set.ls (function(){ var textColors, ref$; textColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.textColors : void 8; return function(div, el){ var tcolor, ref$, c, ref1$; tcolor = (el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8) || (el != null ? typeof el.closest == 'function' ? (ref$ = el.closest("[tcolor]")) != null ? ref$.attr("tcolor") : void 8 : void 8 : void 8); if (tcolor) { c = textColors[tcolor]; return (ref1$ = div.mrow.borderTop) != null ? ref1$.css({ backgroundColor: c }) : void 8; } }; })(); mathDiv/createElements/element/combined/msqrt/blinker/end/end.ls (function(){ return function(o, msqrt){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msqrt.after(newElement); }; div.left = function(){ return msqrt.mrow.startCursor("last"); }; div.back = function(){ return msqrt.startCursor(); }; div.right = function(){ return msqrt.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/msqrt/blinker/start/start.ls (function(){ return function(o, msqrt){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msqrt.before(newElement); }; div.left = function(){ return msqrt.previousSibling.startCursor("last").left(); }; div.back = function(){ return msqrt.previousSibling.startCursor("last").back(); }; div.right = function(){ return msqrt.mrow.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/msqrt/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ requestAnimationFrame(function(){ return div.icon.draw(); }); return div.mrow.getCenter() + 3; }; }; })(); mathDiv/createElements/element/combined/msqrt/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var d; d = div.mrow.getMathData(); return { tagName: "msqrt", content: d, asciimath: "sqrt(" + d.asciimath + ")", eval: function(scope){ return Math.sqrt(d.eval(scope)); } }; }; }; })(); mathDiv/createElements/element/combined/msqrt/icon/draw/draw.ls (function(){ var textColors, ref$; textColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.textColors : void 8; return function(div, div2, el){ var w, h, w1, w2, w3, h2, h1, tcolor; w = div.offsetWidth; h = div.offsetHeight; if (div2.lastHeight === h) { return; } div2.lastHeight = h; w1 = w * 0.2; w2 = w * 0.5; w3 = w - 2; h2 = h * 0.48; h1 = h2; tcolor = textColors[el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8]; return div2.html("\n \n"); }; })(); mathDiv/createElements/element/combined/msqrt/icon/icon.ls (function(){ return function(o, el){ var draw, div, div2; draw = function(){ return inc("draw/draw")(div, div2, el); }; div = Div({ alignSelf: "stretch" }).append("   ", div2 = Div({ position: "absolute", left: 0, top: "-2px", right: 0, bottom: 0 })); div.draw = draw; return div; }; })(); mathDiv/createElements/element/combined/msqrt/mrow/borderTop/border.ls (function(){ return function(){ return Div({ position: "absolute", top: "-2px", left: "-2px", right: 0, height: "0.08em", backgroundColor: Color.black }); }; })(); mathDiv/createElements/element/combined/msqrt/mrow/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var msqrt; msqrt = mrow.closest(".msqrt"); return msqrt.blinkerStart.startCursor(); }; mrow.back = function(){ var msqrt, prev; msqrt = mrow.closest(".msqrt"); prev = msqrt.previousSibling; msqrt.remove(); return prev.startCursor("last"); }; mrow.right = function(){ var msqrt; msqrt = mrow.closest(".msqrt"); return msqrt.blinkerEnd.startCursor(); }; mrow.blinkerStart.left = mrow.left; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/msqrt/mrow/mrow.ls (function(){ return function(o, el){ var el1, e, mrow, borderTop; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); mrow.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow); mrow.append(borderTop = inc("borderTop/border")()); mrow.borderTop = borderTop; return mrow; }; })(); mathDiv/createElements/element/combined/msqrt/msqrt.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("msqrt center").css({ display: "inline-flex", alignItems: "flex-start", paddingTop: "3px" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.icon = inc("icon/icon")(o, el), div.mrow = inc("mrow/mrow")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("setFeedbackColor/set")(div); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); inc("setLineColor/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/msqrt/setFeedbackColor/set.ls (function(){ return function(div){ div.addClass("feedbackColor"); return div.setFeedbackColor = function(c){ return requestAnimationFrame(function(){ var ref$, ref1$; if ((ref$ = div.icon.findFirst("path")) != null) { ref$.attr({ stroke: c }); } return (ref1$ = div.mrow.borderTop) != null ? ref1$.css({ backgroundColor: c }) : void 8; }); }; }; })(); mathDiv/createElements/element/combined/msqrt/setLineColor/set.ls (function(){ var textColors, ref$; textColors = (ref$ = document.head.findFirst('#cssColorTags')) != null ? ref$.textColors : void 8; return function(div, el){ var tcolor, ref$, c, ref1$; tcolor = (el != null ? typeof el.attr == 'function' ? el.attr("tcolor") : void 8 : void 8) || (el != null ? typeof el.closest == 'function' ? (ref$ = el.closest("[tcolor]")) != null ? ref$.attr("tcolor") : void 8 : void 8 : void 8); if (tcolor) { c = textColors[tcolor]; return (ref1$ = div.mrow.borderTop) != null ? ref1$.css({ backgroundColor: c }) : void 8; } }; })(); mathDiv/createElements/element/combined/msub/blinker/end/end.ls (function(){ return function(o, msub){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msub.after(newElement); }; div.left = function(){ return msub.wrapper.mrow2.startCursor("last"); }; div.back = function(){ return msub.startCursor(); }; div.right = function(){ return msub.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/msub/blinker/start/start.ls (function(){ return function(o, msub){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msub.before(newElement); }; div.left = function(){ return msub.previousSibling.startCursor("last").left(); }; div.back = function(){ return msub.previousSibling.startCursor("last").back(); }; div.right = function(){ return msub.wrapper.mrow1.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/msub/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/msub/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var d1, d2, asciimath; d1 = div.wrapper.mrow1.getMathData(); d2 = div.wrapper.mrow2.getMathData(); asciimath = ""; if (d1.content.length > 1) { asciimath += "(" + d1.asciimath + ")"; } else { asciimath += d1.asciimath; } asciimath += "_"; if (d2.content.length > 1) { asciimath += "(" + d2.asciimath + ")"; } else { asciimath += d2.asciimath; } return { tagName: "msub", content: [d1, d2], asciimath: asciimath, eval: function(scope){ return "(" + d1.eval(scope) + "+" + d2.eval(scope) + ")"; } }; }; }; })(); mathDiv/createElements/element/combined/msub/msub.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("msub center").css({ display: "inline-flex", alignItems: "flex-start" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/msub/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.offsetHeight - div.mrow1.offsetHeight + div.mrow1.getCenter(); }; }; })(); mathDiv/createElements/element/combined/msub/wrapper/mrow1/cursorOverwrite/cursor.ls (function(){ return function(o, mrow1){ mrow1.left = function(){ var msub; msub = mrow1.closest(".msub"); return msub.blinkerStart.startCursor().left(); }; mrow1.back = function(){ var msub, mrow2Elements; msub = mrow1.closest(".msub"); mrow2Elements = msub.wrapper.mrow2.getElements(); if (mrow2Elements.length === 0) { msub.previousSibling.startCursor("last"); return msub.remove(); } else { msub.after(mrow2Elements); msub.remove(); return _.last(mrow2Elements).startCursor("last"); } }; mrow1.right = function(){ var msub; msub = mrow1.closest(".msub"); return msub.wrapper.mrow2.startCursor("first"); }; mrow1.blinkerStart.left = mrow1.left; return mrow1.blinkerEnd.right = mrow1.right; }; })(); mathDiv/createElements/element/combined/msub/wrapper/mrow1/mrow1.ls (function(){ return function(o, el){ var el1, e, mrow1; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow1); return mrow1; }; })(); mathDiv/createElements/element/combined/msub/wrapper/mrow2/cursorOverwrite/cursor.ls (function(){ return function(o, mrow2){ mrow2.left = function(){ var msub; msub = mrow2.closest(".msub"); return msub.wrapper.mrow1.startCursor("last"); }; mrow2.back = function(){ var msub, mrow1Elements; msub = mrow2.closest(".msub"); mrow1Elements = msub.wrapper.mrow1.getElements(); if (mrow1Elements.length === 0) { msub.previousSibling.startCursor("last"); return msub.remove(); } else { msub.after(mrow1Elements); msub.remove(); return _.last(mrow1Elements).startCursor("last"); } }; mrow2.right = function(){ var msub; msub = mrow2.closest(".msub"); return msub.blinkerEnd.startCursor(); }; mrow2.blinkerStart.left = mrow2.left; return mrow2.blinkerEnd.right = mrow2.right; }; })(); mathDiv/createElements/element/combined/msub/wrapper/mrow2/mrow2.ls (function(){ return function(o, el){ var el2, e, mrow2; el2 = el != null ? el.lastChild : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow2 = e; } else { mrow2 = o.createElement("mrow"); mrow2.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow2); return mrow2; }; })(); mathDiv/createElements/element/combined/msub/wrapper/showOpenClose/show.ls (function(){ return function(o, div){ var update; update = function(){ var mrow1Elements, show, ref$, h; mrow1Elements = div.mrow1.getElements(); show = (ref$ = _.first(mrow1Elements)) != null && ref$.hasClass("mfrac") ? true : mrow1Elements.length > 1 ? true : false; if (show) { div.open.show(); div.close.show(); h = div.mrow1.offsetHeight; div.open.scale(h); return div.close.scale(h); } else { div.open.hide(); return div.close.hide(); } }; div.onChildrenModified(update); return update(); }; })(); mathDiv/createElements/element/combined/msub/wrapper/wrapper.ls (function(){ return function(o, el){ var div; div = Div(); div.css({ display: "flex" }).append(Div({ alignSelf: "flex-end" }).append(Div().addClass("center").css({ display: "flex", alignItems: "flex-start" }).append(div.open = inc("../../_shared/bracket/bracket")(o, el, "(", div), div.mrow1 = inc("mrow1/mrow1")(o, el), div.close = inc("../../_shared/bracket/bracket")(o, el, ")", div))), Div({ fontSize: "0.7em", marginTop: "0.6em", alignSelf: "flex-end", marginLeft: "-4px" }).append(div.mrow2 = inc("mrow2/mrow2")(o, el))); inc("getCenter/get")(o, div); inc("showOpenClose/show")(o, div); return div; }; })(); mathDiv/createElements/element/combined/msubsup/blinker/end/end.ls (function(){ return function(o, msubsup){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msubsup.after(newElement); }; div.left = function(){ return msubsup.wrapper.mrowSup.startCursor("last"); }; div.back = function(){ return msubsup.startCursor(); }; div.right = function(){ return msubsup.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/msubsup/blinker/start/start.ls (function(){ return function(o, msubsup){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msubsup.before(newElement); }; div.left = function(){ return msubsup.previousSibling.startCursor("last").left(); }; div.back = function(){ return msubsup.previousSibling.startCursor("last").back(); }; div.right = function(){ return msubsup.wrapper.mrow1.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/msubsup/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/msubsup/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var asciimath, mrow1MathData, mrowSubMathData, mrowSupMathData; asciimath = ""; mrow1MathData = div.wrapper.mrow1.getMathData(); asciimath += "(" + mrow1MathData.asciimath; asciimath += "+"; mrowSubMathData = div.wrapper.mrowSub.getMathData(); asciimath += mrowSubMathData.asciimath + ")"; mrowSupMathData = div.wrapper.mrowSup.getMathData(); asciimath += "^"; asciimath += "(" + mrowSupMathData.asciimath + ")"; return { tagName: "msubsup", content: [mrow1MathData, mrowSubMathData, mrowSupMathData], asciimath: asciimath, eval: function(scope){ return Math.pow(mrow1MathData.eval(scope) + mrowSubMathData.eval(scope), mrowSupMathData.eval(scope)); } }; }; }; })(); mathDiv/createElements/element/combined/msubsup/msubsup.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("msubsup center").css({ display: "inline-flex", alignItems: "flex-start" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.offsetHeight / 2; }; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/mrow1/cursorOverwrite/cursor.ls (function(){ return function(o, mrow1){ mrow1.left = function(){ var msubsup; msubsup = mrow1.closest(".msubsup"); return msubsup.blinkerStart.startCursor().left(); }; mrow1.back = function(){ var msubsup, mrow2Elements; msubsup = mrow1.closest(".msubsup"); mrow2Elements = msubsup.wrapper.mrow2.getElements(); if (mrow2Elements.length === 0) { msubsup.previousSibling.startCursor("last"); return msubsup.remove(); } else { msubsup.after(mrow2Elements); msubsup.remove(); return _.last(mrow2Elements).startCursor("last"); } }; mrow1.right = function(){ var msubsup; msubsup = mrow1.closest(".msubsup"); return msubsup.wrapper.mrowSup.startCursor("first"); }; mrow1.blinkerStart.left = mrow1.left; return mrow1.blinkerEnd.right = mrow1.right; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/mrow1/mrow1.ls (function(){ return function(o, el){ var el1, e, mrow1; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow1); return mrow1; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/mrowSub/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var msubsup; msubsup = mrow.closest(".msubsup"); return msubsup.wrapper.mrow1.startCursor("last"); }; mrow.back = function(){ var msubsup, mrow1Elements; msubsup = mrow.closest(".msubsup"); mrow1Elements = msubsup.wrapper.mrow1.getElements(); if (mrow1Elements.length === 0) { msubsup.previousSibling.startCursor("last"); return msubsup.remove(); } else { msubsup.after(mrow1Elements); msubsup.remove(); return _.last(mrow1Elements).startCursor("last"); } }; mrow.right = function(){ var msubsup; msubsup = mrow.closest(".msubsup"); return msubsup.blinkerEnd.startCursor(); }; mrow.blinkerStart.left = mrow.left; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/mrowSub/mrowSub.ls (function(){ return function(o, el){ var el2, e, mrow2; el2 = el != null ? el.childrenAll()[1] : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow2 = e; } else { mrow2 = o.createElement("mrow"); mrow2.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow2); return mrow2; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/mrowSup/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var msubsup; msubsup = mrow.closest(".msubsup"); return msubsup.wrapper.mrowSub.startCursor("last"); }; mrow.back = function(){ var msubsup, mrow1Elements; msubsup = mrow.closest(".msubsup"); mrow1Elements = msubsup.wrapper.mrow1.getElements(); if (mrow1Elements.length === 0) { msubsup.previousSibling.startCursor("last"); return msubsup.remove(); } else { msubsup.after(mrow1Elements); msubsup.remove(); return _.last(mrow1Elements).startCursor("last"); } }; mrow.right = function(){ var msubsup; msubsup = mrow.closest(".msubsup"); return msubsup.wrapper.mrowSub.startCursor("first"); }; mrow.blinkerStart.left = mrow.left; return mrow.blinkerEnd.right = mrow.right; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/mrowSup/mrowSup.ls (function(){ return function(o, el){ var el2, e, mrow; el2 = el != null ? el.lastChild : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); mrow.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow); return mrow; }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/showOpenClose/show.ls (function(){ return function(o, div){ var update; update = function(){ var mrow1Elements, show, ref$, h; mrow1Elements = div.mrow1.getElements(); show = (ref$ = _.first(mrow1Elements)) != null && ref$.hasClass("mfrac") ? true : mrow1Elements.length > 1 ? true : false; if (show) { div.open.show(); div.close.show(); h = div.mrow1.offsetHeight; div.open.scale(h); return div.close.scale(h); } else { div.open.hide(); return div.close.hide(); } }; div.onChildrenModified(update); return update(); }; })(); mathDiv/createElements/element/combined/msubsup/wrapper/wrapper.ls (function(){ return function(o, el){ var div; div = Div(); div.css({ display: "flex" }).addClass("center").append(Div({ alignSelf: "center" }).append(Div().addClass("center").css({ display: "flex", alignItems: "flex-start" }).append(div.open = inc("../../_shared/bracket/bracket")(o, el, "(", div), div.mrow1 = inc("mrow1/mrow1")(o, el), div.close = inc("../../_shared/bracket/bracket")(o, el, ")", div))), Div().addClass("center").css({ fontSize: "0.7em", justifyContent: "flex-start", alignSelf: "flex-start", marginLeft: "-2px" }).append(Div().append(div.mrowSup = inc("mrowSup/mrowSup")(o, el).css({ justifyContent: "flex-start" })), Div().append(div.mrowSub = inc("mrowSub/mrowSub")(o, el).css({ justifyContent: "flex-start" })))); inc("getCenter/get")(o, div); inc("showOpenClose/show")(o, div); return div; }; })(); mathDiv/createElements/element/combined/msup/blinker/end/end.ls (function(){ return function(o, msup){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msup.after(newElement); }; div.left = function(){ return msup.wrapper.mrow2.startCursor("last"); }; div.back = function(){ return msup.startCursor(); }; div.right = function(){ return msup.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/msup/blinker/start/start.ls (function(){ return function(o, msup){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return msup.before(newElement); }; div.left = function(){ return msup.previousSibling.startCursor("last").left(); }; div.back = function(){ return msup.previousSibling.startCursor("last").back(); }; div.right = function(){ return msup.wrapper.mrow1.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/msup/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/msup/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var mrow1MathData, mrow2MathData, asciimath, mrow1Content, mrow1FirstC, ref$, mrow1LastC, ref1$, ref2$, mrow2Content, mrow2FirstC, ref3$, mrow2LastC, ref4$, ref5$; mrow1MathData = div.wrapper.mrow1.getMathData(); mrow2MathData = div.wrapper.mrow2.getMathData(); asciimath = ""; mrow1Content = mrow1MathData.content; mrow1FirstC = (ref$ = _.first(mrow1Content)) != null ? ref$.asciimath : void 8; mrow1LastC = (ref1$ = _.last(mrow1Content)) != null ? ref1$.asciimath : void 8; if ((mrow1Content.length > 1 || ((ref2$ = mrow1Content[0]) != null ? ref2$.tagName : void 8) === "mfrac") && !(mrow1FirstC === "(" && mrow1LastC === ")")) { asciimath += "(" + mrow1MathData.asciimath + ")"; } else { asciimath += mrow1MathData.asciimath; } asciimath += "^"; mrow2Content = mrow2MathData.content; mrow2FirstC = (ref3$ = _.first(mrow2Content)) != null ? ref3$.asciimath : void 8; mrow2LastC = (ref4$ = _.last(mrow2Content)) != null ? ref4$.asciimath : void 8; if ((mrow2Content.length > 1 && !(mrow2FirstC === "(" && mrow2LastC === ")")) || (mrow2Content.length === 1 && !((ref5$ = mrow2Content[0].tagName) === "mi" || ref5$ === "mn"))) { asciimath += "(" + mrow2MathData.asciimath + ")"; } else { asciimath += mrow2MathData.asciimath; } return { tagName: "msup", content: [mrow1MathData, mrow2MathData], asciimath: asciimath, eval: function(scope){ var p1, p2; p1 = mrow1MathData.eval(scope); p2 = mrow2MathData.eval(scope); if (p1 == null || p2 == null) { return null; } return Math.pow(p1, p2); } }; }; }; })(); mathDiv/createElements/element/combined/msup/msup.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("msup center").css({ display: "inline-flex", alignItems: "flex-start" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/msup/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.offsetHeight - div.mrow1.offsetHeight + div.mrow1.getCenter(); }; }; })(); mathDiv/createElements/element/combined/msup/wrapper/mrow1/cursorOverwrite/cursor.ls (function(){ return function(o, mrow1){ mrow1.left = function(){ var msup; msup = mrow1.closest(".msup"); return msup.blinkerStart.startCursor().left(); }; mrow1.back = function(){ var msup, mrow2Elements; msup = mrow1.closest(".msup"); mrow2Elements = msup.wrapper.mrow2.getElements(); if (mrow2Elements.length === 0) { msup.previousSibling.startCursor("last"); return msup.remove(); } else { msup.after(mrow2Elements); msup.remove(); return _.last(mrow2Elements).startCursor("last"); } }; mrow1.right = function(){ var msup; msup = mrow1.closest(".msup"); return msup.wrapper.mrow2.startCursor("first"); }; mrow1.blinkerStart.left = mrow1.left; return mrow1.blinkerEnd.right = mrow1.right; }; })(); mathDiv/createElements/element/combined/msup/wrapper/mrow1/mrow1.ls (function(){ return function(o, el){ var el1, e, mrow1; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow1); return mrow1; }; })(); mathDiv/createElements/element/combined/msup/wrapper/mrow2/cursorOverwrite/cursor.ls (function(){ return function(o, mrow2){ mrow2.left = function(){ var msup; msup = mrow2.closest(".msup"); return msup.wrapper.mrow1.startCursor("last"); }; mrow2.back = function(){ var msup, mrow1Elements; msup = mrow2.closest(".msup"); mrow1Elements = msup.wrapper.mrow1.getElements(); if (mrow1Elements.length === 0) { msup.previousSibling.startCursor("last"); return msup.remove(); } else { msup.after(mrow1Elements); msup.remove(); return _.last(mrow1Elements).startCursor("last"); } }; mrow2.right = function(){ var msup; msup = mrow2.closest(".msup"); return msup.blinkerEnd.startCursor(); }; mrow2.blinkerStart.left = mrow2.left; return mrow2.blinkerEnd.right = mrow2.right; }; })(); mathDiv/createElements/element/combined/msup/wrapper/mrow2/mrow2.ls (function(){ return function(o, el){ var el2, e, mrow2; el2 = el != null ? el.lastChild : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow2 = e; } else { mrow2 = o.createElement("mrow"); mrow2.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow2); return mrow2; }; })(); mathDiv/createElements/element/combined/msup/wrapper/showOpenClose/show.ls (function(){ return function(o, div){ var update; update = function(){ var mrow1Elements, show, ref$, h; mrow1Elements = div.mrow1.getElements(); show = (ref$ = _.first(mrow1Elements)) != null && ref$.hasClass("mfrac") ? true : mrow1Elements.length > 1 ? true : false; if (show) { div.open.show(); div.close.show(); h = div.mrow1.offsetHeight; div.open.scale(h); return div.close.scale(h); } else { div.open.hide(); return div.close.hide(); } }; div.onChildrenModified(update); return update(); }; })(); mathDiv/createElements/element/combined/msup/wrapper/wrapper.ls (function(){ return function(o, el){ var div; div = Div(); div.css({ display: "flex" }).append(Div({ paddingTop: "0.1em", alignSelf: "flex-end" }).append(Div().addClass("center").css({ display: "flex", alignItems: "flex-start" }).append(div.open = inc("../../_shared/bracket/bracket")(o, el, "(", div), div.mrow1 = inc("mrow1/mrow1")(o, el), div.close = inc("../../_shared/bracket/bracket")(o, el, ")", div))), Div({ fontSize: "0.7em", marginBottom: "0.6em", alignSelf: "flex-start", paddingLeft: "3px" }).append(div.mrow2 = inc("mrow2/mrow2")(o, el))); inc("getCenter/get")(o, div); inc("showOpenClose/show")(o, div); return div; }; })(); mathDiv/createElements/element/combined/mtable/blinker/end/end.ls (function(){ return function(o, mtable){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mtable.after(newElement); }; div.left = function(){ var lastRow; lastRow = mtable.table.findLast(".mtr"); return lastRow.startCursor("last"); }; div.back = function(){ return mtable.startCursor(); }; div.right = function(){ return mtable.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/mtable/blinker/start/start.ls (function(){ return function(o, mtable){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mtable.before(newElement); }; div.left = function(){ return mtable.previousSibling.startCursor("last").left(); }; div.back = function(){ return mtable.previousSibling.startCursor("last").back(); }; div.right = function(){ var firstRow; firstRow = mtable.table.findFirst(".mtr"); return firstRow.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/mtable/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.table.getCenter(); }; }; })(); mathDiv/createElements/element/combined/mtable/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var w, mrow1MathData, asciimath; w = div.table; mrow1MathData = w.mrow1.getMathData(); asciimath = "bar"; if (mrow1MathData.content.length > 1) { asciimath += "(" + mrow1MathData.asciimath + ")"; } else { asciimath += mrow1MathData.asciimath; } return { tagName: "mtable", content: [mrow1MathData, "over todo"], asciimath: asciimath }; }; }; })(); mathDiv/createElements/element/combined/mtable/mtable.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("mtable center").css({ display: "inline-flex", alignItems: "flex-start" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.table = inc("table/table")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/mtable/table/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.offsetHeight / 2; }; }; })(); mathDiv/createElements/element/combined/mtable/table/mtd/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.mrow.getCenter(); }; }; })(); mathDiv/createElements/element/combined/mtable/table/mtd/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var mrowMathData; mrowMathData = div.mrow.getMathData(); return { tagName: "mtd", content: mrowMathData }; }; }; })(); mathDiv/createElements/element/combined/mtable/table/mtd/mrow/cursorOverwrite/cursor.ls (function(){ return function(o, mrow){ mrow.left = function(){ var mtd, previousSibling; mtd = mrow.closest(".mtd"); previousSibling = mtd.previousSibling; if (previousSibling.hasClass("mtd")) { return previousSibling.startCursor("last").left(); } else { return mtd.closest(".mtr").blinkerStart.left(); } }; mrow.back = function(){ var mtd, prev; mtd = mrow.closest(".mtd"); prev = mtd.previousSibling; mtd.remove(); if (mrow.lastChild.hasClass("end")) { return prev.startCursor("last").back(); } else { return prev.startCursor("last"); } }; mrow.right = function(){ var mtd, nextSibling; mtd = mrow.closest(".mtd"); nextSibling = mtd.nextSibling; if (nextSibling.hasClass("mtd")) { return nextSibling.firstChild.startCursor("first").right(); } else { return mtd.closest(".mtr").blinkerEnd.right(); } }; mrow.blinkerStart.left = mrow.left; mrow.blinkerEnd.right = mrow.right; return mrow.blinkerStart.back = mrow.back; }; })(); mathDiv/createElements/element/combined/mtable/table/mtd/mrow/mrow.ls (function(){ return function(o, el, i, table){ var el1, e, mrow; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow = e; } else { mrow = o.createElement("mrow"); if (el1) { mrow.setElements(e); } else { mrow.setElements(o.createElement("mspace")); } } inc("cursorOverwrite/cursor")(o, mrow); inc("setAlign/set")(o, mrow, i, table); return mrow; }; })(); mathDiv/createElements/element/combined/mtable/table/mtd/mrow/setAlign/set.ls (function(){ return function(o, mrow, i, table){ var align, ref$; align = (ref$ = o.matAttributes) != null ? ref$.align : void 8; if (table.attr("tableType") !== "newline") { align = "center"; } else if (!align) { align = "flex-start"; } else { align = align.split("")[i]; if (!align) { debug("Please specify alignment for all columns in mat tag!"); } align = align === "r" ? "flex-end" : align === "c" ? "center" : "flex-start"; } return mrow.css({ justifyContent: align }); }; })(); mathDiv/createElements/element/combined/mtable/table/mtd/mtd.ls (function(){ return function(o, el, i, table){ var div; div = Td(); div.addClass("mathElement").addClass("mtd center").append(div.mrow = inc("mrow/mrow")(o, el, i, table)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../../../_shared/cursor/cursor")(o, div); inc("../../../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/mtable/table/mtr/blinker/end/end.ls (function(){ return function(o, mtr){ var div; div = inc("../../../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mtr.after(newElement); }; div.left = function(){ return mtr.findLast(".mtd").lastChild.startCursor("last").left(); }; div.back = function(){ var lastMtd, prevMtr, nextMtr, mtable; lastMtd = mtr.findLast(".mtd"); if (lastMtd) { return lastMtd.startCursor("last").back(); } else { prevMtr = mtr.previousSibling; nextMtr = mtr.nextSibling; mtable = mtr.closest(".mtable"); mtr.remove(); return (prevMtr != null ? prevMtr.startCursor("last") : void 8) || (nextMtr != null ? nextMtr.startCursor("last") : void 8) || mtable.startCursor("last"); } }; return div; }; })(); mathDiv/createElements/element/combined/mtable/table/mtr/blinker/start/start.ls (function(){ return function(o, mtr){ var div; div = inc("../../../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return mtr.before(newElement); }; div.back = function(){ return mtr.startCursor(); }; div.right = function(){ return mtr.findFirst(".mtd").firstChild.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/mtable/table/mtr/cells/cells.ls (function(){ return function(o, el, table){ var i$, ref$, len$, i, mtd, results$ = []; for (i$ = 0, len$ = (ref$ = el.findAll("mtd")).length; i$ < len$; ++i$) { i = i$; mtd = ref$[i$]; results$.push(inc("../../mtd/mtd")(o, mtd, i, table)); } return results$; }; })(); mathDiv/createElements/element/combined/mtable/table/mtr/cursorOverwrite/cursor.ls (function(){ return function(o, mtr){ mtr.left = function(){ var mtable, previousRow; mtable = mtr.closest(".mtable"); previousRow = mtr.previousSibling; if (previousRow) { return previousRow.startCursor("last"); } else { return mtable.blinkerStart.startCursor(); } }; mtr.back = function(){ var previousRow, nextRow, mtable; previousRow = mtr.previousSibling; nextRow = mtr.nextSibling; mtable = mtr.closest(".mtable"); mtr.remove(); if (previousRow) { previousRow.startCursor("last"); } else if (nextRow) { nextRow.startCursor("first"); } else { mtable.previousSibling.startCursor("last"); mtable.remove(); } return o.adjustLayout(); }; mtr.right = function(){ var nextRow, mtable; nextRow = mtr.nextSibling; mtable = mtr.closest(".mtable"); if (nextRow) { return nextRow.startCursor("first"); } else { return mtable.nextSibling.startCursor("first"); } }; mtr.blinkerStart.left = mtr.left; return mtr.blinkerEnd.right = mtr.right; }; })(); mathDiv/createElements/element/combined/mtable/table/mtr/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ var maxCenter, i$, ref$, len$, el, center; maxCenter = 0; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.getCenter) { center = el.getCenter(); maxCenter = Math.max(maxCenter, center); } } return maxCenter; }; }; })(); mathDiv/createElements/element/combined/mtable/table/mtr/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var w, mrow1MathData, asciimath; w = div.table; mrow1MathData = w.mrow1.getMathData(); asciimath = "bar"; if (mrow1MathData.content.length > 1) { asciimath += "(" + mrow1MathData.asciimath + ")"; } else { asciimath += mrow1MathData.asciimath; } return { tagName: "mtr", content: [mrow1MathData, "over todo"], asciimath: asciimath }; }; }; })(); mathDiv/createElements/element/combined/mtable/table/mtr/mtr.ls (function(){ return function(o, el, table){ var div; div = Tr(); div.addClass("mathElement").addClass("mtr center").append(div.blinkerStart = inc("blinker/start/start")(o, div), div.cells = inc("cells/cells")(o, el, table), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../../../_shared/cursor/cursor")(o, div); inc("cursorOverwrite/cursor")(o, div); inc("../../../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/mtable/table/table.ls (function(){ return function(o, el){ var div, i, mtr; div = Table(); div.css(el.attr("tableType") === "newline" ? { borderSpacing: "0 0.5em" } : { borderSpacing: "0 0.1em" }); div.append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = el.findAll("mtr")).length; i$ < len$; ++i$) { i = i$; mtr = ref$[i$]; results$.push(inc("mtr/mtr")(o, mtr, el)); } return results$; }())); inc("getCenter/get")(o, div); return div; }; })(); mathDiv/createElements/element/combined/munder/blinker/end/end.ls (function(){ return function(o, munderover){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return munderover.after(newElement); }; div.left = function(){ return munderover.wrapper.mrow3.startCursor("last"); }; div.back = function(){ return munderover.startCursor(); }; div.right = function(){ return munderover.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/munder/blinker/start/start.ls (function(){ return function(o, munderover){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return munderover.before(newElement); }; div.left = function(){ return munderover.previousSibling.startCursor("last").left(); }; div.back = function(){ return munderover.previousSibling.startCursor("last").back(); }; div.right = function(){ return munderover.wrapper.mrow2.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/munder/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/munder/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var w, mrow1MathData, mrow2MathData, asciimath; w = div.wrapper; mrow1MathData = w.mrow1.getMathData(); mrow2MathData = w.mrow2.getMathData(); asciimath = "`lim`_"; if (mrow2MathData.content.length > 1) { asciimath += "(" + mrow2MathData.asciimath + ")"; } else { asciimath += mrow2MathData.asciimath; } asciimath += "^"; return { tagName: "munderover", content: [mrow1MathData, mrow2MathData], asciimath: asciimath }; }; }; })(); mathDiv/createElements/element/combined/munder/munder.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("munder center").css({ display: "inline-flex", alignItems: "flex-start" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/munder/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.mrow1.getCenter(); }; }; })(); mathDiv/createElements/element/combined/munder/wrapper/mrow1/mrow1.ls (function(){ return function(o, el){ var el1, e, mrow1; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } return mrow1; }; })(); mathDiv/createElements/element/combined/munder/wrapper/mrow2/cursorOverwrite/cursor.ls (function(){ return function(o, mrow2){ mrow2.left = function(){ var munderover; munderover = mrow2.closest(".munderover"); return munderover.blinkerStart.startCursor(); }; mrow2.back = function(){ var munderover, mrow3Elements; munderover = mrow2.closest(".munderover"); mrow3Elements = munderover.wrapper.mrow3.getElements(); if (mrow3Elements.length === 0) { munderover.previousSibling.startCursor("last"); return munderover.remove(); } else { munderover.after(mrow3Elements); munderover.remove(); return _.last(mrow3Elements).startCursor("last"); } }; mrow2.right = function(){ var munderover; munderover = mrow2.closest(".munderover"); return munderover.wrapper.mrow3.startCursor("first"); }; mrow2.blinkerStart.left = mrow2.left; return mrow2.blinkerEnd.right = mrow2.right; }; })(); mathDiv/createElements/element/combined/munder/wrapper/mrow2/mrow2.ls (function(){ return function(o, el){ var el2, e, mrow2; el2 = el != null ? el.childrenAll()[1] : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow2 = e; } else { mrow2 = o.createElement("mrow"); mrow2.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow2); return mrow2; }; })(); mathDiv/createElements/element/combined/munder/wrapper/wrapper.ls (function(){ return function(o, el){ var div; div = Div(); div.css({ display: "flex", minWidth: "1em", flexDirection: "column" }).append(Div().append(div.mrow1 = inc("mrow1/mrow1")(o, el).css({ pointerEvents: "none" })), div.mrow2 = inc("mrow2/mrow2")(o, el).css({ marginTop: "-3px", fontSize: "0.8em" })); inc("getCenter/get")(o, div); return div; }; })(); mathDiv/createElements/element/combined/munderover/blinker/end/end.ls (function(){ return function(o, munderover){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return munderover.after(newElement); }; div.left = function(){ return munderover.wrapper.mrow3.startCursor("last"); }; div.back = function(){ return munderover.startCursor(); }; div.right = function(){ return munderover.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/combined/munderover/blinker/start/start.ls (function(){ return function(o, munderover){ var div; div = inc("../../../_shared/blinker/blinker")({ o: o }); div.insert = function(newElement){ return munderover.before(newElement); }; div.left = function(){ return munderover.previousSibling.startCursor("last").left(); }; div.back = function(){ return munderover.previousSibling.startCursor("last").back(); }; div.right = function(){ return munderover.wrapper.mrow2.startCursor("first"); }; return div; }; })(); mathDiv/createElements/element/combined/munderover/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.wrapper.getCenter(); }; }; })(); mathDiv/createElements/element/combined/munderover/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var w, mrow1MathData, mrow2MathData, mrow3MathData, asciimath; w = div.wrapper; mrow1MathData = w.mrow1.getMathData(); mrow2MathData = w.mrow2.getMathData(); mrow3MathData = w.mrow3.getMathData(); asciimath = "sum_"; if (mrow2MathData.content.length > 1) { asciimath += "(" + mrow2MathData.asciimath + ")"; } else { asciimath += mrow2MathData.asciimath; } asciimath += "^"; if (mrow3MathData.content.length > 1) { asciimath += "(" + mrow3MathData.asciimath + ")"; } else { asciimath += mrow3MathData.asciimath; } return { tagName: "munderover", content: [mrow1MathData, mrow2MathData, mrow3MathData], asciimath: asciimath }; }; }; })(); mathDiv/createElements/element/combined/munderover/munderover.ls (function(){ return function(o, el){ var div; div = Div(); div.addClass("mathElement").addClass("munderover center").css({ display: "inline-flex", alignItems: "flex-start" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.wrapper = inc("wrapper/wrapper")(o, el), div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("getCenter/get")(o, div); inc("getMathData/get")(o, el, div); inc("../_shared/cursor/cursor")(o, div); inc("../../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/combined/munderover/wrapper/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ return div.mrow3.offsetHeight + div.mrow1.getCenter() - 3; }; }; })(); mathDiv/createElements/element/combined/munderover/wrapper/mrow1/mrow1.ls (function(){ return function(o, el){ var el1, e, mrow1; el1 = el != null ? el.firstChild : void 8; e = o.createElement(el1); if ((el1 != null ? el1.tagName : void 8) === "mrow") { mrow1 = e; } else { mrow1 = o.createElement("mrow"); mrow1.setElements(e); } return mrow1; }; })(); mathDiv/createElements/element/combined/munderover/wrapper/mrow2/cursorOverwrite/cursor.ls (function(){ return function(o, mrow2){ mrow2.left = function(){ var munderover; munderover = mrow2.closest(".munderover"); return munderover.blinkerStart.startCursor(); }; mrow2.back = function(){ var munderover, mrow3Elements; munderover = mrow2.closest(".munderover"); mrow3Elements = munderover.wrapper.mrow3.getElements(); if (mrow3Elements.length === 0) { munderover.previousSibling.startCursor("last"); return munderover.remove(); } else { munderover.after(mrow3Elements); munderover.remove(); return _.last(mrow3Elements).startCursor("last"); } }; mrow2.right = function(){ var munderover; munderover = mrow2.closest(".munderover"); return munderover.wrapper.mrow3.startCursor("first"); }; mrow2.blinkerStart.left = mrow2.left; return mrow2.blinkerEnd.right = mrow2.right; }; })(); mathDiv/createElements/element/combined/munderover/wrapper/mrow2/mrow2.ls (function(){ return function(o, el){ var el2, e, mrow2; el2 = el != null ? el.childrenAll()[1] : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow2 = e; } else { mrow2 = o.createElement("mrow"); mrow2.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow2); return mrow2; }; })(); mathDiv/createElements/element/combined/munderover/wrapper/mrow3/cursorOverwrite/cursor.ls (function(){ return function(o, mrow3){ mrow3.left = function(){ var munderover; munderover = mrow3.closest(".munderover"); return munderover.wrapper.mrow2.startCursor("last"); }; mrow3.back = function(){ var munderover, mrow2Elements; munderover = mrow3.closest(".munderover"); mrow2Elements = munderover.wrapper.mrow2.getElements(); if (mrow2Elements.length === 0) { munderover.previousSibling.startCursor("last"); return munderover.remove(); } else { munderover.after(mrow2Elements); munderover.remove(); return _.last(mrow2Elements).startCursor("last"); } }; mrow3.right = function(){ var munderover; munderover = mrow3.closest(".munderover"); return munderover.blinkerEnd.startCursor(); }; mrow3.blinkerStart.left = mrow3.left; return mrow3.blinkerEnd.right = mrow3.right; }; })(); mathDiv/createElements/element/combined/munderover/wrapper/mrow3/mrow3.ls (function(){ return function(o, el){ var el2, e, mrow3; el2 = el != null ? el.lastChild : void 8; e = o.createElement(el2); if ((el2 != null ? el2.tagName : void 8) === "mrow") { mrow3 = e; } else { mrow3 = o.createElement("mrow"); mrow3.setElements(e); } inc("cursorOverwrite/cursor")(o, mrow3); return mrow3; }; })(); mathDiv/createElements/element/combined/munderover/wrapper/wrapper.ls (function(){ return function(o, el){ var div; div = Div(); div.css({ display: "flex", minWidth: "1em", flexDirection: "column", alignItems: "stretch" }).append(div.mrow3 = inc("mrow3/mrow3")(o, el).css({ fontSize: "0.8em", marginBottom: "-5px" }), Div().append(div.mrow1 = inc("mrow1/mrow1")(o, el).css({ fontSize: "1.5em", pointerEvents: "none" })), div.mrow2 = inc("mrow2/mrow2")(o, el).css({ fontSize: "0.8em" })); div.mrow1.findFirst(".mo").css({ padding: "" }); inc("getCenter/get")(o, div); return div; }; })(); mathDiv/createElements/element/element.ls (function(){ return function(o, el){ var tags, f, element; if (!el) { return; } tags = { mn: inc("basic/mn/mn"), mi: inc("basic/mi/mi"), mo: inc("basic/mo/mo"), mtext: inc("basic/mtext/mtext"), mspace: inc("basic/mspace/mspace"), unknown: inc("basic/unknown/unknown"), mrow: inc("mrow/mrow"), mfrac: inc("combined/mfrac/mfrac"), mfenced: inc("combined/mfenced/mfenced"), munderover: inc("combined/munderover/munderover"), mover: inc("combined/mover/mover"), munder: inc("combined/munder/munder"), msup: inc("combined/msup/msup"), msub: inc("combined/msub/msub"), msubsup: inc("combined/msubsup/msubsup"), msqrt: inc("combined/msqrt/msqrt"), mroot: inc("combined/mroot/mroot"), mtable: inc("combined/mtable/mtable"), mgap: inc("combined/mgap/mgap"), mfn: inc("combined/mfn/mfn") }; f = tags[el.tagName.toLowerCase()] || tags["unknown"]; element = f(o, el); element.select = inc("_shared/select/select")(o, element); element.unselect = inc("_shared/unselect/unselect")(o, element); return element; }; })(); mathDiv/createElements/element/mrow/blinker/end/end.ls (function(){ return function(o, mrow){ var div; div = inc("../../../combined/_shared/blinker/blinker")({ o: o }).addClass("end"); div.insert = function(newElement){ return div.before(newElement); }; div.left = function(){ return div.previousSibling.startCursor("last").left(); }; div.back = function(){ return div.previousSibling.startCursor("last").back(); }; div.right = function(){ return mrow.startCursor(); }; return div; }; })(); mathDiv/createElements/element/mrow/blinker/start/start.ls (function(){ return function(o, mrow){ var div; div = inc("../../../combined/_shared/blinker/blinker")({ o: o }).addClass("start"); div.insert = function(newElement){ return div.after(newElement); }; div.left = function(){ return mrow.startCursor(); }; div.back = function(){ return mrow.startCursor(); }; div.right = function(){ return div.nextSibling.startCursor("first").right(); }; return div; }; })(); mathDiv/createElements/element/mrow/cursor/cursor.ls (function(){ return function(o, div){ return o.addCursorSupport({ div: div, cursorType: "border", insert: function(newElement){ var i$, ref$, len$, el; for (i$ = 0, len$ = (ref$ = div.getElements()).length; i$ < len$; ++i$) { el = ref$[i$]; el.remove(); } return div.blinkerStart.after(newElement); }, back: function(){ div.previousSibling.startCursor("last"); return div.remove(); }, left: function(){ return div.previousSibling.startCursor("last"); }, right: function(){ return div.nextSibling.startCursor("first"); } }); }; })(); mathDiv/createElements/element/mrow/getCenter/get.ls (function(){ return function(o, div){ div.addClass("getCenter"); return div.getCenter = function(){ var maxCenter, i$, ref$, len$, el, center; maxCenter = 0; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.getCenter) { center = el.getCenter(); maxCenter = Math.max(maxCenter, center); } } return maxCenter; }; }; })(); mathDiv/createElements/element/mrow/getElements/get.ls (function(){ return function(div){ return div.getElements = function(){ var children, elements, el; children = div.childrenAll(); return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = children).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.hasClass("start")) { continue; } else if (el.hasClass("end")) { break; } else { results$.push(el); } } return results$; }()); }; }; })(); mathDiv/createElements/element/mrow/getMathData/eval/eval.ls (function(){ return function(div, scope){ var content, res$, i$, ref$, len$, el, evalString, c, e; res$ = []; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (!el.getMathData) { continue; } else { res$.push(typeof el.getMathData == 'function' ? el.getMathData() : void 8); } } content = res$; evalString = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = content).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.eval(scope)); } return results$; }()).join(" "); try { return eval(evalString); } catch (e$) { e = e$; return null; } }; })(); mathDiv/createElements/element/mrow/getMathData/get.ls (function(){ return function(o, el, div){ return div.getMathData = function(){ var a, res$, i$, ref$, len$, el, asciimath, i, mathData; res$ = []; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (!el.getMathData) { continue; } else { res$.push(el.getMathData()); } } a = res$; asciimath = ""; for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { i = i$; mathData = a[i$]; if (i === 0) { asciimath += mathData.asciimath; } else if (mathData.tagName === "mspace") { asciimath += mathData.asciimath; } else { asciimath += " " + mathData.asciimath; } } return { tagName: "mrow", content: a, asciimath: asciimath, eval: function(scope){ return inc("eval/eval")(div, scope); } }; }; }; })(); mathDiv/createElements/element/mrow/mrow.ls (function(){ return function(o, el){ var div, e; div = Div(); div.addClass("mrow center").css({ display: "flex", alignItems: "flex-start", minWidth: "0.8em" }).append(div.blinkerStart = inc("blinker/start/start")(o, div), div.start = inc("../combined/_shared/blinker/blinker"), el != null && el.childrenAll ? (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = el.childrenAll()).length; i$ < len$; ++i$) { e = ref$[i$]; results$.push(o.createElement(e)); } return results$; }()) : void 8, div.blinkerEnd = inc("blinker/end/end")(o, div)); inc("cursor/cursor")(o, div); inc("getCenter/get")(o, div); inc("showGreyIfEmpty/show")(o, div); inc("setElements/set")(div); inc("getElements/get")(div); inc("getMathData/get")(o, el, div); inc("../_shared/setAttrStyle/set")(div, el); return div; }; })(); mathDiv/createElements/element/mrow/setElements/set.ls (function(){ return function(div){ return div.setElements = function(newElements){ var i$, ref$, len$, el; newElements = _.ensureArray(newElements); for (i$ = 0, len$ = (ref$ = div.getElements()).length; i$ < len$; ++i$) { el = ref$[i$]; el.remove(); } for (i$ = 0, len$ = newElements.length; i$ < len$; ++i$) { el = newElements[i$]; div.blinkerEnd.before(el); } return div; }; }; })(); mathDiv/createElements/element/mrow/showGreyIfEmpty/show.ls (function(){ return function(o, div){ var update; update = function(){ var ref$; return div.css({ backgroundColor: !o.enabled ? "" : div.disableShowGreyIfEmpty ? "" : ((ref$ = o.mode) === "buttons" || ref$ === "write") && div.closest(".gap") == null ? "" : div.blinkerEnd.previousSibling === div.blinkerStart ? "rgba(0, 0, 0, 0.04)" : "" }); }; div.onChildrenModified(update); div.onDomAppend(update); return update(); }; })(); mathDiv/createElements/end/cursor/cursor.ls (function(){ return function(o, div){ return o.addCursorSupport({ div: div, cursorType: "left", insert: function(newElement){ return div.before(newElement); }, back: function(){ return div.previousSibling.startCursor("last").back(); }, left: function(){ return div.previousSibling.startCursor("last").left(); }, right: function(){} }); }; })(); mathDiv/createElements/end/end.ls (function(){ return function(o){ var div; div = Div(); div.addClass("end").css({ overflow: "hidden", minHeight: "100%" }).html(" "); div.nearestTapEnabled = true; inc("cursor/cursor")(o, div); inc("../element/_shared/getCenter/get")(div); return div; }; })(); mathDiv/createElements/start/cursor/cursor.ls (function(){ return function(o, div){ return o.addCursorSupport({ div: div, insert: function(newElement){ return div.after(newElement); }, back: function(){}, left: function(){}, right: function(){ return div.nextSibling.startCursor("first").right(); } }); }; })(); mathDiv/createElements/start/start.ls (function(){ return function(o){ var div; div = Div(); div.addClass("start").css({ overflow: "hidden", minHeight: "100%" }).html(" "); div.nearestTapEnabled = true; inc("cursor/cursor")(o, div); inc("../element/_shared/getCenter/get")(div); return div; }; })(); mathDiv/disable/disable.ls (function(){ return function(o){ return function(){ var ref$; o.enabled = false; if ((ref$ = o.cursorElement) != null) { ref$.stopCursor(); } o.div.css({ backgroundColor: "", pointerEvents: "none" }); o.div.startDiv.css({ width: o.mode === "mathFormula" ? "0.2em" : "0em" }); return o.div.endDiv.css({ width: "0em" }); }; }; })(); mathDiv/div/div.ls (function(){ return function(o){ var div; div = Div().addClass("mathDiv").css({ display: "inline-flex", alignItems: "flex-start", justifyContent: "flex-start" }); if (o.matsci) { div.css({ fontFamily: "Latin Modern, Latin Modern Math, math" }); } div.o = o; div.isConverted = true; inc("tapNearestElement/tap")(o, div); return div; }; })(); mathDiv/div/tapNearestElement/tap.ls (function(){ return function(o, div){ var t, downPos, down, click; t = function(x, y){ return inc("tapElement/tap")(o, div, x, y); }; down = function(e){ var x, ref$, y, ref1$; x = e.pageX || ((ref$ = e.touches) != null ? ref$[0].pageX : void 8); y = e.pageY || ((ref1$ = e.touches) != null ? ref1$[0].pageY : void 8); return downPos = { x: x, y: y }; }; click = function(e){ var ref$, x, ref1$, y, ref2$, i; if ((ref$ = o.slide) != null && ref$.gapClickStartDisabled) { return; } x = e.pageX || ((ref1$ = e.touches) != null ? ref1$[0].pageX : void 8); y = e.pageY || ((ref2$ = e.touches) != null ? ref2$[0].pageY : void 8); if (Math.abs(x - downPos.x) > 30 || Math.abs(y - downPos.y) > 30) { return; } i = 0; while (i <= 200) { i += 2; if (t(x, y + i) || t(x, y - i) || t(x + i, y) || t(x - i, y) || t(x - i, y + i) || t(x + i, y + i) || t(x - i, y - i) || t(x + i, y - i)) { return; } } return div.start(); }; return div.tap({ animation: "none", down: down, up: click }).css({ cursor: "default" }); }; })(); mathDiv/div/tapNearestElement/tapElement/tap.ls (function(){ return function(o, div, x, y){ var el, mgap, currentGap, ref$, tap; el = document.elementFromPoint(x, y); mgap = el != null ? el.closest(".mgap") : void 8; currentGap = (ref$ = app.currentPage.levelPlayer) != null ? ref$.currentGap : void 8; tap = function(){ if (mgap != null) { mgap.selection.unselect(); } if (mgap != null) { mgap.start(); } if (el.charTap != null) { return el.charTap({ pageX: x, pageY: y }); } else { return el.startCursor(); } }; if (!div.contains(el)) { return false; } if (!el.nearestTapEnabled) { return false; } if (mgap != null && currentGap != null && mgap !== currentGap) { currentGap.stopGap(); } tap(); return true; }; })(); mathDiv/enable/enable.ls (function(){ return function(o){ return function(){ o.enabled = true; if (o.gaps.length === 0) { o.div.css({ backgroundColor: Color.grey[100], pointerEvents: "inherit" }); o.div.startDiv.css({ width: "0.2em" }); return o.div.endDiv.css({ width: "1.6em" }); } else { o.div.css({ pointerEvents: "inherit" }); o.div.startDiv.css({ width: "0em" }); return o.div.endDiv.css({ width: "0em" }); } }; }; })(); mathDiv/eval/content/addMultiplication/add.ls (function(){ return function(el, el2, tags, rootTags){ if (in$(el2 != null ? el2.tagName.toLowerCase() : void 8, tags) && in$(el.parent().tagName.toLowerCase(), rootTags) && in$(el2.parent().tagName.toLowerCase(), rootTags)) { el.after(document.createElement("mo").html("*")); return true; } return false; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/eval/content/combineRecurringDecimal/combine.ls (function(){ return function(el, el2){ var num, num2, ref$; if (el.tagName.toLowerCase() === "mn" && (el2 != null ? el2.tagName.toLowerCase() : void 8) === "mover") { num = el.innerHTML; num2 = (ref$ = el2.findFirst("mn")) != null ? ref$.innerHTML : void 8; if (!el2.innerHTML.includes("‾")) { return false; } if (!num.includes(".")) { return false; } if (!num2) { return false; } el.replaceWith(document.createElement("mn").html((num + "") + _.repeat(num2, Math.ceil(30 / num2.length)))); el2.remove(); return true; } return false; }; })(); mathDiv/eval/content/content.ls (function(){ return function(o){ var sourceDiv, tags, rootTags, i$, ref$, len$, el, el2, m2, content; sourceDiv = inc("/mathDiv/calcSourceDiv/calc")({ value: o.getValue() })(); tags = "mi mn mfn mfenced mfrac mgap mover mfn msqrt mroot msub msup mrow munderover".split(" "); rootTags = "mrow math".split(" "); for (i$ = 0, len$ = (ref$ = sourceDiv.findAll(tags.join(","))).length; i$ < len$; ++i$) { el = ref$[i$]; el2 = el.nextSibling; if (inc("combineRecurringDecimal/combine")(el, el2)) { continue; } if (inc("addMultiplication/add")(el, el2, tags, rootTags)) { continue; } } m2 = MathDiv({ value: sourceDiv.outerHTML, matLayout: o.matLayout }); return content = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = m2.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (!el.getMathData) { continue; } else { results$.push(typeof el.getMathData == 'function' ? el.getMathData() : void 8); } } return results$; }()); }; })(); mathDiv/eval/eval.ls (function(){ return function(o){ return function(scope){ var content, evalString, c, result, e; content = inc("content/content")(o); evalString = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = content).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.eval(scope)); } return results$; }()).join(" "); try { result = eval(evalString); if (_.isString(result)) { return null; } else { return result; } } catch (e$) { e = e$; console.log("WARNING: MathDiv eval error in following expression\n" + evalString, e); return null; } }; }; })(); mathDiv/finish/finish.ls (function(){ return function(o){ return function(cancelCallback){ var result, ref$; result = { correctValue: o.div.calcCorrectValue() }; o.stop(); o.disable(); o.isDone = true; if ((ref$ = o.buttonsDiv) != null) { ref$.hide(); } return typeof o.onFinish == 'function' ? o.onFinish(result, cancelCallback) : void 8; }; }; })(); mathDiv/getMathData/get.ls (function(){ return function(o){ return function(){ var content, res$, i$, ref$, len$, el, asciimath, i, mathData; res$ = []; for (i$ = 0, len$ = (ref$ = o.div.childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (!el.getMathData) { continue; } else { res$.push(typeof el.getMathData == 'function' ? el.getMathData() : void 8); } } content = res$; asciimath = ""; for (i$ = 0, len$ = content.length; i$ < len$; ++i$) { i = i$; mathData = content[i$]; if (i === 0) { asciimath += mathData.asciimath; } else if (mathData.tagName === "mspace") { asciimath += mathData.asciimath; } else { asciimath += " " + mathData.asciimath; } } return { tagName: "math", content: content, asciimath: asciimath }; }; }; })(); mathDiv/getValue/get.ls (function(){ return function(o){ return function(){ return o.getMathData().asciimath; }; }; })(); mathDiv/keyManager/keyManager.ls (function(){ return function(o){ var onKey; onKey = function(e){ var f, char; f = e.detail.functionKey; char = e.detail.char; if (_.includes("0123456789", char)) { return o.onKey(char, false); } else if (_.includes("+-*/=", char)) { return o.onKey(char, false); } else if (char === ":") { return o.onKey("÷", false); } else if (char === ",") { return o.onKey(".", false); } else if (char === "_") { return null; } else if (char === "(") { return o.onKey("()", false); } else if (char === "^") { debug("Achtung, die Tastatur-Eingabe von ^ wird nicht mehr unterstützt, weil es nicht sauber funktioniert."); return null; } else if (f === "backspace") { return o.onKey("back", true); } else if (f === "left") { return o.onKey("moveCursorLeft", true); } else if (f === "right") { return o.onKey("moveCursorRight", true); } else if (f === "enter") { return o.onKey("enter", true); } else if (!f) { return o.onKey(char, false); } }; return { start: function(){ if (!o.div.hasClass("keyManager-any")) { o.div.addClass("keyManager-any"); return o.div.bind("keyManager", onKey); } }, stop: function(){ o.div.removeClass("keyManager-any"); return o.div.unbind("keyManager", onKey); } }; }; })(); mathDiv/mathDiv.ls (function(){ return function(o){ var div, that; if (_.isString(o)) { o = { value: o }; } o == null && (o = {}); o.enabled == null && (o.enabled = true); o.debug == null && (o.debug = false); o.matLayout == null && (o.matLayout = {}); o.keyboardLayout = o.keyboardLayout || o.matLayout.keyboardLayout || "mathDiv"; o.keyboardSubmitLabel == null && (o.keyboardSubmitLabel = T("check")); o.gapValidateMode == null && (o.gapValidateMode = "literal"); o.isDone = true; o.div = inc("div/div")(o); o.screenKeyboard = inc("screenKeyboard/screenKeyboard")(o); o.keyManager = inc("keyManager/keyManager")(o); o.onKey = inc("onKey/onKey")(o); o.calcSourceDiv = inc("calcSourceDiv/calc")(o); o.calcSpecialKeys = inc("calcSpecialKeys/calc")(o); o.createElements = inc("createElements/create")(o); o.getMathData = inc("getMathData/get")(o); o.setValue = inc("setValue/set")(o); o.getValue = inc("getValue/get")(o); o.start = inc("start/start")(o); o.finish = inc("finish/finish")(o); o.stop = inc("stop/stop")(o); o.enable = inc("enable/enable")(o); o.disable = inc("disable/disable")(o); o.eval = inc("eval/eval")(o); o.checkEquivalence = inc("checkEquivalence/check")(o); o.setTrigMode = inc("trigMode/set/set")(); o.getTrigMode = inc("trigMode/get/get")(); o.adjustLayout = inc("adjustLayout/adjust")(o); o.setColor = inc("setColor/set")(o); div = o.div; div.start = o.start; div.stop = o.stop; div.getValue = o.getValue; div.setValue = o.setValue; div.enable = o.enable; div.disable = o.disable; div.getMathData = o.getMathData; div.eval = o.eval; div.onKey = o.onKey; div.adjustLayout = o.adjustLayout; div.setColor = o.setColor; div.isStarted = function(){ return o.isStarted && o.div.isVisible(); }; div.isEnabled = function(){ return o.enabled; }; div.isDone = function(){ return o.isDone; }; div.gaps = function(){ return o.gaps; }; div.calcGapStringSolutions = inc("calcGapStringSolutions/calc")(o); div.calcCorrectValue = inc("calcCorrectValue/calc")(o); div.calcSyntax = inc("calcSyntax/calc")(o); div.calcSpecialKeys = o.calcSpecialKeys; div.checkEquivalence = o.checkEquivalence; if (o.mode === "calculator") { div.setTrigMode = o.setTrigMode; div.getTrigMode = o.getTrigMode; } if (o.convertTag) { inc("convertTag/convert")(o); } if (o.matsci && o.value != null) { o.value = _.replaceAll(o.value, "matsci", "mat"); } if (that = o.color) { requestAnimationFrame(function(){ return o.setColor(that); }); } o.setValue(o.value || ""); div.sourceDiv = o.sourceDiv; if (o.enabled) { o.enable(); } else { o.disable(); } return div; }; })(); mathDiv/onKey/_notAllowedChecks/afterInsert/containsNestedElements/check.ls (function(){ return function(element, elementTag, depth){ var recursiveClosest; recursiveClosest = function(element, depth){ var closestElement; closestElement = element.findFirst("." + elementTag); if (depth === 1 && closestElement != null) { return true; } else if (closestElement != null) { return recursiveClosest(closestElement, depth - 1); } else { return false; } }; if (element.hasClass(elementTag)) { depth--; } return recursiveClosest(element, depth); }; })(); mathDiv/onKey/_notAllowedChecks/afterInsert/isNestedElement/check.ls (function(){ return function(element, elementTag, depth){ var recursiveClosest; recursiveClosest = function(element, depth){ var closestElement; closestElement = element.closest("." + elementTag); if (depth === 0 && closestElement != null) { return true; } else if (closestElement != null) { return recursiveClosest(closestElement.parent(), depth - 1); } else { return false; } }; return recursiveClosest(element, depth); }; })(); mathDiv/onKey/_notAllowedChecks/beforeInsert/asciiExponents/check.ls (function(){ return function(o, cursor, value){ return in$(value, "⁰¹²³⁴⁵⁶⁷⁸⁹".split("")); }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/onKey/_notAllowedChecks/beforeInsert/nonNumbersUnderBar/check.ls (function(){ return function(o, cursor, value){ var mrow, bar, valueNotANumber; mrow = cursor.closest(".mrow"); bar = mrow != null ? mrow.closest(".mover") : void 8; if ((bar != null ? bar.overType : void 8) !== "bar") { return false; } valueNotANumber = !in$(value, "0123456789".split("")); return valueNotANumber; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/onKey/checkNotAllowedInsert/check.ls (function(){ return function(o, cursor, value){ if (inc("../_notAllowedChecks/beforeInsert/nonNumbersUnderBar/check")(o, cursor, value)) { return true; } if (inc("../_notAllowedChecks/beforeInsert/asciiExponents/check")(o, cursor, value)) { return true; } return false; }; })(); mathDiv/onKey/checkSmartInsert/check.ls (function(){ return function(o, cursor, value){ var fns, other, constants, all, el, prevMis, prevMisString, mi, v, mis, i$, len$; fns = ["log", "ln", "asin", "acos", "atan", "sin", "cos", "tan"]; other = ["sqrt", "root", "sup", "ncr", "bar", "lrarrow", "rarrow", "larrow"]; constants = ["pi"]; all = fns.concat(other, constants); el = cursor.parent(); prevMis = []; while (el) { if (!el.hasClass("mi")) { break; } prevMis.unshift(el); el = el.previousSibling; } prevMisString = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = prevMis).length; i$ < len$; ++i$) { mi = ref$[i$]; results$.push(mi.text().trim()); } return results$; }()).join("") + value; v = _.find(all, function(f){ return _.includes(prevMisString, f); }); if (!v) { return false; } mis = prevMis.slice(-v.length + 1); mis[0].previousSibling.startCursor("last"); for (i$ = 0, len$ = mis.length; i$ < len$; ++i$) { el = mis[i$]; el.remove(); } if (v === "pi") { return "π"; } else { return v; } }; })(); mathDiv/onKey/clear/clear.ls (function(){ return function(o){ return (typeof o.clear == 'function' ? o.clear() : void 8) || o.setValue(""); }; })(); mathDiv/onKey/insert/_notAllowedDiv/insert.ls (function(){ return function(c){ var mrow, redDiv; mrow = c.closest(".mrow") || c.closest(".mathDiv"); redDiv = Div({ position: "absolute", left: 0, right: 0, top: 0, bottom: 0, pointerEvents: "none", background: Color.red[100], opacity: 0.3 }).appendTo(mrow); return setTimeout(function(){ return redDiv.remove(); }, 200); }; })(); mathDiv/onKey/insert/abs/insert.ls (function(){ return function(o, c, v){ var mfenced; mfenced = o.createElement(document.createElement("mfenced").attr({ open: "|", close: "|" })); c.insert(mfenced); return mfenced.mrow.startCursor("first"); }; })(); mathDiv/onKey/insert/fenced/insert.ls (function(){ return function(o, c, v){ var mfenced; mfenced = o.createElement(document.createElement("mfenced").attr({ open: v[0], close: v[1] })); c.insert(mfenced); return mfenced.mrow.startCursor("first"); }; })(); mathDiv/onKey/insert/fn/insert.ls (function(){ return function(o, c, v){ var mfn, arg; mfn = o.createElement(document.createElement("mfn").html(v)); c.insert(mfn); arg = mfn.notation === "post" ? mfn.previousSibling : mfn.nextSibling; if ((arg != null && arg.hasClass("mathElement")) && !arg.hasClass("mo")) { mfn.wrapper.mrow1.setElements(arg); if (mfn.notation === "post") { mfn.startCursor("last"); } else { arg.startCursor("first"); } } else { if (mfn.operator === "logbase") { mfn.wrapper.base.mrow.startCursor("last"); } else { mfn.wrapper.mrow1.startCursor("last"); } } return o.adjustLayout(); }; })(); mathDiv/onKey/insert/fraction/insert.ls (function(){ return function(o, c, v){ var el, mfrac, prev; el = document.createElement("mfrac"); mfrac = o.createElement(el); c.insert(mfrac); if (inc("../../_notAllowedChecks/afterInsert/isNestedElement/check")(mfrac, "mfrac", 2)) { mfrac.remove(); inc("../_notAllowedDiv/insert")(c); return; } prev = mfrac.previousSibling; if (prev.hasClass("mathElement") && !prev.hasClass("mo")) { if (inc("../../_notAllowedChecks/afterInsert/containsNestedElements/check")(prev, "mfrac", 2)) { mfrac.remove(); inc("../_notAllowedDiv/insert")(c); return; } mfrac.wrapper.mrow1.firstChild.after(prev); el = mfrac.wrapper.mrow2.firstChild; } else { el = mfrac.wrapper.mrow1.firstChild; } el.startCursor("last"); return o.adjustLayout(); }; })(); mathDiv/onKey/insert/identifier/insert.ls (function(){ return function(o, c, v){ var mi; mi = o.createElement(document.createElement("mi").html(v)); c.insert(mi); return mi.lastChild.startCursor(); }; })(); mathDiv/onKey/insert/ncr/insert.ls (function(){ return function(o, c){ var mfenced, el, mfrac, prev, e; mfenced = o.createElement(document.createElement("mfenced").attr({ open: "(", close: ")" })); el = document.createElement("mfrac"); el.attr("linethickness", "0"); mfrac = o.createElement(el); mfenced.mrow.setElements(mfrac); c.insert(mfenced); if (inc("../../_notAllowedChecks/afterInsert/isNestedElement/check")(mfrac, "mfrac", 1)) { mfenced.remove(); inc("../_notAllowedDiv/insert")(c); return; } prev = mfenced.previousSibling; if (prev.hasClass("mathElement") && prev.hasClass("mn")) { mfrac.wrapper.mrow1.firstChild.after(prev); e = mfrac.wrapper.mrow2.firstChild; } else { e = mfrac.wrapper.mrow1.firstChild; } e.startCursor("last"); return o.adjustLayout(); }; })(); mathDiv/onKey/insert/number/insert.ls (function(){ return function(o, c, v){ var mn; mn = o.createElement(document.createElement("mn").html(v)); c.insert(mn); return mn.lastChild.startCursor(); }; })(); mathDiv/onKey/insert/operator/insert.ls (function(){ return function(o, c, v){ var mo; mo = o.createElement(document.createElement("mo").html(v)); c.insert(mo); return mo.lastChild.startCursor(); }; })(); mathDiv/onKey/insert/over/insert.ls (function(){ return function(o, c, v){ var type, mover, next, prev; type = (function(){ switch (v) { case "bar": return "‾"; case "rarrow": return "→"; case "larrow": return "←"; case "lrarrow": return "↔"; } }()); mover = o.createElement(document.createElement("mover").html(document.createElement("mo").html(type))); c.insert(mover); if (inc("../../_notAllowedChecks/afterInsert/isNestedElement/check")(mover, "mover", 1)) { mover.remove(); inc("../_notAllowedDiv/insert")(c); return; } next = mover.nextSibling; prev = mover.previousSibling; if ((next != null && next.hasClass("mn")) && (prev != null && prev.hasClass("mn")) && in$(prev.lastChild.innerHTML[0], ",.0123456789".split(""))) { mover.wrapper.mrow1.setElements(next); return next.startCursor("first"); } else { return mover.wrapper.mrow1.startCursor("last"); } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/onKey/insert/root/insert.ls (function(){ return function(o, c){ var mroot, next; mroot = o.createElement("mroot"); c.insert(mroot); if (inc("../../_notAllowedChecks/afterInsert/isNestedElement/check")(mroot, "mroot", 3)) { mroot.remove(); inc("../_notAllowedDiv/insert")(c); return; } next = mroot.nextSibling; if ((next != null && next.hasClass("mathElement")) && !next.hasClass("mo")) { if (inc("../../_notAllowedChecks/afterInsert/containsNestedElements/check")(next, "mroot", 3)) { mroot.remove(); inc("../_notAllowedDiv/insert")(c); return; } mroot.mrow.setElements(next); return next.startCursor("first"); } else { return mroot.exp.mrow.startCursor("last"); } }; })(); mathDiv/onKey/insert/sqrt/insert.ls (function(){ return function(o, c){ var msqrt, next; msqrt = o.createElement("msqrt"); c.insert(msqrt); if (inc("../../_notAllowedChecks/afterInsert/isNestedElement/check")(msqrt, "msqrt", 3)) { msqrt.remove(); inc("../_notAllowedDiv/insert")(c); return; } next = msqrt.nextSibling; if ((next != null && next.hasClass("mathElement")) && !next.hasClass("mo")) { if (inc("../../_notAllowedChecks/afterInsert/containsNestedElements/check")(next, "msqrt", 3)) { msqrt.remove(); inc("../_notAllowedDiv/insert")(c); return; } msqrt.mrow.setElements(next); return next.startCursor("first"); } else { return msqrt.mrow.startCursor("last"); } }; })(); mathDiv/onKey/insert/sub/insert.ls (function(){ return function(o, c){ var msub, prev, mfencedElements; if (inc("../_notAllowed/notAllowed")(c, "msub")) { return; } msub = o.createElement("msub"); c.insert(msub); prev = msub.previousSibling; if (prev.hasClass("mn") || prev.hasClass("mi") || prev.hasClass("mfrac")) { msub.wrapper.mrow1.setElements(prev); msub.wrapper.mrow2.startCursor("last"); } else if (prev.hasClass("mfenced")) { mfencedElements = prev.mrow.getElements(); msub.wrapper.mrow1.setElements(mfencedElements); msub.wrapper.mrow2.startCursor("last"); prev.remove(); } else { msub.wrapper.mrow1.startCursor("last"); } return o.adjustLayout(); }; })(); mathDiv/onKey/insert/subFilled/insert.ls (function(){ return function(o, c, v){ var msub, createChild, v0, v1; msub = o.createElement("msub"); c.insert(msub); createChild = function(s){ var mn, mi; if (_.includes("0123456789.", s)) { return mn = o.createElement(document.createElement("mn").html(s)); } else { return mi = o.createElement(document.createElement("mi").html(s)); } }; if (v) { v0 = v.split("_")[0]; v1 = v.split("_")[1]; msub.wrapper.mrow1.setElements(createChild(v0)); msub.wrapper.mrow2.setElements(createChild(v1)); } o.adjustLayout(); return msub.blinkerEnd.startCursor(); }; })(); mathDiv/onKey/insert/sup/insert.ls (function(){ return function(o, c){ var msup, prev; msup = o.createElement("msup"); c.insert(msup); if (inc("../../_notAllowedChecks/afterInsert/isNestedElement/check")(msup, "msup", 2)) { msup.remove(); inc("../_notAllowedDiv/insert")(c); return; } prev = msup.previousSibling; if (_.some(["mn", "mi", "mfrac", "msub", "mfenced", "mfn"], function(c){ return prev.hasClass(c); })) { msup.wrapper.mrow1.setElements(prev); msup.wrapper.mrow2.startCursor("last"); } else { msup.wrapper.mrow1.startCursor("last"); } return o.adjustLayout(); }; })(); mathDiv/onKey/onKey.ls (function(){ return function(o){ return function(value, special){ var v, c, ref$, ref1$, ref2$, ref3$, smartInsert; v = value; c = o.cursorElement; if (!c) { return; } if (v.trim() === "") { return; } if (!special) { if ((ref$ = o.currentGap) != null) { ref$.selection['delete'](); } } if (!special && inc("checkNotAllowedInsert/check")(o, c, v)) { inc("insert/_notAllowedDiv/insert")(c); return; } if (_.includes("0123456789.", v)) { inc("insert/number/insert")(o, c, v); } else if (v === ",") { inc("insert/number/insert")(o, c, "."); } else if (_.includes('+-*÷=<>', v)) { inc("insert/operator/insert")(o, c, v); } else if (v === "ncr") { inc("insert/ncr/insert")(o, c); } else if (v === "fraction" || v === "/") { inc("insert/fraction/insert")(o, c, v); } else if (v === "sup") { inc("insert/sup/insert")(o, c); } else if (_.includes(v, "_")) { inc("insert/subFilled/insert")(o, c, v); } else if (v === "()" || v === "[]" || v === "{}") { inc("insert/fenced/insert")(o, c, v); } else if (v === "abs") { inc("insert/abs/insert")(o, c); } else if (v === "sqrt") { inc("insert/sqrt/insert")(o, c); } else if (v === "root") { inc("insert/root/insert")(o, c); } else if (v === "bar" || v === "rarrow" || v === "larrow" || v === "lrarrow") { inc("insert/over/insert")(o, c, v); } else if (in$(v, "sin cos tan asin acos atan log logbase ln !".split(" "))) { inc("insert/fn/insert")(o, c, v); } else if (v === "clear") { inc("clear/clear")(o); } else if (v === "back") { if ((ref1$ = o.currentGap) != null) { ref1$.selection['delete'](); } if (c != null) { c.back(); } } else if (v === "moveCursorLeft") { if ((ref2$ = o.currentGap) != null) { ref2$.selection.unselect(); } if (c != null) { c.left(); } } else if (v === "moveCursorRight") { if ((ref3$ = o.currentGap) != null) { ref3$.selection.unselect(); } if (c != null) { c.right(); } } else if (v === "enter" || v === "submit") { inc("submit/submit")(o); } else if (!special) { if (engine.isDebug && (smartInsert = inc("checkSmartInsert/check")(o, c, v))) { o.onKey(smartInsert); } else { inc("insert/identifier/insert")(o, c, v); } } else { inc("insert/_notAllowedDiv/insert")(c); } return o.adjustLayout(); }; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } mathDiv/onKey/submit/submit.ls (function(){ return function(o){ var ref$; return (typeof o.submit == 'function' ? o.submit() : void 8) || ((ref$ = o.currentGap) != null ? ref$.submit() : void 8); }; })(); mathDiv/screenKeyboard/keyboardHeader/_div/div.ls (function(){ return function(html){ return Div({ display: "flex", flex: "0 1 auto", padding: "0.3em 0.6em" }).html(Div({ flex: "1 1 auto", whiteSpace: "nowrap", textAlign: "center" }).html(html)); }; })(); mathDiv/screenKeyboard/keyboardHeader/arrows/arrows.ls (function(){ return function(o, hideSubmit){ var css; css = { borderRadius: "5px", overflow: "visible", backgroundColor: Color.grey[200], padding: hideSubmit ? "0.5em 1em" : "0.5em" }; return Div({ display: "flex", flex: "0 1 auto", alignItems: "stretch", marginRight: !hideSubmit ? "0.8em" : void 8 }).append(Button("←").css({ marginRight: "0.4em" }).css(css).tap(function(){ return o.onKey("moveCursorLeft", true); }), Button("→").css(css).tap(function(){ return o.onKey("moveCursorRight", true); })); }; })(); mathDiv/screenKeyboard/keyboardHeader/header.ls (function(){ return function(o){ var template, hideSubmit, hideArrows, hideHeader; template = inc("/../app01/lib/gui/screenKeyboard/_templates/templates")[o.keyboardLayout]; hideSubmit = _.includes(template != null ? template.main.join("|") : void 8, "submit"); hideArrows = o.matLayout.hideArrows; hideHeader = hideArrows && _.isEmpty(o.specialKeys) && o.keyboardLayout === "mathDivNumbers"; return function(screenKeyboard){ var div; div = Div({ display: "flex", minHeight: "2.5em", alignItems: "stretch", padding: "4px" }).addClass("keyboardHeader").html(inc("specialKeys/specialKeys")(o), inc("spacer/spacer")(), !hideArrows ? inc("arrows/arrows")(o, hideSubmit) : void 8, !hideSubmit ? inc("submit/submit")(o) : void 8); if (hideHeader) { div.hide(); } return div; }; }; })(); mathDiv/screenKeyboard/keyboardHeader/spacer/spacer.ls (function(){ return function(){ return Div({ flex: "0 1 auto" }); }; })(); mathDiv/screenKeyboard/keyboardHeader/specialKeys/specialKeys.ls (function(){ return function(o){ var specialKeys, div, k; specialKeys = o.specialKeys; return div = Div({ display: "flex", justifyContent: "flex-start", flex: "1 1 auto", flexWrap: "wrap" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.sortBy(_.keys(specialKeys))).length; i$ < len$; ++i$) { k = ref$[i$]; results$.push(specialKeys[k]); } return results$; }())); }; })(); mathDiv/screenKeyboard/keyboardHeader/submit/submit.ls (function(){ return function(o){ return inc("../_div/div")(T("check")).css({ backgroundColor: Color.grey[200], width: "6em", borderRadius: "5px" }).tap(function(){ return o.onKey("submit", true); }); }; })(); mathDiv/screenKeyboard/screenKeyboard.ls (function(){ return function(o){ var parent, create; parent = null; create = function(){ var screenKeyboard; parent = o.keyboardParentDiv || app.currentPage.bottom; if (o.keyboardParentDiv) { parent.addClass("keyboardParentDiv"); } parent.addClass("safeAreaPaddingLeft").addClass("safeAreaPaddingRight").addClass("safeAreaPaddingBottom"); parent.append(screenKeyboard = inc("/../app01/lib/gui/screenKeyboard/keyboard")({ onKey: o.onKey, input: o.div, layout: o.keyboardLayout, keyboardHeader: o.showKeyboardHeader ? inc("keyboardHeader/header")(o) : void 8, shiftStatus: false, submitLabel: o.keyboardSubmitLabel, showNewLine: false, showSubmit: true }).show()).show(); screenKeyboard.css({ maxWidth: "40em", margin: "0 auto" }); return o.div.screenKeyboard = screenKeyboard; }; return { start: function(){ if (!o.div.screenKeyboard) { create(); } return o.div.screenKeyboard.start(); }, stop: function(){ var ref$, ref1$; return (ref$ = o.div) != null ? (ref1$ = ref$.screenKeyboard) != null ? ref1$.stop() : void 8 : void 8; } }; }; })(); mathDiv/setColor/set.ls (function(){ return function(o){ return function(color, div){ var i$, ref$, len$, el, results$ = []; div == null && (div = o.div); div.css({ color: color }); for (i$ = 0, len$ = (ref$ = div.findAll(".feedbackColor")).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(el.setFeedbackColor(color)); } return results$; }; }; })(); mathDiv/setValue/addClickPadding/add.ls (function(){ return function(o){ var add; add = function(){ var ref$, ref1$; if ((ref$ = o.div.parent()) != null && ref$.hasClass("mixed")) { return; } if (((ref1$ = _.last(o.elements)) != null && ref1$.hasClass("mgap")) && o.mode === "write") { return o.div.css({ padding: "0 0.5em" }); } }; return o.div.onDomAppend(add); }; })(); mathDiv/setValue/disableNonGaps/calcDisable/calc.ls (function(){ return function(el){ var p; if (el.hasClass("mgap")) { return false; } if (el.findAll(".mgap").length > 0) { return false; } p = el.parent(); while (p) { if (p.hasClass("mathDiv")) { return true; } else if (p.hasClass("mgap")) { return false; } p = p.parent(); } return true; }; })(); mathDiv/setValue/disableNonGaps/disable.ls (function(){ return function(o){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = o.div.findAll(".cursorSupport")).length; i$ < len$; ++i$) { el = ref$[i$]; if (inc("calcDisable/calc")(el)) { results$.push(el.css({ pointerEvents: "none" })); } } return results$; }; })(); mathDiv/setValue/set.ls (function(){ return function(o){ return function(value){ var i$, ref$, len$, i, el; if (value.match(/[0-9],[0-9]/)) { debug("ACHTUNG: In Mat-tags bitte nicht ',' als Dezimalseparator verwenden sondern '.'"); } o.value = value; o.calcSourceDiv(); o.createElements(); inc("addClickPadding/add")(o); if (o.div.isVisible()) { o.adjustLayout(); } else { o.div.onDomAppendAndVisible(function(){ return o.adjustLayout(); }); } o.gaps = o.div.findAll(".mgap"); for (i$ = 0, len$ = (ref$ = o.gaps).length; i$ < len$; ++i$) { i = i$; el = ref$[i$]; el.gapIndex = i; el.addClass("gap" + i); } if (o.gaps.length > 0) { o.isDone = false; return inc("disableNonGaps/disable")(o); } else if (o.isStarted) { return o.div.endDiv.startCursor(); } }; }; })(); mathDiv/start/start.ls (function(){ return function(o){ return function(){ var ref$, ref1$, ref2$; if (o.gaps.length === 0 && ((ref$ = o.mode) === "buttons" || ref$ === "write")) { if (typeof o.onFinish == 'function') { o.onFinish(); } return; } if (!o.enabled) { return; } if (!o.div.isVisible()) { return; } if (((ref$ = body.findFirst(".gapWriteMistakeHint")) != null && ref$.isVisible()) && body.findFirst(".bottomMessage") == null) { return; } if ((ref1$ = o.slide) != null && ref1$.levelPlayer.currentGap) { return; } inc("updateAppLastInput/update")(o); if ((ref2$ = o.mode) === "mathFormula" || ref2$ === "write") { o.specialKeys = o.calcSpecialKeys(); } if ((ref2$ = o.mode) === "write" || ref2$ === "mathFormula" || ref2$ === "calculator") { o.screenKeyboard.start(); o.keyManager.start(); } else if (o.mode === "buttons") { if ((ref2$ = o.buttonsDiv) != null) { ref2$.parent().show(); } } o.isStarted = true; o.adjustLayout(); if (!o.cursorElement) { if (o.gaps.length > 0) { inc("startNextGap/start")(o); } else { o.div.endDiv.startCursor(); } } if (typeof o.onStart == 'function') { o.onStart(); } return o.div; }; }; })(); mathDiv/start/startNextGap/start.ls (function(){ return function(o){ var nextGap; nextGap = _.find(o.gaps, function(g){ return !g.gapIsCompleted; }); if (o.currentGap && !o.currentGap.gapIsCompleted) { return o.currentGap.start(); } else if (nextGap) { return nextGap.start(); } else { return o.finish(); } }; })(); mathDiv/start/updateAppLastInput/update.ls (function(){ return function(o){ var lastInput, lastPopupInput, ref$, ref1$; lastInput = app.lastInput; if (lastInput && lastInput !== o.div) { lastInput.stop(); } lastPopupInput = app.lastPopupInput; if (lastPopupInput && lastPopupInput !== o.div) { lastPopupInput.stop(); } if (!((ref$ = app.currentPopup) != null && ref$.contains(o.div))) { return app.lastInput = o.div; } else if ((ref1$ = app.currentPopup) != null && ref1$.contains(o.div)) { return app.lastPopupInput = o.div; } }; })(); mathDiv/stop/stop.ls (function(){ return function(o){ return function(){ var ref$, ref1$; if (!o.isStarted) { return; } if ((ref$ = o.cursorElement) != null) { ref$.stopCursor(); } o.screenKeyboard.stop(); o.keyManager.stop(); o.isStarted = false; if ((ref1$ = app.currentPage.levelPlayer) != null) { ref1$.currentGap = undefined; } if (typeof o.onStop == 'function') { o.onStop(); } return o.div; }; }; })(); mathDiv/trigMode/get/get.ls (function(){ return function(){ return function(){ var key, value; key = "mathDivCalculatorTrigMode"; value = inc("/../app01/lib/util/cache/get/get")(key); if (value == null) { value = "deg"; inc("/../app01/lib/util/cache/set/set")(key, value); } return value; }; }; })(); mathDiv/trigMode/set/set.ls (function(){ return function(){ return function(v){ if (v !== "deg" && v !== "rad") { debug("trigMode value " + v + " not valid"); return; } return inc("/../app01/lib/util/cache/set/set")("mathDivCalculatorTrigMode", v); }; }; })();