3836,6,154,8,90,57,1464,59,3998,60,1306,60,8158,65,663,71,291,65,191,69,288,72,644,67,2087,53,1155,62,162,61,365,57,168,59,277,34,190,36,866,46,235,61,2277,46,316,85,133,89,157,86,243,77,343,62,415,62,597,60,610,82,621,68,243,102,308,68,263,70,195,102,571,106,134,102,245,98,590,98,241,91,488,66,309,66,309,84,447,101,202,68,265,64,308,70,361,64,308,68,349,62,257,66,278,66,533,80,656,66,420,81,252,95,595,74,75,81,77,76,370,92,345,90,122,76,91,93,302,75,82,78,419,74,664,64,481,73,121,77,334,84,130,93,826,76,991,91,225,91,303,90,346,92,619,91,91,91,97,95,392,109,532,91,84,95,320,91,361,91,84,92,164,92,205,90,94,96,227,87,429,90,92,90,92,89,429,92,523,89,93,78,310,83,631,77,280,83,371,84,529,84,323,94,270,77,246,95,578,48,368,86,240,103,308,64,275,38,129,47,342,14,562,34,714,49,483,46,189,71,217,85,596,52,215,54,183,62,295,80,321,56,461,85,334,86,169,105,447,76,727,79,574,61,799,58,522,76,756,62,799,44,516,29,334,59,334,46,173,66,1053,80,346,79,286,79,274,78,275,72,1063,87,404,86,287,89,406,88,289,51,133,55,240,65,463,64,536,33,753,54,399,75,416,68,400,49,457,55,552,66,351,48,209,36,451,32,581,63,280,41,908,61,348,63,297,65,310,67,393,61,567,69,292,66,230,78,404,46,451,60,472,56,220,50,353,55,329,45,182,70,268,55,902,49,131,67,97,71,260,74,761,67,113,78,97,73,214,71,84,54,81,48,550,65,115,60,190,58,332,56,206,67,116,62,189,60,338,52,555,55,627,46,702,66,378,69,333,68,797,68,117,65,255,56,995,48,378,40,818,78,215,46,216,70,543,53,247,50,244,57,435,65,344,52,416,50,684,34,77,41,670,47,280,52,262,47,181,50,259,43,494,54,160,41,283,48,307,41,726,47,70,53,185,48,183,53,583,48,183,41,397,48,548,56,136,48,131,55,240,41,308,49,185,62,385,48,641,50,230,58,485,58,243,40,390,47,361,48,189,40,350,48,193,47,551,41,778,47,70,53,208,48,183,53,82,48,183,53,82,48,183,43,470,51,75,50,581,51,75,32,1349,38,304,45,118,47,139,55,176,40,513,49,312,49,223,38,274,45,538,48,238,45,259,38,253,46,87,42,486,55,287,67,197,61,86,49,171,38,382,51,166,45,231,48,140,51,213,42,356,55,141,49,534,38,523,45,299,38,451,45,310,52,152,52,223,46,76,39,470,55,159,57,158,46,450,33,578,51,594,51,136,38,1171,47,420,47,265,79,268,80,411,91,383,116,424,71,487,60,211,58,223,65,286,49,373,47,267,61,726,82,333,105,370,74,131,84,240,69,157,92,370,89,206,68,421,68,579,77,266,62,1104,66,339,107,402,107,170,92,267,99,238,98,76,85,641,88,256,97,178,122,313,109,603,97,717,66,506,60,783,40,69,44,309,40,291,44,166,54,382,40,263,33,1101,48,374,58,316,40,650,44,375,41,128,58,220,58,442,60,409,46,158,44,520,74,462,41,847,48,234,52,400,71,284,58,609,59,540,52,539,56,547,38,429,45,159,49,164,45,197,49,527,38,571,45,289,49,339,49,539,44,120,33,256,42,615,51,222,56,451,34,121,45,399,39,241,45,499,19,367,32,2099,47,281,47,222,21,637,34,98,46,522,52,1282,46,138,38,259,37,1283,43,296,32,312,30,129,55,179,69,484,65,706,77,522,77,125,80,138,107,255,86,469,85,463,81,1448,54,297,60,303,34,307,46,130,49,947,69,557,71,181,58,482,62,719,73,337,63,971,73,184,29,158,37,151,36,158,34,309,46,227,54,378,63,267,46,374,51,657,53,583,27,272,29,461,29,935,29,539,33,259,19,4786,39,123,39,95,41,106,38,178,32,539,50,146,44,295,66,409,49,221,60,428,68,335,48,249,55,449,69,254,51,515,56,521,65,1050,71,266,50,710,66,440,47,299,41,187,31,2175,48,347,65,425,53,257,57,155,89,711,82,543,90,1041,76,530,65,409,58,544,48,347,35,156,20,317,53,425,57,168,32,283,20,211,47,173,48,205,36,694,59,324,59,216,52,162,56,442,59,372,52,159,61,306,61,73,54,144,47,1103,73,190,69,257,64,884,81,470,71,301,67,593,51,867,56,284,57,536,47,389,80,416,60,401,77,707,62,1570,71,345,73,553,79,553,38,359,36,117,29,1124,36,216,54,356,48,326,28,342,25,427,34,605,36,115,42,227,28,297,24,110,26,423,33,193,34,175,35,171,35,146,28,248,24,638,23,575,43,377,37,128,21,520,31,179,25,486,25,196,36,69,36,76,47,948,56,318,52,91,54,212,48,359,37,373,63,465,62,306,67,276,55,795,52,222,60,694,61,354,46,520
_info
{"project":"math-div2","branch":"master","version":157,"versionDate":"2024-05-31T09:43:49.000Z","fromVersion":0,"reset":true,"checksumDocs":"546-260001"}
init.ls
(function(){
return function(){
return window.MathDiv2 = inc("mathDiv/mathDiv");
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMgetSymbol/get.ls
(function(){
return function(am, str){
var k, j, match2, more, mk, st, tagst, i, integ, obj1, obj2;
k = 0;
j = 0;
match2 = "";
more = true;
mk = undefined;
st = undefined;
tagst = undefined;
i = 1;
while (i <= str.length && more) {
st = str.slice(0, i);
j = k;
k = am.position(am.AMnames, st, j);
if (k < am.AMnames.length && str.slice(0, am.AMnames[k].length) === am.AMnames[k]) {
match2 = am.AMnames[k];
mk = k;
i = match2.length;
}
more = k < am.AMnames.length && str.slice(0, am.AMnames[k].length) >= am.AMnames[k];
i++;
}
am.AMpreviousSymbol = am.AMcurrentSymbol;
if (match2 !== "") {
am.AMcurrentSymbol = am.AMsymbols[mk].ttype;
return am.AMsymbols[mk];
}
am.AMcurrentSymbol = am.CONST;
k = 1;
st = str.slice(0, 1);
integ = true;
while (("0" <= st && st <= "9" || st === am.decimalsign) && k <= str.length) {
st = str.slice(k, k + 1);
k++;
}
if (st === am.decimalsign) {
st = str.slice(k, k + 1);
if ("0" <= st && st <= "9") {
integ = false;
k++;
while ("0" <= st && st <= "9" && k <= str.length) {
st = str.slice(k, k + 1);
k++;
}
}
}
if (integ && k > 1 || k > 2) {
st = str.slice(0, k - 1);
tagst = "mn";
} else {
k = 2;
st = str.slice(0, 1);
tagst = "mi";
}
if (st === "-" && str.charAt(1) !== ' ' && am.AMpreviousSymbol === am.INFIX) {
am.AMcurrentSymbol = am.INFIX;
obj1 = {
input: st,
tag: tagst,
output: st,
ttype: am.UNARY,
func: true
};
return obj1;
}
obj2 = {
input: st,
tag: tagst,
output: st,
ttype: am.CONST,
func: true
};
return obj2;
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMparseExpr/parse.ls
(function(){
return function(am, str, rightbracket){
var newFrag, result, node, symbol, len, right, left, pos, matrix, m, i, j, columnlines, row, frag, n, k, table;
newFrag = document.createDocumentFragment();
for (;;) {
str = am.AMremoveCharsAndBlanks(str, 0);
result = am.AMparseIexpr(str);
node = result[0];
str = result[1];
symbol = am.AMgetSymbol(str);
if (symbol.ttype === am.INFIX && symbol.input === '/') {
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseIexpr(str);
if (result[0] === null) {
result[0] = am.createMmlNode('mo', document.createTextNode('□'));
} else {
am.AMremoveBrackets(result[0]);
}
str = result[1];
am.AMremoveBrackets(node);
node = am.createMmlNode(symbol.tag, node);
node.appendChild(result[0]);
newFrag.appendChild(node);
symbol = am.AMgetSymbol(str);
} else if (node) {
newFrag.appendChild(node);
}
if (!((symbol.ttype !== am.RIGHTBRACKET && (symbol.ttype !== am.LEFTRIGHT || rightbracket) || am.AMnestingDepth === 0) && symbol !== null && symbol.output !== '')) {
break;
}
}
if (symbol.ttype === am.RIGHTBRACKET || symbol.ttype === am.LEFTRIGHT) {
len = newFrag.childNodes.length;
if (len > 0 && newFrag.childNodes[len - 1].nodeName === 'mrow' && newFrag.childNodes[len - 1].lastChild && newFrag.childNodes[len - 1].lastChild.firstChild) {
right = newFrag.childNodes[len - 1].lastChild.firstChild.nodeValue;
if (right === ')' || right === ']') {
left = newFrag.childNodes[len - 1].firstChild.firstChild.nodeValue;
if (left === '(' && right === ')' && symbol.output !== '}' || left === '[' && right === ']') {
pos = [];
matrix = true;
m = newFrag.childNodes.length;
i = 0;
while (matrix && i < m) {
pos[i] = [];
node = newFrag.childNodes[i];
if (matrix) {
matrix = node.nodeName === 'mrow' && (i === m - 1 || node.nextSibling.nodeName === 'mo' && node.nextSibling.firstChild.nodeValue === ',') && node.firstChild.firstChild && node.firstChild.firstChild.nodeValue === left && node.lastChild.firstChild && node.lastChild.firstChild.nodeValue === right;
}
if (matrix) {
j = 0;
while (j < node.childNodes.length) {
if (node.childNodes[j].firstChild.nodeValue === ',') {
pos[i][pos[i].length] = j;
}
j++;
}
}
if (matrix && i > 1) {
matrix = pos[i].length === pos[i - 2].length;
}
i = i + 2;
}
matrix = matrix && (pos.length > 1 || pos[0].length > 0);
columnlines = [];
if (matrix) {
row = undefined;
frag = undefined;
n = undefined;
k = undefined;
table = document.createDocumentFragment();
i = 0;
while (i < m) {
row = document.createDocumentFragment();
frag = document.createDocumentFragment();
node = newFrag.firstChild;
n = node.childNodes.length;
k = 0;
node.removeChild(node.firstChild);
j = 1;
while (j < n - 1) {
if (typeof pos[i][k] !== 'undefined' && j === pos[i][k]) {
node.removeChild(node.firstChild);
if (node.firstChild.nodeName === 'mrow' && node.firstChild.childNodes.length === 1 && node.firstChild.firstChild.firstChild.nodeValue === '∣') {
if (i === 0) {
columnlines.push('solid');
}
node.removeChild(node.firstChild);
node.removeChild(node.firstChild);
j += 2;
k++;
} else if (i === 0) {
columnlines.push('none');
}
row.appendChild(am.createMmlNode('mtd', frag));
k++;
} else {
frag.appendChild(node.firstChild);
}
j++;
}
row.appendChild(am.createMmlNode('mtd', frag));
if (i === 0) {
columnlines.push('none');
}
if (newFrag.childNodes.length > 2) {
newFrag.removeChild(newFrag.firstChild);
newFrag.removeChild(newFrag.firstChild);
}
table.appendChild(am.createMmlNode('mtr', row));
i = i + 2;
}
node = am.createMmlNode('mtable', table);
node.setAttribute('columnlines', columnlines.join(' '));
if (typeof symbol.invisible === 'boolean' && symbol.invisible) {
node.setAttribute('columnalign', 'left');
}
newFrag.replaceChild(node, newFrag.firstChild);
}
}
}
}
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
if (typeof symbol.invisible !== 'boolean' || !symbol.invisible) {
node = am.createMmlNode('mo', document.createTextNode(symbol.output));
newFrag.appendChild(node);
}
}
return [newFrag, str];
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMparseIexpr/parse.ls
(function(){
return function(am, str){
var sym1, result, node, symbol, underover, sym2, res2;
str = am.AMremoveCharsAndBlanks(str, 0);
sym1 = am.AMgetSymbol(str);
result = am.AMparseSexpr(str);
node = result[0];
str = result[1];
symbol = am.AMgetSymbol(str);
if (symbol.ttype === am.INFIX && symbol.input !== '/') {
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseSexpr(str);
if (result[0] === null) {
result[0] = am.createMmlNode('mo', document.createTextNode('□'));
} else {
am.AMremoveBrackets(result[0]);
}
str = result[1];
underover = sym1.ttype === am.UNDEROVER || sym1.ttype === am.UNARYUNDEROVER;
if (symbol.input === '_') {
sym2 = am.AMgetSymbol(str);
if (sym2.input === '^') {
str = am.AMremoveCharsAndBlanks(str, sym2.input.length);
res2 = am.AMparseSexpr(str);
am.AMremoveBrackets(res2[0]);
str = res2[1];
node = am.createMmlNode(underover ? 'munderover' : 'msubsup', node);
node.appendChild(result[0]);
node.appendChild(res2[0]);
} else {
node = am.createMmlNode(underover ? 'munder' : 'msub', node);
node.appendChild(result[0]);
}
} else if (symbol.input === '^' && underover) {
node = am.createMmlNode('mover', node);
node.appendChild(result[0]);
} else {
node = am.createMmlNode(symbol.tag, node);
node.appendChild(result[0]);
}
}
return [node, str];
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMparseSexpr/parse.ls
(function(){
return function(am, str){
var newFrag, symbol, result, node, c, i, st, accnode, newst, j, result2;
newFrag = document.createDocumentFragment();
str = am.AMremoveCharsAndBlanks(str, 0);
symbol = am.AMgetSymbol(str);
if (symbol === null || symbol.ttype === am.RIGHTBRACKET && am.AMnestingDepth > 0) {
return [null, str];
}
if (symbol.ttype === am.DEFINITION) {
str = symbol.output + am.AMremoveCharsAndBlanks(str, symbol.input.length);
symbol = am.AMgetSymbol(str);
}
switch (symbol.ttype) {
case am.UNDEROVER:
case am.CONST:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
return [am.createMmlNode(symbol.tag, document.createTextNode(symbol.output)), str];
case am.LEFTBRACKET:
am.AMnestingDepth++;
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseExpr(str, true);
am.AMnestingDepth--;
if (typeof symbol.invisible === 'boolean' && symbol.invisible) {
node = am.createMmlNode('mrow', result[0]);
} else {
node = am.createMmlNode('mo', document.createTextNode(symbol.output));
node = am.createMmlNode('mrow', node);
node.appendChild(result[0]);
}
return [node, result[1]];
case am.TEXT:
c = str.charAt(0);
if (c === '{') {
i = str.indexOf('}');
} else if (c === '(') {
i = str.indexOf(')');
} else if (c === '[') {
i = str.indexOf(']');
} else {
i = str.slice(1).indexOf(symbol.input) + 1;
}
if (i === -1) {
i = str.length;
}
st = str.slice(1, i);
if (st.charAt(0) === ' ') {
node = am.createMmlNode('mspace');
node.setAttribute('width', '1ex');
newFrag.appendChild(node);
}
newFrag.appendChild(am.createMmlNode(symbol.tag, document.createTextNode(st)));
if (st.charAt(st.length - 1) === ' ') {
node = am.createMmlNode('mspace');
node.setAttribute('width', '1ex');
newFrag.appendChild(node);
}
str = am.AMremoveCharsAndBlanks(str, i + 1);
return [am.createMmlNode('mrow', newFrag), str];
case am.UNARYUNDEROVER:
case am.UNARY:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseSexpr(str);
if (result[0] === null) {
if (symbol.tag === 'mi' || symbol.tag === 'mo') {
return [am.createMmlNode(symbol.tag, document.createTextNode(symbol.output)), str];
} else {
result[0] = am.createMmlNode('mi', '');
}
}
if (typeof symbol.func === 'boolean' && symbol.func) {
st = str.charAt(0);
if (st === '^' || st === '_' || st === '/' || st === '|' || st === ',' || symbol.input.length === 1 && symbol.input.match(/\w/) && st !== '(') {
return [am.createMmlNode(symbol.tag, document.createTextNode(symbol.output)), str];
} else {
node = am.createMmlNode('mrow', am.createMmlNode(symbol.tag, document.createTextNode(symbol.output)));
node.appendChild(result[0]);
return [node, result[1]];
}
}
am.AMremoveBrackets(result[0]);
if (symbol.input === 'sqrt') {
return [am.createMmlNode(symbol.tag, result[0]), result[1]];
} else if (typeof symbol.rewriteleftright !== 'undefined') {
node = am.createMmlNode('mrow', am.createMmlNode('mo', document.createTextNode(symbol.rewriteleftright[0])));
node.appendChild(result[0]);
node.appendChild(am.createMmlNode('mo', document.createTextNode(symbol.rewriteleftright[1])));
return [node, result[1]];
} else if (symbol.input === 'cancel') {
node = am.createMmlNode(symbol.tag, result[0]);
node.setAttribute('notation', 'updiagonalstrike');
return [node, result[1]];
} else if (typeof symbol.acc === 'boolean' && symbol.acc) {
node = am.createMmlNode(symbol.tag, result[0]);
accnode = am.createMmlNode('mo', document.createTextNode(symbol.output));
if (symbol.input === 'vec' && (result[0].nodeName === 'mrow' && result[0].childNodes.length === 1 && result[0].firstChild.firstChild.nodeValue !== null && result[0].firstChild.firstChild.nodeValue.length === 1 || result[0].firstChild && result[0].firstChild.nodeValue !== null && result[0].firstChild.nodeValue.length === 1)) {
accnode.setAttribute('stretchy', false);
}
node.appendChild(accnode);
return [node, result[1]];
} else {
if (typeof symbol.codes !== 'undefined') {
i = 0;
while (i < result[0].childNodes.length) {
if (result[0].childNodes[i].nodeName === 'mi' || result[0].nodeName === 'mi') {
st = result[0].nodeName === 'mi'
? result[0].firstChild.nodeValue
: result[0].childNodes[i].firstChild.nodeValue;
newst = [];
j = 0;
while (j < st.length) {
if (st.charCodeAt(j) > 64 && st.charCodeAt(j) < 91) {
newst = newst + symbol.codes[st.charCodeAt(j) - 65];
} else if (st.charCodeAt(j) > 96 && st.charCodeAt(j) < 123) {
newst = newst + symbol.codes[st.charCodeAt(j) - 71];
} else {
newst = newst + st.charAt(j);
}
j++;
}
if (result[0].nodeName === 'mi') {
result[0] = am.createMmlNode('mo').appendChild(document.createTextNode(newst));
} else {
result[0].replaceChild(am.createMmlNode('mo').appendChild(document.createTextNode(newst)), result[0].childNodes[i]);
}
}
i++;
}
}
node = am.createMmlNode(symbol.tag, result[0]);
node.setAttribute(symbol.atname, symbol.atval);
return [node, result[1]];
}
case am.BINARY:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseSexpr(str);
if (result[0] === null) {
return [am.createMmlNode('mo', document.createTextNode(symbol.input)), str];
}
am.AMremoveBrackets(result[0]);
result2 = am.AMparseSexpr(result[1]);
if (result2[0] === null) {
return [am.createMmlNode('mo', document.createTextNode(symbol.input)), str];
}
am.AMremoveBrackets(result2[0]);
if (['color', 'class', 'id'].indexOf(symbol.input) >= 0) {
if (str.charAt(0) === '{') {
i = str.indexOf('}');
} else if (str.charAt(0) === '(') {
i = str.indexOf(')');
} else if (str.charAt(0) === '[') {
i = str.indexOf(']');
}
st = str.slice(1, i);
node = am.createMmlNode(symbol.tag, result2[0]);
if (symbol.input === 'color') {
node.setAttribute('mathcolor', st);
} else if (symbol.input === 'class') {
node.setAttribute('class', st);
} else if (symbol.input === 'id') {
node.setAttribute('id', st);
}
return [node, result2[1]];
}
if (symbol.input === 'root' || symbol.output === 'stackrel') {
newFrag.appendChild(result2[0]);
}
newFrag.appendChild(result[0]);
if (symbol.input === 'frac') {
newFrag.appendChild(result2[0]);
}
return [am.createMmlNode(symbol.tag, newFrag), result2[1]];
case am.FUNC1:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseSexpr(str);
am.AMremoveBrackets(result[0]);
node = am.createMmlNode(symbol.tag, result[0]);
if (symbol.atname) {
node.setAttribute(symbol.atname, symbol.atval);
}
return [node, result[1]];
case am.FUNC2:
case am.FUNC2FLIP:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseSexpr(str);
result2 = am.AMparseSexpr(result[1]);
am.AMremoveBrackets(result[0]);
am.AMremoveBrackets(result2[0]);
if (symbol.ttype === am.FUNC2) {
newFrag.appendChild(result[0]);
newFrag.appendChild(result2[0]);
} else if (symbol.ttype === am.FUNC2FLIP) {
newFrag.appendChild(result2[0]);
newFrag.appendChild(result[0]);
}
return [am.createMmlNode(symbol.tag, newFrag), result2[1]];
case am.INFIX:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
return [am.createMmlNode('mo', document.createTextNode(symbol.output)), str];
case am.SPACE:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
node = am.createMmlNode('mspace');
node.setAttribute('width', '1ex');
newFrag.appendChild(node);
newFrag.appendChild(am.createMmlNode(symbol.tag, document.createTextNode(symbol.output)));
node = am.createMmlNode('mspace');
node.setAttribute('width', '1ex');
newFrag.appendChild(node);
return [am.createMmlNode('mrow', newFrag), str];
case am.LEFTRIGHT:
am.AMnestingDepth++;
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
result = am.AMparseExpr(str, false);
am.AMnestingDepth--;
st = '';
if (result[0].lastChild !== null) {
st = result[0].lastChild.firstChild.nodeValue;
}
if (st === '|' && str.charAt(0) !== ',') {
node = am.createMmlNode('mo', document.createTextNode(symbol.output));
node = am.createMmlNode('mrow', node);
node.appendChild(result[0]);
return [node, result[1]];
} else {
node = am.createMmlNode('mo', document.createTextNode('∣'));
node = am.createMmlNode('mrow', node);
return [node, str];
}
default:
str = am.AMremoveCharsAndBlanks(str, symbol.input.length);
return [am.createMmlNode(symbol.tag, document.createTextNode(symbol.output)), str];
}
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMremoveBrackets/remove.ls
(function(){
return function(am, node){
var st;
st = null;
if (!node.hasChildNodes()) {
return;
}
if (node.firstChild.hasChildNodes() && (node.nodeName === "mrow" || node.nodeName === "M:MROW")) {
if (node.firstChild.nextSibling && node.firstChild.nextSibling.nodeName === "mtable") {
return;
}
st = node.firstChild.firstChild.nodeValue;
if (st === "(" || st === "[" || st === "{") {
node.removeChild(node.firstChild);
}
}
if (node.lastChild.hasChildNodes() && (node.nodeName === "mrow" || node.nodeName === "M:MROW")) {
st = node.lastChild.firstChild.nodeValue;
if (st === ")" || st === "]" || st === "}") {
return node.removeChild(node.lastChild);
}
}
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMremoveCharsAndBlanks/remove.ls
(function(){
return function(am, str, n){
var st, i;
if (str.charAt(n) === "\\" && str.charAt(n + 1) !== "\\" && str.charAt(n + 1) !== " ") {
st = str.slice(n + 1);
} else {
st = str.slice(n);
}
i = 0;
while (i < st.length && st.charCodeAt(i) <= 32) {
i += 1;
}
return st.slice(i);
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMsymbols/AMsymbolsSlim.ls
(function(){
return function(am, m){
var a;
a = _.concat(inc("basicMoSymbols/mo")(am), inc("styleSymbols/symbols")(am, m), inc("symbols/symbols")(am));
return _.orderBy(a, "input");
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMsymbols/basicMoSymbols/mo.ls
(function(){
return function(am){
var s, i$, len$, c, results$ = [];
s = "=+-*÷<>";
s += ",";
s += "≥≤×·±≈⇔≪≫∈∉⊥∃∂∣∤∝↤↦←→⟵⟶⇐⇒∩∪⋃⋂";
for (i$ = 0, len$ = s.length; i$ < len$; ++i$) {
c = s[i$];
results$.push({
input: c,
tag: "mo",
output: c,
ttype: am.CONST
});
}
return results$;
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMsymbols/styleSymbols/symbols.ls
(function(){
return function(am, m){
var styles, k, i$, len$, s, a, results$ = [];
styles = _.concat("fontweight_bold", "fontstyle_italic", "textdecoration_underline", (function(){
var results$ = [];
for (k in m.styles.textColors) {
results$.push("color_" + k);
}
return results$;
}()), (function(){
var results$ = [];
for (k in m.styles.backgroundColors) {
results$.push("background_" + k);
}
return results$;
}()));
for (i$ = 0, len$ = styles.length; i$ < len$; ++i$) {
s = styles[i$];
a = s.split("_");
results$.push({
input: "style_" + s,
tag: "mstyle",
atname: "style_" + a[0],
atval: a[1],
ttype: am.FUNC1
});
}
return results$;
};
})();
mathDiv/_shared/asciimath/asciimathLS/AMsymbols/symbols/symbols.ls
(function(){
return function(am){
var symbols;
return symbols = [
{
input: "`",
tag: "mtext",
ttype: am.TEXT
}, {
input: "SPACE",
tag: "mtext",
output: "SPACE",
ttype: am.CONST
}, {
input: "⋅",
tag: "mo",
output: "*",
ttype: am.CONST
}, {
input: ":",
tag: "mo",
output: "÷",
ttype: am.CONST
}, {
input: "(",
tag: "mo",
output: "(",
ttype: am.LEFTBRACKET
}, {
input: ")",
tag: "mo",
output: ")",
ttype: am.RIGHTBRACKET
}, {
input: "[",
tag: "mo",
output: "[",
ttype: am.LEFTBRACKET
}, {
input: "]",
tag: "mo",
output: "]",
ttype: am.RIGHTBRACKET
}, {
input: "{",
tag: "mo",
output: "{",
ttype: am.LEFTBRACKET
}, {
input: "}",
tag: "mo",
output: "}",
ttype: am.RIGHTBRACKET
}, {
input: "{:",
tag: "mo",
output: "{:",
ttype: am.LEFTBRACKET
}, {
input: ":}",
tag: "mo",
output: ":}",
ttype: am.RIGHTBRACKET
}, {
input: "/",
tag: "mfrac",
output: "/",
ttype: am.INFIX
}, {
input: "_",
tag: "msub",
output: "_",
ttype: am.INFIX
}, {
input: "^",
tag: "msup",
output: "^",
ttype: am.INFIX
}, {
input: "sqrt",
tag: "msqrt",
ttype: am.FUNC1
}, {
input: "abs",
tag: "mf_abs",
ttype: am.FUNC1
}, {
input: "bar",
tag: "mf_bar",
ttype: am.FUNC1
}, {
input: "lrarrow",
tag: "mf_lrarrow",
ttype: am.FUNC1
}, {
input: "larrow",
tag: "mf_larrow",
ttype: am.FUNC1
}, {
input: "rarrow",
tag: "mf_rarrow",
ttype: am.FUNC1
}, {
input: "gaptag",
tag: "mgap",
ttype: am.FUNC1
}, {
input: "sin",
tag: "mf_sin",
ttype: am.FUNC1
}, {
input: "cos",
tag: "mf_cos",
ttype: am.FUNC1
}, {
input: "tan",
tag: "mf_tan",
ttype: am.FUNC1
}, {
input: "ln",
tag: "mf_ln",
ttype: am.FUNC1
}, {
input: "log",
tag: "mf_log",
ttype: am.FUNC1
}, {
input: "asin",
tag: "mf_asin",
ttype: am.FUNC1
}, {
input: "acos",
tag: "mf_acos",
ttype: am.FUNC1
}, {
input: "atan",
tag: "mf_atan",
ttype: am.FUNC1
}, {
input: "ncr",
tag: "mf_ncr",
ttype: am.FUNC1
}, {
input: "unit",
tag: "mf_unit",
ttype: am.FUNC1
}, {
input: "log_",
tag: "mf_logbase",
ttype: am.FUNC2FLIP
}, {
input: "root",
tag: "mroot",
ttype: am.FUNC2FLIP
}, {
input: "lim_",
tag: "mf_lim",
ttype: am.FUNC1
}, {
input: "sum_",
tag: "mf_sum",
ttype: am.FUNC1
}
];
};
})();
mathDiv/_shared/asciimath/asciimathLS/asciimathLS.ls
(function(){
return function(m){
var am;
am = window.asciimath;
am.decimalsign = ".";
inc("initTokenTypes/init")(am);
am.AMmathml = "http://www.w3.org/1998/Math/MathML";
am.AMsymbols = inc("AMsymbols/AMsymbolsSlim")(am, m);
am.AMnames = _.map(am.AMsymbols, "input");
am.AMnestingDepth = null;
am.AMpreviousSymbol = null;
am.AMcurrentSymbol = null;
am.createMmlNode = function(t, frag){
return inc("createMmlNode/create")(am, t, frag);
};
am.AMremoveCharsAndBlanks = function(str, n){
return inc("AMremoveCharsAndBlanks/remove")(am, str, n);
};
am.position = function(arr, str, n){
return inc("position/position")(am, arr, str, n);
};
am.AMgetSymbol = function(str){
return inc("AMgetSymbol/get")(am, str);
};
am.AMremoveBrackets = function(node){
return inc("AMremoveBrackets/remove")(am, node);
};
am.AMparseSexpr = function(str){
return inc("AMparseSexpr/parse")(am, str);
};
am.AMparseIexpr = function(str){
return inc("AMparseIexpr/parse")(am, str);
};
am.AMparseExpr = function(str, rightbracket){
return inc("AMparseExpr/parse")(am, str, rightbracket);
};
am.parseMath = function(str){
return inc("parseMath/parse")(am, str);
};
return am;
};
})();
mathDiv/_shared/asciimath/asciimathLS/createMmlNode/create.ls
(function(){
return function(am, t, frag){
var node;
node = document.createElementNS(am.AMmathml, t);
if (frag) {
node.appendChild(frag);
}
return node;
};
})();
mathDiv/_shared/asciimath/asciimathLS/initTokenTypes/init.ls
(function(){
return function(am){
am.CONST = 0;
am.UNARY = 1;
am.BINARY = 2;
am.INFIX = 3;
am.LEFTBRACKET = 4;
am.RIGHTBRACKET = 5;
am.SPACE = 6;
am.UNDEROVER = 7;
am.DEFINITION = 8;
am.LEFTRIGHT = 9;
am.TEXT = 10;
am.BIG = 11;
am.LONG = 12;
am.STRETCHY = 13;
am.MATRIX = 14;
am.UNARYUNDEROVER = 15;
am.FUNC1 = 16;
am.FUNC2 = 17;
return am.FUNC2FLIP = 18;
};
})();
mathDiv/_shared/asciimath/asciimathLS/parseMath/parse.ls
(function(){
return function(am, s){
var frag;
am.AMnestingDepth = 0;
s = s.trim();
frag = am.AMparseExpr(s, false)[0];
return am.createMmlNode("math", frag);
};
})();
mathDiv/_shared/asciimath/asciimathLS/position/position.ls
(function(){
return function(am, arr, str, n){
var h, m, i;
if (n === 0) {
n = -1;
h = arr.length;
while (n + 1 < h) {
m = n + h >> 1;
if (arr[m] < str) {
n = m;
} else {
h = m;
}
}
return h;
} else {
i = n;
while (i < arr.length && arr[i] < str) {
i++;
}
}
return i;
};
})();
mathDiv/_shared/asciimath/init.ls
(function(){
var initalized;
initalized = false;
return function(m){
if (initalized) {
return;
}
initalized = true;
window.asciimath = {};
return inc("asciimathLS/asciimathLS")(m);
};
})();
mathDiv/_shared/formatXml/format.ls
(function(){
return function(xml){
var xmlDoc, xsltDoc, xsltProcessor, resultDoc, resultXml;
xmlDoc = new DOMParser().parseFromString(xml, "application/xml");
xsltDoc = new DOMParser().parseFromString(['', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ''].join("\n"), "application/xml");
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDoc);
resultDoc = xsltProcessor.transformToDocument(xmlDoc);
return resultXml = new XMLSerializer().serializeToString(resultDoc);
};
})();
mathDiv/_shared/getAsciimathFromMathml/get.ls
(function(){
return function(mathml){
var ns, div, mEl, am;
ns = "http://www.w3.org/1998/Math/MathML";
div = document.createElementNS(ns, "math");
mEl = div.html(mathml).firstChild;
return am = inc("getAmOfElement/get")(mEl);
};
})();
mathDiv/_shared/getAsciimathFromMathml/getAmOfElement/get.ls
(function(){
return function(el, autowrap){
var get, getA, t, c, mr1, mr2, mr3, a, s1, s2, am, ref$, gap, n, ref1$;
get = function(el2){
return inc(THISFILE)(el2);
};
getA = function(el2){
return inc(THISFILE)(el2, true);
};
t = el.tagName;
c = el.childrenAll();
mr1 = c[0];
mr2 = c[1];
mr3 = c[2];
if (t === "mn" || t === "mo" || t === "mi") {
return el.textContent;
} else if (t === "mtext") {
return "`" + el.textContent + "`";
} else if (t === "mspace") {
return " ";
} else if (t === "mfrac") {
return getA(mr1) + "/" + getA(mr2);
} else if (t === "msup") {
return get(mr1) + "^" + getA(mr2);
} else if (t === "msubsup") {
return get(mr1) + "_" + getA(mr2) + "^" + getA(mr3);
} else if (t === "msub") {
return get(mr1) + "_" + getA(mr2);
} else if (t === "msqrt") {
return "sqrt(" + get(mr1) + ")";
} else if (t === "mroot") {
return "root" + getA(mr2) + "(" + get(mr1) + ")";
} else if (t === "mf_fac") {
return get(mr1) + "!";
} else if (t === "mfenced") {
a = el.attr("type");
s1 = a[0] === " "
? "{:"
: a[0];
s2 = a[1] === " "
? ":}"
: a[1];
return s1 + "" + get(mr1) + s2;
} else if (t === "mgap") {
am = (ref$ = get(mr1)) != null ? ref$ : "";
gap = el.attr("gap");
return "" + gap + "";
} else if (in$(t, inc("../../standardFunctions/functions")("mf_")) || (t === "mf_bar" || t === "mf_abs" || t === "mf_fac" || t === "mf_larrow" || t === "mf_rarrow" || t === "mf_lrarrow")) {
n = t.split("_")[1];
return n + "(" + get(mr1) + ")";
} else if (t === "mf_ncr") {
return "ncr(" + get(mr1) + ", " + get(mr2) + ")";
} else if (t === "mf_logbase") {
return "log_" + getA(mr2) + "(" + get(mr1) + ")";
} else if (t === "mf_lim") {
return "lim_" + getA(mr1);
} else if (t === "mf_sum") {
return "sum_" + getA(mr1) + "^" + getA(mr2);
} else if (t === "mf_unit") {
return "unit(" + get(mr1) + ")";
} else if (t === "math" || t === "mrow") {
a = _.compact(_.map(c, get));
am = a.join(" ");
if (autowrap && (a.length > 1 || ((ref$ = (ref1$ = el.firstChild) != null ? ref1$.tagName : void 8) !== "mn" && ref$ !== "mo" && ref$ !== "mi"))) {
return "(" + am + ")";
} else {
return am;
}
} else {
return "UNKNOWN_" + t;
}
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
mathDiv/_shared/getMathElFromAsciimath/get.ls
(function(){
return function(m, am){
var am2, mEl;
if (am.length === 0) {
return inc("postprocess/_shared/createElementNS/create")("math");
}
inc("../asciimath/init")(m);
am2 = inc("preprocess/preprocess")(m, am);
mEl = window.asciimath.parseMath(am2);
return mEl = inc("postprocess/postprocess")(mEl, am);
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/_shared/createElementNS/create.ls
(function(){
return function(n){
var ns;
ns = "http://www.w3.org/1998/Math/MathML";
return document.createElementNS(ns, n);
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/_shared/wrapAllChildrenInMrow/wrap.ls
(function(){
return function(el){
var mrow;
mrow = inc("../createElementNS/create")("mrow");
mrow.append(el.childrenAll());
return el.append(mrow);
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/_shared/wrapNthChildInMrow/wrap.ls
(function(){
return function(el, index){
var child, mrow;
child = el.childrenAll()[index];
if (child.tagName === "mrow") {
return;
}
mrow = inc("../createElementNS/create")("mrow");
child.replaceWith(mrow);
return mrow.append(child);
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/centerAndAlign/process.ls
(function(){
return function(mEl, am){
var d, el, that;
am = am.trim();
if (!_.startsWith(am, "") + 1);
el = d.firstChild;
if (that = el.attr("center") === "true") {
mEl.attr({
center: that
});
}
if (that = el.attr("align")) {
return mEl.attr({
align: that
});
}
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/fac/fac.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, elPrev, el2, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mi")).length; i$ < len$; ++i$) {
el = ref$[i$];
elPrev = el.previousSibling;
if (el.textContent !== "!" || !elPrev) {
continue;
}
el2 = inc("../_shared/createElementNS/create")("mf_fac");
elPrev.replaceWith(el2);
el2.html(elPrev);
results$.push(el.remove());
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/gap/gap.ls
(function(){
return function(mEl){
var i$, ref$, len$, i, el, s, el2, gap, that, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mgap")).length; i$ < len$; ++i$) {
i = i$;
el = ref$[i$];
s = el.findFirst("mtext").textContent;
el2 = Div().html(s).firstChild;
gap = el2.innerHTML;
gap = _.replaceAll(gap, "GAPQUOTE", "`");
gap = _.replaceAll(gap, "GAPLESSTHAN", "<");
gap = _.replaceAll(gap, "GAPMORETHAN", ">");
el.attr({
gap: gap
});
el.attr({
index: i
});
if (that = el2.attr("gapvalidatemode")) {
el.attr({
validatemode: that
});
}
results$.push(el.empty());
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mf/mf.ls
(function(){
var w;
w = inc("../_shared/wrapNthChildInMrow/wrap");
return function(mEl){
var a, i$, ref$, len$, el, results$ = [];
a = inc("../../../standardFunctions/functions")("mf_");
for (i$ = 0, len$ = (ref$ = mEl.findAll(a.join(", "))).length; i$ < len$; ++i$) {
el = ref$[i$];
w(el, 0);
}
for (i$ = 0, len$ = (ref$ = mEl.findAll("mf_abs, mf_bar, mf_fac, mf_lim, mf_sum, mf_ncr, mf_unit")).length; i$ < len$; ++i$) {
el = ref$[i$];
w(el, 0);
}
for (i$ = 0, len$ = (ref$ = mEl.findAll("mf_logbase")).length; i$ < len$; ++i$) {
el = ref$[i$];
w(el, 0);
results$.push(w(el, 1));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mf_ncr/extractMrows/extract.ls
(function(){
return function(el){
var mrow, children, mo, splitIndex, c, mrow1, mrow2, i$, len$, i, el2;
mrow = el.firstChild;
children = mrow.childrenAll();
mo = _.find(children, {
tagName: "mo",
textContent: ","
});
splitIndex = _.indexOf(children, mo);
c = function(){
return inc("../../_shared/createElementNS/create")("mrow");
};
mrow1 = c();
mrow2 = c();
for (i$ = 0, len$ = children.length; i$ < len$; ++i$) {
i = i$;
el2 = children[i$];
if (i === splitIndex) {
continue;
} else if (splitIndex === -1 || i < splitIndex) {
mrow1.append(el2);
} else {
mrow2.append(el2);
}
}
return el.html([mrow1, mrow2]);
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mf_ncr/mf_ncr.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mf_ncr")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("extractMrows/extract")(el));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mf_sum/mergeAndReplaceParentSup/mergeAndReplace.ls
(function(){
return function(el){
var elP, mrow2;
elP = el.parent().parent();
if ((elP != null ? elP.tagName : void 8) === "msup") {
mrow2 = elP.lastChild;
el.append(mrow2);
return elP.replaceWith(el);
} else {
mrow2 = inc("../../_shared/createElementNS/create")("mrow");
return el.append(mrow2);
}
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mf_sum/mf_sum.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mf_sum")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("mergeAndReplaceParentSup/mergeAndReplace")(el));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfenced/mfenced.ls
(function(){
return function(mEl){
inc("moBracketsToMfenced/moBracketsToMfenced")(mEl);
inc("semicolonToMtable/semicolonToMtable")(mEl);
return inc("setTableAlignAndSpacings/set")(mEl);
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfenced/moBracketsToMfenced/convertMrow/convert.ls
(function(){
var c, types;
c = inc("../../../_shared/createElementNS/create");
types = inc("types/types")();
return function(mEl, el){
var el1, ref$, el2, c1, c2, type, el3;
el1 = (ref$ = el.firstChild) != null
? ref$
: {};
el2 = (ref$ = el.lastChild) != null
? ref$
: {};
if (el1.tagName !== "mo" || el2.tagName !== "mo") {
return;
}
c1 = el1.textContent;
c2 = el2.textContent;
type = types[c1 + " " + c2];
if (!type) {
return;
}
el1.remove();
el2.remove();
return el.replaceWith(el3 = c("mfenced").attr({
type: type
}).html(c("mrow").html(el.childrenAll())));
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfenced/moBracketsToMfenced/convertMrow/types/types.ls
(function(){
return function(){
return {
"( )": "()",
"[ ]": "[]",
"{ }": "{}",
"{: }": " }",
"{ :}": "{ ",
"{: :}": " "
};
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfenced/moBracketsToMfenced/moBracketsToMfenced.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mrow")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("convertMrow/convert")(mEl, el));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfenced/semicolonToMtable/convertEl/convert.ls
(function(){
var c;
c = function(t){
return inc("../../../_shared/createElementNS/create")(t);
};
return function(el){
var mrow, children, mtable, mtr, mtd, i$, len$;
mrow = el.firstChild;
children = mrow.childrenAll();
if (!_.find(children, {
innerHTML: ";"
})) {
return;
}
mtable = c("mtable");
mtr = c("mtr").appendTo(mtable);
mtd = c("mtd").appendTo(mtr);
for (i$ = 0, len$ = children.length; i$ < len$; ++i$) {
el = children[i$];
if (el.innerHTML === ";") {
mtr = c("mtr").appendTo(mtable);
mtd = c("mtd").appendTo(mtr);
} else {
mtd.append(el);
}
}
return mrow.html(mtable);
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfenced/semicolonToMtable/semicolonToMtable.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mfenced")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("convertEl/convert")(el));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfenced/setTableAlignAndSpacings/set.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, type, el2, ref1$, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mfenced")).length; i$ < len$; ++i$) {
el = ref$[i$];
type = el.attr("type");
el2 = (ref1$ = el.firstChild) != null ? ref1$.firstChild : void 8;
if ((type === "()" || type === "[]") && (el2 != null ? el2.tagName : void 8) === "mtable") {
results$.push(el2.attr({
align_columns: "c",
row_spacing: 0.1,
column_spacing: 0.4
}));
}
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mfrac/mfrac.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mfrac")).length; i$ < len$; ++i$) {
el = ref$[i$];
inc("../_shared/wrapNthChildInMrow/wrap")(el, 0);
results$.push(inc("../_shared/wrapNthChildInMrow/wrap")(el, 1));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mroot/mroot.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mroot")).length; i$ < len$; ++i$) {
el = ref$[i$];
inc("../_shared/wrapNthChildInMrow/wrap")(el, 0);
results$.push(inc("../_shared/wrapNthChildInMrow/wrap")(el, 1));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mstyle/flattenElement/flatten.ls
(function(){
return function(styleEl){
var i$, ref$, len$, el, j$, ref1$, len1$, attr, n, v;
inc("removeWrapperMrow/remove")(styleEl);
for (i$ = 0, len$ = (ref$ = styleEl.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
for (j$ = 0, len1$ = (ref1$ = styleEl.attributes).length; j$ < len1$; ++j$) {
attr = ref1$[j$];
n = attr.name;
v = styleEl.attr(n);
el.setAttribute(n, v);
}
}
return styleEl.replaceWith(styleEl.childrenAll());
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mstyle/flattenElement/removeWrapperMrow/remove.ls
(function(){
return function(styleEl){
if (styleEl.childrenAll.length === 1, styleEl.firstChild.tagName === "mrow") {
return styleEl.firstChild.replaceWith(styleEl.firstChild.childrenAll());
}
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mstyle/mstyle.ls
(function(){
return function(mEl){
var styleElements, i$, len$, styleEl;
styleElements = mEl.findAll("mstyle");
for (i$ = 0, len$ = styleElements.length; i$ < len$; ++i$) {
styleEl = styleElements[i$];
inc("flattenElement/flatten")(styleEl);
}
return mEl;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/msub/msub.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("msub")).length; i$ < len$; ++i$) {
el = ref$[i$];
inc("../_shared/wrapNthChildInMrow/wrap")(el, 0);
results$.push(inc("../_shared/wrapNthChildInMrow/wrap")(el, 1));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/msubsup/msubsup.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("msubsup")).length; i$ < len$; ++i$) {
el = ref$[i$];
inc("../_shared/wrapNthChildInMrow/wrap")(el, 0);
inc("../_shared/wrapNthChildInMrow/wrap")(el, 1);
results$.push(inc("../_shared/wrapNthChildInMrow/wrap")(el, 2));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/msup/msup.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("msup")).length; i$ < len$; ++i$) {
el = ref$[i$];
inc("../_shared/wrapNthChildInMrow/wrap")(el, 0);
results$.push(inc("../_shared/wrapNthChildInMrow/wrap")(el, 1));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mtable/mtable.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mtable")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.parent().tagName === "mrow") {
el.parent().replaceWith(el);
}
el.removeAttribute("columnlines");
results$.push(el.removeAttribute("columnalign"));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mtd/mtd.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mtd")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("../_shared/wrapAllChildrenInMrow/wrap")(el));
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/mtext/mtext.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mtext")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.parent().tagName === "mrow") {
results$.push(el.parent().replaceWith(el));
}
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/postprocess.ls
(function(){
return function(mEl, am){
inc("centerAndAlign/process")(mEl, am);
inc("mfenced/mfenced")(mEl);
inc("mtext/mtext")(mEl);
inc("msup/msup")(mEl);
inc("msub/msub")(mEl);
inc("msubsup/msubsup")(mEl);
inc("mfrac/mfrac")(mEl);
inc("mroot/mroot")(mEl);
inc("mtd/mtd")(mEl);
inc("mtable/mtable")(mEl);
inc("space/space")(mEl);
inc("fac/fac")(mEl);
inc("mf/mf")(mEl);
inc("mf_ncr/mf_ncr")(mEl);
inc("mf_sum/mf_sum")(mEl);
inc("mstyle/mstyle")(mEl);
inc("gap/gap")(mEl);
inc("primeSymbols/primeSymbols")(mEl);
return mEl;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/primeSymbols/primeSymbols.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, ref1$, ref2$, c, ref3$, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mi")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (!el.parentNode) {
continue;
}
if (el.tagName === "mi" && el.textContent === "'") {
while (((ref1$ = el.nextSibling) != null ? ref1$.tagName : void 8) === "mi" && ((ref2$ = el.nextSibling) != null ? ref2$.textContent : void 8) === "'") {
el.textContent += "'";
el.nextSibling.remove();
}
c = {
"'": "′",
"''": "″",
"'''": "‴",
"''''": "⁗"
};
results$.push(el.textContent = (ref3$ = c[el.textContent]) != null
? ref3$
: el.textContent);
}
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/postprocess/space/space.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, v, v2, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mtext")).length; i$ < len$; ++i$) {
el = ref$[i$];
v = el.innerHTML;
v2 = v.split("SPACE").join(" ");
if (v === "SPACE") {
results$.push(el.replaceWith(inc("../_shared/createElementNS/create")("mspace")));
} else if (v2 !== v) {
results$.push(el.innerHTML = v2);
}
}
return results$;
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/_convertTagToSymbol/convert.ls
(function(){
return function(s, tag, styleSymbol){
s = inc("wrapNestedString/wrap")(s, tag, "||");
s = inc("wrapNestedString/wrap")(s, tag, "
");
s = s.split(tag).join(styleSymbol + "(");
return s = s.split("" + tag.substr(1)).join(")");
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/_convertTagToSymbol/wrapNestedString/wrap.ls
(function(){
return function(s, tag, wrapString){
var openTag, closeTag, seperator, s2, a, res$, i$, ref$, len$;
if (!_.includes(s, tag)) {
return s;
}
openTag = tag;
closeTag = "" + tag.substr(1);
seperator = "_!!!_";
s2 = s;
s2 = s2.split(openTag).join(seperator + openTag);
s2 = s2.split(closeTag).join(closeTag + seperator);
res$ = [];
for (i$ = 0, len$ = (ref$ = s2.split(seperator)).length; i$ < len$; ++i$) {
s = ref$[i$];
if (s.startsWith(tag)) {
res$.push(s = _.replaceAll(s, wrapString, closeTag + wrapString + tag));
} else {
res$.push(s);
}
}
a = res$;
return a.join("");
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convert3Dots/convert.ls
(function(){
return function(s){
return s.split("...").join("…");
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertDoubleQuotes/convert.ls
(function(){
return function(s){
return s = s.split('"').join('`');
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertGapTags/convert.ls
(function(){
return function(s){
var r;
if (!_.includes(s, "", "GAPMORETHAN");
s = s.split("").join("/gap>`)");
return s;
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertGapTags/replaceInGapTag/replace.ls
(function(){
return function(s, s1, s2){
var regex1;
regex1 = /]*>(.*?)<\/gap>/g;
return s.replace(regex1, function(matchString, innerString){
var pos, a;
pos = _.indexOf(matchString, ">") + 1;
return a = [matchString.substr(0, pos), _.replaceAll(innerString, s1, s2), matchString.substr(pos + innerString.length)].join("");
});
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertHtmlEntitiesToUnicode/convert.ls
(function(){
return function(s){
var t;
t = document.createElement("textarea");
t.innerHTML = s;
return t.value;
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertLogbase/convert.ls
(function(){
return function(s){
return s = _.replaceAll(s, "`logbase`", "log_");
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertOldSyntaxQuotedFunctions/convert.ls
(function(){
return function(s){
var a, i$, len$, f;
a = inc("../../../standardFunctions/functions")();
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
f = a[i$];
s = _.replaceAll(s, "`" + f + "`", f);
}
s = _.replaceAll(s, "`lim`_", "lim_");
s = _.replaceAll(s, "`sum`_", "sum_");
return s;
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertSpaces/convert.ls
(function(){
return function(s){
return s.split(" ").join("SPACE");
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertStyleTags/convert.ls
(function(){
return function(s, m){
var c, k;
c = inc("../_convertTagToSymbol/convert");
s = c(s, "", "style_fontweight_bold");
s = c(s, "", "style_fontstyle_italic");
s = c(s, "", "style_textdecoration_underline");
for (k in m.styles.textColors) {
s = c(s, "", "style_color_" + k);
}
for (k in m.styles.backgroundColors) {
s = c(s, "", "style_background_" + k);
}
return s;
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/convertTable/convert.ls
(function(){
return function(s){
var lines, columns, lineParts, res$, i$, len$, l, p, lines2;
lines = s.split("
");
if (lines.length === 1) {
return s;
}
columns = 0;
res$ = [];
for (i$ = 0, len$ = lines.length; i$ < len$; ++i$) {
l = lines[i$];
p = l.split("||");
columns = Math.max(p.length, columns);
res$.push(p);
}
lineParts = res$;
for (i$ = 0, len$ = lineParts.length; i$ < len$; ++i$) {
l = lineParts[i$];
while (l.length < columns) {
l.push("");
}
}
s = "{:";
res$ = [];
for (i$ = 0, len$ = lineParts.length; i$ < len$; ++i$) {
l = lineParts[i$];
res$.push("(" + l.join(", ") + ")");
}
lines2 = res$;
s += lines2.join(", ");
return s += ":}";
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/preprocess.ls
(function(){
return function(m, am){
var s;
s = am;
s = inc("convertStyleTags/convert")(s, m);
s = inc("convertSpaces/convert")(s);
s = inc("convert3Dots/convert")(s);
s = inc("convertDoubleQuotes/convert")(s);
s = inc("convertGapTags/convert")(s);
s = inc("convertHtmlEntitiesToUnicode/convert")(s);
s = inc("convertOldSyntaxQuotedFunctions/convert")(s);
s = inc("convertLogbase/convert")(s);
s = inc("convertTable/convert")(s);
return s = inc("removeMatTag/remove")(s);
};
})();
mathDiv/_shared/getMathElFromAsciimath/preprocess/removeMatTag/remove.ls
(function(){
return function(s){
s = _.replaceAll(s, //, "");
return s = _.replaceAll(s, "", "");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/_createEl/create.ls
(function(){
return function(n, v){
var ns, el, i$, len$, el2;
ns = "http://www.w3.org/1998/Math/MathML";
el = document.createElementNS(ns, n);
if (_.isArray(v)) {
for (i$ = 0, len$ = v.length; i$ < len$; ++i$) {
el2 = v[i$];
el.appendChild(v);
}
} else if (_.isString(v) || _.isNumber(v)) {
el.textContent = v;
}
return el;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/_createElCommand/create.ls
(function(){
return function(c){
var el;
el = inc("../_createEl/create")("command");
el.attr({
command: c
});
return el;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/_createPlaceholderElement/create.ls
(function(){
return function(p){
var m, am, placeholders, ref$, prefix, i$, to$, i, mathml, mEl, len$, el, t, elPl, elPlClone;
m = p.m;
am = p.am;
placeholders = (ref$ = p.placeholders) != null
? ref$
: [];
prefix = "$_$";
for (i$ = 1, to$ = placeholders.length; i$ <= to$; ++i$) {
i = i$;
am = _.replaceAll(am, "$" + i, "`" + (prefix + i) + "`");
}
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(p.m, am);
mEl = Div().html(mathml).firstChild;
for (i$ = 0, len$ = (ref$ = mEl.findAll("mtext")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (_.startsWith(el.textContent, "$_$")) {
t = el.textContent;
i = +t[prefix.length] - 1;
elPl = placeholders[i];
if (!elPl) {
continue;
}
elPlClone = elPl.cloneNode(true);
el.replaceWith(elPlClone);
}
}
inc("../convertChildren")(m, mEl);
return mEl = mEl.firstChild;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertChildren.ls
(function(){
return function(m, mEl){
var c, i$, ref$, len$, t, f, v;
inc("mergeFnBar/merge")(mEl);
inc("fixMtextToMi/fix")(mEl);
inc("fixMinusSigns/fix")(mEl);
inc("fixPercentPosition/fix")(mEl);
inc("fixStandardVarNames/fix")(mEl);
inc("fixSpecialPlusMinus/fix")(mEl);
inc("fixWrongMultiplyAndDivideChar/fix")(mEl);
inc("fixMissingMultiply/fix")(mEl);
c = function(t, v){
return inc("convertElements/convertElements")(m, mEl, t, v);
};
for (i$ = 0, len$ = (ref$ = ["msqrt", "mfenced", "mf_abs", "mf_fac", "mfrac", "mf_logbase", "mf_lim", "mf_sum", "mf_ncr", "mf_unit", "msup", "msub", "msubsup", "mroot"]).length; i$ < len$; ++i$) {
t = ref$[i$];
c(t);
}
for (i$ = 0, len$ = (ref$ = inc("/mathDiv/_shared/standardFunctions/functions")("mf_")).length; i$ < len$; ++i$) {
f = ref$[i$];
c(f);
}
for (i$ = 0, len$ = (ref$ = ["÷", "*", "+", "-"]).length; i$ < len$; ++i$) {
v = ref$[i$];
c("mo", v);
}
if (mEl.childrenAll().length !== 1) {
throw Error("can't parse valid mathJson");
}
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/_combi1/combi1.ls
(function(){
return function(m, o, command){
var mrow1;
mrow1 = o.el.firstChild;
inc("../../convertChildren")(m, mrow1);
return o.el.replaceWith(inc("../../_createElCommand/create")(command).html(mrow1.firstChild));
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/_combi2/combi2.ls
(function(){
return function(m, o, command){
var c, mrow1, mrow2, f;
c = o.el.childrenAll();
mrow1 = c[0];
mrow2 = c[1];
f = inc("../../convertChildren");
f(m, mrow1);
f(m, mrow2);
return o.el.replaceWith(inc("../../_createElCommand/create")(command).html(mrow1.firstChild, mrow2.firstChild));
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/_findAll/find.ls
(function(){
return function(mEl, tag, value){
var i$, ref$, len$, i, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.childrenAll()).length; i$ < len$; ++i$) {
i = i$;
el = ref$[i$];
if (el.tagName.toLowerCase() !== tag) {
continue;
}
if (value != null && el.textContent !== value) {
continue;
}
results$.push(el);
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/convertElements.ls
(function(){
var stFunctions;
stFunctions = inc("/mathDiv/_shared/standardFunctions/functions")("mf_");
return function(m, mEl, tag, value){
var elements, i$, len$, el, o, results$ = [];
elements = inc("_findAll/find")(mEl, tag, value);
for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) {
el = elements[i$];
o = {
el: el,
prevEl: el.previousSibling,
nextEl: el.nextSibling
};
if (in$(tag, stFunctions)) {
tag = "mf_generic";
}
results$.push(inc(tag + "/convert")(m, o));
}
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/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_abs/convert.ls
(function(){
return function(m, o){
return inc("../_combi1/combi1")(m, o, "Abs");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_fac/convert.ls
(function(){
return function(m, o){
return inc("../_combi1/combi1")(m, o, "Factorial");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_generic/convert.ls
(function(){
return function(m, o){
var c, mrow1, elC;
c = o.el.tagName.split("_")[1];
c = c[0].toUpperCase() + c.substr(1);
if (_.startsWith(c, "A")) {
c = "Arc" + c.substr(1);
}
mrow1 = o.el.firstChild;
inc("../../convertChildren")(m, mrow1);
elC = inc("../../_createElCommand/create")(c).html(mrow1.firstChild);
o.el.replaceWith(elC);
return inc("convertDegree/convert")(m, elC);
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_generic/convertDegree/convert.ls
(function(){
return function(m, elC){
var c, el2;
if (m.trigonometryMode !== "deg") {
return;
}
c = elC.attr("command");
if (c === "Sin" || c === "Cos" || c === "Tan") {
el2 = inc("../../../_createPlaceholderElement/create")({
m: m,
am: "$1/180*π",
placeholders: [elC.firstChild]
});
return elC.firstChild.replaceWith(el2);
} else if (c === "Arcsin" || c === "Arccos" || c === "Arctan") {
el2 = inc("../../../_createPlaceholderElement/create")({
m: m,
am: "$1/π*180",
placeholders: [elC]
});
return elC.replaceWith(el2);
}
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_lim/convert.ls
(function(){
return function(m, o){
throw Error("mf_lim isn't supported");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_logbase/convert.ls
(function(){
return function(m, o){
var command, c, mrow1, mrow2, f;
command = "Log";
c = o.el.childrenAll();
mrow1 = c[0];
mrow2 = c[1];
f = inc("../../convertChildren");
f(m, mrow1);
f(m, mrow2);
return o.el.replaceWith(inc("../../_createElCommand/create")(command).html(mrow1.firstChild, mrow2.firstChild));
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_ncr/convert.ls
(function(){
return function(m, o){
var c, mrow1, mrow2, f, el2;
c = o.el.childrenAll();
mrow1 = c[0];
mrow2 = c[1];
f = inc("../../convertChildren");
f(m, mrow1);
f(m, mrow2);
el2 = inc("../../_createPlaceholderElement/create")({
m: m,
am: "($1!)/(($1-$2)!*($2)!)",
placeholders: [mrow1.firstChild, mrow2.firstChild]
});
return o.el.replaceWith(el2);
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_sum/convert.ls
(function(){
return function(m, o){
throw Error("mf_sum isn't supported");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mf_unit/convert.ls
(function(){
return function(m, o){
var mrow1;
mrow1 = o.el.firstChild;
inc("../../convertChildren")(m, mrow1);
return o.el.replaceWith(mrow1.firstChild);
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mfenced/convert.ls
(function(){
return function(m, o){
var mrow1;
mrow1 = o.el.firstChild;
inc("../../convertChildren")(m, mrow1);
mrow1.firstChild.attr({
fenced: true
});
return o.el.replaceWith(mrow1.firstChild);
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mfrac/convert.ls
(function(){
return function(m, o){
return inc("../_combi2/combi2")(m, o, "Divide");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mo/calcCommand/calc.ls
(function(){
return function(o, v){
v = o.el.textContent;
if (v === "*") {
return "Multiply";
} else if (v === "+") {
return "Add";
} else if (v === "-") {
return "Subtract";
} else if (v === "÷") {
return "Divide";
}
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mo/convert.ls
(function(){
return function(m, o){
var command, elC;
if (!o.prevEl) {
throw Error("prevEl before mo missing");
}
if (!o.nextEl) {
throw Error("nextEl after mo missing");
}
command = inc("calcCommand/calc")(o);
if (o.prevEl.attr("command") === command) {
o.prevEl.append(o.nextEl);
o.el.remove();
return;
}
elC = inc("../../_createElCommand/create")(command);
o.el.replaceWith(elC);
return elC.html(o.prevEl, o.nextEl);
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/mroot/convert.ls
(function(){
return function(m, o){
return inc("../_combi2/combi2")(m, o, "Root");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/msqrt/convert.ls
(function(){
return function(m, o){
return inc("../_combi1/combi1")(m, o, "Sqrt");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/msub/convert.ls
(function(){
return function(m, o){
var command, c, mrow1, mrow2, ref$, el;
command = "Log";
c = o.el.childrenAll();
mrow1 = c[0];
mrow2 = c[1];
if (mrow1.firstChild.tagName !== "mi" || ((ref$ = mrow2.firstChild.tagName) !== "mn" && ref$ !== "mi" && ref$ !== "mtext")) {
throw Error("msub has invalid element");
}
el = mrow1.firstChild;
el.textContent += "_" + mrow2.firstChild.textContent;
return o.el.replaceWith(el);
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/msubsup/convert.ls
(function(){
return function(m, o){
var command, c, mrow1, mrow2, mrow3, ref$, el;
command = "Log";
c = o.el.childrenAll();
mrow1 = c[0];
mrow2 = c[1];
mrow3 = c[2];
if (mrow1.firstChild.tagName !== "mi") {
throw Error("msubsup must be mi");
}
if ((ref$ = mrow2.firstChild.tagName) !== "mn" && ref$ !== "mi" && ref$ !== "mtext") {
throw Error("msubsup exp isn't valid");
}
el = mrow1.firstChild;
el.textContent += "_" + mrow2.firstChild.textContent;
mrow2.remove();
return inc("../_combi2/combi2")(m, o, "Power");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/convertElements/msup/convert.ls
(function(){
return function(m, o){
return inc("../_combi2/combi2")(m, o, "Power");
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/fixMinusSigns/fix.ls
(function(){
return function(mEl){
var a, i$, len$, el, results$ = [];
a = mEl.childrenAll();
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
el = a[i$];
if (el.textContent === "-" && el.previousSibling != null) {
results$.push(el.before(inc("../_createEl/create")("mo", "+")));
}
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/fixMissingMultiply/fix.ls
(function(){
return function(mEl){
var a, i$, len$, i, elRight, elLeft, results$ = [];
a = mEl.childrenAll();
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
i = i$;
elRight = a[i$];
if (i === 0) {
continue;
}
elLeft = a[i - 1];
if (elLeft.tagName === "mo" && elRight.tagName === "mo") {
throw Error("2 neighbour mo elements are invalid");
}
if (elLeft.tagName === "mo" || elRight.tagName === "mo") {
continue;
}
if (elRight.tagName === "mn" && elLeft.tagName !== "mf_unit") {
throw Error("missing mo element before mn element");
}
results$.push(elRight.before(inc("../_createEl/create")("mo", "*")));
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/fixMtextToMi/fix.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mtext")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(el.replaceWith(inc("../_createEl/create")("mi", el.textContent + "")));
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/fixPercentPosition/fix.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, ref1$, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mi")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.textContent === "%" && _.includes((ref1$ = el.previousSibling) != null ? ref1$.textContent : void 8, "%")) {
throw Error("percent sign is in an invalid position");
}
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/fixSpecialPlusMinus/fix.ls
(function(){
return function(mEl){
var a, i$, len$, i, el, elPrev, ref$, c, el1, el2, results$ = [];
a = mEl.childrenAll();
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
i = i$;
el = a[i$];
elPrev = a[i - 1];
if (!(el.tagName === "mo" && ((ref$ = el.textContent) === "-" || ref$ === "+"))) {
continue;
}
if (elPrev && elPrev.tagName !== "mo") {
continue;
}
c = inc("../_createEl/create");
el1 = c("mn", el.textContent + "1");
el2 = c("mo", "*");
el.replaceWith(el1);
results$.push(el1.after(el2));
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/fixStandardVarNames/fix.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, c, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mi")).length; i$ < len$; ++i$) {
el = ref$[i$];
c = el.textContent;
if (c === "π") {
el.textContent = "Pi";
}
if (c === "e") {
results$.push(el.textContent = "ExponentialE");
}
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/fixWrongMultiplyAndDivideChar/fix.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, c, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mo")).length; i$ < len$; ++i$) {
el = ref$[i$];
c = el.textContent;
if (c === ":") {
results$.push(el.textContent = "÷");
}
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/mergeFnBar/merge.ls
(function(){
return function(mEl){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = mEl.findAll("mf_bar")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("mergeInPreviousMn/merge")(el));
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/convertChildren/mergeFnBar/mergeInPreviousMn/merge.ls
(function(){
return function(el){
var maxDigits, prevEl, t, v, v2, i$, i, digits, dif;
maxDigits = 20;
prevEl = el.previousSibling;
t = prevEl != null ? prevEl.tagName : void 8;
v = prevEl != null ? prevEl.textContent : void 8;
v2 = el.textContent;
if (t !== "mn" || !_.includes(v, ".") || _.isNaN(+v2)) {
throw Error("fn_bar is invalid");
}
for (i$ = 1; i$ <= maxDigits; ++i$) {
i = i$;
v += v2;
}
i = _.indexOf(v, ".");
digits = v.length - i - 1;
dif = digits - maxDigits;
if (dif > 0) {
v = v.substr(0, v.length - dif);
}
prevEl.textContent = v;
return el.remove();
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/get.ls
(function(){
return function(m, am){
var mathml, mEl, mj, e;
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, am);
mEl = Div().html(mathml).firstChild;
try {
inc("convertChildren/convertChildren")(m, mEl);
mj = inc("parseMathJson/parse")(mEl);
} catch (e$) {
e = e$;
}
return {
mathJson: mj,
hasError: e != null,
errors: e
? [e.message]
: []
};
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/parseMathJson/getCommandChildrenArray/get.ls
(function(){
return function(el){
var i$, ref$, len$, el2, results$ = [];
for (i$ = 0, len$ = (ref$ = el.childrenAll()).length; i$ < len$; ++i$) {
el2 = ref$[i$];
results$.push(inc("getChildMathJson/get")(el2));
}
return results$;
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/parseMathJson/getCommandChildrenArray/getChildMathJson/get.ls
(function(){
return function(el2){
var t, c;
t = el2.tagName;
c = el2.textContent;
if (t === "mn") {
return +c;
} else if (t === "mi") {
return c;
} else if (t === "command") {
return _.concat(el2.attr("command"), inc("../get")(el2));
} else {
throw Error("parse array contains invalid element");
}
};
})();
mathDiv/_shared/getMathJsonFromAsciimath/parseMathJson/parse.ls
(function(){
return function(mEl){
var el, t;
el = mEl.firstChild;
t = el.tagName;
if (t === "command") {
return _.concat(el.attr("command"), inc("getCommandChildrenArray/get")(el));
} else if (t === "mn") {
return +el.textContent;
} else {
return el.textContent;
}
};
})();
mathDiv/_shared/getRootElement/get.ls
(function(){
return function(m){
var ref$;
return ((ref$ = m.currentGap) != null ? ref$.mrow : void 8) || m.masterMrow;
};
})();
mathDiv/_shared/standardFunctions/functions.ls
(function(){
return function(prefix){
var a, a2, f;
prefix == null && (prefix = "");
a = ["sin", "cos", "tan", "asin", "acos", "atan", "ln", "log"];
return a2 = (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = a).length; i$ < len$; ++i$) {
f = ref$[i$];
results$.push(prefix + f);
}
return results$;
}());
};
})();
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/checkEquivalence/check.ls
(function(){
return function(m, p){
var gapValidateMode, ref$, isEqual, i$, ref1$, len$, s;
gapValidateMode = (ref$ = p.gapValidateMode) != null
? ref$
: m.gapValidateMode;
isEqual = function(v1, v2){
if (gapValidateMode === "literal" || inc("hasMathJsonError/has")(m, v1, v2)) {
return inc("isEqualLiteral/is")(m, v1, v2);
} else if (gapValidateMode === "literalSorted") {
return inc("isEqualLiteralSorted/is")(m, v1, v2);
} else if (gapValidateMode === "value") {
return inc("isEqualValue/is")(m, v1, v2, p.precision);
}
};
for (i$ = 0, len$ = (ref$ = (ref1$ = p.solutions) != null
? ref1$
: [p.value2]).length; i$ < len$; ++i$) {
s = ref$[i$];
if (isEqual(p.value, s)) {
return true;
}
}
return false;
};
})();
mathDiv/checkEquivalence/hasMathJsonError/has.ls
(function(){
return function(m, am1, am2){
var getMj, i$, ref$, len$, am;
getMj = inc("/mathDiv/_shared/getMathJsonFromAsciimath/get");
for (i$ = 0, len$ = (ref$ = [am1, am2]).length; i$ < len$; ++i$) {
am = ref$[i$];
if (getMj(m, am).hasError) {
m.validationFallback = true;
debug("The expression " + am + " cannot currently be evaluated by this gapValidateMode. Falling back to gapValidateMode: \"literal\".");
}
}
return getMj(m, am1).hasError || getMj(m, am2).hasError;
};
})();
mathDiv/checkEquivalence/isEqualLiteral/is.ls
(function(){
return function(m, v1, v2){
var f, m1, m2;
f = inc("/mathDiv/_shared/getMathElFromAsciimath/get");
m1 = f(m, v1);
m2 = f(m, v2);
return m1.outerHTML === m2.outerHTML;
};
})();
mathDiv/checkEquivalence/isEqualLiteralSorted/getSortedMathJson/get.ls
(function(){
return function(m, v){
var mjsonSorted;
mjsonSorted = _.cloneDeep(inc("/mathDiv/_shared/getMathJsonFromAsciimath/get")(m, v).mathJson);
inc("sortMathJson/sort")(mjsonSorted);
return mjsonSorted;
};
})();
mathDiv/checkEquivalence/isEqualLiteralSorted/getSortedMathJson/sortMathJson/sort.ls
(function(){
return function(mjson){
var type, i$, to$, i, child, childrenSorted, len$, c, results$ = [];
type = mjson[0];
for (i$ = 1, to$ = mjson.length - 1; i$ <= to$; ++i$) {
i = i$;
child = mjson[i];
if (_.isArray(child)) {
inc(THISFILE)(child);
}
}
if (type !== "Add" && type !== "Multiply") {
return;
}
childrenSorted = _.orderBy(_.drop(mjson), function(c){
return c.toString();
});
while (mjson.length > 0) {
mjson.shift();
}
mjson.push(type);
for (i$ = 0, len$ = childrenSorted.length; i$ < len$; ++i$) {
c = childrenSorted[i$];
results$.push(mjson.push(c));
}
return results$;
};
})();
mathDiv/checkEquivalence/isEqualLiteralSorted/is.ls
(function(){
return function(m, v1, v2){
var g, mjson1Sorted, mjson2Sorted;
g = inc("getSortedMathJson/get");
mjson1Sorted = g(m, v1);
mjson2Sorted = g(m, v2);
return _.isEqual(mjson1Sorted, mjson2Sorted);
};
})();
mathDiv/checkEquivalence/isEqualValue/_getVars/get.ls
(function(){
return function(m, am1, am2){
var variables;
variables = _.concat(inc("getVars/get")(m, am1), inc("getVars/get")(m, am2));
return variables = _.uniq(variables);
};
})();
mathDiv/checkEquivalence/isEqualValue/_getVars/getVars/get.ls
(function(){
return function(m, am){
var variables, mj;
variables = {};
mj = inc("/mathDiv/_shared/getMathJsonFromAsciimath/get")(m, am);
mj = mj.mathJson;
inc("getVarsInMathJson/get")(mj, variables);
delete variables.Pi;
delete variables.ExponentialE;
return _.keys(variables).sort();
};
})();
mathDiv/checkEquivalence/isEqualValue/_getVars/getVars/getVarsInMathJson/get.ls
(function(){
return function(mj, variables){
var i$, len$, i, c;
variables == null && (variables = {});
if (_.isString(mj)) {
variables[mj] = true;
} else if (_.isArray(mj)) {
for (i$ = 0, len$ = mj.length; i$ < len$; ++i$) {
i = i$;
c = mj[i$];
if (i > 0) {
inc(THISFILE)(c, variables);
}
}
}
return variables;
};
})();
mathDiv/checkEquivalence/isEqualValue/_isEqual/equal.ls
(function(){
return function(r1, r2, precision){
var v1, v2, epsilon, abs1, abs2, dif;
if (r1.hasError || r2.hasError) {
return false;
}
v1 = r1.result;
v2 = r2.result;
if (precision != null) {
return _.round(v1, precision) === _.round(v2, precision);
}
epsilon = Math.pow(2, -25);
abs1 = Math.abs(v1);
abs2 = Math.abs(v2);
dif = Math.abs(v1 - v2);
if (abs1 === 0 || abs2 === 0) {
return dif < epsilon;
} else {
return dif / (abs1 + abs2) < epsilon;
}
};
})();
mathDiv/checkEquivalence/isEqualValue/_replaceUnitsWithConstants/_createEl/create.ls
(function(){
return function(n, v){
var ns, el, i$, len$, el2;
ns = "http://www.w3.org/1998/Math/MathML";
el = document.createElementNS(ns, n);
if (_.isArray(v)) {
for (i$ = 0, len$ = v.length; i$ < len$; ++i$) {
el2 = v[i$];
el.appendChild(v);
}
} else if (_.isString(v) || _.isNumber(v)) {
el.textContent = v;
}
return el;
};
})();
mathDiv/checkEquivalence/isEqualValue/_replaceUnitsWithConstants/calcConstant/calc.ls
(function(){
return function(textEl){
var conversions, unit;
conversions = inc("conversions/conversions");
unit = textEl.textContent;
return conversions[unit];
};
})();
mathDiv/checkEquivalence/isEqualValue/_replaceUnitsWithConstants/calcConstant/conversions/conversions.ls
(function(){
return {
mm: "0.123456789",
cm: "1.23456789",
dm: "12.3456789",
m: "123.456789",
km: "123456.789",
ml: "0.234567891",
cl: "2.34567891",
dl: "23.4567891",
l: "234.567891",
g: "0.345678912",
kg: "345.678912",
s: "0.456789123",
min: "27.40734738",
h: "1644.4408428",
ct: "0.567891234",
"€": "56.7891234",
p: "0.678912345",
"£": "67.8912345",
"¢": "0.789123456",
"$": "78.9123456",
"°": "0.891234567",
rad: "0.891234567*(π/180)"
};
})();
mathDiv/checkEquivalence/isEqualValue/_replaceUnitsWithConstants/replace.ls
(function(){
return function(m, am){
var mEl, i$, ref$, len$, unitEl, j$, ref1$, len1$, textEl, constant;
mEl = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, am);
for (i$ = 0, len$ = (ref$ = mEl.findAll("mf_unit")).length; i$ < len$; ++i$) {
unitEl = ref$[i$];
for (j$ = 0, len1$ = (ref1$ = unitEl.findAll("mtext")).length; j$ < len1$; ++j$) {
textEl = ref1$[j$];
constant = inc("calcConstant/calc")(textEl);
if (!constant) {
debug("Warning: the unit '" + textEl.textContent + "' is not supported in gapValidateMode: 'value'.");
continue;
}
textEl.replaceWith(inc("_createEl/create")("mn", constant));
}
}
am = inc("/mathDiv/_shared/getAsciimathFromMathml/get")(mEl);
return am = _.replaceAll(am, "unit", "");
};
})();
mathDiv/checkEquivalence/isEqualValue/checkMultiVar/calcTestVariations/calc.ls
(function(){
var primes;
primes = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59];
return function(variables){
var pos, neg, fPos, fNeg, i$, len$, i, variable, p, ref$, p1, f;
pos = {};
neg = {};
fPos = {};
fNeg = {};
for (i$ = 0, len$ = variables.length; i$ < len$; ++i$) {
i = i$;
variable = variables[i$];
p = (ref$ = primes[i]) != null
? ref$
: i + 1;
p1 = (ref$ = primes[i + 1]) != null
? ref$
: i + 2;
f = parseFloat(p + "." + p1);
pos[variable] = p;
neg[variable] = -p;
fPos[variable] = f;
fNeg[variable] = -f;
}
return [pos, neg, fPos, fNeg];
};
})();
mathDiv/checkEquivalence/isEqualValue/checkMultiVar/check.ls
(function(){
return function(m, am1, am2, variables, precision){
var testVariations, i$, len$, variation, r1, r2;
testVariations = inc("calcTestVariations/calc")(variables);
for (i$ = 0, len$ = testVariations.length; i$ < len$; ++i$) {
variation = testVariations[i$];
r1 = m.eval({
am: am1,
vars: variation
});
r2 = m.eval({
am: am2,
vars: variation
});
if (_.isNaN(r1.result) || !_.isFinite(r1.result) || _.isNaN(r2.result) || !_.isFinite(r2.result)) {
m.validationFallback = true;
debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\".");
return inc("../../isEqualLiteral/is")(m, am1, am2);
}
if (!inc("../_isEqual/equal")(r1, r2, precision)) {
return inc("../../isEqualLiteral/is")(m, am1, am2);
}
}
return true;
};
})();
mathDiv/checkEquivalence/isEqualValue/checkNoVar/check.ls
(function(){
return function(m, am1, am2, precision){
var r1, r2;
r1 = m.eval({
am: am1
});
r2 = m.eval({
am: am2
});
if (_.isNaN(r1.result) || !_.isFinite(r1.result) || _.isNaN(r2.result) || !_.isFinite(r2.result)) {
m.validationFallback = true;
debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\".");
return inc("../../isEqualLiteral/is")(m, am1, am2);
}
if (inc("../_isEqual/equal")(r1, r2, precision)) {
return true;
}
return false;
};
})();
mathDiv/checkEquivalence/isEqualValue/checkSingleVar/calcTestValues/calc.ls
(function(){
return function(am1, am2, variable){
var isDefined, rounds, testValues, round;
isDefined = function(value){
var input, ref$, sol;
input = MathDiv2().eval({
am: am1,
vars: (ref$ = {}, ref$[variable + ""] = value, ref$)
}).result;
sol = MathDiv2().eval({
am: am2,
vars: (ref$ = {}, ref$[variable + ""] = value, ref$)
}).result;
return !_.isNaN(input) && _.isFinite(input) && !_.isNaN(sol) && _.isFinite(sol);
};
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]];
return testValues = (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = rounds).length; i$ < len$; ++i$) {
round = ref$[i$];
results$.push(_.find(round, isDefined));
}
return results$;
}());
};
})();
mathDiv/checkEquivalence/isEqualValue/checkSingleVar/check.ls
(function(){
return function(m, am1, am2, variable, precision){
var testValues, i$, len$, value, r1, ref$, r2;
testValues = inc("calcTestValues/calc")(am1, am2, variable);
if (_.compact(testValues).length < 4) {
m.validationFallback = true;
debug("The expression cannot currently be evaluated by gapValidateMode: \"value\". Falling back to gapValidateMode: \"literal\".");
return inc("../../isEqualLiteral/is")(m, am1, am2);
}
for (i$ = 0, len$ = testValues.length; i$ < len$; ++i$) {
value = testValues[i$];
r1 = m.eval({
am: am1,
vars: (ref$ = {}, ref$[variable + ""] = value, ref$)
});
r2 = m.eval({
am: am2,
vars: (ref$ = {}, ref$[variable + ""] = value, ref$)
});
if (!inc("../_isEqual/equal")(r1, r2, precision)) {
return inc("../../isEqualLiteral/is")(m, am1, am2);
}
}
return true;
};
})();
mathDiv/checkEquivalence/isEqualValue/is.ls
(function(){
return function(m, am1, am2, precision){
var variables;
am1 = inc("_replaceUnitsWithConstants/replace")(m, am1);
am2 = inc("_replaceUnitsWithConstants/replace")(m, am2);
variables = inc("_getVars/get")(m, am1, am2);
if (variables.length === 0) {
return inc("checkNoVar/check")(m, am1, am2, precision);
} else if (variables.length === 1) {
return inc("checkSingleVar/check")(m, am1, am2, variables[0], precision);
} else {
return inc("checkMultiVar/check")(m, am1, am2, variables, precision);
}
};
})();
mathDiv/checkSyntax/check.ls
(function(){
return function(m){
var fixLog, mathml, newValue;
fixLog = [];
mathml = m.getMathml();
mathml = Div().html(mathml).firstChild;
inc("fix_doubleOperator/fix")(m, mathml, fixLog);
if (fixLog.length > 0) {
newValue = inc("/mathDiv/_shared/getAsciimathFromMathml/get")(mathml);
m.setValue(newValue);
}
return fixLog;
};
})();
mathDiv/checkSyntax/fix_doubleOperator/_createEl/create.ls
(function(){
return function(n, v){
var ns, el, i$, len$, el2;
ns = "http://www.w3.org/1998/Math/MathML";
el = document.createElementNS(ns, n);
if (_.isArray(v)) {
for (i$ = 0, len$ = v.length; i$ < len$; ++i$) {
el2 = v[i$];
el.appendChild(v);
}
} else if (_.isString(v) || _.isNumber(v)) {
el.textContent = v;
}
return el;
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fix.ls
(function(){
return function(m, mathml, fixLog){
inc("fixAdditiveAdditive/fix")(m, mathml, fixLog);
return inc("fixMultiplicativeAdditive/fix")(m, mathml, fixLog);
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixAdditiveAdditive/fix.ls
(function(){
return function(m, mathml, fixLog){
var i$, ref$, len$, mo, ref1$, ref2$, ref3$, ref4$, results$ = [];
for (i$ = 0, len$ = (ref$ = mathml.findAll("mo")).length; i$ < len$; ++i$) {
mo = ref$[i$];
if (mo.textContent === "+") {
if (((ref1$ = mo.nextSibling) != null ? ref1$.textContent : void 8) === "+") {
inc("fixPlusPlus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else if (((ref2$ = mo.nextSibling) != null ? ref2$.textContent : void 8) === "-") {
inc("fixPlusMinus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else {
continue;
}
} else if (mo.textContent === "-") {
if (((ref3$ = mo.nextSibling) != null ? ref3$.textContent : void 8) === "+") {
inc("fixMinusPlus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else if (((ref4$ = mo.nextSibling) != null ? ref4$.textContent : void 8) === "-") {
inc("fixMinusMinus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else {
continue;
}
}
}
return results$;
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixAdditiveAdditive/fixMinusMinus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.nextSibling.replaceWith(inc("../../_createEl/create")("mo", "+"));
mo.remove();
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix double minus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixAdditiveAdditive/fixMinusPlus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.nextSibling.remove();
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix minus plus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixAdditiveAdditive/fixPlusMinus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.remove();
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix plus minus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixAdditiveAdditive/fixPlusPlus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.remove();
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix double plus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixMultiplicativeAdditive/fix.ls
(function(){
return function(m, mathml, fixLog){
var i$, ref$, len$, mo, ref1$, ref2$, ref3$, ref4$, results$ = [];
for (i$ = 0, len$ = (ref$ = mathml.findAll("mo")).length; i$ < len$; ++i$) {
mo = ref$[i$];
if (mo.textContent === "*") {
if (((ref1$ = mo.nextSibling) != null ? ref1$.textContent : void 8) === "+") {
inc("fixMultiplyPlus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else if (((ref2$ = mo.nextSibling) != null ? ref2$.textContent : void 8) === "-") {
inc("fixMultiplyMinus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else {
continue;
}
} else if (mo.textContent === "÷") {
if (((ref3$ = mo.nextSibling) != null ? ref3$.textContent : void 8) === "+") {
inc("fixDividePlus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else if (((ref4$ = mo.nextSibling) != null ? ref4$.textContent : void 8) === "-") {
inc("fixDivideMinus/fix")(mathml, mo, fixLog);
results$.push(inc(THISFILE)(m, mathml, fixLog));
} else {
continue;
}
}
}
return results$;
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixMultiplicativeAdditive/fixDivideMinus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.nextSibling.nextSibling.after(inc("../../_createEl/create")("mo", ")"));
mo.nextSibling.before(inc("../../_createEl/create")("mo", "("));
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix divide minus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixMultiplicativeAdditive/fixDividePlus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.nextSibling.remove();
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix divide plus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixMultiplicativeAdditive/fixMultiplyMinus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.nextSibling.nextSibling.after(inc("../../_createEl/create")("mo", ")"));
mo.nextSibling.before(inc("../../_createEl/create")("mo", "("));
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix multiply minus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/checkSyntax/fix_doubleOperator/fixMultiplicativeAdditive/fixMultiplyPlus/fix.ls
(function(){
return function(mathml, mo, fixLog){
var originalMathml, fixedMathml;
originalMathml = mathml.clone();
mo.nextSibling.remove();
fixedMathml = mathml.clone();
return fixLog.push({
type: "fix multiply plus",
originalMathml: originalMathml,
fixedMathml: fixedMathml
});
};
})();
mathDiv/cleanupLayout/adjustBaselineChar/adjust.ls
(function(){
return function(m, hc){
var mT;
mT = hc.center - 1.3 / 2;
return m.baselineChar.css({
marginTop: mT + "em"
});
};
})();
mathDiv/cleanupLayout/adjustTableCellCenters/adjust.ls
(function(){
return function(m){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = m.div.findAll(".mtr")).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("adjustRow/adjust")(el, m));
}
return results$;
};
})();
mathDiv/cleanupLayout/adjustTableCellCenters/adjustRow/adjust.ls
(function(){
return function(el, m){
var centerMax, c, i$, len$, i, el2, hc, results$ = [];
centerMax = 0;
c = el.childrenAll();
for (i$ = 0, len$ = c.length; i$ < len$; ++i$) {
i = i$;
el2 = c[i$];
hc = el2.mrow.getHC();
centerMax = Math.max(centerMax, hc.center);
}
for (i$ = 0, len$ = c.length; i$ < len$; ++i$) {
i = i$;
el2 = c[i$];
hc = el2.mrow.getHC();
results$.push(el2.mrow.css({
marginTop: centerMax - hc.center + "em"
}));
}
return results$;
};
})();
mathDiv/cleanupLayout/autowrapMfracWithMfenceInRow1/autowrap.ls
(function(){
return function(m, tagName){
var i$, ref$, len$, el, firstEl, elMfrac, s, n, o, elF, results$ = [];
for (i$ = 0, len$ = (ref$ = m.div.findAll("." + tagName)).length; i$ < len$; ++i$) {
el = ref$[i$];
firstEl = el.mrow1.firstChild;
if (firstEl.elementTagName === "mfrac") {
elMfrac = el.mrow1.firstChild;
s = m.getSelection();
n = s.anchorNode;
o = s.anchorOffset;
elF = m.createElement('');
elF.mrow1.html(elMfrac);
el.mrow1.html(elF);
results$.push(m.setSelection(n, o));
}
}
return results$;
};
})();
mathDiv/cleanupLayout/cleanup.ls
(function(){
return function(m){
var i$, ref$, len$, el, tagName, hc;
for (i$ = 0, len$ = (ref$ = m.div.findAll(".mrow")).length; i$ < len$; ++i$) {
el = ref$[i$];
inc("mergeMnNeighbours/merge")(m, el);
}
inc("adjustTableCellCenters/adjust")(m);
for (i$ = 0, len$ = (ref$ = ["msub", "msup", "msubsup", "mf_fac"]).length; i$ < len$; ++i$) {
tagName = ref$[i$];
inc("fixMoreThan1ChildInMrow1/fix")(m, tagName);
inc("autowrapMfracWithMfenceInRow1/autowrap")(m, tagName);
}
for (i$ = 0, len$ = (ref$ = m.div.findAll(".mrow")).length; i$ < len$; ++i$) {
el = ref$[i$];
el.adjustChildrenHC();
}
hc = m.masterMrow.getHC();
inc("adjustBaselineChar/adjust")(m, hc);
inc("setScrollDivHeight/set")(m, hc);
m.history.save();
return m.updateCustomCursor();
};
})();
mathDiv/cleanupLayout/fixMoreThan1ChildInMrow1/fix.ls
(function(){
return function(m, tagName){
var i$, ref$, len$, el, results$ = [];
for (i$ = 0, len$ = (ref$ = m.div.findAll("." + tagName)).length; i$ < len$; ++i$) {
el = ref$[i$];
inc("fixMoreThan1Children/fix")(m, el);
}
for (i$ = 0, len$ = (ref$ = m.div.findAll("." + tagName)).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(inc("fixPreviousMn/fix")(m, el));
}
return results$;
};
})();
mathDiv/cleanupLayout/fixMoreThan1ChildInMrow1/fixMoreThan1Children/fix.ls
(function(){
return function(m, el){
var s, n, o, a, i$, len$, el2;
if (el.mrow1.childrenAll().length === 1) {
return;
}
s = m.getSelection();
n = s.anchorNode;
o = s.anchorOffset;
a = el.mrow1.childrenAll();
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
el2 = a[i$];
if (el2 === _.last(a)) {
break;
}
el.before(el2);
}
m.setSelection(n, o);
return inc("../../mergeMnNeighbours/merge")(m, m.masterMrow);
};
})();
mathDiv/cleanupLayout/fixMoreThan1ChildInMrow1/fixPreviousMn/fix.ls
(function(){
return function(m, el){
var el1, el2, s, n, o;
el1 = el.previousSibling;
el2 = el.mrow1.firstChild;
if ((el1 != null ? el1.elementTagName : void 8) !== "mn") {
return;
}
if (el2.elementTagName !== "mn") {
return;
}
s = m.getSelection();
n = s.anchorNode;
o = s.anchorOffset;
el.mrow1.prepend(el1);
m.setSelection(n, o);
return inc("../../mergeMnNeighbours/merge")(m, el.mrow1);
};
})();
mathDiv/cleanupLayout/mergeMnNeighbours/merge.ls
(function(){
return function(m, div){
var t, i$, ref$, len$, el1, el2, ref1$, results$ = [];
t = "mn";
for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) {
el1 = ref$[i$];
el2 = (ref1$ = el1.nextSibling) != null
? ref1$
: {};
if (el1.elementTagName === t && el2.elementTagName === t && el1.getStyleAttrString() === el2.getStyleAttrString()) {
inc("merge/merge")(m, el1, el2);
inc(THISFILE)(m, div);
break;
}
}
return results$;
};
})();
mathDiv/cleanupLayout/mergeMnNeighbours/merge/merge.ls
(function(){
return function(m, el1, el2){
var s1, s2, s, t, cursorEl, offset, style, el3;
s1 = el1.getMathValue();
s2 = el2.getMathValue();
s = s1 + s2;
t = el1.elementTagName;
cursorEl = m.getCursorElement();
offset = m.getSelection().anchorOffset;
style = el1.getStyleAttrString();
el3 = m.createElement("<" + t + style + ">" + s + "" + t + ">");
m.removeElement(el1);
m.replaceElement(el2, el3);
if (cursorEl === el1) {
return m.setSelection(el3, offset);
} else if (cursorEl === el2) {
return m.setSelection(el3, s1.length + offset);
}
};
})();
mathDiv/cleanupLayout/setScrollDivHeight/calcPaddingExtra/calc.ls
(function(){
var cache;
cache = {};
return function(paddingContent){
var that, div, s, p;
if (that = cache[paddingContent]) {
return that;
}
if (!paddingContent) {
return 0;
}
div = Div({
padding: paddingContent
});
s = div.style;
p = +s.paddingTop.replace("em", "") + +s.paddingBottom.replace("em", "");
cache[paddingContent] = p;
return p;
};
})();
mathDiv/cleanupLayout/setScrollDivHeight/set.ls
(function(){
return function(m, hc){
var p, ref$;
p = inc("calcPaddingExtra/calc")(m.params.paddingContent);
return (ref$ = m.scrollDiv) != null ? ref$.css({
height: hc.height + p + "em"
}) : void 8;
};
})();
mathDiv/clipboard/onCopyOrCut/on.ls
(function(){
return function(m, e){
var ns, mathml, am;
if (window.getSelection().isCollapsed === false) {
return;
}
ns = "http://www.w3.org/1998/Math/MathML";
mathml = document.createElementNS(ns, "math").html(m.getSelectionMathml());
am = inc("/mathDiv/_shared/getAsciimathFromMathml/get")(mathml);
e.clipboardData.setData("text/plain", am);
e.preventDefault();
if (e.type === "cut") {
m.deleteSelectionRange();
return m.cleanupLayout();
}
};
})();
mathDiv/clipboard/onPaste/on.ls
(function(){
return function(m, e){
var c, ref$, s, mathml, d, i$, len$, elSrc, el;
c = (ref$ = e.clipboardData) != null
? ref$
: {};
s = c.getData("text/plain") || c.getData("Text") || "";
if (!s || s.length > 1000) {
return;
}
try {
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, s);
} catch (e$) {}
if (!mathml) {
return;
}
m.deleteSelectionRange();
d = Div().html(mathml).firstChild;
for (i$ = 0, len$ = (ref$ = d.childrenAll()).length; i$ < len$; ++i$) {
elSrc = ref$[i$];
el = m.createElement(elSrc);
m.insertElement(el);
}
return m.cleanupLayout();
};
})();
mathDiv/createElement/_shared/centerStartEndCombi123/center.ls
(function(){
return function(c, div){
var mT, i$, ref$, len$, el, results$ = [];
mT = c - 1.3 / 2 + "em";
for (i$ = 0, len$ = (ref$ = [div.spacerStart, div.spacerEnd]).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(el.css({
marginTop: mT
}));
}
return results$;
};
})();
mathDiv/createElement/_shared/div/div.ls
(function(){
return function(m, sourceEl){
var tagName, div;
tagName = sourceEl.tagName.toLowerCase();
div = Div().cssClass({
display: "inline-flex",
background: "var(--style_background)",
color: "var(--style_color)",
fontWeight: "var(--style_fontweight)",
fontStyle: "var(--style_fontstyle)",
textDecoration: "var(--style_textdecoration)",
alignItems: "flex-start"
}).addClass("mathElement " + tagName + " svgExportBackground");
div.isMathElement = true;
div.elementTagName = tagName;
div.previousMathElement = function(){
return inc("previousMathElement/element")(div);
};
div.nextMathElement = function(){
return inc("nextMathElement/element")(div);
};
div.parentMathElement = function(mo){
return inc("parentMathElement/element")(div, mo);
};
inc("styleAttributes/set/set")(m, div, sourceEl);
div.getStyleAttrString = function(){
return inc("styleAttributes/getString/get")(div);
};
return div;
};
})();
mathDiv/createElement/_shared/div/nextMathElement/element.ls
(function(){
return function(div){
var p, mathElements, index, i$, to$, i, el;
p = div.parentMathElement();
mathElements = p.findAll(".mathElement");
index = _.indexOf(mathElements, div);
for (i$ = index, to$ = mathElements.length - 1; i$ <= to$; ++i$) {
i = i$;
el = mathElements[i];
if (el !== div && !div.contains(el)) {
return el;
}
}
};
})();
mathDiv/createElement/_shared/div/parentMathElement/element.ls
(function(){
return function(div, mainOnly){
var el, ref$;
el = (ref$ = div.parent()) != null ? ref$.closest(".mathElement, .mathDiv") : void 8;
if (!el) {
return;
}
if (mainOnly && el.hasClass("mrow") || el.hasClass("spacer")) {
return inc(THISFILE)(el, mainOnly);
} else {
return el;
}
};
})();
mathDiv/createElement/_shared/div/previousMathElement/element.ls
(function(){
return function(div){
var p, mathElements, index, i$, i, el;
p = div.parentMathElement();
mathElements = p.findAll(".mathElement");
index = _.indexOf(mathElements, div);
for (i$ = index; i$ >= 0; --i$) {
i = i$;
el = mathElements[i];
if (el !== div && !div.contains(el)) {
return el;
}
}
};
})();
mathDiv/createElement/_shared/div/styleAttributes/getString/get.ls
(function(){
return function(div){
var a, i$, ref$, len$, attr, n, that;
a = [];
for (i$ = 0, len$ = (ref$ = div.attributes).length; i$ < len$; ++i$) {
attr = ref$[i$];
n = attr.name;
if (n === "class" || n === "style" || n === "copy_id") {
continue;
}
if (that = div.attr(n)) {
a.push(n + '="' + that + '"');
}
}
if (a.length === 0) {
return "";
} else {
return " " + a.join(" ");
}
};
})();
mathDiv/createElement/_shared/div/styleAttributes/set/set.ls
(function(){
return function(m, div, sourceEl){
var a, i$, len$, i, n, v, v2, ref$, results$ = [];
if (sourceEl.attr == null) {
return;
}
a = ["style_color", "style_background", "style_fontweight", "style_fontstyle", "style_textdecoration"];
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
i = i$;
n = a[i$];
v = sourceEl.attr(n);
if (v) {
v2 = i === 0
? m.styles.textColors[v]
: i === 1 ? m.styles.backgroundColors[v] : v;
div.attr((ref$ = {}, ref$[n + ""] = v, ref$));
results$.push(div.cssVar((ref$ = {}, ref$[n + ""] = v2, ref$)));
}
}
return results$;
};
})();
mathDiv/createElement/_shared/enableBasicStartBehaviour/back/back.ls
(function(){
return function(m, div){
var that;
if (div.mrow1.isEmpty() && div.mrow2.isEmpty()) {
return m.removeElement(div);
} else if (that = div.previousMathElement()) {
that.setCursor("end");
return m.getCursorElement().back();
} else {
return div.parentMathElement().back();
}
};
})();
mathDiv/createElement/_shared/enableBasicStartBehaviour/enable.ls
(function(){
return function(m, div){
div.spacerStart.setCursor = function(pos, options){
return inc("setCursorStart/set")(m, div, pos, options);
};
return div.mrow1.back = function(){
return inc("back/back")(m, div);
};
};
})();
mathDiv/createElement/_shared/enableBasicStartBehaviour/setCursorStart/set.ls
(function(){
return function(m, div, pos, options){
if (pos === "start" && (options != null ? options.cursorShift : void 8) === 1) {
div.mrow1.setCursor("start");
return m.getCursorElement().moveCursor("right");
} else if (pos === "end" && div.previousMathElement()) {
return div.previousMathElement().setCursor("end", {
cursorShift: -1
});
} else {
return m.setSelection(div.spacerStart, 0);
}
};
})();
mathDiv/createElement/_shared/fenceSvg/svg.ls
(function(){
return function(div, pos, type, height){
var h, div2;
type == null && (type = "()");
h = height != null ? height : 1.3;
div2 = Div({
display: "flex"
}).addClass("fenceSvg " + pos).html(inc("svg/svg")(pos, type, h));
div2.updateHeight = function(h2){
if (h2 !== h) {
return div2.replaceWith(inc(THISFILE)(div, pos, type, h2));
}
};
if (pos === "left") {
return div.fenceSvgLeft = div2;
} else {
return div.fenceSvgRight = div2;
}
};
})();
mathDiv/createElement/_shared/fenceSvg/svg/calcPath/calc.ls
(function(){
return function(pos, type2, h){
var factor, p, y1, y2;
factor = 1.3 / h;
p = factor * 10;
y1 = p;
y2 = 100 - p;
switch (type2) {
case "(":
case ")":
return "M 80 " + y1 + "A 100 60 0 0 0 80 " + y2 + "";
case "[":
case "]":
return "M 90 " + y1 + "L50 " + y1 + "L50 " + y2 + "L90 " + y2 + "";
case "{":
case "}":
return "M 90 " + y1 + " Q50 " + y1 + ", 50 25L50 40Q50 50, 10 50Q50 50, 50 60L50 75Q50 " + y2 + ", 90 " + y2 + "";
case " ":
return "";
}
};
})();
mathDiv/createElement/_shared/fenceSvg/svg/pageDebug.ls
(function(){
return function(page){
return {
start: function(){
return page.html(inc("svg")("left", "{}", 1.3).css({
transform: "scale(5)",
background: Color.grey[100]
}).cssVar({
style_color: "black"
}));
}
};
};
})();
mathDiv/createElement/_shared/fenceSvg/svg/svg.ls
(function(){
return function(pos, type, h){
var type2, p, svg;
type2 = pos === "left"
? type[0]
: type[1];
p = inc("calcPath/calc")(pos, type2, h);
return svg = inc("../../../_shared/svgPathPercentage/svg")({
width: "0.4em",
height: h + "em",
path: p,
flipX: pos === "right"
}).css(type2 === " " ? {
visibility: "hidden",
width: 0
} : void 8);
};
})();
mathDiv/createElement/_shared/getMathmlCombi123/get.ls
(function(){
return function(div){
var t, s, a, ref$, ref1$;
t = div.elementTagName;
s = div.getStyleAttrString();
a = _.concat("<" + t + s + ">", div.mrow1.getMathml(), (ref$ = div.mrow2) != null ? ref$.getMathml() : void 8, (ref1$ = div.mrow3) != null ? ref1$.getMathml() : void 8, "" + t + ">");
return a.join("");
};
})();
mathDiv/createElement/_shared/mainDiv/div.ls
(function(){
return function(div){
return div.mainDiv = Div({
display: "flex"
}).html(inc("../fenceSvg/svg")(div, "left"), div.mrow1, inc("../fenceSvg/svg")(div, "right"));
};
})();
mathDiv/createElement/_shared/setCursorCombi123/getSortedMrows/get.ls
(function(){
return function(div){
var a, res$, i$, i;
res$ = [];
for (i$ = 1; i$ <= 3; ++i$) {
i = i$;
res$.push(div["mrow" + i]);
}
a = res$;
a = _.compact(a);
return a.sort(function(el1, el2){
if (el1.compareDocumentPosition(el2) === 4) {
return -1;
}
});
};
})();
mathDiv/createElement/_shared/setCursorCombi123/set.ls
(function(){
return function(m, div, pos, options){
var that, mrows;
if (pos === "start") {
return div.spacerStart.setCursor(pos, options);
} else if (pos === "end") {
return div.spacerEnd.setCursor(pos, options);
} else if (pos === "before") {
if (that = div.previousMathElement()) {
return that.setCursor("end");
} else {
return div.parentMathElement().setCursor("before");
}
} else if (pos === "after") {
if (that = div.nextMathElement()) {
return that.setCursor("start");
} else {
return div.parentMathElement().setCursor("after");
}
} else if (pos === "firstMrowStart") {
mrows = inc("getSortedMrows/get")(div);
return _.first(mrows).setCursor("start");
} else if (pos === "firstMrowEnd") {
mrows = inc("getSortedMrows/get")(div);
return _.first(mrows).setCursor("end");
} else if (pos === "lastMrowEnd") {
mrows = inc("getSortedMrows/get")(div);
return _.last(mrows).setCursor("end");
}
};
})();
mathDiv/createElement/_shared/spacer/_div/div.ls
(function(){
return function(m, tagName){
return inc("../../div/div")(m, {
tagName: "spacer"
}).css({
height: "1.3em"
});
};
})();
mathDiv/createElement/_shared/spacer/emptyPlaceholder/back/back.ls
(function(){
return function(m, div, spacer){
return spacer.parentMathElement().back();
};
})();
mathDiv/createElement/_shared/spacer/emptyPlaceholder/borderDiv/div.ls
(function(){
return function(div){
return Div({
position: "absolute",
top: "1px",
left: "1px",
right: "1px",
bottom: "1px",
pointerEvents: "none",
border: div.transparentPlaceholder ? "1px solid transparent" : "1px solid var(--style_empty_color)"
});
};
})();
mathDiv/createElement/_shared/spacer/emptyPlaceholder/emptyPlaceholder.ls
(function(){
return function(m, div){
var spacer;
spacer = inc("../_div/div")(m).addClass("emptyPlaceholder").css({
minWidth: "0.7em",
justifyContent: "flex-start",
paddingLeft: div.transparentPlaceholder ? "0em" : "0.25em"
}).html(inc("borderDiv/div")(div));
spacer.isEmptyPlaceholder = true;
spacer.getHC = function(){
return inc("getHC/get")(m);
};
spacer.setCursor = function(){
return inc("setCursor/set")(m, spacer);
};
spacer.moveCursor = function(direction){
return inc("moveCursor/move")(direction, spacer, div);
};
spacer.insertElement = function(elNew){
return inc("insertElement/insert")(m, spacer, elNew);
};
spacer.back = function(){
return inc("back/back")(m, div, spacer);
};
spacer.getMathml = function(){
return "";
};
return spacer;
};
})();
mathDiv/createElement/_shared/spacer/emptyPlaceholder/getHC/get.ls
(function(){
return function(m){
var h;
h = m.styles.lineHeight;
return {
height: h,
center: h * 0.5
};
};
})();
mathDiv/createElement/_shared/spacer/emptyPlaceholder/insertElement/insert.ls
(function(){
return function(m, spacer, elNew){
return m.replaceElement(spacer, elNew);
};
})();
mathDiv/createElement/_shared/spacer/emptyPlaceholder/moveCursor/move.ls
(function(){
return function(d, spacer, div){
if (d === "left") {
return spacer.parentMathElement().setCursor("before");
} else if (d === "right") {
return spacer.parentMathElement().setCursor("after");
}
};
})();
mathDiv/createElement/_shared/spacer/emptyPlaceholder/setCursor/set.ls
(function(){
return function(m, spacer){
return m.setSelection(spacer, 0);
};
})();
mathDiv/createElement/_shared/spacer/end/back/back.ls
(function(){
return function(spacer){
return spacer.moveCursor("left");
};
})();
mathDiv/createElement/_shared/spacer/end/end.ls
(function(){
return function(m, div){
var spacer;
spacer = inc("../_div/div")(m).css({
width: "0.1em",
marginLeft: "-0.1em"
}).addClass("spacerEnd");
spacer.setCursor = function(pos, options){
return inc("setCursor/set")(m, div, spacer, pos, options);
};
spacer.moveCursor = function(direction){
return inc("moveCursor/move")(direction, spacer, div);
};
spacer.insertElement = function(elNew){
return inc("insertElement/insert")(m, div, elNew);
};
spacer.back = function(){
return inc("back/back")(spacer);
};
return div.spacerEnd = spacer;
};
})();
mathDiv/createElement/_shared/spacer/end/insertElement/insert.ls
(function(){
return function(m, div, elNew){
m.setSelection(div, "after");
return m.insertElement(elNew);
};
})();
mathDiv/createElement/_shared/spacer/end/moveCursor/move.ls
(function(){
return function(d, spacer, div){
if (d === "left") {
return spacer.previousMathElement().setCursor("end");
} else if (d === "right") {
return div.setCursor("after");
}
};
})();
mathDiv/createElement/_shared/spacer/end/setCursor/set.ls
(function(){
return function(m, div, spacer, pos, options){
if (pos === "end" && (options != null ? options.cursorShift : void 8) === -1) {
return spacer.moveCursor("left");
} else if (pos === "start" && div.nextMathElement()) {
return div.nextMathElement().setCursor("start");
} else {
return m.setSelection(spacer, 0);
}
};
})();
mathDiv/createElement/_shared/spacer/start/back/back.ls
(function(){
return function(m, div){
var that;
if (that = div.previousMathElement()) {
that.setCursor("end");
return m.getCursorElement().back();
} else {
return div.parentMathElement().back();
}
};
})();
mathDiv/createElement/_shared/spacer/start/insertElement/insert.ls
(function(){
return function(m, div, elNew){
m.setSelection(div, "before");
return m.insertElement(elNew);
};
})();
mathDiv/createElement/_shared/spacer/start/moveCursor/move.ls
(function(){
return function(d, spacer, div){
if (d === "left") {
return div.setCursor("before");
} else if (d === "right") {
return spacer.nextMathElement().setCursor("start");
}
};
})();
mathDiv/createElement/_shared/spacer/start/setCursor/set.ls
(function(){
return function(m, div, spacer, pos, options){
if (pos === "start" && (options != null ? options.cursorShift : void 8) === 1) {
return spacer.moveCursor("right");
} else if (pos === "end" && div.previousMathElement()) {
return div.previousMathElement().setCursor("end");
} else {
return m.setSelection(spacer, 0);
}
};
})();
mathDiv/createElement/_shared/spacer/start/start.ls
(function(){
return function(m, div){
var spacer;
spacer = inc("../_div/div")(m).css({
width: "0.1em",
marginRight: "-0.1em"
}).addClass("spacerStart");
spacer.setCursor = function(pos, options){
return inc("setCursor/set")(m, div, spacer, pos, options);
};
spacer.moveCursor = function(direction){
return inc("moveCursor/move")(direction, spacer, div);
};
spacer.insertElement = function(elNew){
return inc("insertElement/insert")(m, div, elNew);
};
spacer.back = function(){
return inc("back/back")(m, div);
};
return div.spacerStart = spacer;
};
})();
mathDiv/createElement/_shared/svgPathPercentage/svg.ls
(function(){
var c;
c = function(t){
return document.createElementNS("http://www.w3.org/2000/svg", t);
};
return function(p){
var ref$;
return c("svg").attr({
viewBox: "0 0 100 100",
width: p.width,
height: p.height,
preserveAspectRatio: "none",
overflow: "visible"
}).addClass("svgExport").html(c("path").attr({
"vector-effect": "non-scaling-stroke",
"stroke-width": (ref$ = p.strokeWidth) != null ? ref$ : "1px",
fill: (ref$ = p.fill) != null ? ref$ : "none",
stroke: (ref$ = p.strokeColor) != null ? ref$ : "var(--style_color)",
d: p.path
}).attr(p.flipX ? {
transform: "translate(100), scale(-1, 1)"
} : void 8));
};
})();
mathDiv/createElement/basic/_div/back/back.ls
(function(){
return function(m, div){
var sel, offset, content, that, a, s, t, style, elNew;
sel = m.getSelection();
offset = sel.anchorOffset;
content = div.getMathValue();
if (offset === 0) {
if (that = div.previousMathElement()) {
that.setCursor("end");
return m.getCursorElement().back();
} else {
return div.parentMathElement().back();
}
} else if (offset > 0 && content.length > 1) {
a = content.split("");
a.splice(offset - 1, 1);
s = a.join("");
t = div.elementTagName;
style = div.getStyleAttrString();
elNew = m.createElement("<" + t + style + ">" + s + "" + t + ">");
m.replaceElement(div, elNew);
return m.setSelection(elNew, offset - 1);
} else {
return m.removeElement(div);
}
};
})();
mathDiv/createElement/basic/_div/chars/charSpan/arrowChar/char.ls
(function(){
return function(c){
return [
" ", inc("/mathDiv/createElement/_shared/svgPathPercentage/svg")({
width: "100%",
height: "100%",
path: c === "⟶" || c === "⟵" ? "M12,50 L83,50 M75,35 L88,50 L75,65" : "M12,50 L73,50 M55,35 L78,50 L55,65",
flipX: c === "←" || c === "⟵"
}).css({
position: "absolute",
left: 0,
right: 0,
bottom: 0,
top: 0
})
];
};
})();
mathDiv/createElement/basic/_div/chars/charSpan/digit3Space/space.ls
(function(){
return function(m, tagName, content, i){
var i2, pos;
if (!m.showDigit3Space || tagName !== "mn") {
return;
}
i2 = content.indexOf(".");
if (i2 > -1 && i >= i2) {
return;
}
pos = content.split(".")[0].length - i;
if (pos > 1 && pos % 3 === 1) {
return twitch({
en: ",",
de: " ",
fr: " ",
pt: " ",
es: " "
});
}
};
})();
mathDiv/createElement/basic/_div/chars/charSpan/displayChar/char.ls
(function(){
return function(m, char, tagName, span){
var t;
t = tagName;
if (t === "mspace" || t === "mtext" || t === "mi") {
if (char === " ") {
return " ";
} else {
return char;
}
} else if (t === "mn") {
if (char === ".") {
return twitch({
de: ",",
en: ".",
fr: ",",
es: ".",
pt: ","
});
} else {
return char;
}
} else if (t === "mo") {
if (char === "*") {
char = twitch({
de: "⋅",
en: "×",
fr: "×",
es: "×",
pt: "×"
});
if (char === "⋅") {
span.css({
minWidth: "0.5em"
});
}
return char;
} else if (char === "÷" || char === ":") {
char = twitch({
de: ":",
en: "÷",
fr: ":",
es: "÷",
pt: "÷"
});
if (char === ":") {
span.css({
minWidth: "0.5em"
});
}
return char;
} else if (char === "-") {
return "−";
} else if (char === "+") {
return "+";
} else {
return char;
}
}
};
})();
mathDiv/createElement/basic/_div/chars/charSpan/getMathValue/get.ls
(function(){
return function(char, tagName){
if (tagName === "mspace") {
return "";
} else {
return char;
}
};
})();
mathDiv/createElement/basic/_div/chars/charSpan/pipeChar/char.ls
(function(){
return function(){
return [
"  ", inc("/mathDiv/createElement/_shared/svgPathPercentage/svg")({
width: "100%",
height: "100%",
path: "M50,15 L50, 85"
}).css({
position: "absolute",
left: 0,
right: 0,
bottom: 0,
top: 0
})
];
};
})();
mathDiv/createElement/basic/_div/chars/charSpan/span.ls
(function(){
return function(m, char, i, content, tagName){
var span;
span = Span().addClass("char svgExport").css({
textDecoration: "inherit"
}).css(tagName === "mo"
? {
display: "inline-block",
textAlign: char === "," ? "left" : "center",
minWidth: in$(char, "=<>≥≤≪≫≈⇔")
? "0.8em"
: char === ","
? "0.4em"
: char === "⟶" || char === "⟵" ? "1.2em" : "0.6em"
}
: tagName === "mi" && (char === "′" || char === "″" || char === "‴" || char === "⁗") ? {
display: "inline-block",
marginRight: "-0.10em"
} : void 8);
span.html(tagName === "mi" && char === "|"
? inc("pipeChar/char")()
: char === "→" || char === "←" || char === "⟶" || char === "⟵"
? inc("arrowChar/char")(char)
: inc("displayChar/char")(m, char, tagName, span), inc("digit3Space/space")(m, tagName, content, i));
span.getMathValue = function(){
return inc("getMathValue/get")(char, tagName);
};
return span;
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
mathDiv/createElement/basic/_div/chars/chars.ls
(function(){
return function(m, el){
var tagName, content, chars, res$, i$, len$, i, char;
tagName = el.tagName.toLowerCase();
content = tagName === "mspace"
? " "
: el.textContent;
res$ = [];
for (i$ = 0, len$ = content.length; i$ < len$; ++i$) {
i = i$;
char = content[i$];
res$.push(inc("charSpan/span")(m, char, i, content, tagName));
}
chars = res$;
return chars;
};
})();
mathDiv/createElement/basic/_div/div.ls
(function(){
return function(m, el){
var div;
div = inc("../../_shared/div/div")(m, el).css({
display: "inline-block",
padding: "0 0.05em"
}).css(el.tagName === "mtext" ? {
paddingRight: "0.15em"
} : void 8).addClass("basic").html(inc("chars/chars")(m, el));
div.getHC = function(){
return inc("getHC/get")(m, div, el);
};
div.insertElement = function(elNew){
return inc("insertElement/insert")(m, div, elNew);
};
div.setCursor = function(pos, options){
return inc("setCursor/set")(m, div, pos, options);
};
div.moveCursor = function(direction){
return inc("moveCursor/move")(m, div, direction);
};
div.back = function(){
return inc("back/back")(m, div);
};
div.getMathValue = function(){
return inc("getMathValue/get")(m, div);
};
div.getMathml = function(){
return inc("getMathml/get")(div);
};
return div;
};
})();
mathDiv/createElement/basic/_div/getHC/fixGapBetweenToStyledMnElements/fix.ls
(function(){
return function(div){
var ref$;
if (div.elementTagName === "mn" && ((ref$ = div.previousSibling) != null ? ref$.elementTagName : void 8) === "mn") {
return div.css({
marginLeft: "-0.1em"
});
}
};
})();
mathDiv/createElement/basic/_div/getHC/get.ls
(function(){
return function(m, div, el){
var h;
h = m.styles.lineHeight;
inc("setPlusMinusMarginRight/set")(el, div);
inc("fixGapBetweenToStyledMnElements/fix")(div);
return {
height: h,
center: h * 0.5
};
};
})();
mathDiv/createElement/basic/_div/getHC/setPlusMinusMarginRight/set.ls
(function(){
return function(el, div){
var ref$, ppNode, ref1$, previousSibling, that;
if ((ref$ = el.textContent) !== "-" && ref$ !== "+") {
return;
}
ppNode = (ref$ = (ref1$ = div.parentNode) != null ? ref1$.parentNode : void 8) != null
? ref$
: {};
previousSibling = (that = div.previousSibling)
? that
: ppNode.elementTagName === "mgap" ? ppNode.previousSibling : void 8;
if (!previousSibling || previousSibling.elementTagName === "mo") {
return div.css({
marginRight: "-0.1em"
});
} else {
return div.css({
marginRight: ""
});
}
};
})();
mathDiv/createElement/basic/_div/getMathValue/get.ls
(function(){
return function(m, div){
var a, res$, i$, ref$, len$, span;
res$ = [];
for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) {
span = ref$[i$];
res$.push(span.getMathValue());
}
a = res$;
return a.join("");
};
})();
mathDiv/createElement/basic/_div/getMathml/get.ls
(function(){
return function(div){
var t, v, s;
t = div.elementTagName;
v = div.getMathValue();
s = div.getStyleAttrString();
if (v === ">") {
v = ">";
}
if (v === "<") {
v = "<";
}
return "<" + t + s + ">" + v + "" + t + ">";
};
})();
mathDiv/createElement/basic/_div/insertElement/insert.ls
(function(){
return function(m, div, elNew){
var sel, offset, divs;
sel = m.getSelection();
offset = sel.anchorOffset;
if (offset === 0) {
m.setSelection(div, "before");
return m.insertElement(elNew);
} else if (offset === div.childrenAll().length) {
m.setSelection(div, "after");
return m.insertElement(elNew);
} else {
divs = inc("splitDiv/split")(m, div, offset);
return m.replaceElement(div, [divs[0], elNew, divs[1]]);
}
};
})();
mathDiv/createElement/basic/_div/insertElement/splitDiv/split.ls
(function(){
return function(m, div, offset){
var t, s, s1, s2, style;
t = div.elementTagName;
s = div.getMathValue();
s1 = s.substr(0, offset);
s2 = s.substr(offset);
style = div.getStyleAttrString();
return [m.createElement("<" + t + style + ">" + s1 + "" + t + ">"), m.createElement("<" + t + style + ">" + s2 + "" + t + ">")];
};
})();
mathDiv/createElement/basic/_div/moveCursor/move.ls
(function(){
return function(m, div, direction){
var sel, offset;
sel = m.getSelection();
offset = sel.anchorOffset;
if (direction === "left") {
if (offset > 0) {
return m.setSelection(div, offset - 1);
} else {
return div.setCursor("before");
}
} else if (direction === "right") {
if (offset < div.childrenAll().length) {
return m.setSelection(div, offset + 1);
} else {
return div.setCursor("after");
}
}
};
})();
mathDiv/createElement/basic/_div/setCursor/set.ls
(function(){
return function(m, div, pos, options){
var cursorShift, that;
cursorShift = (options != null ? options.cursorShift : void 8) || 0;
if (pos === "start") {
return m.setSelection(div, 0 + cursorShift);
} else if (pos === "end") {
return m.setSelection(div, div.childrenAll().length + cursorShift);
} else if (pos === "before") {
if (that = div.previousMathElement()) {
return that.setCursor("end", {
cursorShift: -1
});
} else {
return div.parentMathElement().setCursor("before");
}
} else if (pos === "after") {
if (that = div.nextMathElement()) {
return that.setCursor("start", {
cursorShift: 1
});
} else {
return div.parentMathElement().setCursor("after");
}
}
};
})();
mathDiv/createElement/basic/el.ls
(function(){
return function(m, el){
return inc("_div/div")(m, el);
};
})();
mathDiv/createElement/combi1/_div/div.ls
(function(){
return function(m, el){
var c, row, div;
c = el.childrenAll();
row = c[0];
div = inc("../../_shared/div/div")(m, el).addClass("combi1");
div.html(inc("../../_shared/spacer/start/start")(m, div), inc("mrow/mrow")(m, div, row), inc("../../_shared/spacer/end/end")(m, div));
div.getHC = function(){
return inc("getHC/get")(div);
};
div.setCursor = function(pos, options){
return inc("../../_shared/setCursorCombi123/set")(m, div, pos, options);
};
div.getMathml = function(){
return inc("../../_shared/getMathmlCombi123/get")(div);
};
div.centerStartEnd = function(c){
return inc("../../_shared/centerStartEndCombi123/center")(c, div);
};
return div;
};
})();
mathDiv/createElement/combi1/_div/getHC/get.ls
(function(){
return function(div){
var hc, ref$, ref1$;
hc = div.mrow1.getHC();
if ((ref$ = div.fenceSvgLeft) != null) {
ref$.updateHeight(hc.height);
}
if ((ref1$ = div.fenceSvgRight) != null) {
ref1$.updateHeight(hc.height);
}
div.centerStartEnd(hc.center);
return hc;
};
})();
mathDiv/createElement/combi1/_div/mrow/back/back.ls
(function(){
return function(m, div){
var childElements;
if (div.mrow1.isEmpty()) {
return m.removeElement(div);
} else {
childElements = div.mrow1.childrenAll();
m.replaceElement(div, childElements);
return _.first(childElements).setCursor("start");
}
};
})();
mathDiv/createElement/combi1/_div/mrow/mrow.ls
(function(){
return function(m, div, row){
var el;
el = m.createElement(row || "");
el.back = function(){
return inc("back/back")(m, div);
};
return div.mrow1 = el;
};
})();
mathDiv/createElement/combi1/mfenced/back/back.ls
(function(){
return function(m, div){
var childElements;
if (div.mrow1.isEmpty()) {
return m.removeElement(div);
} else {
childElements = div.mrow1.childrenAll();
m.replaceElement(div, childElements);
return _.last(childElements).setCursor("end");
}
};
})();
mathDiv/createElement/combi1/mfenced/el.ls
(function(){
return function(m, el){
var type, div;
type = el.attr("type") || "()";
div = inc("../_div/div")(m, el);
div.attr({
type: type
}).html(div.spacerStart, inc("../../_shared/fenceSvg/svg")(div, "left", type), div.mrow1, inc("../../_shared/fenceSvg/svg")(div, "right", type), div.spacerEnd);
div.mrow1.centerVertical = true;
div.getMathml = function(){
return inc("getMathml/get")(div, type);
};
div.spacerEnd.back = function(){
return inc("back/back")(m, div);
};
return div;
};
})();
mathDiv/createElement/combi1/mfenced/getMathml/get.ls
(function(){
return function(div, type){
var a;
a = _.concat("", div.mrow1.getMathml(), "");
return a.join("");
};
})();
mathDiv/createElement/combi1/msqrt/el.ls
(function(){
return function(m, el){
var div;
div = inc("../_div/div")(m, el);
div.html(div.spacerStart.css({
margin: ""
}), inc("../../combi2/mroot/mainDiv/div")(div), div.spacerEnd.css({
margin: ""
}));
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/combi1/msqrt/getHC/get.ls
(function(){
return function(div){
var hc, extraTop, h, c;
hc = div.mrow1.getHC();
extraTop = inc("../../../combi2/mroot/getHC/calcExtraTop/calc")(div, hc);
h = hc.height + extraTop;
c = hc.center + extraTop / 2;
div.svgIcon.updateHeight(h);
div.centerStartEnd(c);
return {
height: h,
center: c
};
};
})();
mathDiv/createElement/combi2/_div/div.ls
(function(){
return function(m, el){
var c, row1, row2, div;
c = el.childrenAll();
row1 = c[0];
row2 = c[1];
div = inc("../../_shared/div/div")(m, el).addClass("combi2");
div.html(inc("../../_shared/spacer/start/start")(m, div), inc("mrow1/mrow")(m, div, row1), inc("mrow2/mrow")(m, div, row2), inc("../../_shared/spacer/end/end")(m, div));
div.getHC = function(){
return inc("getHC/get")(div);
};
div.setCursor = function(pos, options){
return inc("../../_shared/setCursorCombi123/set")(m, div, pos, options);
};
div.getMathml = function(){
return inc("../../_shared/getMathmlCombi123/get")(div);
};
div.centerStartEnd = function(c){
return inc("../../_shared/centerStartEndCombi123/center")(c, div);
};
return div;
};
})();
mathDiv/createElement/combi2/_div/getHC/get.ls
(function(){
return function(div){
return div.mrow1.getHC();
};
})();
mathDiv/createElement/combi2/_div/mrow1/back/back.ls
(function(){
return function(m, div){
if (div.mrow1.isEmpty() && div.mrow2.isEmpty()) {
return m.removeElement(div);
} else {
return m.getCursorElement().moveCursor("left");
}
};
})();
mathDiv/createElement/combi2/_div/mrow1/mrow.ls
(function(){
return function(m, div, row1){
var el;
el = m.createElement(row1 || "");
el.back = function(){
return inc("back/back")(m, div);
};
return div.mrow1 = el;
};
})();
mathDiv/createElement/combi2/_div/mrow2/back/back.ls
(function(){
return function(m, div){
var isEmpty1, isEmpty2, a, el;
isEmpty1 = div.mrow1.isEmpty();
isEmpty2 = div.mrow2.isEmpty();
if (isEmpty1 && isEmpty2) {
return m.removeElement(div);
} else if (isEmpty1) {
a = div.mrow2.childrenAll();
m.replaceElement(div, a);
return _.first(a).setCursor("start");
} else if (isEmpty2) {
a = div.mrow1.childrenAll();
m.replaceElement(div, a);
return _.last(a).setCursor("end");
} else {
el = div.mrow1.lastChild;
a = _.concat(div.mrow1.childrenAll(), div.mrow2.childrenAll());
m.replaceElement(div, a);
return el.setCursor("end");
}
};
})();
mathDiv/createElement/combi2/_div/mrow2/mrow.ls
(function(){
return function(m, div, row2){
var el;
el = m.createElement(row2 || "");
el.back = function(){
return inc("back/back")(m, div);
};
return div.mrow2 = el;
};
})();
mathDiv/createElement/combi2/mfrac/el.ls
(function(){
return function(m, el){
var div;
div = inc("../_div/div")(m, el).css({
alignItems: "flex-start"
});
div.html(div.spacerStart.css({
margin: ""
}), Div({
display: "flex",
flexDirection: "column",
alignItems: "stretch"
}).html(div.mrow1, inc("line/line")(div), div.mrow2), div.spacerEnd.css({
margin: ""
}));
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/combi2/mfrac/getHC/get.ls
(function(){
return function(div){
var isNested, hLine, childScale, h1, h2, h, center;
isNested = inc("isNested/is")(div);
hLine = !isNested ? 0.25 : 0.1;
childScale = !isNested ? 0.9 : 0.7;
div.mrow1.css({
fontSize: childScale + "em"
});
div.mrow2.css({
fontSize: childScale + "em"
});
div.line.css({
height: hLine + "em"
});
h1 = div.mrow1.getHC().height * childScale;
h2 = div.mrow2.getHC().height * childScale;
h = h1 + h2 + hLine;
center = h1 + hLine * 0.5;
div.centerStartEnd(center);
return {
height: h,
center: h1 + hLine * 0.5
};
};
})();
mathDiv/createElement/combi2/mfrac/getHC/isNested/is.ls
(function(){
return function(div){
var ref$;
return ((ref$ = div.parent()) != null ? ref$.closest(".mfrac") : void 8) != null;
};
})();
mathDiv/createElement/combi2/mfrac/line/line.ls
(function(){
return function(div){
return div.line = Div({
width: "100%",
height: "1px"
}).html(inc("svgLine/svg")(div));
};
})();
mathDiv/createElement/combi2/mfrac/line/svgLine/svg.ls
(function(){
return function(){
var svg;
return svg = inc("../../../../_shared/svgPathPercentage/svg")({
width: "100%",
height: "100%",
path: "M0 50 L 100 50"
}).css({
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0
});
};
})();
mathDiv/createElement/combi2/mroot/el.ls
(function(){
return function(m, el){
var div;
div = inc("../_div/div")(m, el);
div.scaleExp = 0.6;
div.html(div.spacerStart.css({
margin: ""
}), inc("expDiv/div")(div), inc("mainDiv/div")(div), div.spacerEnd.css({
margin: ""
}));
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/combi2/mroot/expDiv/div.ls
(function(){
return function(div){
return div.expDiv = Div({
display: "flex",
fontSize: div.scaleExp + "em",
alignSelf: "flex-start",
marginRight: "-0.3em"
}).html(div.mrow2);
};
})();
mathDiv/createElement/combi2/mroot/getHC/calcExtraTop/calc.ls
(function(){
return function(div, hc1){
var top, i$, ref$, len$, c, ref1$;
top = 0.25;
if (hc1.height > 1.3) {
return top;
}
div.mrow1.getHC();
for (i$ = 0, len$ = (ref$ = div.mrow1.childrenAll()).length; i$ < len$; ++i$) {
c = ref$[i$];
if ((ref1$ = c.elementTagName) === "mfenced" || ref1$ === "msqrt" || ref1$ === "mroot" || ref1$ === "mf_abs") {
return top;
}
}
return 0;
};
})();
mathDiv/createElement/combi2/mroot/getHC/get.ls
(function(){
return function(div){
var hc1, hc2, extraTop, scale, h1, h2, hMax, mT;
hc1 = div.mrow1.getHC();
hc2 = div.mrow2.getHC();
extraTop = inc("calcExtraTop/calc")(div, hc1);
scale = div.scaleExp;
h1 = hc1.height;
h2 = hc2.height * scale + h1 * (1 - scale);
hMax = Math.max(h1, h2);
mT = h2 < hMax ? (hMax - h2) / scale : 0;
div.expDiv.css({
marginTop: mT + extraTop / 4 + "em"
});
mT = h1 < hMax ? hMax - h1 : 0;
div.mainDiv.css({
marginTop: mT + "em"
});
div.svgIcon.updateHeight(h1 + extraTop);
div.centerStartEnd(hc1.center + mT + extraTop / 2);
return {
height: hMax + extraTop,
center: hc1.center + mT + extraTop / 2
};
};
})();
mathDiv/createElement/combi2/mroot/mainDiv/div.ls
(function(){
return function(div){
return div.mainDiv = Div({
display: "flex",
alignItems: "stretch"
}).html(inc("svgIcon/svg")(div), Div({
display: "flex",
alignSelf: "stretch"
}).html(div.mrow1, inc("svgLine/svg")()));
};
})();
mathDiv/createElement/combi2/mroot/mainDiv/svgIcon/svg.ls
(function(){
return function(div, height){
var y2, marginTop, svg;
height == null && (height = 1.3);
y2 = height > 1.3 ? 92 : 87;
marginTop = 0.09;
svg = inc("../../../../_shared/svgPathPercentage/svg")({
width: "0.6em",
height: height - marginTop + "em",
path: "M0,55 L27,55 L60," + y2 + " L80,0 L100,0"
}).css({
marginTop: marginTop + "em"
});
svg.updateHeight = function(h){
if (h !== height) {
return svg.replaceWith(inc(THISFILE)(div, h));
}
};
return div.svgIcon = svg;
};
})();
mathDiv/createElement/combi2/mroot/mainDiv/svgLine/svg.ls
(function(){
return function(){
return inc("../../../../_shared/svgPathPercentage/svg")({
width: "100%",
height: "5px",
strokeWidth: "1px",
path: "M 0 0 L 100 0"
}).css({
position: "absolute",
top: 0,
left: 0,
marginTop: "0.09em"
});
};
})();
mathDiv/createElement/combi2/msub/el.ls
(function(){
return function(m, el){
var div;
div = inc("../_div/div")(m, el);
div.scaleBase = 0.7;
div.css({
alignItems: "flex-start"
});
div.html(div.spacerStart, div.mrow1, inc("subDiv/div")(div), div.spacerEnd);
div.mrow1.centerVertical = true;
div.getHC = function(){
return inc("getHC/get")(div);
};
inc("../../_shared/enableBasicStartBehaviour/enable")(m, div);
return div;
};
})();
mathDiv/createElement/combi2/msub/getHC/get.ls
(function(){
return function(div){
var hc1, hc2, scale, h1, h2, hMax, mT;
hc1 = div.mrow1.getHC();
hc2 = div.mrow2.getHC();
scale = div.scaleBase;
h1 = hc1.height;
h2 = hc2.height * scale + h1 * (1 - scale);
hMax = Math.max(h1, h2);
mT = hMax - hc2.height * scale;
div.subDiv.css({
marginTop: mT + "em"
});
return {
height: hMax,
center: hc1.center
};
};
})();
mathDiv/createElement/combi2/msub/subDiv/div.ls
(function(){
return function(div){
return div.subDiv = Div({
display: "flex",
marginLeft: "-0.05em"
}).html(div.mrow2.css({
fontSize: div.scaleBase + "em",
marginTop: "0.2em"
}));
};
})();
mathDiv/createElement/combi2/msup/el.ls
(function(){
return function(m, el){
var div;
div = inc("../_div/div")(m, el);
div.scaleExp = 0.7;
div.html(div.spacerStart, div.mrow1, inc("expDiv/div")(div), div.spacerEnd);
div.mrow1.centerVertical = true;
div.getHC = function(){
return inc("getHC/get")(div);
};
inc("../../_shared/enableBasicStartBehaviour/enable")(m, div);
return div;
};
})();
mathDiv/createElement/combi2/msup/expDiv/div.ls
(function(){
return function(div){
return div.expDiv = Div({
display: "flex",
alignSelf: "flex-start",
marginLeft: "-0.05em"
}).html(div.mrow2.css({
fontSize: div.scaleExp + "em"
}));
};
})();
mathDiv/createElement/combi2/msup/getHC/get.ls
(function(){
return function(div){
var hc1, hc2, scale, h1, h2, hMax, ref$, mT;
hc1 = div.mrow1.getHC();
hc2 = div.mrow2.getHC();
scale = div.scaleExp;
h1 = hc1.height;
h2 = hc2.height * scale + h1 * (1 - scale);
hMax = Math.max(h1, h2);
if (hc1.height > 1.3 || ((ref$ = div.mrow1.firstChild.elementTagName) === "mfenced" || ref$ === "msqrt" || ref$ === "mf_abs")) {
hMax += 0.2;
}
mT = h1 < hMax ? hMax - h1 : 0;
div.mrow1.css({
marginTop: mT + "em"
});
div.centerStartEnd(hc1.center + mT);
return {
height: hMax,
center: hc1.center + mT
};
};
})();
mathDiv/createElement/combi3/_div/div.ls
(function(){
return function(m, el){
var c, row1, row2, row3, div;
c = el.childrenAll();
row1 = c[0];
row2 = c[1];
row3 = c[2];
div = inc("../../_shared/div/div")(m, el).addClass("combi3");
div.html(inc("../../_shared/spacer/start/start")(m, div), inc("mrow1/mrow")(m, div, row1), inc("mrow2/mrow")(m, div, row2), inc("mrow3/mrow")(m, div, row3), inc("../../_shared/spacer/end/end")(m, div));
div.getHC = function(){
return inc("getHC/get")(div);
};
div.setCursor = function(pos, options){
return inc("../../_shared/setCursorCombi123/set")(m, div, pos, options);
};
div.getMathml = function(){
return inc("../../_shared/getMathmlCombi123/get")(div);
};
div.centerStartEnd = function(c){
return inc("../../_shared/centerStartEndCombi123/center")(c, div);
};
return div;
};
})();
mathDiv/createElement/combi3/_div/getHC/get.ls
(function(){
return function(div){
return div.mrow1.getHC();
};
})();
mathDiv/createElement/combi3/_div/mrow1/back/back.ls
(function(){
return function(m, div){
if (div.mrow1.isEmpty() && div.mrow2.isEmpty() && div.mrow3.isEmpty()) {
return m.removeElement(div);
} else {
return m.getCursorElement().moveCursor("left");
}
};
})();
mathDiv/createElement/combi3/_div/mrow1/mrow.ls
(function(){
return function(m, div, row1){
var el;
el = m.createElement(row1 || "");
el.back = function(){
return inc("back/back")(m, div);
};
return div.mrow1 = el;
};
})();
mathDiv/createElement/combi3/_div/mrow2/back/back.ls
(function(){
return function(m, div){
return div.mrow1.setCursor("end");
};
})();
mathDiv/createElement/combi3/_div/mrow2/mrow.ls
(function(){
return function(m, div, row2){
var el;
el = m.createElement(row2 || "");
el.back = function(){
return inc("back/back")(m, div);
};
return div.mrow2 = el;
};
})();
mathDiv/createElement/combi3/_div/mrow3/back/back.ls
(function(){
return function(m, div){
return div.mrow2.setCursor("end");
};
})();
mathDiv/createElement/combi3/_div/mrow3/mrow.ls
(function(){
return function(m, div, row3){
var el;
el = m.createElement(row3 || "");
el.back = function(){
return inc("back/back")(m, div);
};
return div.mrow3 = el;
};
})();
mathDiv/createElement/combi3/msubsup/el.ls
(function(){
return function(m, el){
var div;
div = inc("../_div/div")(m, el);
div.scaleSmall = 0.7;
div.css({
alignItems: "flex-start"
}).html(div.spacerStart, div.mrow1, Div({
display: "flex",
flexDirection: "column-reverse",
fontSize: div.scaleSmall + "em",
alignItems: "flex-start"
}).html(inc("subDiv/div")(div), inc("expDiv/div")(div)), div.spacerEnd);
div.mrow1.centerVertical = true;
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/combi3/msubsup/expDiv/div.ls
(function(){
return function(div){
return div.expDiv = div.mrow3;
};
})();
mathDiv/createElement/combi3/msubsup/getHC/get.ls
(function(){
return function(div){
var hc1, hc2, hc3, scale, h1, h2, hMax, mB, mT, center;
hc1 = div.mrow1.getHC();
hc2 = div.mrow2.getHC();
hc3 = div.mrow3.getHC();
scale = div.scaleSmall;
h1 = hc1.height;
h2 = hc2.height * scale + hc3.height * scale;
hMax = Math.max(h1, h2);
if (hc1.height > 1.3) {
hMax += 0.6;
}
mB = Math.max(0, (hMax - h2) / scale);
div.expDiv.css({
marginBottom: mB + "em"
});
mT = Math.max(0, (hMax - h1) / 2);
div.mrow1.css({
marginTop: mT + "em"
});
center = hc1.center + mT;
div.centerStartEnd(center);
return {
height: hMax,
center: center
};
};
})();
mathDiv/createElement/combi3/msubsup/subDiv/div.ls
(function(){
return function(div){
return div.subDiv = div.mrow2;
};
})();
mathDiv/createElement/create.ls
(function(){
return function(m, srcEl){
var t;
if (_.isString(srcEl)) {
srcEl = Div().html(srcEl).firstChild;
}
t = srcEl.tagName.toLowerCase();
if (t === "mrow") {
return inc("mrow/el")(m, srcEl);
} else if (t === "mgap") {
return inc("mgap/el")(m, srcEl);
} else if (t === "mn" || t === "mo" || t === "mi" || t === "mtext" || t === "mspace") {
return inc("basic/el")(m, srcEl);
} else if (t === "msqrt" || t === "mfenced") {
return inc("combi1/" + t + "/el")(m, srcEl);
} else if (t === "mfrac" || t === "msup" || t === "msub" || t === "mroot") {
return inc("combi2/" + t + "/el")(m, srcEl);
} else if (t === "msubsup") {
return inc("combi3/" + t + "/el")(m, srcEl);
} else if (t === "mtable") {
return inc("table/" + t + "/el")(m, srcEl);
} else if (in$(t, inc("../_shared/standardFunctions/functions")("mf_"))) {
return inc("mf/mf_generic/el")(m, srcEl);
} else if (t === "mf_rarrow" || t === "mf_larrow" || t === "mf_lrarrow") {
return inc("mf/mf_arrow/el")(m, srcEl);
} else if (t === "mf_abs" || t === "mf_fac" || t === "mf_bar" || t === "mf_ncr" || t === "mf_logbase" || t === "mf_lim" || t === "mf_sum" || t === "mf_unit") {
return inc("mf/" + t + "/el")(m, srcEl);
} else {
return debug("invalid srcEl", srcEl);
}
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
mathDiv/createElement/mf/mf_abs/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi1/_div/div")(m, el);
div.html(div.spacerStart.css({
margin: ""
}), inc("lineDiv/div")(), div.mrow1, inc("lineDiv/div")(), div.spacerEnd.css({
margin: ""
}));
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_abs/getHC/get.ls
(function(){
return function(div){
var hc;
hc = div.mrow1.getHC();
div.centerStartEnd(hc.center);
return hc;
};
})();
mathDiv/createElement/mf/mf_abs/lineDiv/div.ls
(function(){
return function(){
return Div({
display: "flex",
width: "0.3em",
alignSelf: "stretch"
}).html(inc("svgLine/svg")());
};
})();
mathDiv/createElement/mf/mf_abs/lineDiv/svgLine/svg.ls
(function(){
return function(){
return inc("../../../../_shared/svgPathPercentage/svg")({
width: "100%",
height: "100%",
strokeWidth: "1px",
path: "M50 5 L 50 95"
});
};
})();
mathDiv/createElement/mf/mf_arrow/el.ls
(function(){
return function(m, el){
var div, ref$;
div = inc("../../combi1/_div/div")(m, el);
div.arrowType = el.tagName.split("_")[1].toLowerCase();
div.html(div.spacerStart.css({
margin: ""
}), Div({
display: "flex"
}).html(div.mrow1, inc("svgLine/svg")(), (ref$ = div.arrowType) === "larrow" || ref$ === "lrarrow" ? inc("svgHead/svg")("left") : void 8, (ref$ = div.arrowType) === "rarrow" || ref$ === "lrarrow" ? inc("svgHead/svg")("right") : void 8), div.spacerEnd.css({
margin: ""
}));
return div;
};
})();
mathDiv/createElement/mf/mf_arrow/svgHead/svg.ls
(function(){
return function(t){
return inc("../../../_shared/svgPathPercentage/svg")({
width: "3px",
height: "5px",
strokeWidth: "1px",
path: t === "left" ? "M100 5 L0 50 L100 95" : "M0 5 L100 50 L0 95"
}).css({
position: "absolute",
top: 0
}).css(t === "left"
? {
left: "-1px"
}
: {
right: "-1px"
});
};
})();
mathDiv/createElement/mf/mf_arrow/svgLine/svg.ls
(function(){
return function(){
return inc("../../../_shared/svgPathPercentage/svg")({
width: "100%",
height: "5px",
path: "M 0 50 L 100 50",
strokeWidth: "1.0px"
}).css({
position: "absolute",
top: 0,
left: 0
});
};
})();
mathDiv/createElement/mf/mf_bar/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi1/_div/div")(m, el);
div.html(div.spacerStart, Div({
display: "flex"
}).html(div.mrow1, inc("svgLine/line")()), div.spacerEnd);
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_bar/getHC/get.ls
(function(){
return function(div){
var hc, l, ref$, ref1$, r, ref2$, ref3$;
hc = div.mrow1.getHC();
l = ((ref$ = div.previousSibling) != null ? ref$.elementTagName : void 8) === ((ref1$ = div.mrow1.firstChild) != null ? ref1$.elementTagName : void 8) ? "-0.07em" : void 8;
r = ((ref2$ = div.nextSibling) != null ? ref2$.elementTagName : void 8) === ((ref3$ = div.mrow1.lastChild) != null ? ref3$.elementTagName : void 8) ? "-0.07em" : void 8;
div.css({
marginLeft: l,
marginRight: r
});
div.centerStartEnd(hc.center);
return hc;
};
})();
mathDiv/createElement/mf/mf_bar/svgLine/line.ls
(function(){
return function(){
return inc("../../../_shared/svgPathPercentage/svg")({
width: "100%",
height: "2px",
path: "M 3 0 L 97 0",
strokeWidth: "1px"
}).css({
position: "absolute",
top: 0,
left: 0,
marginTop: "0.2em"
});
};
})();
mathDiv/createElement/mf/mf_fac/back/back.ls
(function(){
return function(m, div){
var childElements;
if (div.mrow1.isEmpty()) {
return m.removeElement(div);
} else {
childElements = div.mrow1.childrenAll();
m.replaceElement(div, childElements);
return _.last(childElements).setCursor("end");
}
};
})();
mathDiv/createElement/mf/mf_fac/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi1/_div/div")(m, el);
div.html(div.spacerStart, div.mrow1, inc("facDiv/div")(), div.spacerEnd);
div.spacerEnd.back = function(){
return inc("back/back")(m, div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_fac/facDiv/div.ls
(function(){
return function(){
return Div().addClass("svgExport").html("!");
};
})();
mathDiv/createElement/mf/mf_generic/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi1/_div/div")(m, el);
div.funcName = el.tagName.split("_")[1].toLowerCase();
div.html(div.spacerStart.css({
margin: ""
}), inc("funcNameDiv/div")(div), inc("../../_shared/fenceSvg/svg")(div, "left"), div.mrow1, inc("../../_shared/fenceSvg/svg")(div, "right"), div.spacerEnd);
div.mrow1.centerVertical = true;
div.getHC_original = div.getHC;
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_generic/funcNameDiv/div.ls
(function(){
return function(div){
var n, isA;
n = div.funcName;
if (_.startsWith(n, "a")) {
isA = true;
n = n.substr(1);
}
return div.funcNameDiv = Div({
display: "flex",
marginRight: "-0.05em"
}).addClass("funcNameDiv").html(inc("name/name")(n), inc("expMinusOne/exp")(isA));
};
})();
mathDiv/createElement/mf/mf_generic/funcNameDiv/expMinusOne/exp.ls
(function(){
return function(isA){
if (!isA) {
return;
}
return Div({
display: "flex",
alignSelf: "flex-start",
fontSize: "0.7em",
marginLeft: "0.1em"
}).addClass("svgExport").html("-1");
};
})();
mathDiv/createElement/mf/mf_generic/funcNameDiv/name/name.ls
(function(){
return function(n){
return Div().addClass("svgExport").html(n);
};
})();
mathDiv/createElement/mf/mf_generic/getHC/get.ls
(function(){
return function(div){
var hc, mT;
hc = div.getHC_original();
mT = hc.height / 2 - 1.3 / 2;
div.funcNameDiv.css({
marginTop: mT + "em"
});
return hc;
};
})();
mathDiv/createElement/mf/mf_lim/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi1/_div/div")(m, el);
div.scaleUnder = 0.7;
div.html(div.spacerStart.css({
margin: ""
}), Div({
display: "flex",
flexDirection: "column"
}).html(inc("funcNameDiv/div")(div), inc("underDiv/div")(div)), div.spacerEnd.css({
margin: ""
}));
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_lim/funcNameDiv/div.ls
(function(){
return function(div){
return div.funcNameDiv = Div({
display: "flex",
marginBottom: "-0.25em"
}).addClass("funcNameDiv svgExport").html("lim");
};
})();
mathDiv/createElement/mf/mf_lim/getHC/get.ls
(function(){
return function(div){
var hc, h1, h2, h, c;
hc = div.mrow1.getHC();
h1 = 1.3;
h1 = h1 - 0.25;
h2 = hc.height * div.scaleUnder;
h = h1 + h2;
c = 1.3 / 2;
div.centerStartEnd(c);
return {
height: h,
center: c
};
};
})();
mathDiv/createElement/mf/mf_lim/underDiv/div.ls
(function(){
return function(div){
return div.baseDiv = Div({
display: "flex",
fontSize: div.scaleUnder + "em"
}).html(div.mrow1);
};
})();
mathDiv/createElement/mf/mf_logbase/baseDiv/div.ls
(function(){
return function(div){
return div.baseDiv = Div({
display: "flex"
}).html(div.mrow2.css({
fontSize: div.scaleBase + "em",
marginTop: "0.3em",
marginLeft: "0.05em",
marginRight: "-0.15em"
}));
};
})();
mathDiv/createElement/mf/mf_logbase/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi2/_div/div")(m, el);
div.scaleBase = 0.7;
div.html(div.spacerStart, inc("funcNameDiv/div")(div), inc("baseDiv/div")(div), inc("../../_shared/mainDiv/div")(div), div.spacerEnd);
div.mrow1.centerVertical = true;
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_logbase/funcNameDiv/div.ls
(function(){
return function(div){
return div.funcNameDiv = Div({
display: "flex"
}).addClass("funcNameDiv svgExport").html("log");
};
})();
mathDiv/createElement/mf/mf_logbase/getHC/get.ls
(function(){
return function(div){
var hc1, hc2, scale, h1, h2, hMax, mT, mT2;
hc1 = div.mrow1.getHC();
hc2 = div.mrow2.getHC();
scale = div.scaleBase;
h1 = hc1.height;
h2 = scale * hc2.height + (1 - scale) * hc1.height;
hMax = Math.max(h1, h2);
mT = h1 / 2 - 1.3 / 2;
div.funcNameDiv.css({
marginTop: mT + "em"
});
mT2 = mT + (1 - scale);
div.baseDiv.css({
marginTop: mT2 + "em"
});
div.fenceSvgLeft.updateHeight(h1);
div.fenceSvgRight.updateHeight(h1);
div.centerStartEnd(hc1);
return {
height: hMax,
center: hc1.center
};
};
})();
mathDiv/createElement/mf/mf_ncr/el.ls
(function(){
return function(m, el){
var childScale, div;
childScale = 0.7;
div = inc("../../combi2/_div/div")(m, el);
div.html(div.spacerStart, inc("../../_shared/fenceSvg/svg")(div, "left"), Div({
display: "flex",
flexDirection: "column",
alignItems: "stretch"
}).html(div.mrow1.css({
fontSize: childScale + "em"
}), div.mrow2.css({
fontSize: childScale + "em"
})), inc("../../_shared/fenceSvg/svg")(div, "right"), div.spacerEnd);
div.getHC = function(){
return inc("getHC/get")(div, childScale);
};
return div;
};
})();
mathDiv/createElement/mf/mf_ncr/getHC/get.ls
(function(){
return function(div, childScale){
var h1, h2, h;
h1 = div.mrow1.getHC().height * childScale;
h2 = div.mrow2.getHC().height * childScale;
h = h1 + h2;
div.fenceSvgLeft.updateHeight(h);
div.fenceSvgRight.updateHeight(h);
div.centerStartEnd(h1);
return {
height: h,
center: h1
};
};
})();
mathDiv/createElement/mf/mf_sum/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi2/_div/div")(m, el);
div.scaleUnderOver = 0.7;
div.html(div.spacerStart.css({
margin: ""
}), Div({
display: "flex",
flexDirection: "column-reverse"
}).html(inc("underOverDiv/div")(div, div.mrow1), inc("underOverSvg/svg")(div), inc("underOverDiv/div")(div, div.mrow2)), div.spacerEnd.css({
margin: ""
}));
div.getHC = function(){
return inc("getHC/get")(div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_sum/getHC/get.ls
(function(){
return function(div){
var hc1, hc2, hc3, h, c;
hc1 = div.mrow1.getHC();
hc2 = div.mrow2.getHC();
hc3 = 1.3;
h = hc1.height * div.scaleUnderOver + 1.3 + hc2.height * div.scaleUnderOver;
c = hc2.height * div.scaleUnderOver + 1.3 / 2;
div.centerStartEnd(c);
return {
height: h,
center: c
};
};
})();
mathDiv/createElement/mf/mf_sum/underOverDiv/div.ls
(function(){
return function(div, mrow){
return Div({
display: "flex",
fontStyle: "italic",
fontSize: div.scaleUnderOver + "em"
}).html(mrow);
};
})();
mathDiv/createElement/mf/mf_sum/underOverSvg/svg.ls
(function(){
return function(div){
return inc("../../../_shared/svgPathPercentage/svg")({
width: "1em",
height: "1.3em",
path: "M80,10 L10,10 L50,50 L10,90 L80,90",
strokeWidth: "1.5px"
}).addClass("funcNameDiv");
};
})();
mathDiv/createElement/mf/mf_unit/back/back.ls
(function(){
return function(m, div){
return m.removeElement(div);
};
})();
mathDiv/createElement/mf/mf_unit/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../combi1/_div/div")(m, el);
div.html(div.spacerStart.css({
margin: ""
}), inc("mrow/mrow")(div), div.spacerEnd);
div.spacerStart.moveCursor = function(direction){
return inc("moveCursor/moveStart")(direction, div);
};
div.spacerEnd.moveCursor = function(direction){
return inc("moveCursor/moveEnd")(direction, div);
};
div.spacerEnd.back = function(){
return inc("back/back")(m, div);
};
return div;
};
})();
mathDiv/createElement/mf/mf_unit/moveCursor/moveEnd.ls
(function(){
return function(d, div){
if (d === "left") {
return div.setCursor("start");
} else if (d === "right") {
return div.setCursor("after");
}
};
})();
mathDiv/createElement/mf/mf_unit/moveCursor/moveStart.ls
(function(){
return function(d, div){
if (d === "left") {
return div.setCursor("before");
} else if (d === "right") {
return div.setCursor("end");
}
};
})();
mathDiv/createElement/mf/mf_unit/mrow/mrow.ls
(function(){
return function(div){
var mrow, i$, ref$, len$, el;
mrow = div.mrow1;
mrow.css({
marginLeft: "-0.1em",
pointerEvents: "none"
});
for (i$ = 0, len$ = (ref$ = mrow.findAll(".mtext")).length; i$ < len$; ++i$) {
el = ref$[i$];
el.css({
paddingRight: "0.05em"
});
}
for (i$ = 0, len$ = (ref$ = mrow.findAll(".msub")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.nextSibling) {
el.css({
marginRight: "-0.1em"
});
}
}
return mrow;
};
})();
mathDiv/createElement/mgap/el.ls
(function(){
return function(m, el){
var c, row, div;
c = el.childrenAll();
row = c[0];
div = inc("../_shared/div/div")(m, el).css({
background: Color.grey[100],
cursor: "text",
margin: "0 0.05em",
minWidth: "1em",
paddingLeft: "0.1em",
paddingRight: "0.2em",
justifyContent: "flex-start"
});
div.html(inc("mrow/mrow")(m, div, row));
div.getHC = function(){
return inc("getHC/get")(div);
};
div.setCursor = function(pos){
return inc("setCursor/set")(div, pos);
};
div.getMathml = function(){
return inc("getMathml/get")(div);
};
inc("gap/gap")(m, el, div);
return div;
};
})();
mathDiv/createElement/mgap/gap/calcChoices/calc.ls
(function(){
return function(v){
var parts, defaultCorrect, choices, p;
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/createElement/mgap/gap/finishGap/finish.ls
(function(){
return function(m, gap){
delete m.slide.levelPlayer.currentGap;
gap.css({
cursor: ""
});
return m.startNextGap();
};
})();
mathDiv/createElement/mgap/gap/gap.ls
(function(){
return function(m, el, div){
var gap, gapContent, validateMode, index, that;
gap = div;
gapContent = el.attr("gap");
validateMode = el.attr("validatemode");
index = +el.attr("index");
gap.addClass("gap gap" + index + "").addClass(m.mode === "gapButtons" ? "gapButton" : void 8).attr({
gap: gapContent,
index: index
});
if (that = validateMode) {
gap.attr({
validatemode: that
});
}
gap.gapIndex = index;
gap.gapIsCompleted = false;
gap.gapValidateMode = validateMode != null
? validateMode
: m.gapValidateMode;
gap.choices = inc("calcChoices/calc")(gapContent);
gap.startGap = function(){
return inc("startGap/start")(m, gap);
};
gap.stopGap = function(){
return inc("stopGap/stop")(m, gap);
};
gap.finishGap = function(){
return inc("finishGap/finish")(m, gap);
};
gap.getValue = function(){
return inc("getValue/get")(m, gap);
};
gap.setValue = function(v){
return inc("setValue/set")(m, gap, v);
};
if (m.mode === "gapWrite") {
gap.submitGap = function(){
return inc("submitGap/gapWrite/submit")(m, gap);
};
}
if (m.mode === "gapButtons") {
return gap.submitGap = function(button){
return inc("submitGap/gapButtons/submit")(m, gap, button);
};
}
};
})();
mathDiv/createElement/mgap/gap/getValue/get.ls
(function(){
return function(m, gap){
var amParts, res$, i$, ref$, len$, el, mathml, am, v;
if (gap.mrow.isEmpty()) {
return "";
}
res$ = [];
for (i$ = 0, len$ = (ref$ = gap.mrow.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
mathml = el.getMathml();
res$.push(am = inc("/mathDiv/_shared/getAsciimathFromMathml/get")(mathml));
}
amParts = res$;
v = amParts.join("");
return v = v.split(" ").join("");
};
})();
mathDiv/createElement/mgap/gap/setValue/set.ls
(function(){
return function(m, gap, value){
var mEl, row;
mEl = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, value);
row = "" + mEl.innerHTML + "";
gap.mrow.replaceWith(inc("../../mrow/mrow")(m, gap, row));
return m.cleanupLayout();
};
})();
mathDiv/createElement/mgap/gap/startGap/gapButtons/reuseOldButtonsDiv/reuse.ls
(function(){
return function(m, gap){
var i$, ref$, len$, el;
for (i$ = 0, len$ = (ref$ = m.buttonsDiv.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
el.css({
pointerEvents: "inherit"
});
}
return m.buttonsDiv.css({
pointerEvents: "auto"
}).show();
};
})();
mathDiv/createElement/mgap/gap/startGap/gapButtons/showButtons/button/button.ls
(function(){
return function(m, gap, choice, i){
var tap, value, button;
tap = function(){
var ref$;
return (ref$ = m.slide.levelPlayer.currentGap) != null ? ref$.submitGap(button) : void 8;
};
value = choice;
button = Button({
minWidth: "1em",
label: inc("/mathDiv/mathDiv")({
value: value,
enabled: false
})
}).css({
margin: "0.5em",
minWidth: "1em"
}).tap(tap);
button.value = value;
return button;
};
})();
mathDiv/createElement/mgap/gap/startGap/gapButtons/showButtons/calcShuffledChoices/calc.ls
(function(){
return function(m, gap){
var that, choices;
if (that = gap.shuffledChoices) {
return that;
}
choices = _.map(gap.choices, "text");
if (m.combineButtons) {
choices = _.concat(choices, inc("calcOtherSlideGapChoices/calc")(m, gap));
}
choices = _.uniq(choices);
if (m.shuffleButtons) {
choices = _.shuffleWithSeed(choices);
}
return gap.shuffledChoices = choices;
};
})();
mathDiv/createElement/mgap/gap/startGap/gapButtons/showButtons/calcShuffledChoices/calcOtherSlideGapChoices/calc.ls
(function(){
return function(m, gap){
var choices, gaps, ref$, i$, len$, g, j$, ref1$, len1$, c;
choices = [];
gaps = ((ref$ = m.slide.div.closest(".mixed")) != null ? ref$.gaps() : void 8) || m.slide.div.findAll(".mgap");
for (i$ = 0, len$ = gaps.length; i$ < len$; ++i$) {
g = gaps[i$];
for (j$ = 0, len1$ = (ref1$ = g.choices).length; j$ < len1$; ++j$) {
c = ref1$[j$];
choices.push(c.text);
}
}
return choices;
};
})();
mathDiv/createElement/mgap/gap/startGap/gapButtons/showButtons/show.ls
(function(){
return function(m, gap){
var choices, ref$, i, choice;
choices = inc("calcShuffledChoices/calc")(m, gap);
if ((ref$ = m.buttonsDiv.parent()) != null) {
ref$.show();
}
return m.buttonsDiv.css({
pointerEvents: "auto",
opacity: 0
}).html((function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = choices).length; i$ < len$; ++i$) {
i = i$;
choice = ref$[i$];
results$.push(inc("button/button")(m, gap, choice, i));
}
return results$;
}())).fadeIn();
};
})();
mathDiv/createElement/mgap/gap/startGap/gapButtons/start.ls
(function(){
return function(m, gap){
if (m.combineButtons && m.buttonsDiv.childrenAll().length > 0) {
return inc("reuseOldButtonsDiv/reuse")(m, gap);
} else {
return inc("showButtons/show")(m, gap);
}
};
})();
mathDiv/createElement/mgap/gap/startGap/gapWrite/start.ls
(function(){
return function(m, gap){
var n;
gap.cssVar({
style_empty_color: m.styles.emptyColor
});
n = m.getSelection().anchorNode;
if (!gap.contains(n)) {
gap.setCursor("end");
}
return m.startScreenKeyboard();
};
})();
mathDiv/createElement/mgap/gap/startGap/initSlideContext/init.ls
(function(){
return function(m, gap){
var g;
g = m.slide.levelPlayer.currentGap;
if (g !== gap) {
if (g != null) {
g.stopGap();
}
}
m.slide.levelPlayer.currentGap = gap;
m.slide.gapClickStartDisabled = false;
return app.currentPage.scrollElementIntoView(gap, {
padding: 50
});
};
})();
mathDiv/createElement/mgap/gap/startGap/start.ls
(function(){
return function(m, gap){
if (m.currentGap && m.currentGap !== gap) {
m.currentGap.stopGap();
}
inc("initSlideContext/init")(m, gap);
m.start({
dontSetCursor: true
});
m.currentGap = gap;
if (m.mode === "gapWrite") {
inc("gapWrite/start")(m, gap);
} else if (m.mode === "gapButtons") {
inc("gapButtons/start")(m, gap);
}
return m.updateCustomCursor();
};
})();
mathDiv/createElement/mgap/gap/stopGap/stop.ls
(function(){
return function(m, gap){
var ref$, ref1$, ref2$;
m.stopScreenKeyboard();
if ((ref$ = m.buttonsDiv) != null) {
ref$.hide();
}
m.stop();
delete m.currentGap;
return ref2$ = (ref1$ = m.slide.levelPlayer).currentGap, delete ref1$.currentGap, ref2$;
};
})();
mathDiv/createElement/mgap/gap/submitGap/_calcResult/calc.ls
(function(){
return function(m, gap, value){
var choices, solutionStrings, isCorrect;
choices = inc("calcAvailableChoices/calc")(m, gap);
choices = inc("filterFittingChoices/filter")(gap, choices);
solutionStrings = _.map(_.filter(choices, {
correct: true
}), "text");
if (m.params.mode === "gapButtons") {
isCorrect = in$(value, solutionStrings);
} else {
isCorrect = m.checkEquivalence({
value: value,
solutions: solutionStrings,
gapValidateMode: gap.gapValidateMode
});
}
if (isCorrect) {
return {
correct: true
};
} else {
return {
correct: false,
solution: inc("calcSolution/calc")(choices)
};
}
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
mathDiv/createElement/mgap/gap/submitGap/_calcResult/calcAvailableChoices/calc.ls
(function(){
return function(m, gap){
var usedValues;
if (!m.uniqueSolutions || _.filter(gap.choices, "correct").length === 1) {
return gap.choices;
}
usedValues = inc("calcUsedSlideGapValues/calc")(m, gap);
return _.filter(gap.choices, function(c){
return !m.checkEquivalence({
value: c.text,
solutions: usedValues
});
});
};
})();
mathDiv/createElement/mgap/gap/submitGap/_calcResult/calcAvailableChoices/calcUsedSlideGapValues/calc.ls
(function(){
return function(m, gap){
var gaps, ref$, usedValues;
gaps = ((ref$ = m.div.closest(".mixed")) != null ? ref$.gaps() : void 8) || m.gaps;
gaps = _.filter(gaps, function(g){
return g.gapIsCompleted && g.choices.length > 1;
});
return usedValues = _.map(gaps, function(g){
var v, ref$;
return v = (ref$ = g.correctValue) != null
? ref$
: g.value;
});
};
})();
mathDiv/createElement/mgap/gap/submitGap/_calcResult/calcSolution/calc.ls
(function(){
return function(choices){
var c;
c = _.find(choices, {
correct: true
});
return c != null ? c.text : void 8;
};
})();
mathDiv/createElement/mgap/gap/submitGap/_calcResult/filterFittingChoices/filter.ls
(function(){
return function(gap, choices){
var choices2;
choices2 = _.filter(choices, function(c){
return c.correct && _.includes(c.text, gap.getValue());
});
if (choices2.length > 0) {
return choices2;
} else {
return choices;
}
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapButtons/finish/finish.ls
(function(){
return function(m, button, gap){
button.setState("normal");
inc("removeCorrectButton/remove")(m, button, gap);
return gap.finishGap();
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapButtons/finish/removeCorrectButton/isDone/is.ls
(function(){
return function(m, button){
var v, gaps, ref$, i$, len$, g;
v = button.value;
gaps = ((ref$ = m.div.closest(".mixed")) != null ? ref$.gaps() : void 8) || m.gaps;
for (i$ = 0, len$ = gaps.length; i$ < len$; ++i$) {
g = gaps[i$];
if (g.gapIsCompleted) {
continue;
}
if (_.find(g.choices, {
text: v,
correct: true
})) {
return false;
}
}
return true;
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapButtons/finish/removeCorrectButton/remove.ls
(function(){
return function(m, button, gap){
var isDone;
if (!m.removeCorrectButton) {
return;
}
isDone = inc("isDone/is")(m, button);
if (isDone) {
return button.css({
visibility: "hidden"
});
}
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapButtons/onCorrect/on.ls
(function(){
return function(m, gap, button, result, finish){
var c, action;
gap.cssVar({
style_color: c = Color.green[500]
});
button.setState("correct");
m.cursor.hide();
m.slide.levelPlayer.progressBar.showGreen();
action = {
gap: gap.gapIndex,
value: button.value
};
return m.params.onActionCorrect(action, function(){
gap.gapIsCompleted = true;
gap.value = button.value;
return setTimeout(finish, 700);
});
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapButtons/onMistake/on.ls
(function(){
return function(m, gap, button, result, finish){
var ref$, onTimeout;
gap.cssVar({
style_color: Color.red[500]
});
button.setState("wrong");
m.cursor.hide();
m.slide.levelPlayer.progressBar.addElement().showRed();
if (typeof (ref$ = m.params).onActionMistake == 'function') {
ref$.onActionMistake({
gap: gap.gapIndex,
value: button.value,
solution: result.solution
});
}
onTimeout = function(){
if (body.findFirst(".feedback")) {
return setTimeout(onTimeout, 100);
} else {
return inc("retry/retry")(m, gap, button);
}
};
return setTimeout(onTimeout, 700);
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapButtons/onMistake/retry/retry.ls
(function(){
return function(m, gap, button){
gap.mrow.html(gap.mrow.formerChildren);
gap.cssVar({
style_color: "black"
});
button.setState("normal");
m.buttonsDiv.css({
pointerEvents: ""
});
m.slide.gapClickStartDisabled = false;
return m.cleanupLayout();
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapButtons/submit.ls
(function(){
return function(m, gap, button){
var value, result, fillGap, freeze, decide, onCorrect, onMistake, finish;
value = button.value;
result = inc("../_calcResult/calc")(m, gap, value);
if (gap.gapIsCompleted) {
return;
}
if (m.params.submitGap != null) {
m.params.submitGap(m, gap, result, button);
return;
}
fillGap = function(){
var mEl, mrowChoice;
mEl = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, value);
mrowChoice = m.createElement("" + mEl.innerHTML + "");
gap.mrow.formerChildren = gap.mrow.childrenAll();
gap.mrow.html(mrowChoice);
m.cleanupLayout();
return freeze();
};
freeze = function(){
m.slide.gapClickStartDisabled = true;
m.buttonsDiv.css({
pointerEvents: "none"
});
return decide();
};
decide = function(){
if (result.correct) {
return onCorrect();
} else {
return onMistake();
}
};
onCorrect = function(){
return inc("onCorrect/on")(m, gap, button, result, finish);
};
onMistake = function(){
return inc("onMistake/on")(m, gap, button, result, finish);
};
finish = function(){
return inc("finish/finish")(m, button, gap);
};
return fillGap();
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onCorrect/on.ls
(function(){
return function(m, gap, value, result, finish){
var action;
gap.cssVar({
style_color: Color.green[500]
});
m.slide.levelPlayer.progressBar.showGreen();
action = {
gap: gap.gapIndex,
value: value
};
return m.params.onActionCorrect(action, function(){
gap.gapIsCompleted = true;
gap.value = value;
return finish();
});
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/contentDiv/buttonRetry/button.ls
(function(){
return function(t){
return Button({
label: T("tryAgain"),
icon: path("/../app01/lib/svg/icon/refresh.svg")
}).css({
marginRight: "0.8em"
}).tap(function(){
return t("retry");
}).addClass("keyManager-enter keyManager-esc").bind("keyManager", function(){
var ref$;
if ((ref$ = body.findFirst(".calculatorBackground")) != null && ref$.isVisible()) {
return;
}
return t("retry");
});
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/contentDiv/buttonSolve/button.ls
(function(){
return function(t){
return Button({
label: T("solve"),
icon: path("/../app01/lib/svg/icon/lock-open.svg")
}).tap(function(){
return t("solve");
});
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/contentDiv/div.ls
(function(){
return function(onClose){
return Div({
padding: "0.3em",
textAlign: "center"
}).html(inc("text/text")(), Div({
margin: "0.7em 0 0.4em"
}).html(inc("buttonRetry/button")(onClose), inc("buttonSolve/button")(onClose), inc("keyDiv/div")(onClose)));
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/contentDiv/keyDiv/div.ls
(function(){
return function(close){
return Div().addClass("keyManager-enter keyManager-esc keyManager-space").bind("keyManager", function(){
if (body.findFirst(".calculatorBackground")) {
return;
}
return close("keyboard");
});
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/contentDiv/text/text.ls
(function(){
return function(){
return Div().html(T("oopsWrong"));
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/message.ls
(function(){
return function(m, gap, value, result, finish){
var div;
div = Div({
display: "flex",
height: m.screenKeyboard.lastHeight + "px"
}).addClass("bottomMessage hint gapWriteMistakeHint keyManagerScope gestureManagerScope").html(inc("contentDiv/div")(function(v){
return div.onClose(v);
})).appendTo(app.currentPage.bottom).fadeIn();
div.onClose = function(v){
return inc("onClose/on")(v, div, m, gap, value, result, finish);
};
div.solveAndContinue = function(){
return div.onClose("solve");
};
div.retryAndContinue = function(){
return div.onClose("retry");
};
div.isDone = function(){
return div.isClosed;
};
return div;
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/onClose/on.ls
(function(){
return function(v, div, m, gap, value, result, finish){
m.enabled = true;
div.isClosed = true;
div.remove();
if (v === "solve") {
return inc("solve/solve")(m, gap, value, result, finish);
} else {
return inc("retry/retry")(m, gap);
}
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/onClose/retry/retry.ls
(function(){
return function(m, gap){
m.slide.gapClickStartDisabled = false;
gap.cssVar({
style_color: gap._originalGapColor
});
m.startNextGap();
return m.selectAll();
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/onClose/solve/showSolution/diagonalLine/line.ls
(function(){
return function(){
return inc("/mathDiv/createElement/_shared/svgPathPercentage/svg")({
width: "100%",
height: "100%",
path: "M 0 0 L 100 100",
strokeWidth: "1.5px",
strokeColor: Color.red[500]
}).css({
position: "absolute",
top: 0,
bottom: 0,
left: 0,
right: 0
}).addClass("diagonalLine");
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/onClose/solve/showSolution/show.ls
(function(){
return function(m, gap, result){
var mElInput, mElSolution, mEl, mrowInput, mrowSolution;
mElInput = gap.getMathml();
mElSolution = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, result.solution);
mEl = gap.getMathml();
mrowInput = m.createElement(mEl).findFirst(".mrow");
mEl = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, result.solution);
mrowSolution = m.createElement("" + mEl.innerHTML + "").cssVar({
style_color: Color.grey[500]
});
gap.mrow.html(mrowInput, mrowSolution);
m.cleanupLayout();
return mrowInput.append(inc("diagonalLine/line")());
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/bottomMessage/onClose/solve/solve.ls
(function(){
return function(m, gap, value, result, finish){
var solve, onTimeout;
solve = function(){
var ref$;
inc("showSolution/show")(m, gap, result);
m.slide.levelPlayer.progressBar.showGrey();
if (typeof (ref$ = m.params).onActionResolved == 'function') {
ref$.onActionResolved({
gap: gap.gapIndex,
solution: result.solution
});
}
gap.gapIsCompleted = true;
gap.value = result.solution;
return setTimeout(onTimeout, 500);
};
onTimeout = function(){
var gaps, ref$, nextGap;
gaps = (ref$ = m.slide) != null ? ref$.div.findAll(".gap") : void 8;
nextGap = _.find(gaps, {
gapIsCompleted: false
});
if (!nextGap && !m.slide.finishButton) {
m.slide.finishButton = true;
}
return finish();
};
return solve();
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/onMistake/on.ls
(function(){
return function(m, gap, value, result, finish){
var ref$;
gap._originalGapColor = gap.cssVar("style_color");
gap.cssVar({
style_color: Color.red[500],
style_empty_color: Color.red[200]
});
m.enabled = false;
inc("bottomMessage/message")(m, gap, value, result, finish);
m.slide.levelPlayer.progressBar.addElement().showRed();
return typeof (ref$ = m.params).onActionMistake == 'function' ? ref$.onActionMistake({
gap: gap.gapIndex,
value: value,
solution: result.solution
}) : void 8;
};
})();
mathDiv/createElement/mgap/gap/submitGap/gapWrite/submit.ls
(function(){
return function(m, gap){
var value, result, freeze, decide, onCorrect, onMistake, finish;
value = gap.getValue();
result = inc("../_calcResult/calc")(m, gap, value);
if (value.length === 0 || gap.gapIsCompleted) {
return;
}
if (m.params.submitGap != null) {
m.params.submitGap(m, gap, result);
return;
}
freeze = function(){
m.stop();
m.slide.gapClickStartDisabled = true;
gap.css({
userSelect: "none"
});
return decide();
};
decide = function(){
if (result.correct) {
return onCorrect();
} else {
return onMistake();
}
};
onCorrect = function(){
return inc("onCorrect/on")(m, gap, value, result, finish);
};
onMistake = function(r){
return inc("onMistake/on")(m, gap, value, result, finish);
};
finish = function(){
return gap.finishGap();
};
return freeze();
};
})();
mathDiv/createElement/mgap/getHC/get.ls
(function(){
return function(div){
return div.mrow.getHC();
};
})();
mathDiv/createElement/mgap/getMathml/get.ls
(function(){
return function(div){
var t, f;
t = div.elementTagName;
f = function(n){
if (div.attr(n) != null) {
return n + '="' + div.attr(n) + '" ';
} else {
return "";
}
};
return "<" + t + " " + f('gap') + " " + f('index') + " " + f('validatemode') + ">" + div.mrow.getMathml() + "" + t + ">";
};
})();
mathDiv/createElement/mgap/mrow/mrow.ls
(function(){
return function(m, div, row){
var el, f;
el = m.createElement(row || "");
el.transparentPlaceholder = true;
el.back = function(){};
f = el.setCursor;
el.setCursor = function(pos){
if (pos === "start" || pos === "end") {
return f(pos);
}
};
return div.mrow = el;
};
})();
mathDiv/createElement/mgap/setCursor/set.ls
(function(){
return function(div, pos){
if (pos === "start") {
return div.mrow.setCursor(pos);
} else if (pos === "end") {
return div.mrow.setCursor(pos);
}
};
})();
mathDiv/createElement/mrow/adjustChildrenHC/adjust.ls
(function(){
return function(m, div){
var hc, i$, ref$, len$, el, hc2, results$ = [];
hc = div.getHC();
for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.hasClass("diagonalLine")) {
continue;
}
hc2 = el.getHC();
results$.push(el.css({
height: hc2.height + "em",
marginTop: hc.center - hc2.center + "em"
}));
}
return results$;
};
})();
mathDiv/createElement/mrow/back/back.ls
(function(){
return function(m, div){
var that;
if (div.isEmpty()) {
return m.removeElement(div);
} else if (that = div.previousMathElement()) {
that.setCursor("end");
return m.getCursorElement().back();
} else {
return div.parentMathElement().back();
}
};
})();
mathDiv/createElement/mrow/el.ls
(function(){
return function(m, el){
var div;
div = inc("../_shared/div/div")(m, el).css({
alignItems: "flex-start"
});
div.html(inc("elements/elements")(m, el, div));
div.centerVertical = false;
div.transparentPlaceholder = inc("transparentPlacholder/transparentPlacholder")(m, div);
div.getHC = function(){
return inc("getHC/get")(div);
};
div.adjustChildrenHC = function(){
return inc("adjustChildrenHC/adjust")(m, div);
};
div.insertElement = function(elNew){
return inc("modify/insertElement/insert")(m, div, elNew);
};
div.removeElement = function(el2){
return inc("modify/removeElement/remove")(m, div, el2);
};
div.replaceElement = function(el2, el3){
return inc("modify/replaceElement/replace")(m, div, el2, el3);
};
div.setCursor = function(pos){
return inc("setCursor/set")(m, div, pos);
};
div.moveCursor = function(direction){
return inc("moveCursor/move")(m, div, direction);
};
div.back = function(){
return inc("back/back")(m, div);
};
div.getMathml = function(){
return inc("getMathml/get")(m, div);
};
div.isEmpty = function(){
return inc("isEmpty/is")(div);
};
return div;
};
})();
mathDiv/createElement/mrow/elements/elements.ls
(function(){
return function(m, el, div){
var elements, i$, len$, el2, results$ = [];
elements = el.childrenAll();
if (elements.length === 0) {
return inc("../../_shared/spacer/emptyPlaceholder/emptyPlaceholder")(m, div);
} else {
for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) {
el2 = elements[i$];
results$.push(m.createElement(el2));
}
return results$;
}
};
})();
mathDiv/createElement/mrow/getHC/centerVertical/center.ls
(function(){
return function(div, hc){
var h, d, p;
h = hc.height;
d = h - hc.center * 2;
if (d === 0) {
p = "";
} else if (d < 0) {
p = "0 0 " + (-d + "em") + " 0";
h = h - d;
hc = {
height: h,
center: h / 2
};
} else {
p = (d + "em") + " 0 0 0";
h = h + d;
hc = {
height: h,
center: h / 2
};
}
return hc;
};
})();
mathDiv/createElement/mrow/getHC/get.ls
(function(){
return function(div){
var hMax, cMax, hcs, res$, i$, ref$, len$, el, hc, h;
hMax = 0;
cMax = 0;
res$ = [];
for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.hasClass("diagonalLine")) {
continue;
}
res$.push(el.getHC());
}
hcs = res$;
for (i$ = 0, len$ = hcs.length; i$ < len$; ++i$) {
hc = hcs[i$];
cMax = Math.max(cMax, hc.center);
}
for (i$ = 0, len$ = hcs.length; i$ < len$; ++i$) {
hc = hcs[i$];
h = cMax - hc.center + hc.height;
hMax = Math.max(hMax, h);
}
hc = {
height: hMax,
center: cMax
};
if (div.centerVertical) {
hc = inc("centerVertical/center")(div, hc);
}
return hc;
};
})();
mathDiv/createElement/mrow/getMathml/get.ls
(function(){
return function(m, div){
var t, a, el;
t = div.elementTagName;
a = _.concat("<" + t + ">", (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
if (!el.getMathml) {
continue;
}
results$.push(el.getMathml());
}
return results$;
}()), "" + t + ">");
return a.join("");
};
})();
mathDiv/createElement/mrow/isEmpty/is.ls
(function(){
return function(div){
var ref$;
return (ref$ = div.firstChild.isEmptyPlaceholder) != null ? ref$ : false;
};
})();
mathDiv/createElement/mrow/modify/insertElement/insert.ls
(function(){
return function(m, div, el){
var sel, offset;
sel = m.getSelection();
offset = sel.anchorOffset;
if (offset > 0) {
return div.childrenAll()[offset - 1].after(el);
} else {
return div.prepend(el);
}
};
})();
mathDiv/createElement/mrow/modify/removeElement/remove.ls
(function(){
return function(m, div, el){
var prevEl, nextEl, that, el2;
prevEl = el.previousMathElement();
nextEl = el.nextMathElement();
el.remove();
if (that = prevEl) {
return that.setCursor("end");
} else if (that = nextEl) {
return that.setCursor("start");
} else {
m.setSelection(div, 0);
el2 = inc("../../../_shared/spacer/emptyPlaceholder/emptyPlaceholder")(m, div);
div.insertElement(el2);
return el2.setCursor("start");
}
};
})();
mathDiv/createElement/mrow/modify/replaceElement/replace.ls
(function(){
return function(m, div, elOld, elementsNew){
var res$, i$, len$, el;
if (elementsNew.constructor.name === "HTMLCollection") {
res$ = [];
for (i$ = 0, len$ = elementsNew.length; i$ < len$; ++i$) {
el = elementsNew[i$];
res$.push(el);
}
elementsNew = res$;
}
elementsNew = _.ensureArray(elementsNew);
elOld.before(elementsNew);
elOld.remove();
return _.last(elementsNew).setCursor("end");
};
})();
mathDiv/createElement/mrow/moveCursor/move.ls
(function(){
return function(m, div, direction){
var sel, offset;
sel = m.getSelection();
offset = sel.anchorOffset;
return debug("todo mrow move");
};
})();
mathDiv/createElement/mrow/setCursor/set.ls
(function(){
return function(m, div, pos){
var that;
if (pos === "start") {
return div.firstChild.setCursor("start");
} else if (pos === "end") {
return div.lastChild.setCursor("end");
} else if (pos === "before") {
if (that = div.previousMathElement()) {
return that.setCursor("end");
} else {
return div.parentMathElement().setCursor("before");
}
} else if (pos === "after") {
if (that = div.nextMathElement()) {
return that.setCursor("start");
} else {
return div.parentMathElement().setCursor("after");
}
}
};
})();
mathDiv/createElement/mrow/transparentPlacholder/transparentPlacholder.ls
(function(){
return function(m, div){
div._transparentPlacholder == null && (div._transparentPlacholder = false);
Object.defineProperty(div, "transparentPlaceholder", {
get: function(){
return div._transparentPlacholder;
},
set: function(v){
div._transparentPlacholder = v;
if (div.firstChild.hasClass("emptyPlaceholder")) {
return div.firstChild.replaceWith(inc("../../_shared/spacer/emptyPlaceholder/emptyPlaceholder")(m, div));
}
}
});
return false;
};
})();
mathDiv/createElement/table/mtable/el.ls
(function(){
return function(m, el){
var div, el2;
div = inc("../../_shared/div/div")(m, el).css({
margin: "0 0.05em"
});
div.html(inc("../../_shared/spacer/start/start")(m, div), Div({
display: "table",
borderSpacing: 0
}).html(div.rows = (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = el.childrenAll()).length; i$ < len$; ++i$) {
el2 = ref$[i$];
results$.push(inc("../mtr/el")(m, el2));
}
return results$;
}())), inc("../../_shared/spacer/end/end")(m, div));
inc("setAlignColumns/set")(m, el, div);
inc("setRowSpacing/set")(m, el, div);
inc("setColumnSpacing/set")(m, el, div);
div.getHC = function(){
return inc("getHC/get")(div);
};
div.setCursor = function(pos, options){
return inc("setCursor/set")(div, pos, options);
};
div.getMathml = function(){
return inc("getMathml/get")(div, el);
};
return div;
};
})();
mathDiv/createElement/table/mtable/getHC/get.ls
(function(){
return function(div){
var h, i$, ref$, len$, el, hc;
h = 0;
for (i$ = 0, len$ = (ref$ = div.rows).length; i$ < len$; ++i$) {
el = ref$[i$];
hc = el.getHC();
h += hc.height;
}
return {
height: h,
center: h / 2
};
};
})();
mathDiv/createElement/table/mtable/getMathml/get.ls
(function(){
return function(div, el){
var t, aString, a;
t = div.elementTagName;
aString = inc("getAttributeString/get")(el);
a = _.concat("<" + t + " " + aString + ">", (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = div.rows).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(el.getMathml());
}
return results$;
}()), "" + t + ">");
return a.join("");
};
})();
mathDiv/createElement/table/mtable/getMathml/getAttributeString/get.ls
(function(){
return function(el){
var a, i$, ref$, len$, n, that;
a = [];
for (i$ = 0, len$ = (ref$ = ["align_columns", "row_spacing", "column_spacing"]).length; i$ < len$; ++i$) {
n = ref$[i$];
if (that = el.attr(n)) {
a.push(n + '="' + that + '"');
}
}
return a.join(" ");
};
})();
mathDiv/createElement/table/mtable/setAlignColumns/set.ls
(function(){
return function(m, el, div){
var aligns, i$, ref$, len$, mtr, lresult$, j$, ref1$, len1$, i, mtd, a, mrow, jf, results$ = [];
aligns = el.attr("align_columns") || m.alignColumns || "l";
for (i$ = 0, len$ = (ref$ = div.rows).length; i$ < len$; ++i$) {
mtr = ref$[i$];
lresult$ = [];
for (j$ = 0, len1$ = (ref1$ = mtr.childrenAll()).length; j$ < len1$; ++j$) {
i = j$;
mtd = ref1$[j$];
a = aligns[i] || aligns[0];
mrow = mtd.firstChild;
jf = {
l: "flex-start",
c: "center",
r: "flex-end"
};
lresult$.push(mrow.css({
justifyContent: jf[a]
}));
}
results$.push(lresult$);
}
return results$;
};
})();
mathDiv/createElement/table/mtable/setColumnSpacing/set.ls
(function(){
return function(m, el, div){
var colSpacing, i$, ref$, len$, mtr, lresult$, j$, ref1$, len1$, i, mtd, results$ = [];
colSpacing = +(el.attr("column_spacing") || 0);
if (colSpacing === 0) {
return;
}
for (i$ = 0, len$ = (ref$ = div.rows).length; i$ < len$; ++i$) {
mtr = ref$[i$];
lresult$ = [];
for (j$ = 0, len1$ = (ref1$ = mtr.childrenAll()).length; j$ < len1$; ++j$) {
i = j$;
mtd = ref1$[j$];
if (i > 0) {
lresult$.push(mtd.css({
paddingLeft: colSpacing + "em"
}));
}
}
results$.push(lresult$);
}
return results$;
};
})();
mathDiv/createElement/table/mtable/setCursor/set.ls
(function(){
return function(div, pos, options){
var that;
if (pos === "start") {
return div.spacerStart.setCursor(pos, options);
} else if (pos === "end") {
return div.spacerEnd.setCursor(pos, options);
} else if (pos === "before") {
if (that = div.previousMathElement()) {
return that.setCursor("end");
} else {
return div.parentMathElement().setCursor("before");
}
} else if (pos === "after") {
if (that = div.nextMathElement()) {
return that.setCursor("start");
} else {
return div.parentMathElement().setCursor("after");
}
}
};
})();
mathDiv/createElement/table/mtable/setRowSpacing/set.ls
(function(){
return function(m, el, div){
var rowSpacing, i$, ref$, len$, i, mtr, lresult$, j$, ref1$, len1$, mtd, results$ = [];
rowSpacing = +(el.attr("row_spacing") || 0.3);
for (i$ = 0, len$ = (ref$ = div.rows).length; i$ < len$; ++i$) {
i = i$;
mtr = ref$[i$];
lresult$ = [];
for (j$ = 0, len1$ = (ref1$ = mtr.childrenAll()).length; j$ < len1$; ++j$) {
mtd = ref1$[j$];
mtd.rowSpacing = i === 0 ? 0 : rowSpacing;
if (i > 0) {
lresult$.push(mtd.css({
paddingTop: rowSpacing + "em"
}));
}
}
results$.push(lresult$);
}
return results$;
};
})();
mathDiv/createElement/table/mtd/el.ls
(function(){
return function(m, el){
var div;
div = inc("../../_shared/div/div")(m, el).css({
display: "table-cell",
padding: "",
verticalAlign: "top"
});
div.html(inc("mrow/mrow")(m, div, el));
div.getHC = function(){
return inc("getHC/get")(div);
};
div.setCursor = function(pos, options){
return inc("setCursor/set")(div, pos, options);
};
div.getMathml = function(){
return inc("getMathml/get")(div);
};
return div;
};
})();
mathDiv/createElement/table/mtd/getHC/get.ls
(function(){
return function(div){
var hc, rs;
hc = div.mrow.getHC();
rs = div.rowSpacing;
return {
height: hc.height + rs,
center: hc.center + rs
};
};
})();
mathDiv/createElement/table/mtd/getMathml/get.ls
(function(){
return function(div){
var t, a;
t = div.elementTagName;
a = _.concat("<" + t + ">", div.mrow.getMathml(), "" + t + ">");
return a.join("");
};
})();
mathDiv/createElement/table/mtd/mrow/mrow.ls
(function(){
return function(m, div, el){
el = m.createElement(el.firstChild).css({
display: "flex"
});
if (m.mode !== "input") {
el.transparentPlaceholder = true;
}
return div.mrow = el;
};
})();
mathDiv/createElement/table/mtd/setCursor/set.ls
(function(){
return function(div, pos, options){
var that;
if (pos === "start") {
return div.mrow.setCursor(pos, options);
} else if (pos === "end") {
return div.mrow.setCursor(pos, options);
} else if (pos === "before") {
if (that = div.previousMathElement()) {
return that.setCursor("end");
} else {
return div.parentMathElement().setCursor("before");
}
} else if (pos === "after") {
if (that = div.nextMathElement()) {
return that.setCursor("start");
} else {
return div.parentMathElement().setCursor("after");
}
}
};
})();
mathDiv/createElement/table/mtr/el.ls
(function(){
return function(m, el){
var div, el2;
div = inc("../../_shared/div/div")(m, el).css({
display: "table-row"
});
div.html((function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = el.childrenAll()).length; i$ < len$; ++i$) {
el2 = ref$[i$];
results$.push(inc("../mtd/el")(m, el2));
}
return results$;
}()));
div.getHC = function(){
return inc("getHC/get")(div);
};
div.setCursor = function(pos, options){
return inc("setCursor/set")(div, pos, options);
};
div.getMathml = function(){
return inc("getMathml/get")(div);
};
return div;
};
})();
mathDiv/createElement/table/mtr/getHC/get.ls
(function(){
return function(div){
var h, c, i$, ref$, len$, el, hc;
h = 0;
c = 0;
for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
hc = el.getHC();
h = Math.max(h, hc.height);
c = Math.max(c, hc.center);
}
return {
height: h,
center: c
};
};
})();
mathDiv/createElement/table/mtr/getMathml/get.ls
(function(){
return function(div){
var t, a, el;
t = div.elementTagName;
a = _.concat("<" + t + ">", (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(el.getMathml());
}
return results$;
}()), "" + t + ">");
return a.join("");
};
})();
mathDiv/createElement/table/mtr/setCursor/set.ls
(function(){
return function(div, pos, options){
var that;
if (pos === "start") {
return div.firstChild.setCursor(pos, options);
} else if (pos === "end") {
return div.firstChild.setCursor(pos, options);
} else if (pos === "before") {
if (that = div.previousMathElement()) {
return that.setCursor("end");
} else {
return div.parentMathElement().setCursor("before");
}
} else if (pos === "after") {
if (that = div.nextMathElement()) {
return that.setCursor("start");
} else {
return div.parentMathElement().setCursor("after");
}
}
};
})();
mathDiv/createElements/baselineChar/char.ls
(function(){
return function(m){
return m.baselineChar = Div({
userSelect: "none"
}).html("​");
};
})();
mathDiv/createElements/create.ls
(function(){
return function(m, mathEl){
m.div.html(inc("baselineChar/char")(m), inc("masterMrow/mrow")(m, mathEl));
delete m.cursor;
inc("removeSvgExportClasses/remove")(m);
m.gaps = m.div.findAll(".mgap");
return m.isDone = m.gaps.length === 0;
};
})();
mathDiv/createElements/masterMrow/mrow.ls
(function(){
return function(m, mathEl){
var div, sourceEl;
div = m.createElement("");
div.html(mathEl.childrenAll().length > 0
? (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = mathEl.childrenAll()).length; i$ < len$; ++i$) {
sourceEl = ref$[i$];
results$.push(m.createElement(sourceEl));
}
return results$;
}())
: inc("/mathDiv/createElement/_shared/spacer/emptyPlaceholder/emptyPlaceholder")(m, div));
div.transparentPlaceholder = true;
div.back = function(){};
div.setCursor = function(pos){
return inc("setCursor/set")(div, pos);
};
return m.masterMrow = div;
};
})();
mathDiv/createElements/masterMrow/setCursor/set.ls
(function(){
return function(div, pos){
if (pos === "start" || pos === "before") {
return div.firstChild.setCursor("start");
} else if (pos === "end" || pos === "after") {
return div.lastChild.setCursor("end");
}
};
})();
mathDiv/createElements/removeSvgExportClasses/remove.ls
(function(){
return function(m){
var i$, ref$, len$, c, lresult$, j$, ref1$, len1$, el, results$ = [];
if (m.addSvgExportClasses) {
return;
}
for (i$ = 0, len$ = (ref$ = ["svgExport", "svgExportBackground"]).length; i$ < len$; ++i$) {
c = ref$[i$];
lresult$ = [];
for (j$ = 0, len1$ = (ref1$ = m.div.findAll("." + c)).length; j$ < len1$; ++j$) {
el = ref1$[j$];
lresult$.push(el.removeClass(c));
}
results$.push(lresult$);
}
return results$;
};
})();
mathDiv/createSourceDiv/create.ls
(function(){
return function(m){
return m.sourceDiv = inc("../_shared/getMathElFromAsciimath/get")(m, m.value);
};
})();
mathDiv/deleteSelectionRange/basic/delete.ls
(function(){
return function(m, s){
var r, n1, o1, n2, o2, i, el;
s = m.getSelection();
r = s.getRange();
n1 = r.startContainer;
o1 = r.startOffset;
n2 = r.endContainer;
o2 = r.endOffset;
m.setSelection(n2, o2);
i = 0;
for (;;) {
i++;
s = m.getSelection();
el = m.getCursorElement();
if (i > 500) {
break;
}
if (s.anchorOffset === o1 + 1) {
break;
} else {
el.back();
}
}
return el.back();
};
})();
mathDiv/deleteSelectionRange/delete.ls
(function(){
return function(m){
var s;
s = m.getSelection();
if (s.isCollapsed) {} else if (s.anchorNode === s.focusNode && s.anchorNode.hasClass("basic")) {
return inc("basic/delete")(m);
} else {
return inc("mixed/delete")(m);
}
};
})();
mathDiv/deleteSelectionRange/mixed/delete.ls
(function(){
return function(m){
var s, r, n1, o1, n2, o2, breakEl, i, el, results$ = [];
s = m.getSelection();
r = s.getRange();
n1 = r.startContainer;
o1 = r.startOffset;
n2 = r.endContainer;
o2 = r.endOffset;
breakEl = m.createElement("B");
m.setSelection(n1, o1);
m.insertElement(breakEl);
m.setSelection(n2, o2);
i = 0;
for (;;) {
i++;
el = m.getCursorElement();
if (!el || !breakEl.parent() || i > 500) {
break;
} else {
results$.push(el.back());
}
}
return results$;
};
})();
mathDiv/div/div.ls
(function(){
return function(m){
return Div({
display: "inline-flex",
alignItems: "flex-start",
justifyContent: "flex-start",
padding: m.params.paddingContent,
fontFamily: "Source Sans Pro Solocode"
}).cssVar({
style_color: m.styles.mainColor,
style_empty_color: m.styles.emptyColor
}).onDomRemove(function(){
return m.stop();
}).css({
cursor: "default"
});
};
})();
mathDiv/eval/calcResult/calc.ls
(function(){
return function(aj, o){
var r, command, c, subresults, res$, i$, ref$, len$, aj2, sr0, sr1, ref1$, sr, i;
if (_.isNumber(aj)) {
return {
result: aj,
aj: aj
};
}
if (_.isString(aj)) {
r = o.vars[aj] != null
? o.vars[aj]
: o.varsStandard[aj] != null
? o.varsStandard[aj]
: (o.errors.push("var missing: " + aj), NaN);
return {
result: r,
aj: aj
};
}
command = aj[0];
c = command;
r = 0;
res$ = [];
for (i$ = 0, len$ = (ref$ = aj.slice(1)).length; i$ < len$; ++i$) {
aj2 = ref$[i$];
res$.push(inc(THISFILE)(aj2, o));
}
subresults = res$;
sr0 = (ref$ = subresults[0]) != null ? ref$.result : void 8;
sr1 = (ref1$ = subresults[1]) != null ? ref1$.result : void 8;
if (c === "Add") {
for (i$ = 0, len$ = subresults.length; i$ < len$; ++i$) {
sr = subresults[i$];
r += sr.result;
}
} else if (c === "Subtract") {
for (i$ = 0, len$ = subresults.length; i$ < len$; ++i$) {
i = i$;
sr = subresults[i$];
if (i === 0) {
r = sr.result;
} else {
r -= sr.result;
}
}
} else if (c === "Multiply") {
for (i$ = 0, len$ = subresults.length; i$ < len$; ++i$) {
i = i$;
sr = subresults[i$];
if (i === 0) {
r = sr.result;
} else {
r *= sr.result;
}
}
} else if (c === "Divide") {
for (i$ = 0, len$ = subresults.length; i$ < len$; ++i$) {
i = i$;
sr = subresults[i$];
if (i === 0) {
r = sr.result;
} else {
r *= 1 / sr.result;
}
}
} else if (c === "Abs") {
r = Math.abs(sr0);
} else if (c === "Sqrt") {
r = Math.sqrt(sr0);
} else if (c === "Power") {
r = Math.pow(sr0, sr1);
} else if (c === "Factorial") {
r = inc("factorial/factorial")(sr0);
} else if (c === "Root") {
r = inc("customPow/customPow")(sr0, 1 / sr1);
} else if (c === "Sin") {
r = Math.sin(sr0);
} else if (c === "Cos") {
r = Math.cos(sr0);
} else if (c === "Tan") {
r = Math.tan(sr0);
} else if (c === "Ln") {
r = Math.log(sr0);
} else if (c === "Log") {
r = Math.log(sr0) / Math.log(sr1 != null ? sr1 : 10);
} else if (c === "Arcsin") {
r = Math.asin(sr0);
} else if (c === "Arccos") {
r = Math.acos(sr0);
} else if (c === "Arctan") {
r = Math.atan(sr0);
}
return {
result: _.round(r, o.precision),
aj: aj,
subresults: subresults
};
};
})();
mathDiv/eval/calcResult/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/eval/calcResult/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/eval/eval.ls
(function(){
return function(m, p){
var am, ref$, mj, o, r;
p == null && (p = {});
am = (ref$ = p.am) != null
? ref$
: m.getValue();
mj = inc("/mathDiv/_shared/getMathJsonFromAsciimath/get")(m, am);
if (mj.hasError) {
return {
result: NaN,
hasError: true,
errors: mj.errors
};
}
o = {
precision: (ref$ = p.precision) != null ? ref$ : 16,
errors: [],
vars: (ref$ = _.clone(p.vars)) != null
? ref$
: {},
varsStandard: inc("varsStandard/vars")()
};
r = inc("calcResult/calc")(mj.mathJson, o);
r.precision = o.precision;
r.vars = (ref$ = o.vars) != null
? ref$
: {};
r.errors = o.errors;
r.hasError = o.errors.length > 0;
return r;
};
})();
mathDiv/eval/varsStandard/vars.ls
(function(){
return function(){
return {
Pi: Math.PI,
ExponentialE: Math.E,
"%": 0.01
};
};
})();
mathDiv/gapComponent/calcCorrectValue/calc.ls
(function(){
return function(m){
var gapValues, res$, i$, ref$, len$, gap, v, a, s, t;
res$ = [];
for (i$ = 0, len$ = (ref$ = m.gaps).length; i$ < len$; ++i$) {
gap = ref$[i$];
res$.push(gap.value || gap.getValue());
}
gapValues = res$;
v = m.value;
v = _.replaceAll(v, //, "");
v = _.replaceAll(v, "", "");
a = v.split(/(.*?<\/gap>)/);
s = "";
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
t = a[i$];
if (_.startsWith(t, "/, "");
v = _.replaceAll(v, "", "");
v = _.replaceAll(v, //, "");
gapIndex = -1;
a = v.split(/(.*?<\/gap>)/);
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
t = a[i$];
if (_.startsWith(t, "")) {
gapIndex++;
solutions2 = [];
for (j$ = 0, len1$ = (ref$ = gapSolutions[gapIndex]).length; j$ < len1$; ++j$) {
sol = ref$[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$(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = correctChoices).length; i$ < len$; ++i$) {
c = ref$[i$];
t = c.text;
results$.push(t = _.replaceAll(t, /\s+/g, ""));
}
return results$;
}
};
})();
mathDiv/gapComponent/currentGap/currentGap.ls
(function(){
return function(m){
return Object.defineProperty(m.div, "currentGap", {
get: function(){
return m.currentGap;
}
});
};
})();
mathDiv/gapComponent/finish/finish.ls
(function(){
return function(m){
var result, that;
m.stop();
m.disable();
m.isDone = true;
result = {
correctValue: m.calcCorrectValue()
};
if (that = m.params.onFinish) {
return that(result);
} else {
return debug("mathDiv gap onFinish missing");
}
};
})();
mathDiv/gapComponent/gapComponent.ls
(function(){
return function(m, params){
var ref$, div;
m.gaps = [];
m.currentGap = null;
m.isDone = false;
m.buttonsDiv = params.buttonsDiv;
m.slide = (ref$ = params.slide) != null
? ref$
: {
levelPlayer: {}
};
m.gapValidateMode = (ref$ = params.gapValidateMode) != null ? ref$ : "literal";
m.uniqueSolutions = (ref$ = params.uniqueSolutions) != null ? ref$ : false;
m.shuffleButtons = (ref$ = params.shuffleButtons) != null ? ref$ : true;
m.combineButtons = (ref$ = params.combineButtons) != null ? ref$ : false;
m.removeCorrectButton = (ref$ = params.removeCorrectButton) != null ? ref$ : false;
m.startNextGap = function(){
return inc("startNextGap/start")(m);
};
m.finish = function(){
return inc("finish/finish")(m);
};
m.calcCorrectValue = function(){
return inc("calcCorrectValue/calc")(m);
};
m.calcGapStringSolutions = function(){
return inc("calcGapStringSolutions/calc")(m);
};
m.calcSpecialKeys = function(){
return inc("calcSpecialKeys/calc")(m);
};
div = m.scrollDiv || m.div;
div.gaps = function(){
return m.gaps;
};
div.isDone = function(){
return m.isDone;
};
div.currentGap = inc("currentGap/currentGap")(m);
div.calcCorrectValue = m.calcCorrectValue;
div.calcGapStringSolutions = m.calcGapStringSolutions;
return div.calcSpecialKeys = m.calcSpecialKeys;
};
})();
mathDiv/gapComponent/startNextGap/start.ls
(function(){
return function(m){
var ref$, nextGap;
if (((ref$ = m.currentGap) != null ? ref$.gapIsCompleted : void 8) === false) {
return m.currentGap.startGap();
} else if (nextGap = _.find(m.gaps, {
gapIsCompleted: false
})) {
return nextGap.startGap();
} else {
return m.finish();
}
};
})();
mathDiv/getCursorElement/get.ls
(function(){
return function(m){
var sel, el, ref$, ref1$;
sel = m.getSelection();
el = sel.anchorNode;
while (el) {
if ((ref$ = el.classList) != null && ref$.contains("mathElement")) {
return el;
}
if ((ref1$ = el.classList) != null && ref1$.contains("spacer")) {
return el;
}
el = el.parentElement;
}
};
})();
mathDiv/getRootElement/get.ls
(function(){
return function(m){
var ref$;
return ((ref$ = m.currentGap) != null ? ref$.mrow : void 8) || m.masterMrow;
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calc.ls
(function(){
return function(m, div){
if (div.firstChild.tagName === "SPAN") {
return inc("calcCharsOnly/calc")(m, div);
} else {
return inc("calcMixed/calc")(m, div);
}
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcCharsOnly/calc.ls
(function(){
return function(m, cloneDiv){
var el, elOrg, tag, values, res$, i$, ref$, len$, mathml;
el = cloneDiv.firstChild;
elOrg = m._idElements[el.attr("copy_id")];
tag = elOrg.parent().elementTagName;
res$ = [];
for (i$ = 0, len$ = (ref$ = cloneDiv.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
elOrg = m._idElements[el.attr("copy_id")];
res$.push(elOrg.getMathValue());
}
values = res$;
return mathml = "<" + tag + ">" + values.join("") + "" + tag + ">";
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/calc.ls
(function(){
return function(m, div){
var parts, elements, i$, len$, el, elOrg, mathml;
parts = [];
elements = div.childrenAll();
elements = inc("filterMathElements/filter")(elements);
for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) {
el = elements[i$];
elOrg = m._idElements[el.attr("copy_id")];
if (el.hasClass("basic")) {
parts.push(inc("calcBasicEl/calc")(m, el, elOrg));
} else if (el.outerHTML === elOrg.outerHTML) {
parts.push(inc("calcExactEl/calc")(el, elOrg));
} else {
parts.push(inc("calcModifiedEl/calc")(m, el, elOrg));
}
}
inc("resolveMrows/resolve")(m, parts);
parts = _.filter(parts, function(p){
return p.mathml !== "";
});
return mathml = _.map(parts, "mathml").join("");
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/calcBasicEl/calc.ls
(function(){
return function(m, el, elOrg){
var tag, values, res$, i$, ref$, len$, el2;
if (el.childrenAll().length === 0) {
return "";
}
elOrg = m._idElements[el.attr("copy_id")];
tag = elOrg.elementTagName;
res$ = [];
for (i$ = 0, len$ = (ref$ = el.childrenAll()).length; i$ < len$; ++i$) {
el2 = ref$[i$];
elOrg = m._idElements[el2.attr("copy_id")];
res$.push(elOrg.getMathValue());
}
values = res$;
return {
type: "basic",
el: el,
elOrg: elOrg,
mathml: "<" + tag + ">" + values.join("") + "" + tag + ">"
};
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/calcExactEl/calc.ls
(function(){
return function(el, elOrg){
return {
type: "exact",
el: el,
elOrg: elOrg,
mathml: elOrg.getMathml()
};
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/calcModifiedEl/calc.ls
(function(){
return function(m, el, elOrg){
return {
type: "modified",
el: el,
elOrg: elOrg,
mathml: inc("../../calc")(m, el)
};
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/filterMathElements/extractMathElements/extract.ls
(function(){
return function(el){
var div, mathElements, mE;
div = Div().html(el.outerHTML);
mathElements = [];
for (;;) {
mE = div.findFirst(".mathElement");
if (mE) {
mathElements.push(mE);
mE.remove();
} else {
break;
}
}
return mathElements;
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/filterMathElements/filter.ls
(function(){
return function(elements){
var a, i$, len$, el, mathElements, j$, len1$, el2;
a = [];
for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) {
el = elements[i$];
if (el.hasClass("spacer")) {
continue;
} else if (el.hasClass("mathElement")) {
a.push(el);
} else {
mathElements = inc("extractMathElements/extract")(el);
for (j$ = 0, len1$ = mathElements.length; j$ < len1$; ++j$) {
el2 = mathElements[j$];
a.push(el2);
}
}
}
return mathElements = a;
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/isExactWIP_nochkaputt/is.ls
(function(){
return function(el, elOrg){
var a1, a2, i$, len$, i, el2, el2Org;
debug("checkExact");
a1 = inc("../filterMathElements/filter")(el.childrenAll());
a2 = inc("../filterMathElements/filter")(elOrg.childrenAll());
if (a1.length !== a2.length) {
return false;
}
for (i$ = 0, len$ = a1.length; i$ < len$; ++i$) {
i = i$;
el2 = a1[i$];
el2Org = a2[i];
debug(el2);
debug(el2.outerHTML.length);
debug(el2Org.outerHTML.length);
}
return sdcnjksdcn();
};
})();
mathDiv/getSelectionMathml/calcMathmlOfElement/calcMixed/resolveMrows/resolve.ls
(function(){
return function(m, parts){
var mrowParts, i$, len$, i, part, nextPart, nextNextPart, elOrgParent, ref$, results$ = [];
mrowParts = _.filter(parts, function(p){
return _.startsWith(p.mathml, "", (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = m.masterMrow.childrenAll()).length; i$ < len$; ++i$) {
el = ref$[i$];
results$.push(el.getMathml());
}
return results$;
}()), "");
return a.join("");
};
})();
mathDiv/history/_shared/cursorPath/get/get.ls
(function(){
return function(m, rootEl){
var s;
s = m.getSelection();
return {
anchorPath: inc("getPath/get")(rootEl, s.anchorNode, s.anchorOffset),
focusPath: inc("getPath/get")(rootEl, s.focusNode, s.focusOffset)
};
};
})();
mathDiv/history/_shared/cursorPath/get/getPath/get.ls
(function(){
return function(rootEl, el, offset){
var a, parentEl, childIndex, cp;
a = [];
if (!rootEl.contains(el)) {
return;
}
while (el) {
parentEl = el.parentNode;
childIndex = _.indexOf(parentEl.childNodes, el);
a.push(childIndex);
if (el === rootEl || parentEl === rootEl) {
break;
} else {
el = parentEl;
}
}
a.reverse();
return cp = a.join(",") + "|" + offset;
};
})();
mathDiv/history/_shared/cursorPath/set/getNodeAndOffset/get.ls
(function(){
return function(rootEl, cursorPath){
var el, a, i$, ref$, len$, pos;
el = rootEl;
a = cursorPath.split("|");
for (i$ = 0, len$ = (ref$ = a[0].split(",")).length; i$ < len$; ++i$) {
pos = ref$[i$];
el = el.childNodes[+pos];
}
return [el, +a[1]];
};
})();
mathDiv/history/_shared/cursorPath/set/set.ls
(function(){
return function(m, rootEl, cursorPath){
var ref$, n1, o1, n2, o2, s;
if (!cursorPath) {
return;
}
ref$ = inc("getNodeAndOffset/get")(rootEl, cursorPath.anchorPath), n1 = ref$[0], o1 = ref$[1];
ref$ = inc("getNodeAndOffset/get")(rootEl, cursorPath.focusPath), n2 = ref$[0], o2 = ref$[1];
s = m.getSelection();
return s.setBaseAndExtent(n1, o1, n2, o2);
};
})();
mathDiv/history/_shared/restoreSnapshot/restore.ls
(function(){
return function(m, rootEl, snapshot){
var mathml, sourceDiv, sourceEl, el;
mathml = snapshot.mathml;
sourceDiv = Div().html(mathml).firstChild;
rootEl.html((function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = sourceDiv.childrenAll()).length; i$ < len$; ++i$) {
sourceEl = ref$[i$];
results$.push(m.createElement(sourceEl));
}
return results$;
}()));
if (rootEl.childrenAll().length > 0) {
return inc("../cursorPath/set/set")(m, rootEl, snapshot.cursorPath);
} else {
el = inc("/mathDiv/createElement/_shared/spacer/emptyPlaceholder/emptyPlaceholder")(m, rootEl).appendTo(rootEl);
return el.setCursor("start");
}
};
})();
mathDiv/history/_shared/updateUndoDomClass/update.ls
(function(){
return function(m){
var total, ref$, ref1$, enabled, ref2$, ref3$, i$, ref4$, len$, el, results$ = [];
total = (ref$ = m.getRootElement().snapshots) != null ? (ref1$ = ref$.undo) != null ? ref1$.length : void 8 : void 8;
enabled = total > 1;
if ((ref2$ = m.screenKeyboard) != null) {
if ((ref3$ = ref2$.findFirst(".undo")) != null) {
ref3$.update(enabled);
}
}
if (m.params.undoDomClass) {
for (i$ = 0, len$ = (ref4$ = body.findAll("." + m.params.undoDomClass)).length; i$ < len$; ++i$) {
el = ref4$[i$];
results$.push(el.update(enabled));
}
return results$;
}
};
})();
mathDiv/history/history.ls
(function(){
return function(m){
return {
save: _.debounce(function(){
return inc("save/save")(m);
}, 20),
saveInstant: function(){
return inc("save/save")(m);
},
undo: function(){
return inc("undo/undo")(m);
},
redo: function(){
return inc("redo/redo")(m);
}
};
};
})();
mathDiv/history/redo/redo.ls
(function(){
return function(m){
var rootEl, snapshots, ref$, snapshot;
rootEl = m.getRootElement();
snapshots = rootEl.snapshots;
if (snapshots.redo.length === 0) {
return;
}
if (typeof (ref$ = m.params).onChange == 'function') {
ref$.onChange();
}
snapshot = snapshots.redo.pop();
snapshots.undo.push(snapshot);
inc("../_shared/restoreSnapshot/restore")(m, rootEl, snapshot);
m.cleanupLayout();
return inc("../_shared/updateUndoDomClass/update")(m);
};
})();
mathDiv/history/save/save.ls
(function(){
return function(m, p){
var ref$, rootEl, snapshots, lastSnapshot, cp, mathml, snapshot;
if (!m.div.isVisible() || ((ref$ = m.mode) === "display" || ref$ === "gapButtons")) {
return;
}
rootEl = m.getRootElement();
rootEl.snapshots == null && (rootEl.snapshots = {
undo: [],
redo: []
});
snapshots = rootEl.snapshots;
lastSnapshot = _.last(snapshots.undo) || {};
cp = inc("../_shared/cursorPath/get/get")(m, rootEl);
if (!cp) {
return;
}
if ((p != null && p.cursorPathOnly) && lastSnapshot.mathml) {
lastSnapshot.cursorPath = cp;
return;
}
mathml = rootEl.getMathml();
if (lastSnapshot.mathml === mathml) {
lastSnapshot.cursorPath = cp;
return;
} else if (snapshots.undo.length > 0) {
if (typeof (ref$ = m.params).onChange == 'function') {
ref$.onChange();
}
}
snapshot = {
mathml: mathml,
cursorPath: cp
};
snapshots.undo.push(snapshot);
snapshots.redo = [];
return inc("../_shared/updateUndoDomClass/update")(m);
};
})();
mathDiv/history/undo/undo.ls
(function(){
return function(m){
var rootEl, snapshots, ref$, currentSnapshot, snapshot;
rootEl = m.getRootElement();
snapshots = rootEl.snapshots;
if (!snapshots || snapshots.undo.length < 2) {
return;
}
if (typeof (ref$ = m.params).onChange == 'function') {
ref$.onChange();
}
currentSnapshot = snapshots.undo.pop();
snapshots.redo.push(currentSnapshot);
snapshot = _.last(snapshots.undo);
inc("../_shared/restoreSnapshot/restore")(m, rootEl, snapshot);
m.cleanupLayout();
return inc("../_shared/updateUndoDomClass/update")(m);
};
})();
mathDiv/insertAtCursor/insert.ls
(function(){
return function(m, valueString){
var i$, len$, char, results$ = [];
if (m.started === true) {
for (i$ = 0, len$ = valueString.length; i$ < len$; ++i$) {
char = valueString[i$];
results$.push(m.onKey({
key: char
}));
}
return results$;
}
};
})();
mathDiv/mathDiv.ls
(function(){
return function(params){
var p, m, ref$, div, a, i$, len$, n;
params == null && (params = {});
p = params;
p.keyboardEnabled == null && (p.keyboardEnabled = true);
p.keyboardLayout == null && (p.keyboardLayout = "mathDiv");
p.keyboardShowHeader == null && (p.keyboardShowHeader = true);
p.keyboardHideUndo == null && (p.keyboardHideUndo = false);
p.keyboardHideArrows == null && (p.keyboardHideArrows = false);
p.keyboardSpecialKeys == null && (p.keyboardSpecialKeys = "");
p.paddingContent == null && (p.paddingContent = "");
m = {};
m.params = p != null
? p
: {};
m.value = (ref$ = p.value) != null ? ref$ : "";
m.mode = (ref$ = p.mode) != null ? ref$ : "display";
m.trigonometryMode = (ref$ = p.trigonometryMode) != null ? ref$ : "deg";
m.enabled = (ref$ = p.enabled) != null ? ref$ : false;
m.centerTag = p.centerTag;
m.showDigit3Space = (ref$ = p.showDigit3Space) != null ? ref$ : true;
m.addSvgExportClasses = (ref$ = p.addSvgExportClasses) != null ? ref$ : false;
m.enableHorizontalScroll = (ref$ = p.enableHorizontalScroll) != null ? ref$ : false;
m.started = false;
m.screenKeyboard = null;
m.styles = inc("styles/styles")(m);
m.div = inc("div/div")(m);
m.createElement = function(sourceEl){
return inc("createElement/create")(m, sourceEl);
};
m.createElements = function(mathEl){
return inc("createElements/create")(m, mathEl);
};
m.cleanupLayout = function(){
return inc("cleanupLayout/cleanup")(m);
};
m.updateCustomCursor = function(){
return inc("updateCustomCursor/update")(m);
};
m.onTap = function(e){
return inc("onTap/on")(m, e);
};
m.onKey = function(e){
return inc("onKey/on")(m, e);
};
m.onCopyOrCut = function(e){
return inc("clipboard/onCopyOrCut/on")(m, e);
};
m.onPaste = function(e){
return inc("clipboard/onPaste/on")(m, e);
};
m.onSelectionChange = function(e){
return inc("onSelectionChange/on")(m, e);
};
m.getSelection = function(){
return inc("selection/get")(m);
};
m.setSelection = function(n, o){
return inc("setSelection/set")(m, n, o);
};
m.selectAll = function(){
return inc("selectAll/select")(m);
};
m.deleteSelectionRange = function(){
return inc("deleteSelectionRange/delete")(m);
};
m.getSelectionMathml = function(){
return inc("getSelectionMathml/get")(m);
};
m.insertAtCursor = function(valueString){
return inc("insertAtCursor/insert")(m, valueString);
};
m.insertElement = function(elNew){
return inc("modify/insertElement/insert")(m, elNew);
};
m.replaceElement = function(el, el2){
return inc("modify/replaceElement/replace")(m, el, el2);
};
m.removeElement = function(el){
return inc("modify/removeElement/remove")(m, el);
};
m.getCursorElement = function(){
return inc("getCursorElement/get")(m);
};
m.getRootElement = function(){
return inc("getRootElement/get")(m);
};
m.setValue = function(v){
return inc("setValue/set")(m, v);
};
m.getValue = function(){
return inc("getValue/getAsciimath/get")(m);
};
m.getMathml = function(){
return inc("getValue/getMathml/get")(m);
};
m.getMathJson = function(){
return inc("getValue/getMathJson/get")(m);
};
m.getSvgElement = function(){
return inc("getSvgElement/get")(m);
};
m.history = inc("history/history")(m);
m.start = function(p){
return inc("start/start")(m, p);
};
m.stop = function(){
return inc("stop/stop")(m);
};
m.submit = function(){
return inc("submit/submit")(m);
};
m.startScreenKeyboard = function(){
return inc("screenKeyboard/start/start")(m);
};
m.stopScreenKeyboard = function(){
return inc("screenKeyboard/stop/stop")(m);
};
m.setTrigonometryMode = function(v){
return inc("trigonometryMode/set/set")(m, v);
};
m.getTrigonometryMode = function(v){
return inc("trigonometryMode/get/get")(m);
};
m.setCenterTag = function(v){
return inc("setCenterTag/set")(m, v);
};
m.setEnabled = function(v){
return inc("setEnabled/set")(m, v);
};
m.enable = function(){
return m.setEnabled(true);
};
m.disable = function(){
return m.setEnabled(false);
};
m.isStarted = function(){
return m.started;
};
m.isEnabled = function(){
return m.enabled;
};
m.hasGapMode = function(){
var ref$;
return (ref$ = m.mode) === "gapWrite" || ref$ === "gapButtons";
};
m.eval = function(p){
return inc("eval/eval")(m, p);
};
m.checkEquivalence = function(p){
return inc("checkEquivalence/check")(m, p);
};
m.checkSyntax = function(){
return inc("checkSyntax/check")(m);
};
if (m.enableHorizontalScroll) {
m.scrollDiv = inc("scrollDivSlim/div")(m, m.div);
}
inc("gapComponent/gapComponent")(m, params);
div = m.scrollDiv || m.div;
div.m = m;
div.addClass("mathDiv");
a = "start stop submit enable disable isStarted isEnabled setValue getValue getMathml getSvgElement eval insertAtCursor checkEquivalence checkSyntax";
for (i$ = 0, len$ = (ref$ = a.split(" ")).length; i$ < len$; ++i$) {
n = ref$[i$];
div[n] = m[n];
}
m.setValue(m.value);
m.setEnabled(m.enabled);
return div;
};
})();
mathDiv/modify/insertElement/insert.ls
(function(){
return function(m, elNew){
m.getCursorElement().insertElement(elNew);
return elNew.setCursor("end");
};
})();
mathDiv/modify/removeElement/remove.ls
(function(){
return function(m, el){
return el.parentMathElement().removeElement(el);
};
})();
mathDiv/modify/replaceElement/replace.ls
(function(){
return function(m, el, el2){
return el.parentMathElement().replaceElement(el, el2);
};
})();
mathDiv/onKey/commandKey/back/back.ls
(function(){
return function(m){
var sel;
sel = m.getSelection();
if (sel.isCollapsed) {
return m.getCursorElement().back();
} else {
return m.deleteSelectionRange();
}
};
})();
mathDiv/onKey/commandKey/key.ls
(function(){
return function(m, e){
var v, c, s;
v = e.key;
c = e.ctrlKey || e.metaKey;
s = e.shiftKey;
if (c && v === "a") {
return m.selectAll();
} else if (c && v === "z") {
if (s) {
return m.history.redo();
} else {
return m.history.undo();
}
} else if (v === "ArrowLeft" || v === "ArrowRight" || v === "ArrowUp" || v === "ArrowDown") {
return inc("moveCursor/move")(m, v, e);
} else if (v === "Backspace") {
return inc("back/back")(m);
} else if (v === "Enter" || v === "submit") {
return m.submit();
} else {
return "no";
}
};
})();
mathDiv/onKey/commandKey/moveCursor/control/on.ls
(function(){
return function(m, v){
return inc("/mathDiv/_shared/getRootElement/get")(m).setCursor(v === "ArrowLeft" ? "start" : "end");
};
})();
mathDiv/onKey/commandKey/moveCursor/move.ls
(function(){
return function(m, v, e){
var s, c;
s = e.shiftKey;
c = e.ctrlKey || e.metaKey;
if (s && !c) {
return inc("shift/on")(m, v);
} else if (s && c) {
return inc("shiftControl/on")(m, v);
} else if (c) {
return inc("control/on")(m, v);
} else {
return inc("normal/on")(m, v);
}
};
})();
mathDiv/onKey/commandKey/moveCursor/normal/leftRight/leftRight.ls
(function(){
return function(m, v){
var s, r, n, o;
s = m.getSelection();
r = s.getRange();
if (!s.isCollapsed) {
if (v === "ArrowLeft") {
n = r.startContainer;
o = r.startOffset;
} else if (v === "ArrowRight") {
n = r.endContainer;
o = r.endOffset;
}
return m.setSelection(n, o);
} else {
return m.getCursorElement().moveCursor(v === "ArrowLeft"
? "left"
: v === "ArrowRight" ? "right" : void 8);
}
};
})();
mathDiv/onKey/commandKey/moveCursor/normal/on.ls
(function(){
return function(m, v){
if (v === "ArrowLeft" || v === "ArrowRight") {
return inc("leftRight/leftRight")(m, v);
} else if (v === "ArrowUp" || v === "ArrowDown") {
return inc("upDown/upDown")(m, v);
}
};
})();
mathDiv/onKey/commandKey/moveCursor/normal/upDown/upDown.ls
(function(){
return function(m, v){
var s, n, o, co, x, y, i, e;
s = m.getSelection();
n = s.anchorNode;
o = s.anchorOffset;
m.setSelection(n, o);
co = m.cursor.offset();
x = co.left;
y = v === "ArrowUp"
? co.top - co.height / 2
: co.bottom + co.height / 2;
i = 0;
while (i <= 80) {
i += 1;
y += v === "ArrowUp" ? -1 : 1;
e = {};
if (inc("/mathDiv/onTap/tapDownNearest/tapElement/tap")(m, x, y, e, true)) {
return;
}
}
};
})();
mathDiv/onKey/commandKey/moveCursor/shift/modifySelection/modify.ls
(function(){
return function(m, v){
var s, n1, o1, n2, o2, n3, o3;
s = m.getSelection();
n1 = s.anchorNode;
o1 = s.anchorOffset;
n2 = s.focusNode;
o2 = s.focusOffset;
m.setSelection(n2, o2);
inc("../../normal/on")(m, v);
s = m.getSelection();
n3 = s.anchorNode;
o3 = s.anchorOffset;
return s.setBaseAndExtent(n1, o1, n3, o3);
};
})();
mathDiv/onKey/commandKey/moveCursor/shift/on.ls
(function(){
return function(m, v){
var i, m1, m2, results$ = [];
i = 0;
m1 = m.getSelectionMathml();
for (;;) {
i++;
inc("modifySelection/modify")(m, v);
m2 = m.getSelectionMathml();
if (m2 !== m1 || i > 100) {
break;
}
}
return results$;
};
})();
mathDiv/onKey/commandKey/moveCursor/shiftControl/on.ls
(function(){
return function(m, v){
var rootEl, s, n1, o1, n2, o2;
rootEl = inc("/mathDiv/_shared/getRootElement/get")(m);
s = m.getSelection();
n1 = s.anchorNode;
o1 = s.anchorOffset;
if (v === "ArrowLeft") {
rootEl.setCursor("start");
s = m.getSelection();
n2 = s.anchorNode;
o2 = s.anchorOffset;
} else {
rootEl.setCursor("end");
s = m.getSelection();
n2 = s.anchorNode;
o2 = s.anchorOffset;
}
return s.setBaseAndExtent(n1, o1, n2, o2);
};
})();
mathDiv/onKey/insertKey/convertFuncName/calcRecentMiMoString/calc.ls
(function(){
return function(el){
var a, ref$;
a = [];
for (;;) {
if (!el || ((ref$ = el.elementTagName) !== "mi" && ref$ !== "mo") || a.length === 4) {
break;
}
a.push(el.getMathValue());
el = el.previousSibling;
}
return a.reverse().join("");
};
})();
mathDiv/onKey/insertKey/convertFuncName/convert.ls
(function(){
var names;
names = inc("getNames/get")();
return function(m, el){
var s, i$, ref$, len$, n, j$, to$, i, results$ = [];
s = inc("calcRecentMiMoString/calc")(el);
if (s.length < 2) {
return;
}
for (i$ = 0, len$ = (ref$ = names).length; i$ < len$; ++i$) {
n = ref$[i$];
if (_.endsWith(s, n.name)) {
if (_.endsWith(s, n.ignore)) {
continue;
}
for (j$ = 1, to$ = n.name.length; j$ <= to$; ++j$) {
i = j$;
m.getCursorElement().back();
}
inc("../key")(m, {
key: n.key
});
break;
}
}
return results$;
};
})();
mathDiv/onKey/insertKey/convertFuncName/getNames/get.ls
(function(){
return function(){
var n;
return _.concat(_.map(inc("/mathDiv/_shared/standardFunctions/functions")(), function(n){
return {
name: n,
key: n
};
}), (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = ["sqrt", "root", "ncr", "abs", "bar", "lim", "sum"]).length; i$ < len$; ++i$) {
n = ref$[i$];
results$.push({
name: n,
key: n
});
}
return results$;
}()), {
name: "pi",
key: "π"
}, {
name: "oo",
key: "∞",
ignore: "roo"
}, {
name: "->",
key: "→"
}, {
name: "<-",
key: "←"
});
};
})();
mathDiv/onKey/insertKey/insert/advanced/calcNestedMathml/calc.ls
(function(){
return function(m, options){
var that, el, error, el2;
if (that = m.getSelectionMathml()) {
m.deleteSelectionRange();
return that;
}
if (!options.nestPrevious) {
return "";
}
el = m.getCursorElement();
if (el.hasClass("basic") && m.getSelection().anchorOffset === 0) {
el = el.previousMathElement();
if (!el) {
return "";
}
}
if (el.hasClass("spacerStart")) {
el = el.parentMathElement().previousMathElement();
if (!el) {
return "";
}
}
if (el.hasClass("spacerEnd")) {
el = el.parentMathElement();
}
if (el.elementTagName === "mo") {
return "";
}
try {
m.removeElement(el);
} catch (e$) {
error = e$;
el2 = m.getCursorElement();
log.log({
event: "debugMathDiv2NestedHtmlRemoveError",
errorMessage: error.message,
mathml: m.getMathml(),
value: m.getValue(),
elClassList: Array.from(el != null ? el.classList : void 8),
elTagName: el != null ? el.elementTagName : void 8,
el2ClassList: Array.from(el2 != null ? el2.classList : void 8),
el2TagName: el2 != null ? el2.elementTagName : void 8
});
return "";
}
return el.getMathml();
};
})();
mathDiv/onKey/insertKey/insert/advanced/fenceMultipleElements/fence.ls
(function(){
return function(m, options, el){
var c, elF;
if (options.fenceMultipleElements !== true) {
return;
}
c = el.mrow1.childrenAll();
if (c.length > 1) {
elF = m.createElement('');
elF.mrow1.html(c);
return el.mrow1.html(elF);
}
};
})();
mathDiv/onKey/insertKey/insert/advanced/insert.ls
(function(){
return function(m, tag, options){
var attributeString, mathml, el, that;
options == null && (options = {});
attributeString = options.aString || "";
mathml = inc("calcNestedMathml/calc")(m, options);
el = m.createElement("<" + tag + " " + attributeString + ">\n " + mathml + "\n" + tag + ">");
inc("fenceMultipleElements/fence")(m, options, el);
m.insertElement(el);
el.setCursor("firstMrowEnd");
if (mathml.length > 0 && options.cursorPrefilled != null) {
el.setCursor(options.cursorPrefilled);
}
if (options.preventSelfNesting) {
inc("preventSelfNesting/prevent")(m, el);
}
if (that = options.limitSelfNesting) {
inc("limitSelfNesting/limit")(m, el, that);
}
return el;
};
})();
mathDiv/onKey/insertKey/insert/advanced/limitSelfNesting/limit.ls
(function(){
return function(m, el, limit){
var tag, i$, ref$, len$, t;
m.history.saveInstant();
tag = el.elementTagName;
for (i$ = 0, len$ = (ref$ = m.masterMrow.findAll("." + tag)).length; i$ < len$; ++i$) {
el = ref$[i$];
t = 0;
for (;;) {
el = el.parentMathElement(true);
if ((el != null ? el.elementTagName : void 8) === tag) {
t++;
} else {
break;
}
}
if (t >= limit) {
m.history.saveInstant();
m.history.undo();
return;
}
}
};
})();
mathDiv/onKey/insertKey/insert/basic/insert.ls
(function(){
return function(m, tag, value){
var style, ref$, el;
m.deleteSelectionRange();
style = ((ref$ = m.getCursorElement()) != null ? ref$.getStyleAttrString() : void 8) || "";
el = m.createElement("<" + tag + style + ">" + value + "" + tag + ">");
m.insertElement(el);
return el;
};
})();
mathDiv/onKey/insertKey/insert/insert.ls
(function(){
return function(m, tag, options){
var f;
f = tag === "mn" || tag === "mi" || tag === "mo"
? inc("basic/insert")
: inc("advanced/insert");
return f(m, tag, options);
};
})();
mathDiv/onKey/insertKey/key.ls
(function(){
return function(m, e){
var v, stFunctions, i, el;
if (inc("limitGapLength/limit")(m)) {
return;
}
v = e.key;
stFunctions = inc("/mathDiv/_shared/standardFunctions/functions")();
i = function(tag, options){
return inc("insert/insert")(m, tag, options);
};
if (in$(v, "1234567890.")) {
i("mn", v);
} else if (in$(v, ",")) {
i("mn", ".");
} else if (in$(v, "+-*÷=<>⟵⟶")) {
el = i("mo", v);
inc("convertFuncName/convert")(m, el);
} else if (v === "⋅") {
i("mo", "*");
} else if (v === ":") {
i("mo", "÷");
} else if (in$(v, stFunctions)) {
i("mf_" + v);
} else if (v === "sqrt") {
i("msqrt", {
limitSelfNesting: 2
});
} else if (v === "ncr") {
i("mf_ncr");
} else if (v === "logbase") {
i("mf_logbase", {
limitSelfNesting: 2
});
} else if (v === "root") {
i("mroot", {
limitSelfNesting: 2
});
} else if (v === "subsup") {
i("msubsup");
} else if (v === "abs") {
i("mf_abs");
} else if (v === "bar") {
i("mf_bar");
} else if (v === "lim") {
i("mf_lim");
} else if (v === "sum") {
i("mf_sum");
} else if (v === "larrow") {
i("mf_larrow");
} else if (v === "rarrow") {
i("mf_rarrow");
} else if (v === "lrarrow") {
i("mf_lrarrow");
} else if (v === "/") {
i("mfrac", {
nestPrevious: true,
cursorPrefilled: "lastMrowEnd",
limitSelfNesting: 2
});
} else if (v === "!") {
i("mf_fac", {
nestPrevious: true,
cursorPrefilled: "end"
});
} else if (v === "Dead" || v === "^" || v === "sup") {
i("msup", {
nestPrevious: true,
fenceMultipleElements: true,
limitSelfNesting: 2,
cursorPrefilled: "lastMrowEnd"
});
} else if (v === "sub") {
i("msub", {
nestPrevious: true,
fenceMultipleElements: true,
limitSelfNesting: 1,
cursorPrefilled: "lastMrowEnd"
});
} else if (v === "(" || v === ")" || v === "()") {
i("mfenced", {
aString: 'type="()"'
});
} else if (v === "[" || v === "]" || v === "[]") {
i("mfenced", {
aString: 'type="[]"'
});
} else if (v === "{" || v === "}" || v === "{}") {
i("mfenced", {
aString: 'type="{}"'
});
} else if (v.length === 1) {
el = i("mi", v);
inc("convertFuncName/convert")(m, el);
}
return inc("replaceUnits/replace")(m);
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
mathDiv/onKey/insertKey/limitGapLength/limit.ls
(function(){
return function(m){
var gapLength, rootEl, mathml, am;
gapLength = m.params.gapLength;
if (!gapLength) {
return;
}
rootEl = m.getRootElement();
mathml = m.getRootElement().getMathml();
am = inc("/mathDiv/_shared/getAsciimathFromMathml/get")(mathml);
am = am.split(" ").join("");
if (am.length >= +gapLength) {
return true;
}
};
})();
mathDiv/onKey/insertKey/replaceUnits/_replaceElements/replace.ls
(function(){
return function(m, replaceElements, am){
var i$, len$, el, mathml, elNew;
replaceElements = _.ensureArray(replaceElements);
for (i$ = 0, len$ = replaceElements.length; i$ < len$; ++i$) {
el = replaceElements[i$];
m.removeElement(el);
}
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, am);
elNew = m.createElement(mathml.firstChild);
m.insertElement(elNew);
return elNew.setCursor("end");
};
})();
mathDiv/onKey/insertKey/replaceUnits/_units/units.ls
(function(){
return function(m){
var units, key, specialKey, tag, am;
units = [];
for (key in m.keyboardSpecialKeys) {
specialKey = key.split("|");
tag = specialKey[0];
am = specialKey[1];
if (tag === "mf_unit") {
units.push(am);
}
}
return units;
};
})();
mathDiv/onKey/insertKey/replaceUnits/msupUnit/replace.ls
(function(){
return function(m, unitAm){
inc("replaceSingleMsups/replace")(m, unitAm);
return inc("replaceMiMsupCombination/replace")(m, unitAm);
};
})();
mathDiv/onKey/insertKey/replaceUnits/msupUnit/replaceMiMsupCombination/calcMatch/calc.ls
(function(){
return function(m, el, text, exp){
var replaceElements, i$, to$, i, char, mathml, matchString;
replaceElements = [el];
for (i$ = 1, to$ = text.length - 2; i$ <= to$; ++i$) {
i = i$;
char = text[i];
el = el.nextSibling;
if (el && el.elementTagName === "mi" && el.textContent === char) {
replaceElements.push(el);
} else {
return [false, []];
}
}
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, _.last(text) + "^" + exp);
matchString = mathml.findFirst("msup").outerHTML;
el = el.nextSibling;
if ((el != null ? el.elementTagName : void 8) === "msup" && el.getMathml() === matchString) {
replaceElements.push(el);
} else {
return [false, []];
}
return [true, replaceElements];
};
})();
mathDiv/onKey/insertKey/replaceUnits/msupUnit/replaceMiMsupCombination/replace.ls
(function(){
return function(m, unitAm){
var text, exp, i$, ref$, len$, el, ref1$, isMatch, replaceElements, results$ = [];
text = unitAm.split("`")[1];
exp = unitAm.split("^")[1];
for (i$ = 0, len$ = (ref$ = m.div.findAll(".mi")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.textContent !== text[0]) {
continue;
}
ref1$ = inc("calcMatch/calc")(m, el, text, exp), isMatch = ref1$[0], replaceElements = ref1$[1];
if (isMatch) {
results$.push(inc("../../_replaceElements/replace")(m, replaceElements, unitAm));
}
}
return results$;
};
})();
mathDiv/onKey/insertKey/replaceUnits/msupUnit/replaceSingleMsups/calcMatchStrings/calc.ls
(function(){
return function(m, am){
var a, mathml, msup, i$, ref$, len$, el, elUnit, miElements, res$, j$, ref1$, len1$, s;
a = [];
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, am);
msup = mathml.findFirst("msup");
a.push(msup.outerHTML);
for (i$ = 0, len$ = (ref$ = msup.findAll("mtext")).length; i$ < len$; ++i$) {
el = ref$[i$];
elUnit = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, "unit()").firstChild;
el.after(elUnit);
elUnit.firstChild.html(el);
}
a.push(msup.outerHTML);
for (i$ = 0, len$ = (ref$ = msup.findAll("mtext")).length; i$ < len$; ++i$) {
el = ref$[i$];
res$ = [];
for (j$ = 0, len1$ = (ref1$ = el.textContent).length; j$ < len1$; ++j$) {
s = ref1$[j$];
res$.push(inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, s).firstChild);
}
miElements = res$;
el.replaceWith(miElements);
}
a.push(msup.outerHTML);
for (i$ = 0, len$ = (ref$ = msup.findAll("mf_unit")).length; i$ < len$; ++i$) {
el = ref$[i$];
el.replaceWith(el.firstChild.childrenAll());
}
a.push(msup.outerHTML);
return a;
};
})();
mathDiv/onKey/insertKey/replaceUnits/msupUnit/replaceSingleMsups/replace.ls
(function(){
return function(m, am){
var matchStrings, i$, ref$, len$, el, results$ = [];
matchStrings = inc("calcMatchStrings/calc")(m, am);
for (i$ = 0, len$ = (ref$ = m.div.findAll(".msup")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.closest(".mf_unit")) {
continue;
}
if (in$(el.getMathml(), matchStrings)) {
results$.push(inc("../../_replaceElements/replace")(m, el, am));
}
}
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/onKey/insertKey/replaceUnits/mtextUnit/calcMatch/calc.ls
(function(){
return function(el, text){
var replaceElements, i$, to$, i, char, ref$;
replaceElements = [el];
for (i$ = 1, to$ = text.length - 1; i$ <= to$; ++i$) {
i = i$;
char = text[i];
el = el.nextSibling;
if (el && ((ref$ = el.elementTagName) === "mi" || ref$ === "mf_unit") && el.textContent === char) {
replaceElements.push(el);
} else {
return [false, []];
}
}
return [true, replaceElements];
};
})();
mathDiv/onKey/insertKey/replaceUnits/mtextUnit/replace.ls
(function(){
return function(m, unitAm){
var text, i$, ref$, len$, el, ref1$, isMatch, replaceElements, results$ = [];
text = _.replace(unitAm, "unit(`", "");
text = _.replace(text, "`)", "");
for (i$ = 0, len$ = (ref$ = m.div.findAll(".mi")).length; i$ < len$; ++i$) {
el = ref$[i$];
if (el.textContent !== text[0]) {
continue;
}
ref1$ = inc("calcMatch/calc")(el, text), isMatch = ref1$[0], replaceElements = ref1$[1];
if (isMatch) {
results$.push(inc("../_replaceElements/replace")(m, replaceElements, unitAm));
}
}
return results$;
};
})();
mathDiv/onKey/insertKey/replaceUnits/replace.ls
(function(){
return function(m){
var i$, ref$, len$, unitAm, results$ = [];
for (i$ = 0, len$ = (ref$ = inc("_units/units")(m)).length; i$ < len$; ++i$) {
unitAm = ref$[i$];
if (_.includes(unitAm, "^")) {
results$.push(inc("msupUnit/replace")(m, unitAm));
} else {
results$.push(inc("mtextUnit/replace")(m, unitAm));
}
}
return results$;
};
})();
mathDiv/onKey/isClipboardKey/is.ls
(function(){
return function(e){
var v, c;
v = e.key;
c = e.ctrlKey || e.metaKey;
if (c && (v === "c" || v === "v" || v === "x")) {
return true;
}
};
})();
mathDiv/onKey/on.ls
(function(){
return function(m, e){
if (!m.getCursorElement() || m.mode === "gapButtons") {
return;
}
if (inc("isClipboardKey/is")(e)) {
return;
}
inc("commandKey/key")(m, e) !== "no" || inc("insertKey/key")(m, e);
if (typeof e.preventDefault == 'function') {
e.preventDefault();
}
return m.cleanupLayout();
};
})();
mathDiv/onSelectionChange/fixTextNodePosition/fix.ls
(function(){
return function(m){
var s, n1, o1, n2, o2, f, fix, ref$;
s = m.getSelection();
n1 = s.anchorNode;
o1 = s.anchorOffset;
n2 = s.focusNode;
o2 = s.focusOffset;
f = inc("fix/fix");
if (n1.nodeType === 3) {
fix = true;
ref$ = f(n1, o1), n1 = ref$[0], o1 = ref$[1];
}
if (n2.nodeType === 3) {
fix = true;
ref$ = f(n2, o2), n2 = ref$[0], o2 = ref$[1];
}
if (fix) {
return s.setBaseAndExtent(n1, o1, n2, o2);
}
};
})();
mathDiv/onSelectionChange/fixTextNodePosition/fix/fix.ls
(function(){
return function(n, o){
var span;
span = n.parentNode.closest("span");
n = span.parent();
o = _.indexOf(n.childrenAll(), span) + o;
return [n, o];
};
})();
mathDiv/onSelectionChange/on.ls
(function(){
return function(m, e){
var sel;
sel = m.getSelection();
if (!m.started || !m.div.contains(sel.anchorNode) || !m.div.contains(sel.focusNode)) {
return;
}
inc("fixTextNodePosition/fix")(m);
m.updateCustomCursor();
return m.history.save({
cursorPathOnly: true
});
};
})();
mathDiv/onTap/on.ls
(function(){
return function(m, e){
var t;
if (!m.enabled) {
return;
}
t = function(){
return inc("tapDownNearest/tap")(m, e);
};
if (document.hasFocus()) {
return t();
} else {
return setTimeout(t);
}
};
})();
mathDiv/onTap/tapDownNearest/isDoubleTap/is.ls
(function(){
var lastAt;
lastAt = 0;
return function(e){
var c, d;
c = new Date();
d = c - lastAt;
lastAt = c;
if (d < 300) {
return true;
} else {
return false;
}
};
})();
mathDiv/onTap/tapDownNearest/isTrippleTap/is.ls
(function(){
var lastAt;
lastAt = 0;
return function(e){
var c, d;
if (!e.isDoubleTap) {
return;
}
c = new Date();
d = c - lastAt;
lastAt = c;
if (d < 500) {
return true;
} else {
return false;
}
};
})();
mathDiv/onTap/tapDownNearest/tap.ls
(function(){
return function(m, e){
var x, ref$, y, ref1$, t, i;
if (m.slide.gapClickStartDisabled || !m.enabled) {
return;
}
e.isDoubleTap = inc("isDoubleTap/is")(e);
e.isTrippleTap = inc("isTrippleTap/is")(e);
m.start({
dontSetCursor: true
});
if (e.isTrippleTap) {
m.selectAll();
return;
}
x = e.pageX || ((ref$ = e.touches) != null ? ref$[0].pageX : void 8);
y = e.pageY || ((ref1$ = e.touches) != null ? ref1$[0].pageY : void 8);
t = function(x, y){
return inc("tapElement/tap")(m, x, y, e);
};
i = 0;
while (i <= 40) {
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;
}
}
};
})();
mathDiv/onTap/tapDownNearest/tapElement/char/double/tap.ls
(function(){
return function(el, m, x){
var mEl, s, n1, o1, n2, o2;
mEl = el.closest(".mathElement");
mEl.setCursor("start");
s = m.getSelection();
n1 = s.anchorNode;
o1 = s.anchorOffset;
mEl.setCursor("end");
s = m.getSelection();
n2 = s.anchorNode;
o2 = s.anchorOffset;
return s.setBaseAndExtent(n1, o1, n2, o2);
};
})();
mathDiv/onTap/tapDownNearest/tapElement/char/single/tap.ls
(function(){
return function(el, m, x, e){
var p, i, r;
p = el.parent();
i = _.indexOf(p.childrenAll(), el);
r = el.getClientRects()[0];
if (x > r.left + r.width * 0.3) {
i++;
}
return m.setSelection(p, i);
};
})();
mathDiv/onTap/tapDownNearest/tapElement/char/tap.ls
(function(){
return function(el, m, x, e){
if (e.isDoubleTap) {
return inc("double/tap")(el, m, x, e);
} else {
return inc("single/tap")(el, m, x, e);
}
};
})();
mathDiv/onTap/tapDownNearest/tapElement/fenceSvg/tap.ls
(function(){
return function(el, x){
var r, mathEl, isLeft, center;
r = el.offset();
mathEl = el.closest(".mathElement");
isLeft = el.hasClass("left");
center = r.left + r.width * (isLeft ? 0.5 : 0.3);
if (x < center) {
if (isLeft) {
return mathEl.setCursor("before");
} else {
return mathEl.setCursor("lastMrowEnd");
}
} else {
if (isLeft) {
return mathEl.setCursor("firstMrowStart");
} else {
return mathEl.setCursor("after");
}
}
};
})();
mathDiv/onTap/tapDownNearest/tapElement/funcNameDiv/tap.ls
(function(){
return function(el, x){
var r, mathEl, t, center;
r = el.offset();
mathEl = el.closest(".mathElement");
t = mathEl.elementTagName;
center = r.left + r.width / 2;
if (x < center) {
return mathEl.setCursor("before");
} else if (t === "mf_lim" || t === "mf_sum") {
return mathEl.setCursor("after");
} else {
return mathEl.setCursor("firstMrowStart");
}
};
})();
mathDiv/onTap/tapDownNearest/tapElement/mrow/tap.ls
(function(){
return function(el, x){
if (x - 2 <= el.firstChild.offset().left) {
return el.setCursor("start");
} else {
return el.setCursor("end");
}
};
})();
mathDiv/onTap/tapDownNearest/tapElement/spacer/double/tap.ls
(function(){
return function(el, m){
var mEl, s, n1, o1, n2, o2;
mEl = el.parent();
mEl.setCursor("start");
s = m.getSelection();
n1 = s.anchorNode;
o1 = s.anchorOffset;
mEl.setCursor("end");
s = m.getSelection();
n2 = s.anchorNode;
o2 = s.anchorOffset;
return s.setBaseAndExtent(n1, o1, n2, o2);
};
})();
mathDiv/onTap/tapDownNearest/tapElement/spacer/single/tap.ls
(function(){
return function(el){
return el.setCursor("start");
};
})();
mathDiv/onTap/tapDownNearest/tapElement/spacer/tap.ls
(function(){
return function(el, m, e){
if (e.isDoubleTap) {
return inc("double/tap")(el, m);
} else {
return inc("single/tap")(el);
}
};
})();
mathDiv/onTap/tapDownNearest/tapElement/tap.ls
(function(){
return function(m, x, y, e, enableMrow){
var shift, elPoint, classes, el, gap, s, n1, o1, n2, o2;
shift = e.shiftKey && !e.isDoubleTape;
try {
elPoint = document.elementFromPoint(x, y);
} catch (e$) {}
classes = ".emptyPlaceholder, .char, .spacer, .fenceSvg, .funcNameDiv";
if (enableMrow) {
classes += ", .mrow";
}
el = elPoint != null ? elPoint.closest(classes) : void 8;
if (!el || !m.div.contains(el)) {
return;
}
if (m.hasGapMode()) {
gap = el.closest(".gap");
if (!gap || gap.gapIsCompleted) {
return;
}
if (gap !== m.currentGap) {
gap.startGap();
}
}
if (shift) {
s = m.getSelection();
n1 = s.anchorNode;
o1 = s.anchorOffset;
}
if (el.hasClass("char")) {
inc("char/tap")(el, m, x, e);
} else if (el.hasClass("fenceSvg")) {
inc("fenceSvg/tap")(el, x);
} else if (el.hasClass("spacer")) {
inc("spacer/tap")(el, m, e);
} else if (el.hasClass("mrow")) {
inc("mrow/tap")(el, x);
} else if (el.hasClass("funcNameDiv")) {
inc("funcNameDiv/tap")(el, x);
}
if (shift) {
s = m.getSelection();
n2 = s.anchorNode;
o2 = s.anchorOffset;
s.setBaseAndExtent(n1, o1, n2, o2);
}
return true;
};
})();
mathDiv/screenKeyboard/_screenKeyboard/keyboardHeader/_divWrapper/div.ls
(function(){
return function(){
return Div({
display: "flex",
flex: "0 0 auto",
minHeight: "var(--specialKeyHeight)",
alignSelf: "center",
alignItems: "stretch",
padding: "4px"
});
};
})();
mathDiv/screenKeyboard/_screenKeyboard/keyboardHeader/arrow/arrow.ls
(function(){
return function(m, label, key){
return inc("../_divWrapper/div")().html(Div({
display: "flex",
padding: "0 0.7em",
borderRadius: "5px",
backgroundColor: Color.grey[300]
}).html(label).tap(function(){
return m.onKey({
key: key
});
}));
};
})();
mathDiv/screenKeyboard/_screenKeyboard/keyboardHeader/header.ls
(function(){
return function(m){
var l, isC, template, hideUndo, hideArrows, hideSubmit;
if (!m.params.keyboardShowHeader) {
return;
}
l = m.params.keyboardLayout;
isC = l === "mathDivCalculator";
template = inc("/../app01/lib/gui/screenKeyboard/_templates/templates")[l];
hideUndo = isC || m.params.keyboardHideUndo;
hideArrows = isC || m.params.keyboardHideArrows;
hideSubmit = isC || _.includes(template != null ? template.main.join("") : void 8, "submit");
if (inc("specialKeys/specialKeys")(m).textContent.length === 0 && hideUndo && hideArrows && hideSubmit) {
return;
}
return Div({
display: "flex"
}).addClass("keyboardHeader").html(inc("specialKeys/specialKeys")(m), !hideUndo ? inc("undo/undo")(m) : void 8, !hideArrows ? [inc("arrow/arrow")(m, "←", "ArrowLeft"), inc("arrow/arrow")(m, "→", "ArrowRight")] : void 8, !hideSubmit ? inc("submit/submit")(m) : void 8);
};
})();
mathDiv/screenKeyboard/_screenKeyboard/keyboardHeader/specialKeys/specialKeys.ls
(function(){
return function(m){
var specialKeys, ref$, k;
specialKeys = (ref$ = m.keyboardSpecialKeys) != null
? ref$
: {};
return inc("../_divWrapper/div")().css({
display: "flex",
justifyContent: "flex-start",
flex: "1 1 auto",
flexWrap: "wrap"
}).html((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/_screenKeyboard/keyboardHeader/submit/submit.ls
(function(){
return function(m){
var tap;
tap = function(){
return m.onKey({
key: "Enter"
});
};
return inc("../_divWrapper/div")().html(Div({
display: "flex",
padding: "0 0.8em",
background: Color.grey[350],
borderRadius: "5px"
}).html(m.params.keyboardSubmitLabel || T("check"))).tap(tap);
};
})();
mathDiv/screenKeyboard/_screenKeyboard/keyboardHeader/undo/undo.ls
(function(){
return function(m, enabled){
var tap, div;
enabled == null && (enabled = false);
tap = function(){
return m.history.undo();
};
div = inc("../_divWrapper/div")().addClass("undo").html(Div({
display: "flex",
width: "2.2em",
background: Color.grey[150],
borderRadius: "5px"
}).html(SvgIcon({
svg: path("/../app01/lib/svg/shape/undo.svg"),
size: "0.9em",
color: enabled
? Color.lightBlue[700]
: Color.grey[300]
})).tap(enabled ? tap : void 8));
div.update = function(enabled2){
if (enabled2 !== enabled) {
return div.replaceWith(inc(THISFILE)(m, enabled2));
}
};
return div;
};
})();
mathDiv/screenKeyboard/_screenKeyboard/onKey/on.ls
(function(){
return function(m, v){
if (in$(v, "e.0123456789+-*÷/π!")) {
return m.onKey({
key: v
});
} else if (v === "sup" || v === "sqrt" || v === "root" || v === "ncr" || v === "ln" || v === "logbase" || v === "submit") {
return m.onKey({
key: v
});
} else if (in$(v, inc("/mathDiv/_shared/standardFunctions/functions")())) {
return m.onKey({
key: v
});
} else if (v === "()") {
return m.onKey({
key: "("
});
} else if (v === "moveCursorLeft") {
return m.onKey({
key: "ArrowLeft"
});
} else if (v === "moveCursorRight") {
return m.onKey({
key: "ArrowRight"
});
} else if (v === "back") {
return m.onKey({
key: "Backspace"
});
} else if (v === "clear") {
return m.setValue("");
} else {
return debug("screenkeyboardKey not assigned", v);
}
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
mathDiv/screenKeyboard/_screenKeyboard/parent/parent.ls
(function(){
return function(m){
var that, p;
if (that = m.params.keyboardParentDiv) {
that.addClass("keyboardParentDiv");
}
p = m.params.keyboardParentDiv || app.currentPage.bottom;
return p.addClass("safeAreaPaddingLeft safeAreaPaddingRight safeAreaPaddingBottom").show();
};
})();
mathDiv/screenKeyboard/_screenKeyboard/screenKeyboard.ls
(function(){
return function(m){
var parent, header;
parent = inc("parent/parent")(m);
header = inc("keyboardHeader/header")(m);
return inc("/../app01/lib/gui/screenKeyboard/keyboard")({
submitLabel: m.params.keyboardSubmitLabel,
layout: m.params.keyboardLayout,
showSubmit: true,
keyboardHeader: function(){
return header;
},
onKey: function(v){
return inc("onKey/on")(m, v);
},
input: {
setTrigMode: m.setTrigonometryMode,
getTrigMode: m.getTrigonometryMode
}
}).css({
maxWidth: "40em",
margin: "0 auto"
}).appendTo(parent);
};
})();
mathDiv/screenKeyboard/calcSpecialKeys/calc.ls
(function(){
return function(m){
var template, visibleKeys, usedTags, keyDivs, t;
template = inc("/../app01/lib/gui/screenKeyboard/_templates/templates")[m.params.keyboardLayout];
visibleKeys = template.main.join("|").split("|");
usedTags = inc("calcUsedTags/calc")(m);
keyDivs = {};
for (t in usedTags) {
inc("createKeyDiv/create")(m, t, visibleKeys, keyDivs);
}
return keyDivs;
};
})();
mathDiv/screenKeyboard/calcSpecialKeys/calcUsedTags/addParamsSpecialKeys/add.ls
(function(){
return function(m, a){
var s, i$, ref$, len$, c, s2, results$ = [];
s = m.params.keyboardSpecialKeys;
if (!s) {
return;
}
for (i$ = 0, len$ = (ref$ = ["^", "/"]).length; i$ < len$; ++i$) {
c = ref$[i$];
s = _.replaceAll(" " + s, " " + c, " 2" + c + "2").trim();
}
for (i$ = 0, len$ = (ref$ = s.split(" ")).length; i$ < len$; ++i$) {
s2 = ref$[i$];
results$.push(a.push(s2));
}
return results$;
};
})();
mathDiv/screenKeyboard/calcSpecialKeys/calcUsedTags/calc.ls
(function(){
return function(m){
var usedTags, a, i$, len$, am, mathml;
usedTags = {};
a = _.map(m.gaps, "choices");
a = _.flatten(a);
a = _.map(a, "text");
inc("addParamsSpecialKeys/add")(m, a);
for (i$ = 0, len$ = a.length; i$ < len$; ++i$) {
am = a[i$];
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, am);
inc("findTagsInMathml/find")(mathml, usedTags);
}
return usedTags;
};
})();
mathDiv/screenKeyboard/calcSpecialKeys/calcUsedTags/findTagsInMathml/find.ls
(function(){
return function(el, tags){
var i$, ref$, len$, el2, t, v, am;
tags == null && (tags = {});
for (i$ = 0, len$ = (ref$ = el.childrenAll()).length; i$ < len$; ++i$) {
el2 = ref$[i$];
t = el2.tagName;
if (t === "mn") {
v = el2.textContent;
if (_.includes(v, ".")) {
tags[t + "|."] = true;
}
} else if (t === "mi" || t === "mo" || t === "mtext") {
v = el2.textContent;
if (v) {
tags[t + "|" + v] = true;
}
} else if (t === "mfenced") {
tags[t + "|" + el2.attr("type")] = true;
} else if (t === "msub" || t === "mf_unit") {
am = inc("/mathDiv/_shared/getAsciimathFromMathml/get")(el2);
tags[t + "|" + am] = true;
continue;
} else {
tags[t] = true;
}
inc(THISFILE)(el2, tags);
}
return tags;
};
})();
mathDiv/screenKeyboard/calcSpecialKeys/createKeyDiv/create.ls
(function(){
return function(m, t, visibleKeys, keyDivs){
var a, t1, t2, p;
a = t.split("|");
t1 = a[0];
t2 = a[1];
p = t1 === "mn"
? {
am: ".",
key: "."
}
: t1 === "mo" || t1 === "mi"
? {
am: t2,
key: t2
}
: t1 === "mtext"
? {
am: "`" + t2 + "`",
cursor: "end"
}
: t1 === "msqrt"
? {
am: "sqrt($)",
key: "sqrt"
}
: t1 === "mroot"
? {
am: "root($)($))",
key: "root"
}
: t1 === "msubsup"
? {
am: "$_$^$",
key: "subsup"
}
: t1 === "mfrac"
? {
am: "$/$",
key: "/"
}
: t1 === "msup"
? {
am: "$^$",
key: "^"
}
: t1 === "msub"
? {
am: t2
}
: t1 === "mfenced"
? {
am: "`" + t2 + "`",
key: t2
}
: t1 === "mf_unit"
? {
am: t2,
cursor: "end"
}
: t1 === "mf_abs"
? {
am: "abs($)",
key: "abs"
}
: t1 === "mf_bar"
? {
am: "bar($)",
key: "bar"
}
: t1 === "mf_fac"
? {
am: "$!",
key: "!"
}
: t1 === "mf_ncr"
? {
am: "ncr($, $)",
key: "ncr"
}
: t1 === "mf_lim"
? {
am: "lim_$",
key: "lim"
}
: t1 === "mf_sum"
? {
am: "sum_$^$",
key: "sum"
}
: t1 === "mf_larrow"
? {
am: "larrow($)",
key: "larrow"
}
: t1 === "mf_rarrow"
? {
am: "rarrow($)",
key: "rarrow"
}
: t1 === "mf_lrarrow"
? {
am: "lrarrow($)",
key: "lrarrow"
}
: t1 === "mf_logbase"
? {
am: "log_($)($)",
key: "logbase"
}
: t1 === "mf_sin" || t1 === "mf_cos" || t1 === "mf_tan" || t1 === "mf_ln" || t1 === "mf_log"
? {
am: "`" + t1.substr(3) + " `",
key: t1.substr(3)
}
: t1 === "mf_asin" || t1 === "mf_acos" || t1 === "mf_atan" ? {
am: "`" + t1.substr(4) + " `^(-1)",
key: t1.substr(3)
} : void 8;
if (!p || inc("isVisibleKey/is")(m, p.key, visibleKeys)) {
return;
}
return keyDivs[t] = inc("keyDivElement/div")(p, m);
};
})();
mathDiv/screenKeyboard/calcSpecialKeys/createKeyDiv/isVisibleKey/is.ls
(function(){
return function(m, key, visibleKeys){
var map, that;
map = {
"+": "plus",
"-": "minus",
"*": "multiply",
"÷": "divide",
".": "separator"
};
if (that = map[key]) {
key = that;
}
return in$(key, visibleKeys);
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
mathDiv/screenKeyboard/calcSpecialKeys/createKeyDiv/keyDivElement/div.ls
(function(){
return function(p, m){
var tap;
tap = function(){
var that, am, mathml, el, ref$;
if (that = p.key) {
return m.onKey({
key: that
});
} else {
am = p.am;
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, am);
el = m.createElement(mathml.firstChild);
m.deleteSelectionRange();
m.insertElement(el);
m.cleanupLayout();
return el.setCursor((ref$ = p.cursor) != null ? ref$ : "start");
}
};
return Div({
alignSelf: "stretch",
display: "flex",
padding: "0.3em",
minWidth: "1.8em"
}).html(inc("mathEl/el")(m, p.am)).tap(tap);
};
})();
mathDiv/screenKeyboard/calcSpecialKeys/createKeyDiv/keyDivElement/mathEl/el.ls
(function(){
return function(m, am){
var mathml, el, i$, ref$, len$, el2;
mathml = inc("/mathDiv/_shared/getMathElFromAsciimath/get")(m, am);
el = m.createElement(mathml.innerHTML).cssVar({
style_color: "black"
});
el.getHC();
for (i$ = 0, len$ = (ref$ = el.findAll(".mi")).length; i$ < len$; ++i$) {
el2 = ref$[i$];
if (el2.textContent === "$") {
el2.css({
color: "transparent",
width: "0.65em"
}).append(Div({
position: "absolute",
top: "0.4em",
bottom: "0.4em",
left: "0.1em",
right: "0.1em",
border: "1.5px solid black"
}));
}
}
return el;
};
})();
mathDiv/screenKeyboard/start/start.ls
(function(){
return function(m){
if (!m.params.keyboardEnabled) {
return;
}
if (!m.screenKeyboard) {
m.keyboardSpecialKeys = inc("../calcSpecialKeys/calc")(m);
m.screenKeyboard == null && (m.screenKeyboard = inc("../_screenKeyboard/screenKeyboard")(m));
}
m.screenKeyboard.start();
return m.screenKeyboard.lastHeight = m.screenKeyboard.offsetHeight;
};
})();
mathDiv/screenKeyboard/stop/stop.ls
(function(){
return function(m){
var ref$;
return (ref$ = m.screenKeyboard) != null ? ref$.stop() : void 8;
};
})();
mathDiv/scrollDivSlim/div.ls
(function(){
return function(m, contentHtml){
var div;
div = Div({
display: "inline-flex",
overflow: "hidden",
justifyContent: "flex-start",
alignItems: "flex-start",
maxWidth: "100%"
});
div.minScrollPx = 3;
div.html(div.scrollContainerDiv = Div({
display: "inline-flex",
maxWidth: "100%",
marginBottom: "-30px",
overflowX: "scroll",
webkitOverflowScrolling: "touch",
justifyContent: "flex-start"
}).bind("wheel", function(e){
return inc("onWheel/on")(div, e);
}).bind("scroll", function(){
return div.updateScrollBar();
}).html(div.contentDiv = Div({
display: "inline-flex",
borderRight: "1px solid transparent",
borderBottom: "30px solid transparent"
}).html(contentHtml)), div.scrollBarDiv = Div({
position: "absolute",
bottom: 0,
height: "2px",
background: Color.grey[900],
opacity: 0.07
})).onChildrenModified(function(){
return div.updateScrollBar();
}).onWindowResize(function(){
return div.updateScrollBar();
});
div.updateScrollBar = function(){
return inc("updateScrollBar/update")(div);
};
div.scrollElementIntoView = function(el){
return inc("scrollElementIntoView/scroll")(m, div, el);
};
return div;
};
})();
mathDiv/scrollDivSlim/onWheel/on.ls
(function(){
return function(div, e){
var sc;
sc = div.scrollContainerDiv;
if (sc.scrollWidth < sc.offsetWidth + div.minScrollPx) {
return;
}
sc.scrollLeft += e.deltaY + e.deltaX;
return e.preventDefault();
};
})();
mathDiv/scrollDivSlim/scrollElementIntoView/scroll.ls
(function(){
return function(m, div, el){
var sc, o1, o2, left;
if (!m.getSelection().isCollapsed) {
return;
}
sc = div.scrollContainerDiv;
o1 = el.offset();
o2 = sc.offset();
left = o1.left - o2.left;
if (left < 5) {
return sc.scrollLeft += left - 5;
} else if (left > sc.offsetWidth - 10) {
return sc.scrollLeft += left + 10 - sc.offsetWidth;
}
};
})();
mathDiv/scrollDivSlim/updateScrollBar/update.ls
(function(){
return function(div){
var bar, sc, w1, w2, l;
bar = div.scrollBarDiv;
sc = div.scrollContainerDiv;
w1 = sc.scrollWidth;
w2 = sc.offsetWidth;
l = sc.scrollLeft;
if (w1 - div.minScrollPx > w2) {
return bar.css({
width: w2 / w1 * 100 + "%",
left: l / w1 * 100 + "%"
}).show();
} else {
return bar.hide();
}
};
})();
mathDiv/selectAll/select.ls
(function(){
return function(m){
var rootEl, s, n1, o1, n2, o2;
rootEl = m.getRootElement();
rootEl.firstChild.setCursor("start");
s = m.getSelection();
n1 = s.anchorNode;
o1 = s.anchorOffset;
rootEl.lastChild.setCursor("end");
s = m.getSelection();
n2 = s.anchorNode;
o2 = s.anchorOffset;
return s.setBaseAndExtent(n1, o1, n2, o2);
};
})();
mathDiv/selection/get.ls
(function(){
return function(m){
var _s, ref$, s;
_s = (ref$ = m._selection) != null
? ref$
: m._selection = {
anchorNode: null,
anchorOffset: 0,
focusNode: null,
focusOffset: 0
};
s = _.clone(_s);
s.isCollapsed = inc("isCollapsed/is")(s);
s.getRange = function(){
return inc("getRange/get")(s);
};
s.setBaseAndExtent = function(n1, o1, n2, o2){
return inc("setBaseAndExtent/set")(n1, o1, n2, o2, _s, m);
};
return s;
};
})();
mathDiv/selection/getRange/get.ls
(function(){
return function(s){
var r;
r = document.createRange();
if (s.isCollapsed) {
r.setStart(s.anchorNode, s.anchorOffset);
r.setEnd(s.anchorNode, s.anchorOffset);
} else if (s.anchorNode === s.focusNode) {
r.setStart(s.anchorNode, Math.min(s.anchorOffset, s.focusOffset));
r.setEnd(s.focusNode, Math.max(s.anchorOffset, s.focusOffset));
} else if (s.anchorNode.compareDocumentPosition(s.focusNode) === 4) {
r.setStart(s.anchorNode, s.anchorOffset);
r.setEnd(s.focusNode, s.focusOffset);
} else {
r.setStart(s.focusNode, s.focusOffset);
r.setEnd(s.anchorNode, s.anchorOffset);
}
return r;
};
})();
mathDiv/selection/isCollapsed/is.ls
(function(){
return function(s){
return s.anchorNode === s.focusNode && s.anchorOffset === s.focusOffset;
};
})();
mathDiv/selection/setBaseAndExtent/set.ls
(function(){
return function(n1, o1, n2, o2, s, m){
if (n1) {
s.anchorNode = n1;
}
if (o1 > -1) {
s.anchorOffset = o1;
}
if (n2) {
s.focusNode = n2;
}
if (o2 > -1) {
s.focusOffset = o2;
}
return m.onSelectionChange();
};
})();
mathDiv/setCenterTag/set.ls
(function(){
return function(m, v){
var j;
m.centerTag = v || false;
j = v ? "center" : "flex-start";
if (m.scrollDiv) {
return m.scrollDiv.css({
width: "100%",
justifyContent: j,
margin: "0.6em 0"
});
} else {
return m.div.css({
width: "100%",
justifyContent: j,
margin: "0.6em 0"
});
}
};
})();
mathDiv/setColor/set.ls
(function(){
return function(m, c){
m.styles.mainColor = c;
return m.div.cssVar({
style_color: c
});
};
})();
mathDiv/setEnabled/set.ls
(function(){
return function(m, enabled){
var c, ref$, ref1$;
if (enabled && m.mode === "display") {
debug("mathDiv display mode can't be enabled");
return;
}
m.enabled = enabled;
if (!enabled) {
m.stop();
}
inc("setTap/set")(m, enabled);
c = enabled ? "text" : "";
if ((ref$ = m.scrollDiv) != null) {
ref$.css({
cursor: c
});
}
m.div.css({
cursor: c
});
return (ref1$ = m.cursor) != null ? ref1$.hide() : void 8;
};
})();
mathDiv/setEnabled/setTap/set.ls
(function(){
return function(m, enabled){
if (!enabled || m.onTapIsBinded) {
return;
}
m.onTapIsBinded = true;
return (m.scrollDiv || m.div).tap({
animation: "none",
down: m.onTap
});
};
})();
mathDiv/setSelection/after/set.ls
(function(){
return function(m, node){
var pEl, a, i;
pEl = node.parent();
a = pEl.childrenAll();
i = _.indexOf(a, node);
return inc("../offset/set")(m, pEl, i + 1);
};
})();
mathDiv/setSelection/before/set.ls
(function(){
return function(m, node){
var pEl, a, i;
pEl = node.parent();
a = pEl.childrenAll();
i = _.indexOf(a, node);
return inc("../offset/set")(m, pEl, i);
};
})();
mathDiv/setSelection/offset/set.ls
(function(){
return function(m, node, offset){
var sel;
sel = m.getSelection();
return sel.setBaseAndExtent(node, offset, node, offset);
};
})();
mathDiv/setSelection/set.ls
(function(){
return function(m, node, o){
if (_.isNumber(o)) {
inc("offset/set")(m, node, o);
} else if (o === "before") {
inc("before/set")(m, node);
} else if (o === "after") {
inc("after/set")(m, node);
}
return m.updateCustomCursor();
};
})();
mathDiv/setValue/set.ls
(function(){
return function(m, v){
var mEl, that, ref$;
m.value = v;
if (v.match(/[0-9],[0-9]/)) {
debug("Attention: Don't use ',' in mat-tags as a decimal separator, use '.' instead.");
}
mEl = inc("../_shared/getMathElFromAsciimath/get")(m, m.value);
if (that = mEl.attr("center")) {
m.setCenterTag(that);
}
if (that = mEl.attr("align")) {
m.alignColumns = that;
}
m.createElements(mEl);
if (m.started) {
m.masterMrow.setCursor("end");
}
m.cleanupLayout();
if (((ref$ = projects.documentCache["math-div2"]) != null ? ref$["_syntaxCheck_noMaster/check.ls"] : void 8) != null) {
return inc("/_syntaxCheck_noMaster/check")(m);
}
};
})();
mathDiv/start/start.ls
(function(){
return function(m, p){
var ref$;
if (m.started || !m.enabled || !m.div.isVisible()) {
return;
}
m.started = true;
body.bind("keydown", m.onKey);
body.bind("copy", m.onCopyOrCut);
body.bind("cut", m.onCopyOrCut);
body.bind("paste", m.onPaste);
if ((p != null ? p.dontSetCursor : void 8) !== true) {
if (m.hasGapMode()) {
m.startNextGap();
} else {
m.masterMrow.setCursor("end");
}
}
if (m.mode === "input") {
m.startScreenKeyboard();
}
inc("updateAppLastInput/update")(m);
return typeof (ref$ = m.params).onStart == 'function' ? ref$.onStart() : void 8;
};
})();
mathDiv/start/updateAppLastInput/update.ls
(function(){
return function(m){
var div, i$, ref$, len$, i;
div = m.scrollDiv || m.div;
for (i$ = 0, len$ = (ref$ = [app.lastInput, app.lastPopupInput]).length; i$ < len$; ++i$) {
i = ref$[i$];
if (i && i !== div) {
i.stop();
}
}
if ((ref$ = app.currentPopup) != null && ref$.contains(m.div)) {
return app.lastPopupInput = div;
} else {
return app.lastInput = div;
}
};
})();
mathDiv/stop/clearSelection/clear.ls
(function(){
return function(m){
var s;
s = m.getSelection();
return s.setBaseAndExtent(s.anchorNode, s.anchorOffset);
};
})();
mathDiv/stop/stop.ls
(function(){
return function(m){
var ref$, ref1$, ref2$;
if (!m.started) {
return;
}
m.started = false;
body.unbind("keydown", m.onKey);
body.unbind("copy", m.onCopyOrCut);
body.unbind("cut", m.onCopyOrCut);
body.unbind("paste", m.onPaste);
inc("clearSelection/clear")(m);
if ((ref$ = m.currentGap) != null) {
ref$.stopGap();
}
m.updateCustomCursor();
m.stopScreenKeyboard();
if ((ref1$ = m.buttonsDiv) != null) {
ref1$.hide();
}
return typeof (ref2$ = m.params).onStop == 'function' ? ref2$.onStop() : void 8;
};
})();
mathDiv/styles/isOldEdge/is.ls
(function(){
var isOldEdge;
isOldEdge = null;
return function(){
if (isOldEdge != null) {
return isOldEdge;
}
return isOldEdge = _.includes(navigator.userAgent, "Edge");
};
})();
mathDiv/styles/styles.ls
(function(){
return function(m){
var s, t, ref$;
s = {};
t = (ref$ = document.head.findFirst('#cssColorTags')) != null
? ref$
: {};
s.textColors = (ref$ = t.textColors) != null
? ref$
: {};
s.backgroundColors = (ref$ = t.markColors) != null
? ref$
: {};
s.lineHeight = 1.3;
s.mainColor = (ref$ = m.params.color) != null ? ref$ : "currentcolor";
s.emptyColor = "rgba(0,0,0,0.2)";
if (s.mainColor === "currentcolor" && inc("isOldEdge/is")()) {
s.mainColor = "black";
}
return s;
};
})();
mathDiv/submit/submit.ls
(function(){
return function(m){
var ref$;
return (typeof (ref$ = m.params).submit == 'function' ? ref$.submit() : void 8) || ((ref$ = m.currentGap) != null ? ref$.submitGap() : void 8);
};
})();
mathDiv/trigonometryMode/get/get.ls
(function(){
return function(m){
return m.trigonometryMode;
};
})();
mathDiv/trigonometryMode/set/set.ls
(function(){
return function(m, v){
return m.trigonometryMode = v;
};
})();
mathDiv/updateCustomCursor/_initCursor/init.ls
(function(){
return function(m){
var color, wrapper, cursor, ref$, b;
m.div.css({
caretColor: "transparent"
});
color = Color.grey[800];
wrapper = Div({
flex: "0 0 0",
position: "absolute",
zIndex: 1
}).html(cursor = Div({
position: "absolute",
width: "2px",
height: "2px",
pointerEvents: "none",
backgroundClip: "padding-box",
background: document.hasFocus() ? color : void 8
}).addClass("mathDivCursor").css((ref$ = m.mode) === "gapWrite" || ref$ === "input" ? {
borderTop: b = "0.06em solid transparent",
borderBottom: b
} : void 8).keyframeAnimate({
keyframes: {
"0%": {
opacity: 0.8
},
"40%": {
opacity: 0.8
},
"70%": {
opacity: 0.0
},
"100%": {
opacity: 0.8
}
},
duration: 1000,
iterationCount: "infinite"
}).hide().onWindowFocus(function(){
return cursor.css({
background: color
});
}).onWindowBlur(function(){
return cursor.css({
background: ""
});
}));
m.div.prepend(wrapper);
m.cursorWrapper = wrapper;
return m.cursor = cursor;
};
})();
mathDiv/updateCustomCursor/_restartAnimation/restart.ls
(function(){
return function(cursor){
var i$, ref$, len$, kc;
cursor.show();
for (i$ = 0, len$ = (ref$ = cursor.classList).length; i$ < len$; ++i$) {
kc = ref$[i$];
if (_.startsWith(kc, "keyframe")) {
break;
}
}
cursor.removeClass(kc);
return requestAnimationFrame(function(){
return cursor.addClass(kc);
});
};
})();
mathDiv/updateCustomCursor/calcCurrentScale/calc.ls
(function(){
return function(m){
return m.div.offset().width / m.div.offsetWidth;
};
})();
mathDiv/updateCustomCursor/horizontal/calcPos/calc.ls
(function(){
return function(m, gap){
var dr, gr;
dr = m.div.getClientRects()[0];
gr = gap.getClientRects()[0];
return {
left: gr.left - dr.left,
top: gr.top - dr.top + gr.height - 2,
width: gr.width
};
};
})();
mathDiv/updateCustomCursor/horizontal/update.ls
(function(){
return function(m){
var cursor, gap, p, s;
cursor = m.cursor;
gap = m.currentGap;
if (!gap || !m.started) {
cursor.hide();
return;
}
cursor.show();
inc("../_restartAnimation/restart")(cursor);
p = inc("calcPos/calc")(m, gap);
s = m.scale;
return cursor.css({
left: p.left / s + "px",
top: p.top / s + "px",
width: p.width / s + "px"
});
};
})();
mathDiv/updateCustomCursor/update.ls
(function(){
return function(m){
var t;
t = m.mode;
if (m.mode === "display" || !m.enabled || !m.div.isVisible()) {
return;
}
if (!m.cursor) {
inc("_initCursor/init")(m);
}
m.scale = inc("calcCurrentScale/calc")(m);
if (m.mode === "gapButtons") {
return inc("horizontal/update")(m);
} else {
inc("vertical/update")(m);
return inc("updateRangeCanvas/update")(m);
}
};
})();
mathDiv/updateCustomCursor/updateRangeCanvas/calcRects/calc.ls
(function(){
return function(m){
var s, r, rects, res$, i$, ref$, len$;
s = m.getSelection();
r = s.getRange();
if (r.endOffset === 0) {
r.setEndBefore(r.endContainer);
}
res$ = [];
for (i$ = 0, len$ = (ref$ = r.getClientRects()).length; i$ < len$; ++i$) {
r = ref$[i$];
res$.push({
rect: r,
id: [r.left, r.top, r.width, r.height].join("")
});
}
rects = res$;
rects = _.uniqBy(rects, "id");
return {
rects: rects,
checksum: _.map(rects, "id").join(",")
};
};
})();
mathDiv/updateCustomCursor/updateRangeCanvas/drawRect/draw.ls
(function(){
return function(m, r, o){
var ctx, b, x, y, w, h, s;
ctx = m.rangeCanvas.getContext("2d");
b = 2;
x = r.left - o.left - b / 2;
y = r.top - o.top - b / 2;
w = r.width + b;
h = r.height + b;
ctx.fillStyle = Color.grey[800];
s = m.scale;
return ctx.fillRect(x / s, y / s, w / s, h / s);
};
})();
mathDiv/updateCustomCursor/updateRangeCanvas/rangeCanvas/canvas.ls
(function(){
return function(m){
var c;
c = document.createElement("canvas").attr({
width: m.div.offsetWidth,
height: m.div.offsetHeight
}).css({
position: "absolute",
top: 0,
left: 0,
opacity: 0.2,
pointerEvents: "none"
}).appendTo(m.div);
return m.rangeCanvas = c;
};
})();
mathDiv/updateCustomCursor/updateRangeCanvas/update.ls
(function(){
return function(m){
var sel, cursorEl, ref$, rects, ref1$, ref2$, mrangeCanvas, o, i$, ref3$, len$, r, results$ = [];
sel = m.getSelection();
cursorEl = m.getCursorElement();
if (sel.isCollapsed || !cursorEl || !m.started) {
if ((ref$ = m.rangeCanvas) != null) {
ref$.remove();
}
return;
}
rects = inc("calcRects/calc")(m);
if (rects.checksum === ((ref1$ = m.rangeCanvas) != null ? ref1$.checksum : void 8) && m.rangeCanvas.isVisible()) {
return;
}
if ((ref2$ = m.rangeCanvas) != null) {
ref2$.remove();
}
mrangeCanvas = inc("rangeCanvas/canvas")(m);
mrangeCanvas.checksum = rects.checksum;
o = m.rangeCanvas.offset();
for (i$ = 0, len$ = (ref3$ = rects.rects).length; i$ < len$; ++i$) {
r = ref3$[i$];
results$.push(inc("drawRect/draw")(m, r.rect, o));
}
return results$;
};
})();
mathDiv/updateCustomCursor/vertical/calcPos/calc.ls
(function(){
return function(m, cursor, cursorEl, sel){
if (sel.anchorNode.nodeType === 3) {
return inc("textNode/calc")(m, cursor, cursorEl, sel);
} else {
return inc("divNode/calc")(m, cursor, cursorEl, sel);
}
};
})();
mathDiv/updateCustomCursor/vertical/calcPos/divNode/calc.ls
(function(){
return function(m, cursor, cursorEl, sel){
var offset, anchorNode, dummyDiv, r, rr, dr, wcr, shrink;
offset = sel.anchorOffset;
anchorNode = sel.anchorNode;
dummyDiv = Div({
display: "inline-flex"
}).html("​");
if (offset === 0) {
anchorNode.prepend(dummyDiv);
} else {
anchorNode.childNodes[offset - 1].after(dummyDiv);
}
r = document.createRange();
r.setStart(dummyDiv.firstChild, 0);
rr = r.getClientRects()[0];
dr = m.div.getClientRects()[0];
wcr = m.cursorWrapper.getClientRects()[0];
dummyDiv.remove();
shrink = rr.height * 0.23;
return {
left: rr.left - wcr.left,
top: rr.top - dr.top + (dr.top - wcr.top) + shrink / 2,
height: rr.height - shrink
};
};
})();
mathDiv/updateCustomCursor/vertical/calcPos/textNode/calc.ls
(function(){
return function(m, cursor, cursorEl, sel){
var dr, wcr, rr, shrink;
dr = m.div.getClientRects()[0];
wcr = m.cursorWrapper.getClientRects()[0];
rr = sel.getRange().getClientRects()[0];
shrink = rr.height * 0.23;
return {
left: rr.left - wcr.left,
top: rr.top - dr.top + (dr.top - wcr.top) + shrink / 2,
height: rr.height - shrink
};
};
})();
mathDiv/updateCustomCursor/vertical/update.ls
(function(){
return function(m){
var sel, cursor, cursorEl, p, s, ref$;
sel = m.getSelection();
cursor = m.cursor;
cursorEl = m.getCursorElement();
if (!sel.isCollapsed || !cursorEl || !m.started) {
cursor.hide();
return;
}
inc("../_restartAnimation/restart")(cursor);
p = inc("calcPos/calc")(m, cursor, cursorEl, sel);
s = m.scale;
cursor.css({
left: p.left / s + "px",
top: p.top / s + "px",
height: p.height / s + "px"
});
return (ref$ = m.scrollDiv) != null ? ref$.scrollElementIntoView(m.cursor) : void 8;
};
})();