16020,6,161,31,56,6,905,23,424,72,424,77,685,55,623,47,713,44,135,75,696,53,643,45,723,40,162,77,531,55,727,55,362,47,604,44,258,71,454,36,449,49,3031,46,1551,48,441,59,70,61,214,57,133,62,70,64,119,60,119,54,441,42,664,21,208,40,680,38,315,32,1735,43,159,42,158,37,140,43,228,26,1303,49,246,40,490,36,448,29,100,32,730,39,867,35,2903,39,571,40,876,59,308,22,248,41,376,46,115,41,205,46,264,35,1681,43,514,47,375,43,333,45,140,56,642,43,369,59,660,37,91,28,1807,26,710,51,1022,73,987,73,112,42,251,52,530,76,810,43,451,49,1068,87,344,66,414,86,548,71,485,88,703,95,175,98,880,95,414,96,127,73,57,80,1242,68,847,86,663,88,271,83,2389,88,599,98,585,101,500,107,945,89,534,110,202,92,295,108,375,90,763,94,425,86,410,90,393,92,294,95,1366,78,949,96,253,109,376,113,498,79,1416,113,420,99,979,90,289,106,167,109,157,121,460,120,509,103,2012,88,371,84,688,73,397,71,551,57,1683,49,552,57,1110,53,400,63,717,63,534,72,331,72,135,72,331,47,122,53,146,45,331,66,703,51,275,62,348,60,225,62,217,44,633,65,771,74,260,74,398,76,291,59,344,65,750,74,247,74,392,76,270,59,365,63,388,57,413,35,448,37,1446,28,399,29,1396,31,577,43,1301,27,528,24,449,22,1100,45,490,36,360,34,2497,34,139,38,402,25,469,34,289,49,306,37,289,42,230,53,750,36,269,46,767,48,331,54,268,38,238,63,548,48,325,39,1031,40,88,38,464,53,334,55,915,56,628,58,268,41,1687,71,369,29,799,58,811,34,349,27,362,43,334,22,857,18,1284,34,436,43,490,34,358,36,852,26,1042,26,768,48,3026,51,340,54,3071,57,164,39,290,31,309,56,407,43,494,34,646,34,323,22,1879,28,1817,28,93,43,408,40,426,29,226,32,93,47,368,44,316,33,311,47,310,30,2128,61,1486,39,739,53,667,54,496,56,540,63,222,53,297,61,996,39,762,53,579,63,410,78,1055,87,352,70,504,54,756,56,561,63,222,53,223,39,800,53,844,63,487,76,326,54,459,56,505,30,142,26,113,56,403,52,437,51,228,63,388,69,346,65,312,92,639,87,395,69,456,65,335,45,924,53,911,61,771,46,654,55,501,36,2001,70,526,89,1335,87,657,87,1501,93,172,78,444,81,813,81,294,41,1032,65,879,53,1119,45,1666,49,854,41,689,48,266,32,125,30,154,26,1131,50,624,46,146,35,176,50,1109,22,1078,28,504,36,804,38,203,30,663,21,730,43,393,43,164,37,631,32,1686,15,916,42,90,38,88,42,685,37,221,49,570,57,113,57,103,33,269,38,188,42,2031,36,474,47,623,37,477,46,136,57,623,39,376,35,877,32,251,25,325,44,120,28,278,31,401,47,133,51,339,46,463,58,1280,66,113,66,113,42,283,32,532,49,293,54,2314,53,2499,61,203,65,507,55,483,64,136,75,611,71,1097,61,862,54,691,58,113,47,390,43,192,44,581,34,359,48,634,45,161,52,601,51,604,50,569,68,113,62,1228,46,314,36,2205,53,1502,65,1212,73,4698,71,420,65,270,63,384,68,513,59,627,65,927,76,6935,75,6935,75,208197,82,124196,81,31578,73,2274,65,1117,66,7106,65,2905,65,3432,65,16423,72,1075,71,3861,63,2001,69,507,59,483,68,136,79,360,64,348,58,1674,62,100,51,388,47,159,48,586,38,514,67,396,52,1313,49,166,56,410,46,237,42,235,46,1625,41,650,59,113,53,1192,35,323,37,162,40,136,46,963,57,865,71,1620,65,348,66,384,75,106,86,611,75,907,70,210,61,150,49,551,57,1358,65,725,61,125,61,188,53,440,49,432,58,720,51,1227,53,326,42,304,38,197,39,596,29,384,48,138,47,726,42,237,38,235,42,709,37,226,49,45,31,340,33,200,36,170,51,1279,45,164,53,1175,61,725,57,125,57,188,49,397,47,725,45,389,68,280,61,758,49,1470,58,687,47,1164,49,328,38,299,35,523,25,297,44,138,43,737,46,90,42,88,46,636,41,221,53,561,61,113,61,113,37,334,46,450,39,751,36,251,29,327,48,138,32,278,39,663,45,795,34,702,41,740,41,736,36,228,48,237,44,235,48,482,43,570,55,45,37,228,39,275,47,431,42,132,48,614,51,1938,55,214,68,541,51,2141,64,256,53,299,44,299,40,184,41,373,31,539,50,120,46,510,45,766,47,587,42,212,54,832,38,241,43,206,41,346,52,1004,52,230,55,449,52,1061,40,692,30,308,49,138,51,526,60,747,49,1676,49,132,55,509,36,559,46,310,45,114,52,735,57,1305,63,719,52,251,48,555,41,447,44,272,55,1532,58,496,55,1247,46,1085,63,153,53,912,73,726,88,733,87,599,102,249,102,270,115,163,118,781,98,268,96,379,96,359,98,974,84,502,70,363,77,540,77,540,63,1157,65,406,70,626,66,130,77,942,67,394,53,184,46,392,43,536,33,487,52,120,36,545,52,1005,40,1042,51,496,51,5529,46,639,60,676,60,756,58,646,68,171,61,725,49,218,61,1235,50,1211,62,360,40,1094,43,276,39,229,43,784,38,323,50,702,50,405,32,104,34,730,24,502,48,1068,47,528,37,774,36,533,26,356,45,138,34,398,33,673,57,644,43,4396,61,715,67,398,83,213,72,777,71,1285,81,219,67,478,71,686,66,626,48,1171,63,206,59,417,59,918,47,418,48,1173,39,2379,45,112,49,561,47,149,44,534,44,464,40,460,44,967,39,284,51,991,71,302,67,288,75,1075,69,70,59,254,61,338,63,367,59,103,35,262,42,271,38,171,47,748,62,375,87,673,73,1062,57,1904,79,602,73,353,91,345,88,246,77,731,64,686,84,106,81,99,66,900,66,270,68,119,67,185,63,375,88,673,74,1009,58,1562,74,353,92,345,89,246,78,731,65,686,85,106,82,99,64,229,89,602,63,372,62,560,67,900,67,270,57,389,51,277,47,259,55,192,40,327,54,270,37,469,27,744,46,138,56,754,44,591,42,583,44,721,43,636,38,898,34,707,44,395,40,512,44,823,39,45,57,245,61,285,69,251,65,321,73,1086,67,76,51,908,47,706,35,266,47,171,38,171,47,913,62,686,90,643,73,936,70,502,57,2026,75,467,93,106,73,606,76,441,66,1101,75,714,57,460,51,279,47,261,55,177,40,787,54,287,37,434,27,705,46,138,44,271,44,90,40,88,44,1746,39,115,51,1419,35,607,25,216,40,206,52,1532,73,1297,69,339,61,939,37,263,52,1426,41,330,45,465,49,367,55,532,58,215,61,163,59,186,43,282,59,386,44,212,49,343,49,397,56,114,57,339,73,106,62,586,85,195,76,245,86,149,101,130,100,301,86,223,99,204,51,740,72,181,47,390,72,333,57,600,73,322,88,550,106,580,104,401,110,163,97,259,87,775,98,379,116,320,127,168,115,225,102,358,104,429,82,197,59,617,64,177,84,193,60,462,71,1122,93,255,98,855,98,430,76,1240,61,500,40,414,37,886,34,251,27,1195,46,138,30,278,46,168,56,168,54,587,74,322,62,173,50,510,58,307,52,248,34,876,33,713,48,556,50,757,40,173,56,120,46,382,48,218,62,253,46,539,41,198,43,153,34,405,43,90,39,88,43,671,38,115,50,1383,34,703,39,206,36,781,64,931,83,300,100,2003,97,1056,88,408,105,575,107,778,90,879,74,2671,86,502,81,1123,87,1115,92,205,70,986,52,339,46,515,36,978,48,787,64,2667,49,252,64,797,69,1277,36,723,33,251,26,657,45,138,29,274,37,547,32,755,49,687,46,996,73,260,74,127,46,1916,55,438,55,892,57,315,59,67,51,58,43,1165,32,465,41,310,40,114,52,845,36,305,53,458,36,363,39,212,50,251,50,313,44,563,58,178,48,866,58,848,65,942,48,184,41,392,38,482,28,503,47,138,31,478,35,979,41,1479,44,218,45,318,35,838,43,237,39,298,43,515,38,45,50,1260,34,293,37,198,48,1392,48,682,37,163,52,178,46,895,65,1151,76,519,79,280,79,302,71,479,63,359,70,690,56,2517,65,457,63,942,48,699,50,233,58,593,46,236,48,139,39,554,36,362,26,274,45,138,29,274,33,448,44,90,40,88,44,696,39,45,51,515,57,81,59,237,51,240,35,430,38,178,47,604,70,280,62,260,87,673,73,993,57,3624,66,374,64,1271,74,717,62,336,40,314,37,925,34,251,27,693,46,138,30,274,44,210,46,1534,51,203,51,447,40,339,45,347,49,387,38,1017,34,403,40,88,44,656,39,82,51,1015,35,319,25,122,40,188,38,326,49,1187,49,260,52,443,49,1055,37,692,27,308,46,120,44,1025,56,713,53,2076,46,577,46,1342,65,418,58,1052,63,627,53,1051,66,261,52,1027,42,115,61,610,44,1623,46,996,58,625,62,421,42,154,44,1202,64,397,50,291,50,430,56,473,63,462,42,743,49,278,52,1197,46,619,50,186,48,353,52,1100,33,688,52,434,38,88,42,661,37,174,55,291,49,634,59,376,55,442,59,160,59,319,48,164,33,381,38,223,39,566,42,163,40,286,39,370,51,649,50,343,50,407,45,696,54,215,55,733,60,508,76,161,69,258,57,786,69,429,54,905,52,457,45,248,38,558,47,115,35,882,25,590,44,120,39,550,28,662,51,204,33,149,32,404,45,405,31,279,44,315,32,662,46,151,66,273,83,131,65,151,62,276,51,506,42,378,48,278,38,88,42,1159,37,45,49,1171,33,226,38,206,36,274,47,1096,50,449,47,1021,45,884,38,533,35,692,25,504,44,138,28,345,32,736,31,621,38,314,46,78,42,76,46,529,41,403,61,609,53,1578,61,340,67,283,61,456,63,341,37,191,27,330,40,182,51,453,62,471,49,982,58,510,57,563,45,820,64,560,58,184,49,1809,42,304,39,508,34,368,51,234,53,228,49,224,51,229,38,213,55,771,53,924,34,762,36,276,29,699,48,120,32,300,40,368,36,926,47,804,40,107,57,434,43,88,47,506,42,122,54,721,68,466,62,861,64,379,68,561,71,1071,65,797,67,348,38,105,28,175,56,746,44,551,65,345,60,157,50,3035,52,829,63,190,64,515,65,264,65,242,63,188,43,1233,40,525,39,213,58,106,56,287,59,243,56,249,57,167,54,331,58,464,74,536,86,127,55,192,30,506,49,138,33,333,49,818,48,994,50,78,46,76,50,1116,45,231,57,1212,73,113,39,335,41,105,43,697,42,247,59,745,57,1026,66,139,40,239,33,536,52,138,36,262,56,180,59,57,62,134,61,250,65,77,69,445,68,205,56,3772,59,57,57,1889,48,460,40,977,47,844,51,1136,54,138,39,88,43,506,38,45,50,1059,58,208,58,248,60,269,34,215,24,175,46,583,53,817,64,190,65,515,66,264,66,242,64,188,48,2583,39,248,36,493,35,213,52,648,50,859,26,494,45,138,47,1897,29,477,64,298,44,663,37,168,48,652,43,705,44,322,40,318,44,916,39,45,51,565,59,486,59,103,35,358,25,115,50,1207,56,364,44,1231,49,258,45,242,61,959,38,965,48,82,49,2081,66,581,43,142,49,694,39,383,32,1702,49,553,37,372,37,780,27,305,46,138,41,351,46,537,42,531,46,864,41,45,59,677,53,506,37,229,42,188,63,463,46,2677,65,428,66,768,72,310,88,229,76,538,71,281,57,1467,70,376,65,344,66,712,72,814,88,229,76,947,71,647,57,1790,40,1363,51,627,41,236,39,780,36,251,29,325,48,120,32,274,35,369,43,237,39,235,43,855,38,754,50,1070,58,200,58,278,32,431,34,105,24,267,37,176,46,242,50,422,46,408,48,1264,39,340,45,102,36,592,26,445,45,138,44,845,47,144,45,90,41,128,41,145,40,45,47,262,52,1243,54,206,36,134,45,320,46,166,42,158,56,772,42,245,38,294,42,186,44,183,44,439,45,307,37,944,40,4199,47,511,38,692,28,451,47,138,33,622,37,875,37,512,43,769,39,125,49,115,48,45,55,262,60,978,62,206,44,134,53,347,60,772,46,294,46,692,51,1542,36,504,55,138,41,517,69,1523,60,4393,45,1763,56,1108,45,512,51,676,47,125,38,90,34,88,38,671,33,248,45,358,29,633,34,218,38,247,51,640,38,810,45,1115,31,1077,38,455,21,831,40,120,34,246,36,175,28,354,38,472,64,936,28,957,43,521,39,505,43,1047,38,285,50,1053,32,1062,34,240,43,209,56,515,43,762,50,1050,60,362,39,507,59,423,63,135,57,408,68,294,82,623,68,939,74,528,68,294,58,1230,49,185,49,731,67,1209,74,129,61,146,53,274,50,349,52,187,49,441,36,954,33,239,26,669,45,120,29,262,51,825,56,397,77,1028,44,1163,52,521,48,505,52,1117,47,213,59,1053,41,885,43,271,33,734,69,347,65,432,69,135,61,301,76,282,74,189,55,951,73,702,84,296,72,642,82,253,96,189,86,968,111,450,103,524,114,393,86,577,100,431,97,207,96,403,111,322,105,450,97,353,110,463,108,545,80,522,94,496,96,174,108,219,94,303,109,1081,113,551,104,425,114,390,90,325,107,655,84,568,92,230,95,473,59,218,48,385,58,404,45,855,35,498,51,555,54,120,67,559,53,450,60,434,65,234,53,621,42,90,38,88,42,730,37,395,49,565,57,113,57,113,33,170,42,1610,36,610,47,565,37,266,46,136,57,623,30,1642,37,286,33,272,35,195,35,829,25,197,44,138,47,322,43,318,47,783,42,45,54,565,62,486,62,103,38,229,43,206,55,410,47,2566,52,258,48,259,41,897,51,82,52,675,42,205,40,780,37,251,30,325,49,138,33,274,36,431,43,90,39,88,43,772,38,45,50,561,58,113,58,113,34,226,39,188,58,402,76,411,43,1220,37,666,52,175,36,1010,33,251,26,325,45,120,29,274,32,637,50,90,46,88,50,937,45,139,57,561,65,113,65,113,41,293,45,573,59,174,43,781,40,251,33,375,52,138,64,394,55,211,49,1381,38,499,52,644,56,1144,36,274,51,1319,50,406,40,213,44,166,51,90,47,88,51,1014,46,139,58,123,42,294,60,174,44,833,41,251,34,375,53,138,50,409,39,212,53,650,57,1151,37,274,52,1318,66,394,57,210,51,1380,41,501,45,166,39,718,34,479,46,45,30,291,39,676,32,494,22,261,41,138,39,381,30,2054,27,835,44,493,39,320,51,939,59,113,59,113,35,489,51,604,44,311,52,3156,45,407,37,493,27,537,46,120,32,133,51,355,45,2743,46,391,40,210,34,236,38,149,36,958,38,104,52,377,48,367,52,515,47,940,59,1181,67,254,76,615,67,245,50,267,46,282,43,250,44,869,69,526,84,810,84,265,61,1908,73,766,67,260,69,637,69,545,67,359,54,470,58,659,64,504,62,442,51,402,45,508,35,591,54,138,55,539,54,618,52,719,53,858,38,97,43,493,38,320,50,943,58,140,58,143,34,186,24,304,50,239,43,348,51,3144,44,407,36,372,26,449,45,138,31,151,50,355,44,1882,39,204,33,256,37,149,35,840,37,122,40,1309,31,257,34,76,38,839,33,45,51,375,45,865,29,166,38,209,52,418,46,337,41,817,59,1117,43,200,34,243,31,614,21,400,40,120,24,508,40,304,39,808,49,665,44,45,56,1174,40,148,45,236,43,289,55,333,54,355,57,1139,53,472,40,2310,37,1138,42,692,32,524,51,138,39,468,38,220,45,790,43,338,48,319,45,984,46,90,42,88,46,637,41,45,59,289,53,653,63,267,37,1361,27,1779,40,189,50,251,39,768,36,251,29,954,48,138,32,274,58,574,51,1308,43,156,42,558,60,387,68,116,54,704,42,756,34,333,45,820,45,282,42,580,36,561,43,302,57,653,55,459,65,832,53,456,71,918,53,535,42,189,64,2045,67,1052,50,90,46,88,50,637,45,45,63,284,57,632,67,374,67,309,85,291,60,357,72,2489,86,261,74,838,64,1318,41,268,31,2654,54,619,47,349,45,455,43,709,40,269,33,728,52,138,36,253,40,271,54,310,63,546,93,254,91,270,73,631,56,222,67,241,101,379,98,459,98,185,111,184,137,289,123,592,99,629,81,480,74,459,77,189,66,686,66,351,70,519,62,268,63,229,66,384,63,127,64,966,66,274,75,955,77,639,113,223,102,469,99,478,96,554,108,497,111,312,107,141,130,231,117,735,112,217,92,419,104,456,107,259,77,265,83,443,87,387,83,495,66,386,74,175,58,521,48,1165,72,233,46,342,43,78,39,76,38,45,56,728,50,1499,60,246,34,471,24,2003,40,403,40,345,49,1789,40,239,43,158,45,566,60,203,45,3436,58,449,65,302,63,254,53,222,51,220,54,431,56,244,53,324,43,552,33,566,45,288,50,306,38,672,36,397,33,239,26,1027,45,138,29,262,33,876,41,301,51,619,39,546,58,374,45,604,73,340,48,434,45,764,42,445,45,1590,35,1765,60,606,41,237,37,235,41,871,36,688,54,859,48,880,32,98,38,142,53,463,35,706,56,395,46,2390,69,162,67,92,73,237,62,652,57,310,73,229,61,588,56,400,59,376,54,335,44,2589,67,143,71,225,60,978,55,822,71,229,59,1025,54,774,31,2432,41,780,34,791,33,244,50,734,51,114,48,393,58,549,49,482,24,369,43,138,35,605,49,90,45,88,49,765,44,45,56,1126,40,226,45,192,44,234,43,1316,42,692,39,259,32,372,51,138,35,282,47,329,41,213,38,441,43,158,53,237,49,235,53,1549,48,226,60,1799,42,351,44,105,47,174,53,464,73,274,64,2039,76,350,72,593,77,934,56,543,64,1431,72,726,68,125,68,188,60,432,56,451,65,721,58,1472,60,304,49,329,46,509,36,379,55,138,54,955,48,665,43,183,55,875,63,113,63,113,39,301,44,206,42,346,53,963,53,230,56,449,53,827,41,692,31,308,50,138,48,2396,50,2211,56,512,37,541,41,138,46,608,41,108,53,978,37,265,40,346,51,996,51,230,54,449,51,845,49,673,39,748,29,324,48,138,61,1209,68,494,74,246,70,367,70,628,65,1027,66,79,68,979,77,530,76,241,73,1683,71,468,73,287,72,118,74,252,68,156,77,160,66,668,72,402,70,411,76,654,81,995,76,826,62,339,54,402,48,522,44,299,59,189,64,993,66,545,50,443,35,490,41,608,36,210,48,1101,32,265,35,346,46,996,46,230,49,449,46,905,44,617,34,815,24,324,43,138,56,1203,63,440,69,246,65,367,65,650,60,1027,61,79,76,820,63,152,95,389,88,964,96,246,97,387,78,349,72,530,71,241,68,1683,66,468,68,287,67,118,69,252,63,156,72,160,61,646,67,394,65,411,71,630,83,97,101,99,83,1072,101,391,85,1295,89,209,107,226,101,108,99,148,95,221,85,95,93,219,115,141,95,228,97,108,105,506,97,392,99,226,121,284,71,428,57,339,49,306,43,435,39,299,30,484,47,90,43,88,47,592,42,130,63,1096,54,524,38,266,43,206,41,679,52,2790,52,759,42,205,39,604,40,780,37,251,30,325,49,138,33,274,36,431,47,665,42,91,54,865,38,279,43,206,41,346,52,984,52,230,55,449,52,827,40,692,43,403,30,443,49,138,47,2559,49,2561,60,155,65,949,67,428,51,441,62,591,60,1153,55,843,47,126,36,541,47,665,42,45,54,716,62,113,62,113,38,241,41,274,52,703,52,230,55,449,40,692,43,306,30,308,49,138,47,2327,49,1962,55,2115,36,479,46,90,42,88,46,880,41,256,53,561,61,197,61,103,37,296,27,163,39,830,36,251,29,338,48,138,32,274,48,777,50,315,49,310,63,431,61,82,55,1922,68,246,65,249,57,1096,51,315,34,839,40,321,36,317,40,855,35,45,53,362,47,865,31,219,40,209,43,380,61,1014,57,354,45,163,36,435,33,642,40,431,23,389,42,120,52,841,61,273,42,1333,30,1356,46,90,42,88,46,665,41,248,53,358,37,516,46,749,42,218,43,274,39,828,46,455,29,757,48,120,44,104,36,302,52,218,60,1724,54,619,40,276,47,136,45,609,36,528,40,106,44,90,40,88,44,664,39,45,51,561,59,113,59,113,35,226,40,206,44,1519,38,1102,39,319,56,330,52,839,52,337,46,215,49,1408,46,289,37,826,34,251,27,522,46,138,30,274,47,197,36,270,33,563,34,208,64,239,47,1614,43,337 _info {"project":"app01-trainers","branch":"master","version":266,"versionDate":"2024-05-29T11:00:13.000Z","fromVersion":0,"reset":true,"checksumDocs":"2252-1756816"} _levelPlayerVersion/version.ls (function(){ return function(){ return "v3.4"; }; })(); _t.ls (function(){ return { continueButton: { de: "Weiter", en: "Continue", fr: "Continuer", es: "Continuar", pt: "Continuar" }, closeButton: { de: "Schließen", en: "Close", fr: "Fermer", es: "Cerrar", pt: "Fechar" }, cancelButton: { de: "Abbrechen", en: "Cancel", fr: "Annuler", es: "Cancelar", pt: "Cancelar" }, backButton: { de: "Zurück", en: "Back", fr: "Retour", es: "Anterior", pt: "Voltar" }, yes: { de: "Ja", en: "Yes", fr: "Oui", es: "Sí", pt: "Sim" }, no: { de: "Nein", en: "No", fr: "Non", es: "No", pt: "Não" }, ok: { de: "Ok", en: "Ok", fr: "OK", es: "Ok", pt: "Ok" }, tryAgain: { de: "Nochmal probieren", en: "Try again", fr: "Réessayer", es: "Volver a intentar", pt: "Tentar novamente" }, solveButton: { de: "Lösen", en: "Solve", fr: "Voir la solution", es: "Ver solución", pt: "Ver solução" }, checkButton: { de: "Prüfen", en: "Check", fr: "Vérifier", es: "Comprobar", pt: "Conferir" } }; })(); shared/askSound/ask.ls (function(){ return function(sounds){ var text, play, div, speaker; play = function(newText, onDone){ if (text !== newText) { text = newText; speaker.setSound(sounds[text]); } return speaker.play(onDone); }; div = Div({ display: "block", margin: "-0.75em auto" }).html(speaker = inc("/../app01/lib/gui/speakerIconPlayer/speakerIconPlayer")({ size: "3.5em" })); div.play = play; div.stop = speaker.stop; return div; }; })(); shared/calcAdditionalMedia/_shared/calcTrainerSpecificFeedbacks/calc.ls (function(){ return function(slide, atom){ var trainer, p, feedbacks, o; trainer = slide.trainerParams.trainer; p = slide.getParam; return feedbacks = trainer === "findAll" && atom.objects != null ? (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.filter(atom.objects, "feedback")).length; i$ < len$; ++i$) { o = ref$[i$]; results$.push(p("feedback", o)); } return results$; }()) : []; }; })(); shared/calcAdditionalMedia/images/feedback/addTrainerSpecificFeedback/add.ls (function(){ return function(slide, images, atom){ var feedbacks, i$, len$, feedback, lresult$, j$, v, lresult1$, elements, k$, len1$, el, image, results$ = []; feedbacks = inc("../../../_shared/calcTrainerSpecificFeedbacks/calc")(slide, atom); for (i$ = 0, len$ = feedbacks.length; i$ < len$; ++i$) { feedback = feedbacks[i$]; lresult$ = []; for (j$ in feedback) { v = feedback[j$]; lresult1$ = []; elements = _.ensureArray(v.text); for (k$ = 0, len1$ = elements.length; k$ < len1$; ++k$) { el = elements[k$]; if (el.image) { image = slide.getParam("image", el); lresult1$.push(images.push(image)); } } lresult$.push(lresult1$); } results$.push(lresult$); } return results$; }; })(); shared/calcAdditionalMedia/images/feedback/feedback.ls (function(){ return function(slide, images){ var atoms, i$, len$, atom, feedback, j$, o, elements, k$, len1$, el, image, results$ = []; atoms = slide.atoms || [slide.atom]; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; feedback = slide.getParam("feedback", atom); for (j$ in feedback) { o = feedback[j$]; elements = _.ensureArray(o.text); for (k$ = 0, len1$ = elements.length; k$ < len1$; ++k$) { el = elements[k$]; if (el.image) { image = slide.getParam("image", el); images.push(image); } } } results$.push(inc("addTrainerSpecificFeedback/add")(slide, images, atom)); } return results$; }; })(); shared/calcAdditionalMedia/images/hint/hint.ls (function(){ return function(slide, images){ var calcHintParams, i$, ref$, len$, atom, results$ = []; calcHintParams = function(a){ var hint, texts, i$, len$, t, image, results$ = []; hint = slide.getParam("hint", a); texts = _.ensureArray(hint != null ? hint.text : void 8); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { t = texts[i$]; if (t != null && t.image) { image = slide.getParam("image", t); if (image) { results$.push(images.push(image)); } } } return results$; }; if (slide.atoms) { for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(calcHintParams(atom)); } return results$; } else if (slide.atom) { return calcHintParams(slide.atom); } }; })(); shared/calcAdditionalMedia/images/images.ls (function(){ return function(slide, images){ inc("hint/hint")(slide, images); return inc("feedback/feedback")(slide, images); }; })(); shared/calcAdditionalMedia/lsgs/feedback/addTrainerSpecificFeedback/add.ls (function(){ return function(slide, lsgDescriptions, atom){ var feedbacks, i$, len$, feedback, lresult$, j$, v, lresult1$, elements, k$, len1$, el, lsgD, results$ = []; feedbacks = inc("../../../_shared/calcTrainerSpecificFeedbacks/calc")(slide, atom); for (i$ = 0, len$ = feedbacks.length; i$ < len$; ++i$) { feedback = feedbacks[i$]; lresult$ = []; for (j$ in feedback) { v = feedback[j$]; lresult1$ = []; elements = _.ensureArray(v.text); for (k$ = 0, len1$ = elements.length; k$ < len1$; ++k$) { el = elements[k$]; if (el.lsg) { lsgD = slide.getParam("lsg", el); lresult1$.push(lsgDescriptions.push(lsgD)); } } lresult$.push(lresult1$); } results$.push(lresult$); } return results$; }; })(); shared/calcAdditionalMedia/lsgs/feedback/feedback.ls (function(){ return function(slide, lsgDescriptions){ var atoms, i$, len$, atom, feedback, j$, o, elements, k$, len1$, el, lsgD, results$ = []; atoms = slide.atoms || [slide.atom]; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; feedback = slide.getParam("feedback", atom); for (j$ in feedback) { o = feedback[j$]; elements = _.ensureArray(o.text); for (k$ = 0, len1$ = elements.length; k$ < len1$; ++k$) { el = elements[k$]; if (el.lsg) { lsgD = slide.getParam("lsg", el); lsgDescriptions.push(lsgD); } } } results$.push(inc("addTrainerSpecificFeedback/add")(slide, lsgDescriptions, atom)); } return results$; }; })(); shared/calcAdditionalMedia/lsgs/hint/hint.ls (function(){ return function(slide, lsgDescriptions){ var calcHintParams, i$, ref$, len$, atom, results$ = []; calcHintParams = function(a){ var hint, texts, i$, len$, t, lsgD, results$ = []; hint = slide.getParam("hint", a); texts = _.ensureArray(hint != null ? hint.text : void 8); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { t = texts[i$]; if (t != null && t.lsg) { lsgD = slide.getParam("lsg", t); if (lsgD) { results$.push(lsgDescriptions.push(lsgD)); } } } return results$; }; if (slide.atoms) { for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(calcHintParams(atom)); } return results$; } else if (slide.atom) { return calcHintParams(slide.atom); } }; })(); shared/calcAdditionalMedia/lsgs/lsgs.ls (function(){ return function(slide, lsgDescriptions){ inc("hint/hint")(slide, lsgDescriptions); return inc("feedback/feedback")(slide, lsgDescriptions); }; })(); shared/calcAdditionalMedia/sounds/feedback/addTrainerSpecificFeedback/add.ls (function(){ return function(slide, soundParams, atom){ var feedbacks, i$, len$, feedback, lresult$, j$, v, results$ = []; feedbacks = inc("../../../_shared/calcTrainerSpecificFeedbacks/calc")(slide, atom); for (i$ = 0, len$ = feedbacks.length; i$ < len$; ++i$) { feedback = feedbacks[i$]; lresult$ = []; for (j$ in feedback) { v = feedback[j$]; if (v.sound) { lresult$.push(soundParams.push({ text: v.sound, voice: v.voice || "default", voiceLang: v.voiceLang || "de" })); } } results$.push(lresult$); } return results$; }; })(); shared/calcAdditionalMedia/sounds/feedback/feedback.ls (function(){ return function(slide, soundParams){ var that, i$, o, atoms, len$, atom, feedback, j$, results$ = []; if (that = slide.getParam("feedback")) { for (i$ in that) { o = that[i$]; if (o.sound) { soundParams.push({ text: o.sound, voice: o.voice || "default", voiceLang: o.voiceLang || "de" }); } } } atoms = slide.atoms || [slide.atom]; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; feedback = slide.getParam("feedback", atom); for (j$ in feedback) { o = feedback[j$]; if (o.sound) { soundParams.push({ text: o.sound, voice: o.voice || "default", voiceLang: o.voiceLang || "de" }); } } results$.push(inc("addTrainerSpecificFeedback/add")(slide, soundParams, atom)); } return results$; }; })(); shared/calcAdditionalMedia/sounds/finishSound/sound.ls (function(){ return function(slide, soundParams){ var atom, ref$, sound; atom = (ref$ = slide.atom) != null && ref$.finishSound ? slide.atom : void 8; sound = slide.getParam("finishSound", atom); if (sound != null) { return soundParams.push({ text: sound, voice: slide.getParam("voice", atom), voiceLang: slide.getParam("voiceLang", atom) || "de" }); } }; })(); shared/calcAdditionalMedia/sounds/hint/hint.ls (function(){ return function(slide, soundParams){ var calcHintParams, i$, ref$, len$, atom, results$ = []; calcHintParams = function(a, soundParams){ var hint; hint = slide.getParam("hint", a); if (hint != null && hint.sound) { return soundParams.push({ text: hint.sound, voice: hint.voice || "default", voiceLang: hint.voiceLang || "de" }); } }; if (slide.atoms) { for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(calcHintParams(atom, soundParams)); } return results$; } else if (slide.atom) { return calcHintParams(slide.atom, soundParams); } }; })(); shared/calcAdditionalMedia/sounds/sounds.ls (function(){ return function(slide, soundParams){ inc("speakInstruction/speakInstruction")(slide, soundParams); inc("feedback/feedback")(slide, soundParams); inc("hint/hint")(slide, soundParams); return inc("finishSound/sound")(slide, soundParams); }; })(); shared/calcAdditionalMedia/sounds/speakInstruction/speakInstruction.ls (function(){ return function(slide, soundParams){ var instruction, text, voiceLang, voice; instruction = slide.getParam("instruction", slide.atom); text = instruction != null ? instruction.sound : void 8; if (text) { voiceLang = (instruction != null ? instruction.voiceLang : void 8) || "de"; voice = (instruction != null ? instruction.voice : void 8) || "default"; return soundParams.push({ text: text, voice: voice, voiceLang: voiceLang }); } }; })(); shared/calcStringComparison/calc.ls (function(){ return function(p){ p.highlightColor == null && (p.highlightColor = Color.red[500]); if (p.input.length === 0) { p.parts = [{ type: "insertion", textCorrect: p.solution }]; } else { p.distance = inc("calcDistance/calc")(p.input, p.solution); p.parts = inc("calcParts/calc")(p); } p.htmlInput = function(){ return inc("html/input/input")(p); }; p.htmlSolution = function(){ return inc("html/solution/solution")(p); }; return p; }; })(); shared/calcStringComparison/calcDistance/calc.ls (function(){ return function(input, solution){ var editCheckOrder, arrZ, n, m, createArray, ep, getEntry, checkEdit, getOptimalPathRecursive, getOptimalPath, i$, i, j, j$, path; editCheckOrder = ["substitution", "insertion", "erasure"]; arrZ = null; n = input.length; m = solution.length; createArray = function(n, m){ var arr, i$, i; arr = new Array(n); for (i$ = 0; i$ < n; ++i$) { i = i$; arr[i] = new Array(m); } arr[0][0] = 0; return arrZ = arr; }; ep = function(type, a, b){ if (a != null && a === b) { return 0; } else if (type === "substitution") { return 1; } else if (type === "erasure") { return 0.5; } else if (type === "insertion") { return 0.5; } }; getEntry = function(x, y){ if (x >= 0 && x >= 0) { return arrZ[x][y]; } else { return Infinity; } }; checkEdit = function(i, j, type, strings){ switch (type) { case "insertion": if (arrZ[i][j] === getEntry(i, j - 1) + ep("insertion")) { return [ i, j - 1, { type: "insertion", i: i, j: j } ]; } break; case "substitution": if (arrZ[i][j] === getEntry(i - 1, j - 1) + ep("substitution", strings[0][i - 1], strings[1][j - 1])) { return [ i - 1, j - 1, { type: arrZ[i][j] === arrZ[i - 1][j - 1] ? "correct" : "substitution", i: i, j: j } ]; } break; case "erasure": if (arrZ[i][j] === getEntry(i - 1, j) + ep("erasure")) { return [ i - 1, j, { type: "erasure", i: i, j: j } ]; } } }; getOptimalPathRecursive = function(i, j, path, strings, lastEdit){ var i$, ref$, len$, editCheck, that; if (i === 0 && j === 0) { return path; } if (lastEdit) { _.pull(editCheckOrder, lastEdit); editCheckOrder.unshift(lastEdit); } for (i$ = 0, len$ = (ref$ = editCheckOrder).length; i$ < len$; ++i$) { editCheck = ref$[i$]; if (that = checkEdit(i, j, editCheck, strings)) { path.push(that[2]); return getOptimalPathRecursive(that[0], that[1], path, strings, editCheck); } } }; getOptimalPath = function(input, solution){ var strings, i, j, path; strings = [input, solution]; i = input.length; j = solution.length; path = getOptimalPathRecursive(i, j, [], strings); return path.reverse(); }; createArray(n + 1, m + 1); for (i$ = 0; i$ < n; ++i$) { i = i$; arrZ[i + 1][0] = arrZ[i][0] + ep("erasure", input[i]); } for (i$ = 0; i$ < m; ++i$) { j = i$; arrZ[0][j + 1] = arrZ[0][j] + ep("insertion", solution[j]); } for (i$ = 0; i$ < n; ++i$) { i = i$; arrZ[i + 1][1] = Math.min(arrZ[i][1] + ep("erasure", input[i]), arrZ[i + 1][0] + ep("insertion", solution[0]), arrZ[i][0] + ep("substitution", input[i], solution[0])); } for (i$ = 1; i$ < m; ++i$) { j = i$; arrZ[1][j + 1] = Math.min(arrZ[1][j] + ep("insertion", solution[j]), arrZ[0][j + 1] + ep("erasure", input[0]), arrZ[0][j] + ep("substitution", input[0], solution[j])); } for (i$ = 1; i$ < n; ++i$) { i = i$; for (j$ = 1; j$ < m; ++j$) { j = j$; arrZ[i + 1][j + 1] = Math.min(arrZ[i][j + 1] + ep("erasure", input[i]), arrZ[i + 1][j] + ep("insertion", solution[j]), arrZ[i][j] + ep("substitution", input[i], solution[j])); } } path = getOptimalPath(input, solution); return { distance: arrZ[n][m], array: arrZ, path: path }; }; })(); shared/calcStringComparison/calcParts/calc.ls (function(){ return function(p){ var input, solution, parts, currentPart, i$, ref$, len$, i, step, type, a, res$, j$, len1$, s, ref1$; input = p.input; solution = p.solution; parts = []; currentPart = {}; for (i$ = 0, len$ = (ref$ = p.distance.path).length; i$ < len$; ++i$) { i = i$; step = ref$[i$]; type = step.type === "correct" ? "correct" : step.type === "insertion" ? "insertion" : "wrong"; if (type === currentPart.type) { currentPart.steps.push(step); } else { if (currentPart.type) { parts.push(currentPart); } currentPart = { index: parts.length, type: type, steps: [step] }; } } parts.push(currentPart); for (i$ = 0, len$ = parts.length; i$ < len$; ++i$) { i = i$; p = parts[i$]; if (p.type === "wrong") { res$ = []; for (j$ = 0, len1$ = (ref$ = p.steps).length; j$ < len1$; ++j$) { s = ref$[j$]; res$.push(input[s.i - 1]); } a = res$; p.textWrong = a.join(""); res$ = []; for (j$ = 0, len1$ = (ref$ = p.steps).length; j$ < len1$; ++j$) { s = ref$[j$]; if ((ref1$ = s.type) === "substitution" || ref1$ === "transposition") { res$.push(solution[s.j - 1]); } else { res$.push(""); } } a = res$; p.textCorrect = a.join(""); } else if (p.type === "correct") { res$ = []; for (j$ = 0, len1$ = (ref$ = p.steps).length; j$ < len1$; ++j$) { s = ref$[j$]; res$.push(input[s.i - 1]); } a = res$; p.textCorrect = a.join(""); } else if (p.type === "insertion") { res$ = []; for (j$ = 0, len1$ = (ref$ = p.steps).length; j$ < len1$; ++j$) { s = ref$[j$]; res$.push(solution[s.j - 1]); } a = res$; p.textCorrect = a.join(""); } } return parts; }; })(); shared/calcStringComparison/html/input/input.ls (function(){ return function(p){ var f, part; f = { correct: inc("partCorrect/part"), wrong: inc("partWrong/part"), insertion: inc("partInsertion/part") }; return Span({ userSelect: "text", webkitUserSelect: "text", cursor: "text" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = p.parts).length; i$ < len$; ++i$) { part = ref$[i$]; results$.push(f[part.type](part, p)); } return results$; }())); }; })(); shared/calcStringComparison/html/input/partCorrect/part.ls (function(){ return function(part){ return part.textCorrect; }; })(); shared/calcStringComparison/html/input/partInsertion/part.ls (function(){ return function(part, p){ return Span({ borderBottom: "2px solid " + p.highlightColor, marginLeft: "-0.15em", marginRight: "-0.15em" }).html(Div({ display: "inline-block", width: "0.3em" })); }; })(); shared/calcStringComparison/html/input/partWrong/part.ls (function(){ return function(part, p){ return Span({ borderBottom: "2px solid " + p.highlightColor }).html(part.textWrong); }; })(); shared/calcStringComparison/html/solution/partCorrect/part.ls (function(){ return function(part){ return part.textCorrect; }; })(); shared/calcStringComparison/html/solution/partInsertion/part.ls (function(){ return function(part, p){ return Span({ color: p.highlightColor }).secureHtml(part.textCorrect); }; })(); shared/calcStringComparison/html/solution/partWrong/part.ls (function(){ return function(part, p){ return Span({ color: p.highlightColor }).secureHtml(part.textCorrect); }; })(); shared/calcStringComparison/html/solution/solution.ls (function(){ return function(p){ var f, part; f = { correct: inc("partCorrect/part"), wrong: inc("partWrong/part"), insertion: inc("partInsertion/part") }; return Span({ userSelect: "text", webkitUserSelect: "text", cursor: "text" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = p.parts).length; i$ < len$; ++i$) { part = ref$[i$]; results$.push(f[part.type](part, p)); } return results$; }())); }; })(); shared/calcSvgsFromLsgDescription/calc.ls (function(){ return function(slide, lsgDescriptions){ var svgs, i$, ref$, len$, lsgDescription, lsg, ref1$, required, j$, ref2$, len1$, path; svgs = []; for (i$ = 0, len$ = (ref$ = _.ensureArray(lsgDescriptions)).length; i$ < len$; ++i$) { lsgDescription = ref$[i$]; lsg = ((ref1$ = slide.levelParams.lsgs) != null ? ref1$[lsgDescription.lsg] : void 8) || inc(lsgDescription.lsg); if (!lsg) { continue; } if (_.isFunction(lsg)) { lsg = lsg(lsgDescription); } required = LSG2.util.getRequiredSync(lsg); for (j$ = 0, len1$ = (ref2$ = required.svgs).length; j$ < len1$; ++j$) { path = ref2$[j$]; svgs.push({ path: path }); } } return _.uniqBy(svgs, "path"); }; })(); shared/choices/_t.ls (function(){ return { check: { de: "Prüfen", en: "Check", fr: "Vérifier", es: "Comprobar", pt: "Conferir" }, solution: { de: "Lösung", en: "Solution", fr: "Solution", es: "Solución", pt: "Solução" } }; })(); shared/choices/buttonContinue/button.ls (function(){ return function(click){ return Button({ label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).addClass("choicesContinueButton").css({ padding: "0.7em", minWidth: "5em", marginTop: "1em", backgroundClip: "border-box" }).addClass("keyManager-enter").bind("keyManager", click).tap(click).onDomAppendAndVisible(function(){ return this.keyframeAnimate({ keyframes: { "30%": { transform: "rotate(0deg)" }, "32%": { transform: "rotate(-5deg)" }, "37%": { transform: "rotate(5deg)" }, "39%": { transform: "rotate(0deg)" } }, delay: 6000, duration: 6000, iterationCount: "infinite", timing: "linear" }); }); }; })(); shared/choices/buttonSubmit/button.ls (function(){ return function(click){ return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).addClass("choicesSubmitButton").css({ padding: "0.7em", marginTop: "1em" }).addClass("keyManager-enter").bind("keyManager", click).tap(click); }; })(); shared/choices/choice/choice.ls (function(){ return function(choice, o, i){ var selected, click, solve, showSolution, div, solution, iconCheckOn, iconCheckOff; selected = false; click = function(){ selected = !selected; if (selected) { iconCheckOn.show(); return iconCheckOff.hide(); } else { iconCheckOn.hide(); return iconCheckOff.show(); } }; solve = function(){ var m; m = false; div.css({ pointerEvents: "none" }); if (choice.correct) { if (!selected) { iconCheckOff.setColor(Color.red[500]); m = true; } else { iconCheckOn.setColor(Color.green[500]); } } else { if (selected) { iconCheckOn.setColor(Color.red[500]); m = true; } } if (m) { o.onActionMistake({ text: choice.text, selected: selected, correct: false }); return o.allCorrect = false; } else if (selected) { return o.onActionCorrect({ text: choice.text, selected: selected, correct: true }); } }; showSolution = function(type){ var w; w = solution.show().width({ withMargins: true }); if (type !== "review") { solution.css({ width: 0, margin: 0 }); return solution.css({ width: w + "px", transition: "width 500ms" }); } }; div = Div({ display: "flex", justifyContent: "flex-start", minWidth: "14em", padding: "0.6em 0", whiteSpace: "nowrap", wordWrap: "break-word", textAlign: "left", margin: "0 auto", borderBottom: "1px solid " + Color.grey[300], borderTop: i === 0 ? "1px solid " + Color.grey[300] : void 8 }).append(solution = inc("solution/solution")(choice).hide(), iconCheckOn = inc("iconCheckOn/icon")().hide(), iconCheckOff = inc("iconCheckOff/icon")(), inc("label/label")(o, choice.text)).tap(click); div.solve = solve; div.isSelected = selected; div.label = choice.text; div.showSolution = showSolution; div.iconCheckOn = iconCheckOn; div.iconCheckOff = iconCheckOff; return div; }; })(); shared/choices/choice/iconCheckOff/icon.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/icon/check-off.svg") }).css({ flex: "0 0 auto", marginLeft: "0.5em" }); }; })(); shared/choices/choice/iconCheckOn/icon.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/icon/check-on.svg") }).css({ flex: "0 0 auto", marginLeft: "0.5em" }); }; })(); shared/choices/choice/label/label.ls (function(){ return function(o, label){ return Div({ flex: "1 1 auto", paddingLeft: "0.7em", pointerEvents: "none" }).html(label); }; })(); shared/choices/choice/solution/solution.ls (function(){ return function(choice){ return SvgIcon({ svg: choice.correct ? path("/../app01/lib/svg/icon/check-on.svg") : path("/../app01/lib/svg/icon/check-off.svg") }).css({ flex: "0 0 auto", marginLeft: "0.5em" }); }; })(); shared/choices/choices.ls (function(){ return function(o){ var choiceDivs, clickSubmit, clickContinue, div, i$, ref$, len$, i, choice, d, submitButton, continueButton; o.allCorrect = true; choiceDivs = []; clickSubmit = function(){ var i$, ref$, len$, d; for (i$ = 0, len$ = (ref$ = choiceDivs).length; i$ < len$; ++i$) { d = ref$[i$]; d.solve(); } if (!o.allCorrect) { inc("showSolution/show")(div, choiceDivs); } if (typeof o.onSubmit == 'function') { o.onSubmit(o.allCorrect); } submitButton.css({ pointerEvents: "none", backgroundColor: o.allCorrect ? Color.green[500] : Color.red[500] }); return setTimeout(function(){ submitButton.hide(); return continueButton.fadeIn(); }, 1000); }; clickContinue = function(){ continueButton.remove(); return o.onFinish(); }; div = Div({ display: "inline-block", maxWidth: "100%", padding: "0 0.8em", margin: "2em 0 1em", backgroundColor: 'white' }); for (i$ = 0, len$ = (ref$ = o.choices).length; i$ < len$; ++i$) { i = i$; choice = ref$[i$]; choiceDivs.push(d = inc("choice/choice")(choice, o, i).appendTo(div)); } requestAnimationFrame(function(){ return inc("optimizeSize/optimize")(choiceDivs); }); div.append(submitButton = inc("buttonSubmit/button")(clickSubmit), continueButton = inc("buttonContinue/button")(clickContinue).hide()); div.choices = choiceDivs; return div; }; })(); shared/choices/optimizeSize/calcMaxWidth/calc.ls (function(){ return function(divs){ var maxWidth, i$, len$, div, width; maxWidth = 0; for (i$ = 0, len$ = divs.length; i$ < len$; ++i$) { div = divs[i$]; width = div.width() + 10; maxWidth = Math.max(width, maxWidth); } return maxWidth; }; })(); shared/choices/optimizeSize/optimize.ls (function(){ return function(divs){ var wrapper, maxWidth, i$, len$, div, results$ = []; wrapper = divs[0].closest(".choicesWrapper"); if (wrapper && !wrapper.isVisible()) { wrapper.show(); maxWidth = inc("calcMaxWidth/calc")(divs); wrapper.hide(); } else { maxWidth = inc("calcMaxWidth/calc")(divs); } for (i$ = 0, len$ = divs.length; i$ < len$; ++i$) { div = divs[i$]; results$.push(div.css({ width: maxWidth + "px", maxWidth: "90%", whiteSpace: "normal" })); } return results$; }; })(); shared/choices/showSolution/show.ls (function(){ return function(div, choiceDivs){ var i$, len$, d; for (i$ = 0, len$ = choiceDivs.length; i$ < len$; ++i$) { d = choiceDivs[i$]; d.css({ maxWidth: "95%" }); d.showSolution(); } return choiceDivs[0].prepend(Div({ position: "absolute", top: "-2em", left: "-1.2em", opacity: 0, color: Color.grey[550], fontSize: "0.9em" }).animation({ css: { left: "-0.7em", opacity: 1 }, easing: "linear", duration: 300 }).html(T("solution"))); }; })(); shared/colorBracket/color.ls (function(){ return function(s){ return s.replace(/(\([^)]+?\))/g, "$1"); }; })(); shared/continueButton/button.ls (function(){ return function(callback){ var children, bottom, onContinue, showButton, div; children = null; bottom = app.currentPage.bottom; onContinue = function(){ bottom.append(children); return callback(); }; showButton = function(){ var h; if (app.currentPage.levelPlayer == null) { return; } children = bottom.childrenAll(); bottom.html(div).show(); h = div.height(); return div.keyframeAnimate({ keyframes: { "0%": { height: "0px" }, "100%": { height: h + "px" } }, duration: 500, onCompleted: function(){ return div.css({ height: "" }); } }); }; div = Div(); div.css({ textAlign: "center" }).addClass("continueButton").html(inc("button/button")(onContinue, div, bottom)); div.showButton = showButton; return div; }; })(); shared/continueButton/button/button.ls (function(){ return function(callback, div, bottom){ var click, button; click = function(){ button.css({ pointerEvents: "none" }); return bottom.keyframeAnimate({ keyframes: { "0%": { transform: "translateY(0%)" }, "100%": { transform: "translateY(100%)" } }, duration: 400, delay: 100, onCompleted: function(){ div.remove(); bottom.css({ transform: "" }); return callback(); } }); }; return button = Button({ key: "enter", action: click, label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.8em", backgroundClip: "border-box" }).keyframeAnimate({ keyframes: { "30%": { transform: "rotate(0deg)" }, "32%": { transform: "rotate(-5deg)" }, "37%": { transform: "rotate(5deg)" }, "39%": { transform: "rotate(0deg)" } }, duration: 6000, iterationCount: "infinite", timing: "linear" }); }; })(); shared/convertGapString/convert.ls (function(){ var colorTags; colorTags = inc("/../app01/lib/util/cssColorTags/cssColorTags"); return function(s){ var r, parts, parts2, bold, italic, underline, superscript, subscript, textColor, markColor, gapIndex, i$, len$, p, isGap, j$, ref$, len1$, c, i; r = _.replaceAll; s = String(s); s = r(s, "|", "|"); s = s.replace(/([^(])\(([^(])/g, "$1BRACKETOPEN$2"); s = s.replace(/(\({2})\(/g, "$1BRACKETOPEN"); s = s.replace(/([^)])\)([^)])/g, "$1BRACKETCLOSE$2"); s = s.replace(/\)(\){2})/g, "BRACKETCLOSE$1"); s = r(s, "((", "||GAP"); s = r(s, "))", "||"); parts = s.split("||"); parts = _.filter(parts, function(s){ return s !== ""; }); parts2 = []; bold = false; italic = false; underline = false; superscript = false; subscript = false; textColor = ""; markColor = ""; gapIndex = 0; for (i$ = 0, len$ = parts.length; i$ < len$; ++i$) { p = parts[i$]; isGap = p.substring(0, 3) === "GAP"; p = r(p, "GAP", ""); p = r(p, "BRACKETOPEN", "("); p = r(p, "BRACKETCLOSE", ")"); if (isGap) { parts2.push({ gap: p, bold: bold, italic: italic, underline: underline, gapIndex: gapIndex }); gapIndex++; } else { p = r(p, "
", "||BREAK||"); p = r(p, "
", "||BREAK||"); p = r(p, "
", "||BREAK||"); p = r(p, "
", "||BREAK||"); p = r(p, "", "||BOLD||"); p = r(p, "", "||BOLD||"); p = r(p, "", "||ITALIC||"); p = r(p, "", "||ITALIC||"); p = r(p, "", "||UNDERLINE||"); p = r(p, "", "||UNDERLINE||"); p = r(p, "", "||SUPERSCRIPT||"); p = r(p, "", "||SUPERSCRIPT||"); p = r(p, "", "||SUBSCRIPT||"); p = r(p, "", "||SUBSCRIPT||"); p = r(p, " ", "||SPACE||"); for (j$ = 0, len1$ = (ref$ = _.keys(colorTags.textColors)).length; j$ < len1$; ++j$) { c = ref$[j$]; p = r(p, "", "||MARK-" + c + "||"); p = r(p, "", "||MARK-" + c + "||"); p = r(p, "", "||TEXT-" + c + "||"); p = r(p, "", "||TEXT-" + c + "||"); } for (j$ = 0, len1$ = (ref$ = p.split("||")).length; j$ < len1$; ++j$) { i = j$; p = ref$[j$]; if (p === "BREAK") { parts2.push({ 'break': true }); } else if (p === "BOLD") { bold = !bold; } else if (p === "ITALIC") { italic = !italic; } else if (p === "UNDERLINE") { underline = !underline; } else if (p === "SUPERSCRIPT") { superscript = !superscript; } else if (p === "SUBSCRIPT") { subscript = !subscript; } else if (p === "SPACE") { parts2.push({ space: true, underline: underline, markColor: colorTags.markColors[markColor] }); } else if (_.startsWith(p, "MARK-")) { markColor = markColor ? undefined : p.split("MARK-")[1]; } else if (_.startsWith(p, "TEXT-")) { textColor = textColor ? undefined : p.split("TEXT-")[1]; } else if (p.length > 0) { parts2.push({ word: p, bold: bold, italic: italic, underline: underline, superscript: superscript, subscript: subscript, markColor: colorTags.markColors[markColor], textColor: colorTags.textColors[textColor] }); } } } } return parts2; }; })(); shared/convertPlusPlusArray/convert.ls (function(){ return function(a){ var defaultCorrect, choices, p, s; defaultCorrect = !_.includes(a.join(","), "++"); return choices = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = a).length; i$ < len$; ++i$) { p = ref$[i$]; s = _.replace(p, "++ ", "++"); if (s.substring(0, 2) === "++") { results$.push({ text: s.substring(2), correct: true }); } else if (s.substring(0, 2) === "--") { results$.push({ text: s.substring(2), correct: false }); } else { results$.push({ text: s, correct: defaultCorrect }); } } return results$; }()); }; })(); shared/convertPlusPlusString/convert.ls (function(){ return function(s){ var parts, res$, i$, ref$, len$, p, defaultCorrect, choices; s = s.trim(); s = _.replaceAll(s, "<", "<"); s = _.replaceAll(s, ">", ">"); res$ = []; for (i$ = 0, len$ = (ref$ = s.split(" ")).length; i$ < len$; ++i$) { p = ref$[i$]; if (_.includes(p, ")/; newPart = ""; for (i$ = 0, len$ = (ref$ = p.split(re)).length; i$ < len$; ++i$) { t = ref$[i$]; if (_.startsWith(t, " 20) { debug("Error, you're trying to prepare " + gapSolutions.length + " sounds at once! uniqueSolutions + soundMode b is limited to 20 sounds. Please disable sound / use custom sound / decrease the number of uniqueSolutions", o.text); gapSolutions = gapSolutions.slice(0, 20); } solutions2 = []; for (j$ = 0, len1$ = gapSolutions.length; j$ < len1$; ++j$) { sol = gapSolutions[j$]; for (k$ = 0, len2$ = solutions.length; k$ < len2$; ++k$) { s = solutions[k$]; solutions2.push(s + sol); } } solutions = solutions2; } return solutions; }; })(); shared/gapComponent/calcGapStringSolutions/gapTextSolutions/solutions.ls (function(){ return function(o, part){ var parts, solutions, i$, len$, p, j$, len1$, i, solutions2, choices, ref$, c, k$, len2$, s; parts = inc("/shared/convertGapString/convert")(part.text); solutions = [""]; for (i$ = 0, len$ = parts.length; i$ < len$; ++i$) { p = parts[i$]; if (p.space) { for (j$ = 0, len1$ = solutions.length; j$ < len1$; ++j$) { i = j$; solutions[i] += " "; } } else if (p.word) { for (j$ = 0, len1$ = solutions.length; j$ < len1$; ++j$) { i = j$; solutions[i] += p.word; } } else if (p['break']) { for (j$ = 0, len1$ = solutions.length; j$ < len1$; ++j$) { i = j$; solutions[i] += " "; } } else if (p.gap) { solutions2 = []; choices = inc("/shared/convertPlusPlusString/convert")(p.gap); for (j$ = 0, len1$ = (ref$ = _.filter(choices, { correct: true })).length; j$ < len1$; ++j$) { c = ref$[j$]; for (k$ = 0, len2$ = solutions.length; k$ < len2$; ++k$) { s = solutions[k$]; solutions2.push(s + c.text); } } solutions = solutions2; } } return solutions; }; })(); shared/gapComponent/calcGapStringSolutions/mathDivSolutions/solutions.ls (function(){ return function(o, part){ return MathDiv2({ value: part.text }).calcGapStringSolutions(); }; })(); shared/gapComponent/calcTotalGaps/calc.ls (function(){ return function(b){ var totalMath, totalText, total; totalMath = (b != null ? b.split(//).length : void 8) - 1 || 0; totalText = (b != null ? b.split("((").length : void 8) - 1 || 0; return total = totalMath + totalText; }; })(); shared/gapComponent/component/calcTextParts/calc.ls (function(){ return function(text){ var re, parts, i$, ref$, len$, t; re = /()/; parts = []; for (i$ = 0, len$ = (ref$ = text.split(re)).length; i$ < len$; ++i$) { t = ref$[i$]; if (t.trim() === "") { continue; } if (t.indexOf("", "")[0] + ("`" + t2 + "`") + ""; p2.text = p2.text.slice(t2.length); hasChanged = true; } } if (hasChanged) { parts = _.filter(parts, function(part){ return part.text !== ""; }); } return parts; }; })(); shared/gapComponent/component/component.ls (function(){ return function(o){ var gapComponent; if (!o.mode) { debug("Error: You must specify a gapMode to use this trainer"); } o.textParts = inc("calcTextParts/calc")(o.text); gapComponent = o.textParts.length > 1 && _.find(o.textParts, { type: "mathDiv" }) ? inc("mixed/mixed")(o) : o.text.trim().indexOf("?@\[\]^_`{|}~]/g; return s.replace(punctRegex, ""); }; })(); shared/gapComponent/component/gapText/gapText/createParts/_shared/getMatchingCorrectChoice/get.ls (function(){ return function(o, value){ var clean, gaps, that, usedUniqueSolutions, g, correctChoices, correctChoice; clean = inc("../_cleanString/clean")(o); gaps = (that = o.gap.closest(".mixed")) ? that.gaps() : o.gaps; usedUniqueSolutions = o.uniqueSolutions && _.filter(o.choices, { correct: true }).length > 1 ? (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = gaps).length; i$ < len$; ++i$) { g = ref$[i$]; if (g.gapIsCompleted === true && _.filter(g.choices, { correct: true }).length > 1) { results$.push(clean(g.correctValue || g.getValue())); } else { continue; } } return results$; }()) : []; correctChoices = _.filter(o.choices, function(c){ return c.correct && !_.includes(usedUniqueSolutions, clean(c.text)); }); return correctChoice = _.find(correctChoices, function(c){ return clean(c.text) === value; }) || correctChoices[0]; }; })(); shared/gapComponent/component/gapText/gapText/createParts/appendAndCombine/appendAndCombine.ls (function(){ return function(div, element, lastElement, lastP, p){ var combiner; if ((p.gap && (lastP != null && lastP.word)) || (p.word && (lastP != null && lastP.gap)) || (p.word && (lastP != null && lastP.word)) || (p.space && (lastP != null && lastP.word))) { combiner = inc("combiner/combiner")(); lastElement.wrap(combiner); return lastElement.after(element); } else { return div.append(element); } }; })(); shared/gapComponent/component/gapText/gapText/createParts/appendAndCombine/combiner/combiner.ls (function(){ return function(){ return Div({ display: "inline-block", whiteSpace: "nowrap", lineHeight: "inherit" }); }; })(); shared/gapComponent/component/gapText/gapText/createParts/break/break.ls (function(){ return function(s){ return "
"; }; })(); shared/gapComponent/component/gapText/gapText/createParts/calcGapParams/calc.ls (function(){ return function(o, p){ var gapLength, params; gapLength = _.isArray(o.gapLength) ? o.gapLength[p.gapIndex] : o.gapLength; params = { slide: o.slide, text: p.gap, mode: o.mode, onGapResult: o.onGapResult, onStart: o.onStart, gaps: o.gaps, gapAlign: o.gapAlign, gapLength: gapLength, gapIndex: p.gapIndex, onSubmitCustom: o.onSubmitCustom, onActionCorrect: o.onActionCorrect, onActionMistake: o.onActionMistake, onActionResolved: o.onActionResolved, onActionTrainMistake: o.onActionTrainMistake, trainAttempts: o.trainAttempts, inputEditable: o.inputEditable, tagIndex: o.tagIndex, totalGaps: o.totalGaps, uniqueSolutions: o.uniqueSolutions, learnListMode: o.learnListMode }; if (o.mode === "write") { params.ignoreCase = o.ignoreCase; params.ignoreAccents = o.ignoreAccents; params.keyboardLayout = o.keyboardLayout; params.keyboardSpecialKeys = o.keyboardSpecialKeys; } else if (o.mode === "buttons") { params.buttonsDiv = o.buttonsDiv; params.combineButtons = o.combineButtons; params.removeCorrectButton = o.removeCorrectButton; params.shuffleButtons = o.shuffleButtons; params.trueFalseMode = o.trueFalseMode; params.trueButtonLabel = o.trueButtonLabel; params.falseButtonLabel = o.falseButtonLabel; } return params; }; })(); shared/gapComponent/component/gapText/gapText/createParts/create.ls (function(){ return function(div, o){ var i$, ref$, len$, part, element, params, gap, lastPart, lastElement, results$ = []; for (i$ = 0, len$ = (ref$ = o.parts).length; i$ < len$; ++i$) { part = ref$[i$]; element = part.gap ? (params = inc("calcGapParams/calc")(o, part), gap = o.mode === "write" ? inc("gapWrite/gapWrite")(params) : o.mode === "buttons" ? inc("gapButtons/gapButtons")(params) : void 8, o.gaps.push(gap), gap) : part.space ? inc("space/space")(part) : part['break'] ? inc("break/break")() : inc("word/word")(part, o); inc("appendAndCombine/appendAndCombine")(div, element, lastElement, lastPart, part); if (typeof element.css == 'function') { element.css({ fontWeight: part.bold ? "bold" : void 8, fontStyle: part.italic ? "italic" : void 8 }); } lastPart = part; results$.push(lastElement = element); } return results$; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/cursor/cursor.ls (function(){ return function(){ var interval, onInterval, start, stop, div; onInterval = function(){ if (!div.isVisible()) { clearInterval(interval); interval = null; } return div.css({ visibility: div.css("visibility") === "hidden" ? "visible" : "hidden" }); }; start = function(){ clearInterval(interval); interval = setInterval(onInterval, 500); return div.show(); }; stop = function(){ clearInterval(interval); interval = null; return div.hide(); }; div = Div({ position: "absolute", height: "2px", width: "100%", bottom: "-1px", left: 0, backgroundColor: Color.grey[500] }).addClass("cursor").hide(); div.start = start; div.stop = stop; return div; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/fixedLength/div.ls (function(){ return function(o){ var lengthDiv, i; return lengthDiv = Div({ height: 0, overflow: "hidden" }).append((function(){ var i$, to$, results$ = []; for (i$ = 1, to$ = o.gapLength; i$ <= to$; ++i$) { i = i$; results$.push("0"); } return results$; }())); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/gapButtons.ls (function(){ return function(o){ var startGap, submitGap, stopGap, getValue, click, gap; o.choices = inc("../../calcChoices/calc")(o); if (_.filter(o.choices, { correct: true }).length === 0) { debug("Warning: please specify at least one correct choice in " + o.text + "!"); } o.result = { isDone: false }; o.cursor = inc("cursor/cursor")(o); startGap = function(){ var ref$, i$, ref1$, len$, b; o.slide.gapClickStartDisabled = false; if ((ref$ = o.buttonsDiv) != null) { ref$.show(); } o.slide.levelPlayer.currentGap = gap; o.buttonsDiv.css({ pointerEvents: "" }); for (i$ = 0, len$ = (ref1$ = o.buttonsDiv.childrenAll()).length; i$ < len$; ++i$) { b = ref1$[i$]; if (b.isVisible()) { b.css({ pointerEvents: "" }); } } inc("showButtons/show")(gap, o); if (typeof o.onStart == 'function') { o.onStart(); } return o.cursor.start(); }; submitGap = function(button){ o.slide.gapClickStartDisabled = true; return inc("submit/submit")(o, button, function(){ return o.onGapResult(o.gap); }); }; stopGap = function(){ var ref$; if ((ref$ = o.buttonsDiv) != null) { ref$.hide(); } o.cursor.stop(); return o.slide.levelPlayer.currentGap = undefined; }; getValue = function(){ return gap.correctValue; }; click = function(){ var currentGap; if (gap.css("pointerEvents") === "none") { return; } currentGap = o.slide.levelPlayer.currentGap; if (currentGap === gap || o.result.isDone) { return; } if (o.slide.gapClickStartDisabled) { return; } if (currentGap != null) { currentGap.stopGap(); } return startGap(); }; gap = Div({ display: "inline-block", backgroundColor: Color.grey[100], lineHeight: "inherit", whiteSpace: "pre", padding: "0.1em 0.2em 0.1em 0.1em", margin: "0.14em 0", borderBottom: "2px solid transparent", cursor: "pointer", textAlign: o.gapAlign || "center" }).addClass("gapButton").addClass("gap gap" + o.gapIndex).tap({ up: click, animation: "none" }); inc("setMinWidth/set")(o, gap); gap.append(inc("fixedLength/div")(o), gap.contentSpan = Span().html(" "), gap.tagIndex = inc("tagIndex/tagIndex")(o), o.cursor); if (o.gapLength) { gap.css({ minWidth: "", width: "", paddingLeft: 0, paddingRight: 0 }); } o.gap = gap; gap.click = click; gap.gaps = o.gaps; gap.choices = o.choices; gap.gapIsCompleted = false; gap.submitGap = submitGap; gap.startGap = startGap; gap.stopGap = stopGap; gap.getValue = getValue; gap.result = function(){ return o.result; }; return gap; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/setMinWidth/set.ls (function(){ return function(o, gap){ var dummy, choices, res$, i$, ref$, len$, c, mean, min, minWidth; dummy = Div({ position: "fixed", top: 0, bottom: 0, left: "-1000px", right: 0, visibility: "hidden" }).appendTo(body); res$ = []; for (i$ = 0, len$ = (ref$ = o.choices).length; i$ < len$; ++i$) { c = ref$[i$]; res$.push(Span().html(c.text).appendTo(dummy)); } choices = res$; mean = _.mean(_.map(choices, function(c){ return c.width(); })); min = inc("/../app01/lib/util/emToPx/emToPx")(2); minWidth = Math.max(min, mean); dummy.remove(); return gap.css({ minWidth: minWidth + "px" }); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/showButtons/button/button.ls (function(){ return function(o, choice, i){ var click, div; click = function(){ var ref$; o.buttonsDiv.css({ pointerEvents: "none" }); return (ref$ = o.slide.levelPlayer.currentGap) != null ? ref$.submitGap(div) : void 8; }; div = Button({ label: choice.text, labelAllowWrap: true, action: click, icon: (choice != null ? choice.icon : void 8) === "correct" ? path("/../app01/lib/svg/icon/checkmark.svg") : (choice != null ? choice.icon : void 8) === "wrong" ? path("/../app01/lib/svg/icon/close.svg") : void 8 }).css({ margin: "0.5em" }); div.value = choice.text; return div; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/showButtons/calcChoices/calc.ls (function(){ return function(o, choices){ var choices2, i$, len$, choice; choices2 = []; for (i$ = 0, len$ = choices.length; i$ < len$; ++i$) { choice = choices[i$]; if (choice.text === "" && !choice.icon) { choice.text = "  "; } choices2.push(choice); } if (!o.removeCorrectButton) { choices2 = _.uniqBy(_.map(choices2, function(c){ return _.omit(c, "correct"); }), "text"); } if (o.shuffleButtons && !o.trueFalseMode) { choices2 = _.shuffleWithSeed(choices2); } return choices2; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/showButtons/combineChoices/combine.ls (function(){ return function(o){ var choices, uniqueChoices, i$, ref$, len$, gapButton, j$, ref1$, len1$, choice, otherChoices; choices = []; uniqueChoices = []; for (i$ = 0, len$ = (ref$ = o.slide.div.findAll(".gapButton")).length; i$ < len$; ++i$) { gapButton = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = gapButton.choices).length; j$ < len1$; ++j$) { choice = ref1$[j$]; if (!o.uniqueSolutions || _.filter(gapButton.choices, fn$).length < 2) { choices.push(choice); continue; } otherChoices = _.flatMap(_.filter(gapButton.gaps, fn1$), fn2$); if (otherChoices.some(fn3$) && uniqueChoices.some(fn4$)) { uniqueChoices.push(choice); } else { uniqueChoices.push(choice); choices.push(choice); } } } return choices; function fn$(c){ return c.correct === true; } function fn1$(g){ return g !== gapButton; } function fn2$(g){ return g.choices; } function fn3$(c){ return _.isEqual(c, choice); } function fn4$(c){ return _.isEqual(c, choice); } }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/showButtons/show.ls (function(){ return function(gap, o){ var div, choices, i, choice; div = o.buttonsDiv; if (o.combineButtons && div.childrenAll().length > 0) { return; } choices = o.combineButtons ? inc("combineChoices/combine")(o) : gap.choices; choices = inc("calcChoices/calc")(o, choices); return div.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")(o, choice, i)); } return results$; }())).hide().fadeIn(); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/submit/onCorrect/colorizeGap/colorize.ls (function(){ return function(gap){ var ref$; gap.css({ color: Color.green[500], cursor: "default" }); return (ref$ = gap.findFirst(".icon")) != null ? ref$.setColor(Color.green[500]) : void 8; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/submit/onCorrect/on.ls (function(){ return function(o, button, callback){ var gap; gap = o.gap; gap.gapIsCompleted = true; o.result.isDone = true; button.setState("correct"); inc("colorizeGap/colorize")(gap); o.slide.levelPlayer.progressBar.showGreen(); return inc("onActionCorrect/on")(o, button, callback); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/submit/onCorrect/onActionCorrect/on.ls (function(){ return function(o, button, callback){ var action; action = { gap: o.gapIndex, button: button.value }; return o.onActionCorrect(action, function(){ return setTimeout(function(){ if (o.removeCorrectButton) { button.css({ visibility: "hidden" }); } else { button.setState("normal"); button.css({ pointerEvents: "none" }); } return callback(); }, 500); }); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/submit/onWrong/on.ls (function(){ return function(o, button){ var gap, ref$; gap = o.gap; button.setState("wrong"); gap.css({ color: Color.red[500] }); if ((ref$ = gap.findFirst(".icon")) != null) { ref$.setColor(Color.red[500]); } o.slide.levelPlayer.progressBar.addElement().showRed(); if (typeof o.onActionMistake == 'function') { o.onActionMistake({ gap: o.gapIndex, button: button.value, text: gap.getValue(), solution: gap.correctValue }); } return setTimeout(function(){ o.slide.gapClickStartDisabled = false; button.setState("normal"); o.buttonsDiv.css({ pointerEvents: "" }); gap.css({ color: "black", minWidth: gap.defaultMinWidth, padding: gap.defaultPadding, textAlign: o.gapAlign || "center" }); gap.contentSpan.html(" "); return o.cursor.start(); }, 500); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/submit/showValue/show.ls (function(){ return function(o, button){ var gap, value, that; gap = o.gap; value = button.value; gap.contentSpan.html((that = button.icon) ? Svg({ svg: that.outerHtml() }).css({ verticalAlign: "-0.1em", marginRight: "0.2em" }).addClass("icon") : void 8, value); gap.defaultPadding = gap.css("padding"); gap.defaultMinWidth = gap.css("minWidth"); return gap.css({ paddingLeft: "", paddingRight: "", minWidth: "" }); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/submit/submit.ls (function(){ return function(o, button, callback){ var value, correctChoice; value = button.value; correctChoice = inc("../../_shared/getMatchingCorrectChoice/get")(o, value); o.gap.correctValue = correctChoice.text; o.cursor.stop(); inc("showValue/show")(o, button); if (correctChoice.text === value) { return inc("onCorrect/on")(o, button, callback); } else { return inc("onWrong/on")(o, button); } }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapButtons/tagIndex/tagIndex.ls (function(){ return function(o){ if (o.tagIndex == null) { return; } return Div({ position: "absolute", top: "-12px", left: "-8px", fontSize: "0.7em", backgroundColor: Color.yellow[200], padding: "0.2em", pointerEvents: "none", boxShadow: '0px 0px 2px #bbb' }).html(o.tagIndex === -1 ? o.gapIndex + 1 : o.totalGaps === 1 ? o.tagIndex + 1 : (o.tagIndex + 1) + "." + (o.gapIndex + 1)); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/gap/calcMaxChars/calc.ls (function(){ return function(o){ var that, max, i$, ref$, len$, c, maxChars; if (that = o.maxChars) { return that; } max = 0; for (i$ = 0, len$ = (ref$ = o.choices).length; i$ < len$; ++i$) { c = ref$[i$]; max = Math.max(c.text.length + 5, max); } return maxChars = Math.max(35, max); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/gap/calcSpecialKeys/calc.ls (function(){ return function(o){ var layout, template, keyboardKeys, keyboardKeysFlat, hasShiftKey, i$, len$, key, specialKeys, ref$, choice, j$, ref1$, len1$, char, c; layout = o.keyboardLayout === "standardGuiLanguage" ? twitch({ de: "standardSlimDE", en: "standardSlimEN", fr: "standardSlimFR", es: "standardSlimES", pt: "standardSlimPT" }) : o.keyboardLayout; template = inc("/../app01/lib/gui/screenKeyboard/_templates/templates")[layout]; keyboardKeys = template != null ? template.main.join("|").split("|") : void 8; if (!keyboardKeys) { return; } keyboardKeysFlat = []; hasShiftKey = false; for (i$ = 0, len$ = keyboardKeys.length; i$ < len$; ++i$) { key = keyboardKeys[i$]; if (_.startsWith(key, "shift")) { hasShiftKey = true; } if (!key.match(/^.+?\[.+?\]$/)) { keyboardKeysFlat.push(key[0]); } } keyboardKeysFlat.push(" "); specialKeys = []; for (i$ = 0, len$ = (ref$ = o.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = Array.from(choice.text)).length; j$ < len1$; ++j$) { char = ref1$[j$]; c = hasShiftKey ? char.toLowerCase() : char; if (!in$(c, keyboardKeysFlat)) { specialKeys.push(char); } } } if (specialKeys.length > 0) { return o.keyboardSpecialKeys = specialKeys.sort().join(" "); } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } shared/gapComponent/component/gapText/gapText/createParts/gapWrite/gap/gap.ls (function(){ return function(o, click, submitGap){ var maxChars, f, div; maxChars = inc("calcMaxChars/calc")(o); inc("calcSpecialKeys/calc")(o); f = o.inputEditable ? inc("/../app01/lib/gui/inputEditable/input") : inc("/../app01/lib/gui/input2/input"); div = f({ keyboardHeader: o.keyboardSpecialKeys ? inc("keyboardHeader/header")(o) : void 8, keyboardLayout: o.keyboardLayout, maxLength: maxChars, onSubmit: submitGap, textAlign: o.gapAlign || "center", fixedLength: o.gapLength, enabled: false, lineHeight: "1.4em", linePadding: "0.2em 0.7em 0.2em 0.2em", lineWrapping: true }).addClass("gap gap" + o.gapIndex).append(inc("../../gapButtons/tagIndex/tagIndex")(o)).tap({ up: click, animation: "none" }).css({ minWidth: "1.5em", margin: "0.14em 0", cursor: "pointer", padding: !o.inputEditable ? "0.2em 0.7em 0.2em 0.2em" : void 8 }); if (o.gapLength) { div.css({ minWidth: "", width: "", paddingLeft: 0, paddingRight: 0 }); } return div; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/gap/keyboardHeader/header.ls (function(){ return function(o){ return function(screenKeyboard){ return Div({ display: "flex", minHeight: "2.5em", alignItems: "stretch", padding: "4px" }).addClass("keyboardHeader").html(inc("specialKeys/specialKeys")(o, screenKeyboard)); }; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/gap/keyboardHeader/specialKeys/key/key.ls (function(){ return function(screenKeyboard, key){ return Div({ display: "flex", padding: "0.3em 0.4em", flex: "0 0 auto", minWidth: "2.5em" }).html(Div({ flex: "1 1 auto", whiteSpace: "nowrap", textAlign: "center", overflow: "hidden", textOverflow: "ellipsis", display: "flex", paddingTop: "0.1em" }).html(key)).tap(function(){ return screenKeyboard.onKey(key); }); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/gap/keyboardHeader/specialKeys/specialKeys.ls (function(){ return function(o, screenKeyboard){ var keys, div, key; keys = o.keyboardSpecialKeys.trim(); keys = keys.replace(/\s{2,}/g, " "); keys = _.uniq(keys.split(" ")); return div = Div({ display: "flex", justifyContent: "flex-start", flex: "1 1 auto", flexWrap: "wrap" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = keys).length; i$ < len$; ++i$) { key = ref$[i$]; results$.push(inc("key/key")(screenKeyboard, key)); } return results$; }())); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/gapWrite.ls (function(){ return function(o){ var startGap, submitGap, stopGap, click, gap; o.choices = inc("../../calcChoices/calc")(o); if (_.filter(o.choices, { correct: true }).length === 0) { debug("Warning: Please specify at least one correct choice in " + o.text + "!"); } o.result = { isDone: false }; startGap = function(){ o.slide.gapClickStartDisabled = false; gap.enable(); gap.start(); gap.css({ cursor: "text" }); if (typeof o.onStart == 'function') { o.onStart(); } return o.slide.levelPlayer.currentGap = gap; }; submitGap = function(){ if (o.gap.getValue() === "" && !o.learnListMode) { return; } o.slide.gapClickStartDisabled = true; gap.disable(); return inc("submit/submit")(o, function(){ return o.onGapResult(gap); }); }; stopGap = function(){ gap.stop(); gap.disable(); o.slide.levelPlayer.currentGap = undefined; if (!o.result.isDone) { return gap.css({ cursor: "pointer" }); } }; click = function(){ var currentGap; currentGap = o.slide.levelPlayer.currentGap; if (currentGap === gap || o.result.isDone) { return; } if (o.slide.gapClickStartDisabled) { return; } if (currentGap != null) { currentGap.stopGap(); } return startGap(); }; gap = inc("gap/gap")(o, click, submitGap); o.gap = gap; gap.click = click; gap.startGap = startGap; gap.stopGap = stopGap; gap.submitGap = submitGap; gap.result = function(){ return o.result; }; gap.choices = o.choices; gap.gapIsCompleted = false; return gap; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/compareValues/calcCombinations/calc.ls (function(){ return function(array){ var calc; calc = function(active, rest, a){ var a1, a2; if (!(active != null && active.length) && !(rest != null && rest.length)) { return; } if (!(rest != null && rest.length)) { a.push(active); } else { a1 = active.slice(); a2 = active.slice(); a1.push(rest[0]); calc(a1, rest.slice(1), a); calc(a2, rest.slice(1), a); } return a; }; return _.sortBy(calc([], array, [])); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/compareValues/compare.ls (function(){ return function(o, value, valueSol){ var removePunctuation, isCorrect, checks, checkCombos, i$, len$, combo, cs1, cs2, j$, len1$, c; removePunctuation = inc("../../../_shared/_removePunctuation/remove"); isCorrect = value === valueSol; if (isCorrect) { return { isCorrect: isCorrect }; } if (!o.learnListMode) { return { isCorrect: false }; } checks = [ { type: "ascii", fn: function(s){ return _.deburr(s); } }, { type: "lower", fn: function(s){ return s.toLowerCase(); } }, { type: "punct", fn: function(s){ return removePunctuation(s); } } ]; checkCombos = inc("calcCombinations/calc")(checks); for (i$ = 0, len$ = checkCombos.length; i$ < len$; ++i$) { combo = checkCombos[i$]; cs1 = value.slice(); cs2 = valueSol.slice(); for (j$ = 0, len1$ = combo.length; j$ < len1$; ++j$) { c = combo[j$]; cs1 = c.fn(cs1); cs2 = c.fn(cs2); } if (cs1 === cs2) { return { isHalfCorrect: true, reason: _.map(combo, "type").join("-") }; } } return { isCorrect: false }; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/onCorrect/on.ls (function(){ return function(o, callback){ var gap; gap = o.gap; inc("styleCorrectGap/style")(gap); o.slide.levelPlayer.progressBar.showGreen(); gap.setValue(gap.correctValue); o.result.isDone = true; gap.gapIsCompleted = true; return inc("onActionCorrect/on")(o, gap, callback); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/onCorrect/onActionCorrect/on.ls (function(){ return function(o, gap, callback){ var action; action = { gap: o.gapIndex, text: gap.correctValue }; return o.onActionCorrect(action, callback); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/onCorrect/styleCorrectGap/style.ls (function(){ return function(gap){ return gap.css({ paddingLeft: "", paddingRight: "", minWidth: "", color: Color.green[500], cursor: "default" }); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/onWrong/_hintMistake/feedbackTextAbove/text.ls (function(){ return function(o){ var wrongText, correctText; o.gap.css({ fontSize: "0.9em", lineHeight: "1em", verticalAlign: "middle" }); wrongText = Span().css({ textDecoration: "line-through", color: Color.red[500] }).secureHtml(o.gap.getValue() || " "); correctText = Span().css({ color: Color.grey[550] }).secureHtml(o.gap.correctValue || " "); return Div({ display: "inline-block", lineHeight: "1em" }).append(correctText, "
", wrongText); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/onWrong/_hintMistake/feedbackTextSide/text.ls (function(){ return function(o){ var value, wrongText, solution, correctText; value = o.gap.getValue(); if (value.trim() === "") { wrongText = Span().css({ borderBottom: "2px solid " + Color.red[500] }).html(" "); } else { wrongText = Span().css({ textDecoration: "line-through", color: Color.red[500] }).secureHtml(value || " "); } solution = o.gap.correctValue; correctText = Span().css({ color: Color.grey[550] }).secureHtml(solution || " "); return Span().append(wrongText, " ", correctText); }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/onWrong/_hintMistake/hint.ls (function(){ return function(o, cb){ var callback, isDone, retry, solve, onSolveDone, html, div; callback = function(){ o.slide.div.css({ pointerEvents: "" }); return cb(); }; isDone = false; retry = function(){ isDone = true; o.slide.gapClickStartDisabled = false; o.gap.enable(); o.gap.css({ color: "black" }); o.gap.start(); o.gap.selectAll(); return o.slide.levelPlayer.currentGap = o.gap; }; solve = function(){ var feedbackText; o.slide.levelPlayer.progressBar.showGrey(); if (typeof o.onActionResolved == 'function') { o.onActionResolved({ gap: o.gapIndex, solution: o.gap.correctValue }); } isDone = true; feedbackText = _.some(["lsg", "table"], function(t){ return _.startsWith(o.slide.trainerParams.trainer, t); }) ? inc("feedbackTextAbove/text")(o) : inc("feedbackTextSide/text")(o); o.gap.html(feedbackText).css({ paddingRight: "0em", paddingLeft: "0em", minWidth: "", width: "" }); o.result.isDone = true; o.gap.gapIsCompleted = true; o.slide.div.css({ pointerEvents: "none" }); return setTimeout(onSolveDone, 500); }; onSolveDone = function(){ var gaps, nextGap; gaps = o.slide.div.findAll(".gap"); nextGap = _.find(gaps, { gapIsCompleted: false }); if (!nextGap && !o.slide.finishButton) { o.slide.finishButton = true; } return callback(); }; html = Div({ padding: "0.3em", textAlign: "center" }).html(Div().html(T("solutionWrong")), Div({ margin: "0.7em 0 0.4em" }).html(Button({ label: T("tryAgain"), icon: path("/../app01/lib/svg/icon/refresh.svg") }).tap(function(){ return div.close("retry"); }).css({ marginRight: "0.8em" }), Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).tap(function(){ return div.close("solve"); }))); div = inc("/shared/topMessage/topMessage")({ html: html, onClose: function(type){ if (type === "solve") { return solve(); } else { return retry(); } } }).addClass("hint").addClass("gapWriteMistakeHint"); div.isDone = function(){ return isDone; }; div.solveAndContinue = solve; div.retryAndContinue = retry; return div; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/onWrong/on.ls (function(){ return function(o, callback){ var gap; gap = o.gap; gap.css({ color: Color.red[500], cursor: "default" }); o.slide.levelPlayer.progressBar.addElement().showRed(); inc("_hintMistake/hint")(o, callback); return typeof o.onActionMistake == 'function' ? o.onActionMistake({ gap: o.gapIndex, text: gap.getValue(), solution: gap.correctValue }) : void 8; }; })(); shared/gapComponent/component/gapText/gapText/createParts/gapWrite/submit/submit.ls (function(){ return function(o, callback){ var clean, valueClean, correctChoice, correctChoiceClean, compareResult, that; clean = inc("../../_shared/_cleanString/clean")(o); valueClean = clean(o.gap.getValue()); correctChoice = inc("../../_shared/getMatchingCorrectChoice/get")(o, valueClean); correctChoiceClean = clean(correctChoice.text); o.gap.stop(); o.gap.correctValue = correctChoice.text; compareResult = inc("compareValues/compare")(o, valueClean, correctChoiceClean); if (that = o.onSubmitCustom) { return that(o, compareResult, callback); } else if (compareResult.isCorrect) { return inc("onCorrect/on")(o, callback); } else { return inc("onWrong/on")(o, callback); } }; })(); shared/gapComponent/component/gapText/gapText/createParts/space/space.ls (function(){ return function(part, o){ return Div({ display: "inline-block", lineHeight: "inherit", borderBottom: "2px solid transparent", padding: "0.2em 0 0.1em", margin: "0.14em 0", pointerEvents: "none" }).append(Div({ height: "0" }), Div({ display: "inline-block", textDecoration: part.underline ? "underline" : void 8, backgroundColor: part.markColor, zIndex: 0 }).html(" ")); }; })(); shared/gapComponent/component/gapText/gapText/createParts/word/word.ls (function(){ return function(part, o){ var s; s = part.word; return Div({ display: "inline-block", lineHeight: "inherit", borderBottom: "2px solid transparent", padding: "0.2em 0 0.1em", margin: "0.14em 0", pointerEvents: "none" }).append(Div({ height: "0" }), Div({ display: "inline-block", textDecoration: part.underline ? "underline" : void 8, backgroundColor: part.markColor, color: part.textColor, zIndex: 1 }).secureHtml(part.superscript ? "" + part.word + "" : part.subscript ? "" + part.word + "" : part.word)); }; })(); shared/gapComponent/component/gapText/gapText/gapText.ls (function(){ return function(o){ var isDone, start, stop, finish, div; o.mode == null && (o.mode = "write"); o.gaps = []; o.parts = inc("/shared/convertGapString/convert")(o.text); o.totalGaps = _.filter(o.parts, function(p){ return p.gap; }).length; isDone = o.totalGaps === 0; start = function(){ var i$, ref$, len$, g, results$ = []; if (app.currentPage.levelPlayer == null) { return; } if (o.totalGaps === 0) { o.onFinish(); return; } for (i$ = 0, len$ = (ref$ = o.gaps).length; i$ < len$; ++i$) { g = ref$[i$]; if (!g.result().isDone) { g.startGap(); break; } } return results$; }; stop = function(){ var i$, ref$, len$, g, results$ = []; for (i$ = 0, len$ = (ref$ = o.gaps).length; i$ < len$; ++i$) { g = ref$[i$]; results$.push(g.stopGap()); } return results$; }; finish = function(){ var result; result = { correctValue: o.correctValue }; return o.onFinish(result); }; o.onGapResult = function(gap){ var i$, ref$, len$, g, nextGap; for (i$ = 0, len$ = (ref$ = o.gaps).length; i$ < len$; ++i$) { g = ref$[i$]; if (!g.result().isDone) { nextGap = g; break; } } if (nextGap) { app.currentPage.scrollElementIntoView(nextGap, { padding: 50 }); return nextGap.startGap(); } else { isDone = true; o.correctValue = inc("calcCorrectValue/calc")(o); if ((ref$ = o.buttonsDiv) != null) { ref$.hide(); } o.slide.levelPlayer.currentGap = undefined; return finish(); } }; div = Span().addClass("gapText").css({ lineHeight: "1.4em" }); inc("createParts/create")(div, o); div.start = start; div.stop = stop; div.gaps = function(){ return o.gaps; }; div.isDone = function(){ return isDone; }; div.calcCorrectValue = function(){ return inc("calcCorrectValue/calc")(o); }; return div; }; })(); shared/gapComponent/component/mathDiv/mathDiv.ls (function(){ return function(o){ var p, atom, ref$; p = o.slide.getParam; atom = o.atom; o.gapValidateMode = p("gapValidateMode", atom) || "literal"; o.matLayout = p("matLayout", atom); o.shuffleButtons = (ref$ = p("shuffleButtons", atom)) != null ? ref$ : true; o.combineButtons = (ref$ = p("combineButtons", atom)) != null ? ref$ : false; o.removeCorrectButton = (ref$ = p("removeCorrectButton", atom)) != null ? ref$ : false; o.uniqueSolutions = (ref$ = p("uniqueSolutions", atom)) != null ? ref$ : false; return inc("mathDiv/mathDiv")(o); }; })(); shared/gapComponent/component/mathDiv/mathDiv/mathDiv.ls (function(){ return function(o){ var ref$, ref1$, ref2$, ref3$, ref4$; return MathDiv2({ mode: o.mode === "buttons" ? "gapButtons" : o.mode === "write" ? "gapWrite" : void 8, buttonsDiv: o.buttonsDiv, gapValidateMode: o.gapValidateMode, shuffleButtons: o.shuffleButtons, combineButtons: o.combineButtons, removeCorrectButton: o.removeCorrectButton, uniqueSolutions: o.uniqueSolutions, enableHorizontalScroll: true, keyboardLayout: (ref$ = o.matLayout) != null ? ref$.keyboardLayout : void 8, keyboardShowHeader: (ref1$ = o.matLayout) != null ? ref1$.showKeyboardHeader : void 8, keyboardHideUndo: (ref2$ = o.matLayout) != null ? ref2$.hideUndo : void 8, keyboardHideArrows: (ref3$ = o.matLayout) != null ? ref3$.hideArrows : void 8, keyboardSpecialKeys: (ref4$ = o.matLayout) != null ? ref4$.specialKeys : void 8, slide: o.slide, enabled: true, value: o.text, onStart: o.onStart, onFinish: o.onFinish, onActionCorrect: o.onActionCorrect, onActionMistake: o.onActionMistake, onActionResolved: o.onActionResolved }).css({ maxWidth: "100%", justifyContent: o.textAlign !== "left" ? "center" : void 8 }); }; })(); shared/gapComponent/component/mixed/calcGaps/calc.ls (function(){ return function(o){ var allGaps, index, i$, ref$, len$, c, gaps, j$, len1$, g; allGaps = []; index = 0; for (i$ = 0, len$ = (ref$ = o.components).length; i$ < len$; ++i$) { c = ref$[i$]; if (c.gaps != null) { gaps = c.gaps(); for (j$ = 0, len1$ = gaps.length; j$ < len1$; ++j$) { g = gaps[j$]; g.mixedGapIndex = index++; } allGaps = _.concat(allGaps, gaps); } } return allGaps; }; })(); shared/gapComponent/component/mixed/createComponents/_o2/o2.ls (function(){ return function(part, i, o){ var onAction, o2; onAction = function(action){ action.mixedGapIndex = o.components[i].gaps()[action.gap].mixedGapIndex; return action.gap = i + "_" + action.gap; }; o2 = { text: part.text, slide: o.slide, atom: o.atom, buttonsDiv: o.buttonsDiv, mode: o.mode, type: part.type, onActionCorrect: function(action, callback){ onAction(action); return o.onActionCorrect(action, callback); }, onActionMistake: function(action){ onAction(action); return o.onActionMistake(action); }, onActionResolved: function(action){ onAction(action); return o.onActionResolved(action); }, onStart: o.onStart }; o2.onFinish = inc("../../onComponentFinish/onFinish")(o, o2, i); return o2; }; })(); shared/gapComponent/component/mixed/createComponents/create.ls (function(){ return function(o){ var i, part; return o.components = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = o.textParts).length; i$ < len$; ++i$) { i = i$; part = ref$[i$]; if (part.type === "linebreak") { results$.push(inc("linebreak/break")()); } else if ((ref1$ = part.type) === "gapText" || ref1$ === "text") { results$.push(inc("gapText/gapText")(part, i, o)); } else if (part.type === "mathDiv") { results$.push(inc("mathDiv/mathDiv")(part, i, o)); } } return results$; }()); }; })(); shared/gapComponent/component/mixed/createComponents/gapText/gapText.ls (function(){ return function(part, i, o){ var o2, gapText, i$, ref$, len$, j, gap; o2 = inc("../_o2/o2")(part, i, o); gapText = inc("../../../gapText/gapText")(o2); for (i$ = 0, len$ = (ref$ = gapText.findAll(".gap")).length; i$ < len$; ++i$) { j = i$; gap = ref$[i$]; gap.addClass("gap" + i + "_" + j); } return gapText; }; })(); shared/gapComponent/component/mixed/createComponents/linebreak/break.ls (function(){ return function(){ var div; div = Div({ height: "0.3em" }); div.isDone = function(){ return true; }; return div; }; })(); shared/gapComponent/component/mixed/createComponents/mathDiv/mathDiv.ls (function(){ return function(part, i, o){ var o2, mathDiv, i$, ref$, len$, j, gap; o2 = inc("../_o2/o2")(part, i, o); mathDiv = inc("../../../mathDiv/mathDiv")(o2); for (i$ = 0, len$ = (ref$ = mathDiv.findAll(".gap")).length; i$ < len$; ++i$) { j = i$; gap = ref$[i$]; gap.addClass("gap" + i + "_" + j); } return mathDiv; }; })(); shared/gapComponent/component/mixed/div/div.ls (function(){ return function(o){ return Div({ display: "inline-block" }).addClass("mixed").append(o.components); }; })(); shared/gapComponent/component/mixed/isDone/isDone.ls (function(){ return function(o){ var isDone; return isDone = !_.includes(_.map(o.components, function(c){ return c.isDone(); }), false); }; })(); shared/gapComponent/component/mixed/mixed.ls (function(){ return function(o){ o.components = inc("createComponents/create")(o); o.gaps = inc("calcGaps/calc")(o); o.div = inc("div/div")(o); o.div.gaps = function(){ return o.gaps; }; o.div.start = function(){ return inc("start/start")(o); }; o.div.isDone = function(){ return inc("isDone/isDone")(o); }; return o.div; }; })(); shared/gapComponent/component/mixed/onComponentFinish/onFinish.ls (function(){ return function(o, o2, i){ return function(result){ var found, i$, ref$, len$, g, nextGap, j, c; o.correctValues == null && (o.correctValues = []); o.correctValues[i] = result != null ? result.correctValue : void 8; found = false; for (i$ = 0, len$ = (ref$ = o.gaps).length; i$ < len$; ++i$) { g = ref$[i$]; if (!g.gapIsCompleted) { found = true; nextGap = g; nextGap.startGap(); break; } } if (!found) { for (i$ = 0, len$ = (ref$ = o.components).length; i$ < len$; ++i$) { j = i$; c = ref$[i$]; if ((typeof c.gaps == 'function' ? c.gaps().length : void 8) === 0) { o.correctValues[j] = c.calcCorrectValue(); } } return o.onFinish({ correctValue: o.correctValues.join("") }); } }; }; })(); shared/gapComponent/component/mixed/start/start.ls (function(){ return function(o){ var i$, ref$, len$, g, results$ = []; if (o.gaps.length === 0) { o.onFinish(); return; } for (i$ = 0, len$ = (ref$ = o.gaps).length; i$ < len$; ++i$) { g = ref$[i$]; if (!g.gapIsCompleted) { g.startGap(); break; } } return results$; }; })(); shared/gapComponent/scoreActions/_shared/actionLabel/label.ls (function(){ return function(type){ return Div({ display: "inline-block", minWidth: "0.8em", backgroundColor: "rgba(0, 0, 0, 0.05)", padding: "0 0.2em", color: type === "correct" ? Color.green[500] : type === "resolved" ? Color.grey[550] : Color.red[500] }).onDomAppend(function(){ if (!this.innerHTML) { return this.html(" "); } }); }; })(); shared/gapComponent/scoreActions/_shared/calcTagDiv/calc.ls (function(){ return function(gapIndex){ return Div({ fontSize: "12px", backgroundColor: Color.yellow[200], padding: "0.2em", boxShadow: '0px 0px 2px #bbb', color: "black", marginRight: "0.7em" }).html(gapIndex + 1); }; })(); shared/gapComponent/scoreActions/_shared/calcTagIndex/calc.ls (function(){ return function(slide, action){ var tagIndex; return tagIndex = slide.yellowTagsCountPerSlide ? (slide.yellowTagIndex == null && (slide.yellowTagIndex = 0), slide.yellowTagIndex++) : action.gap; }; })(); shared/gapComponent/scoreActions/actions.ls (function(){ return function(o){ var showYellowTag, slide, gapComponent, actions; showYellowTag = o.showYellowTag; slide = o.slide; gapComponent = o.gapComponent; actions = o.actions; slide.yellowTagsCountPerSlide = o.yellowTagsCountPerSlide; if (gapComponent.hasClass("gapText")) { return inc("gapTextActions/actions")(slide, gapComponent, actions, showYellowTag); } else if (gapComponent.hasClass("mathDiv")) { return inc("mathDivActions/actions")(slide, gapComponent, actions, showYellowTag); } else if (gapComponent.hasClass("mixed")) { return inc("mixedActions/actions")(slide, gapComponent, actions, showYellowTag); } }; })(); shared/gapComponent/scoreActions/gapTextActions/action/action.ls (function(){ return function(slide, gapText, action, showYellowTag){ var gap, row, calcTagDiv; gap = gapText.findFirst(".gap" + action.gap); if (!gap) { return; } row = inc("/shared/scoreActionRowFlex/row")(action, action.correct ? inc("correct/correct")(slide, action) : action.resolved ? inc("resolved/resolved")(slide, action) : inc("mistake/mistake")(slide, action)); calcTagDiv = inc("../../_shared/calcTagDiv/calc"); if (showYellowTag) { if (gap.yellowTagIndex == null) { gap.yellowTagIndex = inc("../../_shared/calcTagIndex/calc")(slide, action); gap.append(calcTagDiv(gap.yellowTagIndex).css({ position: "absolute", left: 0, top: 0 })); } row.append(calcTagDiv(gap.yellowTagIndex).css({ position: "absolute", left: "-6px", top: "-6px" })); } return row; }; })(); shared/gapComponent/scoreActions/gapTextActions/action/correct/correct.ls (function(){ return function(slide, action){ var text; text = action.button || action.text; return Div({ flex: "1 1 auto", display: "flex", justifyContent: "flex-start" }).append(inc("../../../_shared/actionLabel/label")("correct").secureHtml(text)); }; })(); shared/gapComponent/scoreActions/gapTextActions/action/mistake/mistake.ls (function(){ return function(slide, action){ var text, solution; text = action.button || action.text; solution = action.solution; return Div({ flex: "1 1 auto", display: "flex", justifyContent: "flex-start" }).append(inc("../../../_shared/actionLabel/label")("wrong").secureHtml(text), Div().html(T("instead")), inc("../../../_shared/actionLabel/label")("resolved").secureHtml(solution)); }; })(); shared/gapComponent/scoreActions/gapTextActions/action/resolved/resolved.ls (function(){ return function(slide, action){ var solution; solution = action.solution; return Div({ flex: "1 1 auto", display: "flex", justifyContent: "flex-start" }).append(Div().html(T("showSolution")), inc("../../../_shared/actionLabel/label")("resolved").secureHtml(solution)); }; })(); shared/gapComponent/scoreActions/gapTextActions/actions.ls (function(){ return function(slide, gapText, actions, showYellowTag){ var action; return Div().append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { action = ref$[i$]; results$.push(inc("action/action")(slide, gapText, action, showYellowTag)); } return results$; }())); }; })(); shared/gapComponent/scoreActions/mathDivActions/action/action.ls (function(){ return function(slide, mathDiv, action, showYellowTag){ var gap, row, calcTagDiv; gap = mathDiv.findFirst(".gap" + action.gap); if (!gap) { return; } row = inc("/shared/scoreActionRowFlex/row")(action, action.correct ? inc("correct/correct")(action) : action.resolved ? inc("resolved/resolved")(action) : inc("mistake/mistake")(action)); calcTagDiv = inc("../../_shared/calcTagDiv/calc"); if (showYellowTag) { if (gap.yellowTagIndex == null) { gap.yellowTagIndex = inc("../../_shared/calcTagIndex/calc")(slide, action); gap.append(calcTagDiv(gap.yellowTagIndex).css({ position: "absolute", left: 0, top: 0 })); } row.append(calcTagDiv(gap.yellowTagIndex).css({ position: "absolute", left: "-6px", top: "-6px" })); } return row; }; })(); shared/gapComponent/scoreActions/mathDivActions/action/correct/correct.ls (function(){ return function(action){ return Div({ flex: "1 1 auto", display: "flex", justifyContent: "flex-start" }).append(inc("../../../_shared/actionLabel/label")("correct").append(MathDiv2({ value: action.value, enabled: false }))); }; })(); shared/gapComponent/scoreActions/mathDivActions/action/mistake/mistake.ls (function(){ return function(action){ return Div({ flex: "1 1 auto", display: "flex", justifyContent: "flex-start" }).html(inc("../../../_shared/actionLabel/label")("wrong").html(MathDiv2({ value: action.value, enabled: false })), T("instead"), inc("../../../_shared/actionLabel/label")("resolved").html(MathDiv2({ value: action.solution, enabled: false, color: "currentColor" }))); }; })(); shared/gapComponent/scoreActions/mathDivActions/action/resolved/resolved.ls (function(){ return function(action){ return Div({ flex: "1 1 auto", display: "flex", justifyContent: "flex-start" }).append(T("showSolution"), inc("../../../_shared/actionLabel/label")("resolved").append(MathDiv2({ value: action.solution, enabled: false }))); }; })(); shared/gapComponent/scoreActions/mathDivActions/actions.ls (function(){ return function(slide, mathDiv, actions, showYellowTag){ var action; return Div({ textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { action = ref$[i$]; results$.push(inc("action/action")(slide, mathDiv, action, showYellowTag)); } return results$; }())); }; })(); shared/gapComponent/scoreActions/mixedActions/action/action.ls (function(){ return function(slide, gapComponent, action, showYellowTag){ var gap; gap = gapComponent.findFirst(".gap" + action.gap); if (!gap) {} else if (gap.hasClass("mgap")) { return inc("../../mathDivActions/action/action")(slide, gapComponent, action, showYellowTag); } else { return inc("../../gapTextActions/action/action")(slide, gapComponent, action, showYellowTag); } }; })(); shared/gapComponent/scoreActions/mixedActions/actions.ls (function(){ return function(slide, gapComponent, actions, showYellowTag){ var action; slide.yellowTagsCountPerSlide = true; return Div({ textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { action = ref$[i$]; results$.push(inc("action/action")(slide, gapComponent, action, showYellowTag)); } return results$; }())); }; })(); shared/getParam/default/default.ls (function(){ return function(slide, name, atom){ var param; param = (atom != null ? atom[name] : void 8) != null ? atom[name] : slide.trainerParams[name] != null ? slide.trainerParams[name] : slide.levelParams[name] != null ? slide.levelParams[name] : null; if (name === "fontFamily") { switch (param) { case "monospace": return "Source Code Pro"; case "school": return "Solocode School"; default: return param; } } else { return param; } }; })(); shared/getParam/feedback/feedback.ls (function(){ return function(slide, name, atom){ var name, a, t, l, feedback, specialNames, value, i$, len$, n, ref$, ref1$, ref2$, sounds, text; a = _.cloneDeep(atom); t = _.cloneDeep(slide.trainerParams); l = _.cloneDeep(slide.levelParams); feedback = (a != null ? a.feedback : void 8) || (t != null ? t.feedback : void 8); if (!feedback) { return; } specialNames = ["voice", "voiceLang", "style", "speaker", "autoplay"]; for (name in feedback) { value = feedback[name]; if (_.includes(specialNames, name)) { continue; } if (_.isString(value)) { value = { text: value }; } for (i$ = 0, len$ = specialNames.length; i$ < len$; ++i$) { n = specialNames[i$]; value[n] = (ref$ = value[n]) != null ? ref$ : (ref$ = feedback[n]) != null ? ref$ : (ref$ = (ref1$ = t.feedback) != null ? ref1$[n] : void 8) != null ? ref$ : (ref$ = l.feedback) != null ? ref$[n] : void 8; if (n === "voice" || n === "voiceLang") { value[n] == null && (value[n] = (ref2$ = t != null ? t[n] : void 8) != null ? ref2$ : l != null ? l[n] : void 8); } } value.sound == null && (value.sound = value.speaker ? (sounds = (fn$()), sounds.join(" ")) : void 8); feedback[name] = value; } return feedback; function fn$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.ensureArray(value.text)).length; i$ < len$; ++i$) { text = ref$[i$]; if (_.isString(text)) { results$.push(text); } else if (text.text) { results$.push(text.text); } } return results$; } }; })(); shared/getParam/getParam.ls (function(){ return function(slide){ var functions, getParam; functions = { lsg: inc("lsg/lsg"), image: inc("image/image"), feedback: inc("feedback/feedback"), hint: inc("hint/hint"), instruction: inc("instruction/instruction"), 'default': inc("default/default") }; return getParam = function(name, atom){ var f; f = functions[name] || functions["default"]; return f(slide, name, atom); }; }; })(); shared/getParam/hint/hint.ls (function(){ return function(slide, name, atom){ var a, t, l, hint, specialNames, i$, len$, n, ref$, ref1$, ref2$, ref3$, sounds, text; a = _.cloneDeep(atom); t = _.cloneDeep(slide.trainerParams); l = _.cloneDeep(slide.levelParams); hint = (a != null ? a.hint : void 8) || (t != null ? t.hint : void 8) || (l != null ? l.hint : void 8); if (!hint) { return; } if (_.isString(hint)) { hint = { text: hint }; } specialNames = ["voice", "voiceLang", "style", "speaker", "autoplay", "label"]; for (i$ = 0, len$ = specialNames.length; i$ < len$; ++i$) { n = specialNames[i$]; hint[n] = (ref$ = a != null ? (ref1$ = a.hint) != null ? ref1$[n] : void 8 : void 8) != null ? ref$ : (ref$ = t != null ? (ref2$ = t.hint) != null ? ref2$[n] : void 8 : void 8) != null ? ref$ : l != null ? (ref$ = l.hint) != null ? ref$[n] : void 8 : void 8; if (n === "voice" || n === "voiceLang") { hint[n] == null && (hint[n] = (ref3$ = t != null ? t[n] : void 8) != null ? ref3$ : l != null ? l[n] : void 8); } } hint.sound == null && (hint.sound = hint.speaker ? (sounds = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.ensureArray(hint.text)).length; i$ < len$; ++i$) { text = ref$[i$]; if (_.isString(text)) { results$.push(text); } else if (text.text) { results$.push(text.text); } } return results$; }()), sounds.join(" ")) : void 8); if (!hint.text) { return; } return hint; }; })(); shared/getParam/image/image.ls (function(){ return function(slide, name, atom){ var a, t, ref$, l, ref1$, param; a = _.cloneDeep(atom != null ? atom.image : void 8); t = _.cloneDeep((ref$ = slide.trainerParams) != null ? ref$.image : void 8); l = _.cloneDeep((ref1$ = slide.levelParams) != null ? ref1$.image : void 8); if (_.isString(a)) { a = { image: a }; } if (_.isString(t)) { t = { image: t }; } if (_.isString(l)) { l = { image: l }; } if (_.isObject(a) || _.isObject(t) || _.isObject(l)) { param = _.defaults(a, t, l); if (param.image) { param.image = _.trim(param.image); return param; } } }; })(); shared/getParam/instruction/instruction.ls (function(){ return function(slide, name){ var a, t, l, instruction, specialNames, i$, len$, n, ref$, ref1$, ref2$, ref3$; a = _.cloneDeep(slide.atom); t = _.cloneDeep(slide.trainerParams); l = _.cloneDeep(slide.levelParams); instruction = (a != null ? a.instruction : void 8) || (t != null ? t.instruction : void 8) || (l != null ? l.instruction : void 8); if (!instruction) { return; } if (_.isString(instruction)) { instruction = { text: instruction }; } specialNames = ["voice", "voiceLang", "sound", "text", "style", "speaker", "autoplay"]; for (i$ = 0, len$ = specialNames.length; i$ < len$; ++i$) { n = specialNames[i$]; instruction[n] == null && (instruction[n] = (ref$ = a != null ? (ref1$ = a.instruction) != null ? ref1$[n] : void 8 : void 8) != null ? ref$ : (ref$ = t != null ? (ref2$ = t.instruction) != null ? ref2$[n] : void 8 : void 8) != null ? ref$ : l != null ? (ref$ = l.instruction) != null ? ref$[n] : void 8 : void 8); if (n === "voice" || n === "voiceLang") { instruction[n] == null && (instruction[n] = (ref3$ = t != null ? t[n] : void 8) != null ? ref3$ : l != null ? l[n] : void 8); } } instruction.sound == null && (instruction.sound = instruction.speaker ? instruction.text : void 8); if (!instruction.text && !instruction.sound) { return; } return instruction; }; })(); shared/getParam/lsg/lsg.ls (function(){ return function(slide, name, atom){ var a, t, ref$, l, ref1$, param; a = _.cloneDeep(atom != null ? atom.lsg : void 8); t = _.cloneDeep((ref$ = slide.trainerParams) != null ? ref$.lsg : void 8); l = _.cloneDeep((ref1$ = slide.levelParams) != null ? ref1$.lsg : void 8); if (_.isString(a)) { a = { lsg: a }; } if (_.isString(t)) { t = { lsg: t }; } if (_.isString(l)) { l = { lsg: l }; } if (_.isObject(a) || _.isObject(t) || _.isObject(l)) { param = _.defaults(a, t, l); if (param.lsg) { return param; } } }; })(); shared/image/div/div.ls (function(){ return function(width, height, imageData, wrapWithDiv){ var div, wrapper; div = inc("/../app01/lib/gui/image/image")({ base64: imageData != null ? imageData.base64 : void 8, url: imageData != null ? imageData.url : void 8 }).css({ width: width + "px", height: height + "px" }); if (wrapWithDiv) { wrapper = Div({ margin: "1em auto", textAlign: "center" }).html(div); wrapper.image = div; return wrapper; } else { return div; } }; })(); shared/image/image.ls (function(){ return function(o){ var imageParams, slide, parent, wrapWithDiv, ref$, defaultSize, fontScale, image, width, height, imageData, div; imageParams = o.image; slide = o.slide; parent = o.parent; wrapWithDiv = (ref$ = o.wrapWithDiv) != null ? ref$ : false; if (!imageParams) { return; } if (_.isString(imageParams)) { imageParams = { image: imageParams }; } defaultSize = 150; fontScale = inc("/../app01/lib/util/fontSize/calcFontScale/calc")(); image = imageParams.image; if (_.startsWith(image, "pixabay")) { debug("image warning for image " + image + ": pixabay images shouldn't be used anymore."); } width = fontScale * ((imageParams != null ? imageParams.width : void 8) || defaultSize); height = fontScale * ((imageParams != null ? imageParams.height : void 8) || (imageParams != null ? imageParams.width : void 8) || defaultSize); imageData = _.find(slide.mediaParams.images, { id: image }); div = inc("div/div")(width, height, imageData, wrapWithDiv); div.scaleToParent = inc("scaleToParent/scale")(div, width, height, parent, wrapWithDiv); div.scaleToParent(); return div; }; })(); shared/image/scaleToParent/calcScale/calc.ls (function(){ return function(width, parent){ var wrapper, that, scaleFactor, parentWidth, scale; wrapper = (that = app.currentPopup) != null ? that.findFirst(".popupContent") : body; scaleFactor = parent == null || parent.width() === wrapper.width() ? 0.95 : 1; if (parent == null) { parent = wrapper; } parentWidth = parent.width() - +parent.css("paddingLeft").replace("px", "") - +parent.css("paddingRight").replace("px", ""); return scale = (parentWidth * scaleFactor) / width; }; })(); shared/image/scaleToParent/scale.ls (function(){ return function(div, width, height, parent, wrapWithDiv){ return function(){ var scaleDiv, scale; scaleDiv = wrapWithDiv ? div.image : div; scale = inc("calcScale/calc")(width, parent); if (0 < scale && scale < 1) { width = width * scale; height = height * scale; } return scaleDiv.css({ width: width + "px", height: height + "px" }); }; }; })(); shared/instruction/instruction.ls (function(){ return function(slide){ var instruction, text, sound, voice, autoplay, hasPlayed, waitFirstPlayCompletedHandlers, play, stop, finish, waitFirstPlayCompleted, div, speaker, label; instruction = slide.getParam("instruction", slide.atom); text = instruction != null ? instruction.text : void 8; sound = instruction != null ? instruction.sound : void 8; voice = instruction != null ? instruction.voice : void 8; autoplay = instruction != null ? instruction.autoplay : void 8; hasPlayed = sound ? false : true; waitFirstPlayCompletedHandlers = {}; play = function(onFinish){ if (autoplay === false) { slide.levelPlayer.lastInstructionSound = null; return finish(onFinish); } else if (!sound) { slide.levelPlayer.lastInstructionSound = null; return finish(onFinish); } else if (slide.levelPlayer.lastInstructionSound === sound && autoplay !== true) { return finish(onFinish); } else { slide.levelPlayer.lastInstructionSound = sound; return setTimeout(function(){ var ref$; if (((ref$ = slide.div) != null && ref$.isVisible()) && app.currentPage.levelPlayer != null) { return speaker.play(function(){ return finish(onFinish); }); } }, 500); } }; stop = function(){ return typeof speaker != 'undefined' && speaker !== null ? speaker.stop() : void 8; }; finish = function(onFinish){ return requestAnimationFrame(function(){ var i$, ref$, v, j$, len$, cb; hasPlayed = true; if (typeof onFinish == 'function') { onFinish(); } for (i$ in ref$ = waitFirstPlayCompletedHandlers) { v = ref$[i$]; for (j$ = 0, len$ = v.length; j$ < len$; ++j$) { cb = v[j$]; cb(); } } return waitFirstPlayCompletedHandlers = {}; }); }; waitFirstPlayCompleted = function(o){ var key$; if (hasPlayed) { return o.callback(); } else { waitFirstPlayCompletedHandlers[key$ = o.category] == null && (waitFirstPlayCompletedHandlers[key$] = []); return waitFirstPlayCompletedHandlers[o.category].push(o.callback); } }; div = Div({ width: "35em", maxWidth: "90%", margin: "0 auto" }).addClass("instruction").html(Div({ display: "inline-block", lineHeight: "1.4em", padding: "0.5em", margin: "0.5em", fontStyle: "italic", maxWidth: "100%" }).html(speaker = inc("speaker/speaker")(slide, sound, text, voice), label = inc("label/label")(slide, text)).tap(sound ? { animation: "none", up: speaker.toggle } : void 8)); if (!text && !sound) { div.hide(); } div.play = play; div.stop = stop; div.sound = sound; div.hasPlayed = function(){ return hasPlayed; }; div.waitFirstPlayCompleted = waitFirstPlayCompleted; return div; }; })(); shared/instruction/label/label.ls (function(){ return function(slide, text){ return inc("/../app01/lib/seo/element/h2/h2")().css({ display: "inline" }).html(text); }; })(); shared/instruction/speaker/speaker.ls (function(){ return function(slide, sound, text, voice){ var outline, speaker; if (!sound) { return; } outline = (text != null ? text.length : void 8) > 0; sound = slide.sounds[sound + voice]; speaker = inc("/../app01/lib/gui/speakerIconPlayer/speakerIconPlayer")({ outline: outline, size: outline ? "1.4em" : "3.5em" }).css({ marginRight: "0.1em" }); speaker.setSound(sound); return speaker; }; })(); shared/levelPlayer/_t.ls (function(){ return { offlineError: { de: "Du musst online sein, um hier weiter lernen zu können.", en: "To continue learning, please connect to the internet.", fr: "Tu dois être en ligne pour continuer à apprendre.", es: "Por favor, conéctate a la red para seguir aprendiendo.", pt: "Você precisa estar online para continuar aprendendo." }, reloadButton: { de: "Nochmal laden", en: "Reload", fr: "Réessayer", es: "Volver a cargar", pt: "Carregar novamente" } }; })(); shared/levelPlayer/abort/abort.ls (function(){ return function(p){ var abort; return abort = function(){ if (p.isFinished) { return; } p.isFinished = true; inc("../log/abort/abort")(p); inc("/../app01/lib/init/classKit/levelPlayer/abort/abort")(p); return typeof p.onAbort == 'function' ? p.onAbort() : void 8; }; }; })(); shared/levelPlayer/calcCurrentSlideIndex/calc.ls (function(){ return function(p){ var slideIndex; if (p.context !== "idePreview") { return -1; } if (p.previewTrainerIndex != null) { slideIndex = _.findIndex(p.slides, function(s){ return _.isEqual(s.trainerParams, p.level.trainers[p.previewTrainerIndex]); }); return slideIndex - 1; } return -1; }; })(); shared/levelPlayer/calcRound/calc.ls (function(){ return function(){ var lastRound, round, e; lastRound = Store("sourceLevelRound") || 0; round = lastRound + 1; try { Store("sourceLevelRound", round); } catch (e$) { e = e$; log.log({ event: "debugFirefoxNSError", error: e }); } _.setRandomSeed(round); return round; }; })(); shared/levelPlayer/calcTotalAtoms/calc.ls (function(){ return function(p){ var t, i$, ref$, len$, s; t = 0; for (i$ = 0, len$ = (ref$ = p.slides).length; i$ < len$; ++i$) { s = ref$[i$]; if (s.atom) { t++; } else if (s.atoms) { t += s.atoms.length; } } return t; }; })(); shared/levelPlayer/calcTotalProgressElements/calc.ls (function(){ return function(p, onDone){ var totalDone, errors, calcSlides, onSlideCompleted, finish, onError; totalDone = 0; errors = []; calcSlides = function(){ var i$, ref$, len$, slide, results$ = []; for (i$ = 0, len$ = (ref$ = p.slides).length; i$ < len$; ++i$) { slide = ref$[i$]; results$.push(slide.calcTotalProgressElements(onSlideCompleted)); } return results$; }; onSlideCompleted = function(errors2){ var errors; totalDone++; errors = _.concat(errors, errors2); if (totalDone === p.slides.length) { return finish(); } }; finish = function(){ if (errors.length > 0) { return onError(); } else { return onDone(); } }; onError = function(){ debug("calcTotalProgressElements errors"); return debug(errors); }; return calcSlides(); }; })(); shared/levelPlayer/finish/finish.ls (function(){ return function(p){ var finish; return finish = function(){ if (p.isFinished) { return; } p.isFinished = true; inc("../log/finish/finish")(p); inc("/../app01/lib/init/classKit/levelPlayer/finish/finish")(p); return setTimeout(p.onFinish, 400); }; }; })(); shared/levelPlayer/generateSlides/generate.ls (function(){ return function(player){ var trainers, slides, i$, len$, trainer, t, path, trainerParams, levelParams, slide; trainers = _.ensureArray(player.level.trainers); slides = []; for (i$ = 0, len$ = trainers.length; i$ < len$; ++i$) { trainer = trainers[i$]; t = trainer.trainer; path = "/../" + (_.startsWith(t, "kid") ? "app01-kid-trainers/trainers/" + t : _.startsWith(t, "playground") ? "app01-playground-trainers/trainers/" + t.replace("playground/", "") : "app01-trainers/trainers/" + t) + "/generateSlides"; trainerParams = trainer; levelParams = player.level; slides = slides.concat(inc(path)(trainerParams, levelParams)); } for (i$ = 0, len$ = slides.length; i$ < len$; ++i$) { slide = slides[i$]; slide.levelPlayer = player; } return slides; }; })(); shared/levelPlayer/loadSlidesMediaFiles/load.ls (function(){ return function(p){ var index, loadNextSlide, onSlideLoaded; index = -1; loadNextSlide = function(){ var slide; index++; slide = p.slides[index]; return slide != null ? slide.loadMediaFiles({ onDone: onSlideLoaded }) : void 8; }; onSlideLoaded = function(){ return loadNextSlide(); }; return loadNextSlide(); }; })(); shared/levelPlayer/log/_addLearnListProperties/add.ls (function(){ return function(p, e){ var params; params = p.page.params; if (params.context !== "learnList") { return; } delete e.level; e.listCode = p.level.puid.split("/")[2]; return e.startConfig = _.pick(params, ["shuffleAtoms", "switchAB", "soundMode"]); }; })(); shared/levelPlayer/log/abort/abort.ls (function(){ return function(p){ var slide, e; slide = p.slides[p.currentSlideIndex]; if (slide != null) { slide.score.logUnloggedAtoms("levelAbort"); } e = inc("../finish/event")(p); e.event = "abortLevel"; return p.log.log(e); }; })(); shared/levelPlayer/log/finish/calcProgressColorsString/calc.ls (function(){ return function(stats){ var letter, s, s2, lastColor, i$, ref$, len$, c, part; letter = { green: "g", red: "r", grey: "b" }; s = ""; s2 = ""; lastColor = undefined; for (i$ = 0, len$ = (ref$ = stats.progressColors || []).length; i$ < len$; ++i$) { c = ref$[i$]; if (c !== lastColor) { s += "|"; } s += letter[c]; lastColor = c; } for (i$ = 0, len$ = (ref$ = s.split("|")).length; i$ < len$; ++i$) { part = ref$[i$]; if (part) { s2 += part.length === 1 ? part : part.length > 1 ? part.length + part[0] : void 8; } } return s2; }; })(); shared/levelPlayer/log/finish/calcScore/calc.ls (function(){ return function(p){ var s, score; if (p.level.type === "bulb") { return 1; } s = p.progressBar.getStats(); score = (s.totalGreen * 3) / (s.totalGreen + s.totalRed + s.totalGrey); score = _.round(score, 1); if (p.skipFakeResult != null) { score = p.skipFakeResult; } return score = Math.max(0.3, score); }; })(); shared/levelPlayer/log/finish/event.ls (function(){ return function(p){ var score, stats, progressColors, duration, project, e, ref$, ref1$; score = inc("calcScore/calc")(p); stats = p.progressBar.getStats(); progressColors = stats ? inc("calcProgressColorsString/calc")(stats) : void 8; duration = (new Date() - p.startedAt) / 1000; project = p.level.path.split("/")[2]; e = { event: "finishLevel", puid: p.level.puid, level: inc("/../app01/lib/util/projectPath/path")(p.level.path), levelTitle: p.level.title, blockPuid: (ref$ = p.level.parentBlock) != null ? ref$.puid : void 8, blockTitle: (ref1$ = p.level.parentBlock) != null ? ref1$.title : void 8, corrects: stats.totalGreen, mistakes: stats.totalRed, resolved: stats.totalGrey, total: stats.totalProgressElements, progressColors: progressColors, duration: _.round(duration, 1), atoms: p.totalAtoms, score: score, round: p.round, type: p.level.type }; inc("../_addLearnListProperties/add")(p, e); if (p.skipFakeResult != null) { e.isSkipped = true; } if (engine.isDebug) { e.isDebug = true; } return e; }; })(); shared/levelPlayer/log/finish/finish.ls (function(){ return function(p){ var e; return p.log.log(e = inc("event")(p)); }; })(); shared/levelPlayer/log/start/start.ls (function(){ return function(p){ var e, ref$, ref1$; e = { event: "startLevel", puid: p.level.puid, level: inc("/../app01/lib/util/projectPath/path")(p.level.path), blockPuid: (ref$ = p.level.parentBlock) != null ? ref$.puid : void 8, blockTitle: (ref1$ = p.level.parentBlock) != null ? ref1$.title : void 8, round: p.round, type: p.level.type }; if (engine.isDebug) { e.isDebug = true; } inc("../_addLearnListProperties/add")(p, e); return p.log.log(e); }; })(); shared/levelPlayer/playNextSlide/errorPopup/popup.ls (function(){ return function(){ var clickAbort, popup; clickAbort = function(){ popup.close(); app.currentPage.levelPlayer.abort(); return startPage({ history: function(path){ return !_.includes(path, "/level"); }, animation: "fadeIn" }); }; return popup = inc("/../app01/lib/gui/errorPopup/popup")({ onClose: clickAbort }); }; })(); shared/levelPlayer/playNextSlide/offlinePopup/popup.ls (function(){ return function(player, reload){ var clickAbort, clickReload, div, css, popup; clickAbort = function(){ popup.close(); log.log({ event: "debugLevelOfflineAbort", level: player.level.path, slide: player.currentSlideIndex + 1 }); player.abort(); return startPage({ history: function(path){ return !_.includes(path, "/level"); }, animation: "fadeIn" }); }; clickReload = function(){ popup.close(); return reload(); }; div = Div().css({ margin: "1em 0" }).append(Div().css({ padding: "0 0.5em 0.5em" }).html(T("offlineError")), Div().css({ display: "inline-block" }).append(Button({ label: T("cancelButton"), action: clickAbort }).css(css = { margin: "0.5em" }), Button({ label: T("reloadButton"), action: clickReload }).css(css))); return popup = inc("/../app01/lib/gui/popup/popup")({ html: div, onClose: function(type){ if (type === "outside" || type === "icon") { return clickAbort(); } } }); }; })(); shared/levelPlayer/playNextSlide/onSamePageInit/init.ls (function(){ return function(player, slide){ var ref$, ref1$, lastChild; if ((ref$ = slide.div) != null) { ref$.css({ paddingBottom: "1.5em" }); } if ((ref1$ = body.findFirst(".spinner")) != null) { ref1$.remove(); } lastChild = _.last(player.page.childrenAll()); if (lastChild != null) { lastChild.css({ minHeight: "", paddingBottom: "1em", marginBottom: "1em", borderBottom: !((typeof deviceLog != 'undefined' && deviceLog !== null) && deviceLog['var']("hideOnSamePageBorder")) ? "1px solid lightGrey" : void 8 }); } if (slide.trainerParams.deleteLastPage) { return lastChild != null ? lastChild.remove() : void 8; } }; })(); shared/levelPlayer/playNextSlide/onSamePageStart/start.ls (function(){ return function(player, slide){ if (slide.trainerParams.deleteLastPage) { player.page.scrollElementIntoView(slide.div, { instant: true }); } else { player.page.scrollElementIntoView(slide.div); } return slide.trainerParams.deleteLastPage = true; }; })(); shared/levelPlayer/playNextSlide/play.ls (function(){ return function(player){ return function(){ var page, slide, loadSlideMedia, onLoadSlideMediaError, initSlide, startSlide; page = player.page; player.currentSlideIndex++; slide = player.slides[player.currentSlideIndex]; if (!slide) { player.finish(); return; } slide.slideStartedAt = new Date(); player.currentSlide = slide; loadSlideMedia = function(){ inc("prepareMediaLoadingSpinner/spinner")(slide, player); return slide.loadMediaFiles({ onError: onLoadSlideMediaError, onDone: initSlide }); }; onLoadSlideMediaError = function(errors){ if (app.currentPage.levelPlayer !== player) {} else if (_.every(errors, { error: "offline" })) { return inc("offlinePopup/popup")(player, loadSlideMedia); } else { return inc("errorPopup/popup")(); } }; initSlide = function(){ if (app.currentPage.levelPlayer !== player) { return; } _.setRandomSeed(player.round * 100 + player.currentSlideIndex); slide.div = Div().addClass("slide"); if (slide.trainerParams.onSamePage && player.currentSlideIndex !== 0) { inc("onSamePageInit/init")(player, slide); } else { page.empty(); } page.append(slide.div); slide.init(); return startSlide(); }; startSlide = function(){ var ref$; if ((ref$ = app.lastSound) != null) { if (typeof ref$.stop == 'function') { ref$.stop(); } } page.bottom.empty().hide(); page.setBottomFreeze(0); page.disableFreezeMinHeight(); page.centerDuration = 0; if (slide.trainerParams.onSamePage && player.currentSlideIndex !== 0) { slide.start(); return inc("onSamePageStart/start")(player, slide); } else { page.pageScrollWrapper.scrollTop = 0; page.css({ transition: "", height: "" }); page.fadeIn(200); return slide.start(); } }; return loadSlideMedia(); }; }; })(); shared/levelPlayer/playNextSlide/prepareMediaLoadingSpinner/spinner.ls (function(){ return function(slide, player){ if (engine.isMobileApp) { return setTimeout(function(){ if (slide.div == null) { if (slide.trainerParams.onSamePage && player.currentSlideIndex !== 0) { inc("../onSamePageInit/init")(player, slide); } else { player.page.empty(); } return player.page.append(inc("/../app01/lib/gui/spinner/spinner")()); } }, 200); } }; })(); shared/levelPlayer/player.ls (function(){ return function(o){ var p; p = {}; p.log = o.log || log; p.level = _.cloneDeep(o.level); p.progressBar = o.progressBar; p.page = o.page; p.context = o.context; p.previewTrainerIndex = o.previewTrainerIndex; p.round = inc("calcRound/calc")(); p.slides = inc("generateSlides/generate")(p); p.totalAtoms = inc("calcTotalAtoms/calc")(p); p.currentSlideIndex = inc("calcCurrentSlideIndex/calc")(p); p.startedAt = new Date(); p.scoreEvents = []; p.onFinish = o.onFinish; p.onAbort = o.onAbort; p.playNextSlide = inc("playNextSlide/play")(p); p.start = inc("start/start")(p); p.finish = inc("finish/finish")(p); p.abort = inc("abort/abort")(p); p.page.levelPlayer = p; inc("calcTotalProgressElements/calc")(p, function(){ p.progressBar.init(p.slides); return p.start(); }); return p; }; })(); shared/levelPlayer/start/debugUnsentEventsMobile/debug.ls (function(){ return function(){ var i$, ref$, len$, l, results$ = []; if (!engine.isMobileApp) { return; } if (!inc("/../app01/lib/util/isOnline/isOnline")()) { return; } for (i$ = 0, len$ = (ref$ = [log, deviceLog]).length; i$ < len$; ++i$) { l = ref$[i$]; try { results$.push(l.getDetails(fn$)); } catch (e$) {} } return results$; function fn$(d){ var total, unsentEvents; total = d.totalUnsentEvents; if (total <= 10) { return; } unsentEvents = _.filter(l.list(), function(e){ return !e.inserted; }); unsentEvents = _.map(unsentEvents, function(e){ return { event: e.event, created: e.created }; }); return helpers.postEvent(l.id(), { event: "debugMobileUnsentEvents", total: d.totalUnsentEvents, details: d, version: 2, eventsOldest: _.first(unsentEvents), eventsNewest: _.last(unsentEvents) }); } }; })(); shared/levelPlayer/start/start.ls (function(){ return function(p){ return function(){ if (engine.isMobileApp) { inc("/../app01/lib/util/audioContext/refresh/refresh")(); } inc("debugUnsentEventsMobile/debug")(); inc("../log/start/start")(p); inc("/../app01/lib/init/classKit/levelPlayer/start/start")(p); inc("../loadSlidesMediaFiles/load")(p); return p.playNextSlide(); }; }; })(); shared/lsg/calcLsg/calc.ls (function(){ return function(lsgParams, mediaParams){ var lsg, ref$; return lsg = _.endsWith(lsgParams.lsg, ".lsg") ? (mediaParams != null ? (ref$ = mediaParams.lsgs) != null ? ref$[lsgParams.lsg] : void 8 : void 8) || inc(lsgParams.lsg) : _.endsWith(lsgParams.lsg, ".lsr") ? inc(lsgParams.lsg)(lsgParams) : (debug("invalid lsg", lsgParams.lsg), null); }; })(); shared/lsg/checkRequiredArguments/check.ls (function(){ return function(lsgParams, lsg){ var i$, ref$, len$, a; for (i$ = 0, len$ = (ref$ = _.ensureArray(lsg.requiredArguments)).length; i$ < len$; ++i$) { a = ref$[i$]; if (lsgParams[a] == null) { console.log("missing required renderer argument \"" + a + "\". Not displaying renderer"); return false; } } return true; }; })(); shared/lsg/div/div.ls (function(){ return function(lsg, mediaParams, width, height, wrapWithDiv){ var div, ref$, wrapper; div = (ref$ = deviceLog['var']("useLsg3Div")) === "yes" || ref$ === "both" ? inc("/../lsg2/lsg3Div/div")({ lsg: _.cloneDeep(lsg), mediaParams: mediaParams }) : Svg({ svg: LSG2.toSVG(lsg, mediaParams.svgs, mediaParams.lsgs, mediaParams.images) }); div.css({ width: width + "px", height: height + "px", verticalAlign: "top" }); if (wrapWithDiv) { wrapper = Div({ margin: "1em auto", textAlign: "center" }).html(div, deviceLog['var']("useLsg3Div") === "both" ? Svg({ svg: LSG2.toSVG(lsg, mediaParams.svgs, mediaParams.lsgs, mediaParams.images) }).css({ width: width + "px", height: height + "px", verticalAlign: "top", marginLeft: "10px" }) : void 8); wrapper.lsg = div; wrapper.updateLayout = div.updateLayout; return wrapper; } else { return div; } }; })(); shared/lsg/lsg.ls (function(){ return function(o){ var lsgParams, slide, parent, wrapWithDiv, ref$, mediaParams, lsg, that, defaultWidth, fontScale, width, height, div; lsgParams = o.lsg; slide = o.slide; parent = o.parent; wrapWithDiv = (ref$ = o.wrapWithDiv) != null ? ref$ : false; if (_.isString(lsgParams)) { lsgParams = { lsg: lsgParams }; } mediaParams = slide.mediaParams; lsgParams.renderLanguage = slide.levelParams.contentLanguagePrimary; lsg = inc("calcLsg/calc")(lsgParams, mediaParams); if (!lsg) { return; } if (!inc("checkRequiredArguments/check")(lsgParams, lsg)) { return; } if (that = _.find(mediaParams.images, function(image){ return _.startsWith(image.id, "pixabay"); })) { debug("image warning for image " + that.id + " embedded in lsg " + lsgParams.lsg + ": pixabay images shouldn't be used anymore."); } lsg = inc("mergeSettings/merge")(lsgParams, lsg); defaultWidth = wrapWithDiv ? 250 : 150; fontScale = inc("/../app01/lib/util/fontSize/calcFontScale/calc")(); width = fontScale * (lsgParams.width || defaultWidth); height = lsg.height * width / lsg.width; div = inc("div/div")(lsg, mediaParams, width, height, wrapWithDiv); div.scaleToParent = inc("scaleToParent/scale")(div, width, height, parent, wrapWithDiv); div.scaleToParent(); div.lsgData = lsg; return div; }; })(); shared/lsg/mergeSettings/merge.ls (function(){ return function(lsgParams, lsg){ var that; if (that = lsgParams.color) { lsg.color = _.merge(lsg.color, that); } if (that = lsgParams.lineColor) { lsg.lineColor = _.merge(lsg.lineColor, that); } if (that = lsgParams.lineSize) { lsg.lineSize = _.merge(lsg.lineSize, that); } if (that = lsgParams.background) { lsg.background = that; } if (that = lsgParams.renderLanguage) { lsg.renderLanguage = that; } return lsg; }; })(); shared/lsg/scaleToParent/calcScale/calc.ls (function(){ return function(width, parent){ var wrapper, that, scaleFactor, parentWidth, scale; wrapper = (that = app.currentPopup) != null ? that.findFirst(".popupContent") : body; scaleFactor = parent == null || parent.width() === wrapper.width() ? 0.95 : 1; if (parent == null) { parent = wrapper; } parentWidth = parent.width() - +parent.css("paddingLeft").replace("px", "") - +parent.css("paddingRight").replace("px", ""); return scale = (parentWidth * scaleFactor) / width; }; })(); shared/lsg/scaleToParent/scale.ls (function(){ return function(div, width, height, parent, wrapWithDiv){ return function(){ var scaleDiv, scale; scaleDiv = wrapWithDiv ? div.lsg : div; scale = inc("calcScale/calc")(width, parent); if (0 < scale && scale < 1) { width = width * scale; height = height * scale; } return scaleDiv.css({ width: width + "px", height: height + "px" }); }; }; })(); shared/playAskSoundOrSoundA/play.ls (function(){ return function(slide, onDone){ var ref$, p, soundMode, voice, ref1$, text, sound; if (!((ref$ = slide.div) != null && ref$.isVisible())) { return; } p = slide.getParam; soundMode = p("soundMode", slide.atom); voice = (ref1$ = p("voiceA", slide.atom)) != null ? ref1$ : p("voice", slide.atom); text = slide.atom.soundA || slide.atom.sound || slide.atom.a; sound = slide.sounds[text + voice]; if (sound) { slide.currentSound = sound; } if (soundMode === "a" || soundMode === "ab") { return sound.play(function(){ return typeof onDone == 'function' ? onDone() : void 8; }); } else if (soundMode === "askSound") { return setTimeout(function(){ return slide.askSound.play(text + voice, function(){ return typeof onDone == 'function' ? onDone() : void 8; }); }, 500); } else { return typeof onDone == 'function' ? onDone() : void 8; } }; })(); shared/playSoundA/play.ls (function(){ return function(atom, slide, onDone, onProgressUpdate){ var p, soundMode, voice, ref$, text, sound, waitInstruction; p = slide.getParam; soundMode = p("soundMode", atom); voice = (ref$ = p("voiceA", atom)) != null ? ref$ : p("voice", atom); text = atom.soundA || atom.sound || atom.a; sound = slide.sounds[text + voice]; waitInstruction = function(cb, delay){ return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: function(){ return setTimeout(cb, delay); } }); }; if (sound && (soundMode === "a" || soundMode === "ab")) { waitInstruction(function(){ var ref$; if ((ref$ = slide.currentSoundA) != null) { ref$.stop(); } slide.currentSoundA = sound; return sound.play(onDone, onProgressUpdate); }, 300); } else if (sound && soundMode === "askSound") { waitInstruction(function(){ var ref$; if ((ref$ = slide.currentSoundA) != null) { ref$.stop(); } slide.currentSoundA = slide.askSound; return slide.askSound.play(text + voice, onDone); }, 500); } else { setTimeout(onDone, 300); } return sound; }; })(); shared/playSoundB/play.ls (function(){ return function(atom, slide, correctValue, onDone, onProgressUpdate){ var p, soundMode, text, voice, ref$, voiceLang, sound; p = slide.getParam; soundMode = p("soundMode", atom); text = atom.soundB || atom.sound || correctValue || atom.b.replace(/<[^>]+>/g, ''); voice = (ref$ = p("voiceB", atom)) != null ? ref$ : p("voice", atom); voiceLang = (ref$ = p("voiceLangB", atom)) != null ? ref$ : p("voiceLang", atom); sound = slide.sounds[text + voice + voiceLang]; if ((soundMode === "b" || soundMode === "ab") && sound) { slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: function(){ return setTimeout(function(){ return sound.play(onDone, onProgressUpdate); }, 300); } }); } else { setTimeout(onDone, 1000); } return sound; }; })(); shared/randomizePositions/layoutForce/layout.ls (function(){ return function(o){ var origin, margin, numSteps, width, height, rects, i$, ref$, len$, e, maxdist, pullToCenter, distance, calculateForce, setApart, move, updateLayout, performStep, i, results$ = []; origin = { x: o.parentOffset.left, y: o.parentOffset.top }; margin = o.margin || 0; numSteps = 200; width = o.parentOffset.width - 2 * margin; height = o.parentOffset.height - 2 * margin; rects = []; for (i$ = 0, len$ = (ref$ = o.elements).length; i$ < len$; ++i$) { e = ref$[i$]; rects.push(inc("rect/rect")(e, origin)); } maxdist = Math.max(width, height); pullToCenter = function(rect){ var dx, dy, dist, d; dx = rect.centerX - (margin + width / 2); dy = rect.centerY - (margin + height / 2); dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); dx /= dist; dy /= dist; d = dist * 0.08; rect.dx -= dx * d; return rect.dy -= dy * d; }; distance = function(r1, r2){ var dx, dy; dx = Math.max(0, Math.abs(r1.centerX - r2.centerX) - (r1.width + r2.width) / 2); dy = Math.max(0, Math.abs(r1.centerY - r2.centerY) - (r1.height + r2.height) / 2); return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); }; calculateForce = function(rect){ var i$, ref$, len$, r, dx, dy, l, dist, d, results$ = []; rect.dx = 0; rect.dy = 0; pullToCenter(rect); for (i$ = 0, len$ = (ref$ = rects).length; i$ < len$; ++i$) { r = ref$[i$]; if (r !== rect) { dx = rect.centerX - r.centerX; dy = rect.centerY - r.centerY; l = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); dx /= l; dy /= l; dist = distance(rect, r); d = maxdist / (dist + 50); rect.dx += dx * d; results$.push(rect.dy += dy * d); } } return results$; }; setApart = function(rect1){ var i$, ref$, len$, rect2, results$ = []; for (i$ = 0, len$ = (ref$ = rects).length; i$ < len$; ++i$) { rect2 = ref$[i$]; if (rect2 !== rect1) { if (rect1.x === rect2.x && rect1.y === rect2.y && rect1.width === rect2.width && rect1.height === rect2.height) { rect1.x = margin + Math.random() * (width - rect1.width); results$.push(rect1.y = margin + Math.random() * (height - rect1.height)); } } } return results$; }; move = function(r){ r.x += r.dx; r.y += r.dy; if (r.x < margin) { r.x = margin; } if (r.y < margin) { r.y = margin; } if (r.x + r.width > margin + width) { r.x = margin + width - r.width; } if (r.y + r.height > margin + height) { r.y = margin + height - r.height; } setApart(r); r.centerX = r.x + r.width / 2; return r.centerY = r.y + r.height / 2; }; updateLayout = function(rect){ return rect.element.css({ left: rect.x + "px", top: rect.y + "px" }); }; performStep = function(){ var i$, ref$, len$, r, results$ = []; for (i$ = 0, len$ = (ref$ = rects).length; i$ < len$; ++i$) { r = ref$[i$]; calculateForce(r); } for (i$ = 0, len$ = (ref$ = rects).length; i$ < len$; ++i$) { r = ref$[i$]; move(r); results$.push(updateLayout(r)); } return results$; }; if (o.animated) { for (i$ = 0; i$ < numSteps; ++i$) { i = i$; results$.push(setTimeout(fn$, 10 * i)); } return results$; } else { return _.times(numSteps, performStep); } function fn$(){ return performStep(); } }; })(); shared/randomizePositions/layoutForce/rect/rect.ls (function(){ return function(o, origin){ var offset, rect; offset = o.offset(); rect = { x: offset.left - origin.x, y: offset.top - origin.y, width: offset.width, height: offset.height, element: o, dx: 0, dy: 0, centerX: offset.left - origin.x + offset.width / 2, centerY: offset.top - origin.y + offset.height / 2 }; return rect; }; })(); shared/randomizePositions/layoutSpaceDivide/layout.ls (function(){ return function(o){ var margin, mainRect, spaces, validateSplit, splitRect, placeElement, elements, i$, len$, e; margin = o.margin || 0; mainRect = inc("rect/rect")({ x: margin, y: margin, width: o.width - 2 * margin, height: o.height - 2 * margin }); spaces = [mainRect]; validateSplit = function(rect, split){ if (split.x < rect.x) { split.x = rect.x; } if (split.y < rect.y) { split.y = rect.y; } if (split.x + split.width > rect.x + rect.width) { split.width = rect.x + rect.width - split.x; } if (split.y + split.height > rect.y + rect.height) { return split.height = rect.y + rect.height - split.y; } }; splitRect = function(rect, innerRect){ var splits1, top, bottom, left, right, i$, len$, s, splits2, splits, split; splits1 = [ top = inc("rect/rect")({ x: rect.x, y: rect.y, width: rect.width, height: innerRect.y - rect.y }), bottom = inc("rect/rect")({ x: rect.x, y: innerRect.y + innerRect.height, width: rect.width, height: rect.y + rect.height - (innerRect.y + innerRect.height) }), left = inc("rect/rect")({ x: rect.x, y: innerRect.y, width: innerRect.x - rect.x, height: innerRect.height }), right = inc("rect/rect")({ x: innerRect.x + innerRect.width, y: innerRect.y, width: rect.x + rect.width - innerRect.x - innerRect.width, height: innerRect.height }) ]; for (i$ = 0, len$ = splits1.length; i$ < len$; ++i$) { s = splits1[i$]; validateSplit(rect, s); } splits2 = [ top = inc("rect/rect")({ x: innerRect.x, y: rect.y, width: innerRect.width, height: innerRect.y - rect.y }), bottom = inc("rect/rect")({ x: innerRect.x, y: innerRect.y + innerRect.height, width: innerRect.width, height: rect.y + rect.height - (innerRect.y + innerRect.height) }), left = inc("rect/rect")({ x: rect.x, y: rect.y, width: innerRect.x - rect.x, height: rect.height }), right = inc("rect/rect")({ x: innerRect.x + innerRect.width, y: rect.y, width: rect.x + rect.width - innerRect.x - innerRect.width, height: rect.height }) ]; for (i$ = 0, len$ = splits2.length; i$ < len$; ++i$) { s = splits2[i$]; validateSplit(rect, s); } splits = _.maxBy(splits1, "area") > _.maxBy(splits2, "area") ? splits1 : splits2; for (i$ = 0, len$ = splits.length; i$ < len$; ++i$) { split = splits[i$]; if (split.width > 0 && split.height > 0) { spaces.push(split); } } return spaces = _.sortBy(spaces, ["area"]); }; placeElement = function(rect, element){ var offset, x, y, innerRect; rect == null && (rect = mainRect); offset = element.offset(); x = rect.x + Math.random() * (rect.width - offset.width); y = rect.y + Math.random() * (rect.height - offset.height); innerRect = inc("rect/rect")({ x: x, y: y, width: offset.width, height: offset.height }); splitRect(rect, innerRect); return element.css({ left: x + "px", top: y + "px", opacity: 1 }); }; elements = _.sortBy(o.elements, [function(e){ return e.offset().width; }]); for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { e = elements[i$]; e.css({ opacity: 0 }); } return _.forEach(elements, function(element){ var e, offset; e = elements.pop(); offset = e.offset(); return placeElement(spaces.pop(), e); }); }; })(); shared/randomizePositions/layoutSpaceDivide/rect/rect.ls (function(){ return function(o){ var rect; rect = { x: o.x, y: o.y, width: o.width, height: o.height }; rect.area = rect.width * rect.height; return rect; }; })(); shared/randomizePositions/randomize.ls (function(){ return function(elements, parent){ inc("layoutSpaceDivide/layout")({ elements: elements, width: parent.width(), height: parent.height(), margin: 5 }); return inc("layoutForce/layout")({ elements: elements, parentOffset: parent.offset(), margin: 5, animated: false }); }; })(); shared/removeBracket/remove.ls (function(){ return function(s){ var a, s2, i$, len$, p; s = s.split("(").join("|||("); s = s.split(")").join(")|||"); a = s.split("|||"); s2 = ""; for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { p = a[i$]; if (p[0] !== "(") { s2 += p; } } s2 = s2.trim(); s2 = s2.replace(/\s\s+/g, " "); return s2; }; })(); shared/score/feedback/addTrainerSpecificFeedback/add.ls (function(){ return function(feedbackAll, slide, atom, action){ var trainer, o, ref$; trainer = slide.trainerParams.trainer; if (trainer === "findAll" && atom.objects != null) { o = _.find(atom.objects, function(obj){ return obj['class'] === (action != null ? action['class'] : void 8); }); return (ref$ = slide.getParam("feedback", o)) != null ? ref$ : feedbackAll; } else { return feedbackAll; } }; })(); shared/score/feedback/calcFeedback/calc.ls (function(){ return function(action, feedback, feedbackType){ var index, ref$; index = ((ref$ = action != null ? action.mixedGapIndex : void 8) != null ? ref$ : (ref$ = action != null ? action.gap : void 8) != null ? ref$ : action != null ? action.index : void 8) + 1; return feedback = index ? (ref$ = feedback != null ? feedback[feedbackType + index] : void 8) != null ? ref$ : feedback != null ? feedback[feedbackType] : void 8 : feedback != null ? feedback[feedbackType] : void 8; }; })(); shared/score/feedback/feedback.ls (function(){ return function(slide, atom, action, feedbackType, callback){ var feedbackAll, feedback; feedbackAll = slide.getParam("feedback", atom); if (feedbackAll != null && feedbackAll.text) { debug("warning: feedback malformed. the feedback text must be defined underneath a correct/wrong/end/finish property", feedbackAll); } feedbackAll = inc("addTrainerSpecificFeedback/add")(feedbackAll, slide, atom, action); feedback = inc("calcFeedback/calc")(action, feedbackAll, feedbackType); if (!feedback) { if (typeof callback == 'function') { callback(); } return; } return inc("/shared/feedback/feedback")(feedback, slide, callback); }; })(); shared/score/getScoreEvent/get.ls (function(){ return function(slide, atom){ var scoreEvent; if (atom) { return scoreEvent = _.find(slide.levelParams.scoreEvents, function(e){ return e.matchingAtom === atom; }); } else { return scoreEvent = _.find(slide.levelParams.scoreEvents, function(e){ return e.matchingTrainer === slide.trainerParams; }); } }; })(); shared/score/score.ls (function(){ return function(slide){ var scores, getScore, feedback, addActionRetry, addActionResolved, addActionCorrect, addActionMistake, log, logUnloggedAtoms, getScoreEvent; scores = []; getScore = function(atom){ var score; score = _.find(scores, function(s){ return s.atom === atom; }); if (!score) { scores.push(score = { atom: atom, score: inc("score/score")(slide, atom) }); } return score.score; }; feedback = inc("feedback/feedback"); addActionRetry = function(atom, action, callback){ var s; s = getScore(atom); s.addActionRetry(action); return feedback(slide, atom, action, "retry", callback); }; addActionResolved = function(atom, action, callback){ var s; s = getScore(atom); s.addActionResolved(action); return feedback(slide, atom, action, "solution", callback); }; addActionCorrect = function(atom, action, callback){ var s; s = getScore(atom); s.addActionCorrect(action); return feedback(slide, atom, action, "correct", callback); }; addActionMistake = function(atom, action, callback){ var s; s = getScore(atom); s.addActionMistake(action); return feedback(slide, atom, action, "wrong", callback); }; log = function(atom, callback){ var s; s = getScore(atom); s.log(); return feedback(slide, atom, null, "end", callback); }; logUnloggedAtoms = function(type){ var i$, ref$, len$, s, results$ = []; for (i$ = 0, len$ = (ref$ = scores).length; i$ < len$; ++i$) { s = ref$[i$]; s = s.score; if (!s.isLogged()) { results$.push(s.log({ type: type })); } } return results$; }; getScoreEvent = function(atom){ return inc("getScoreEvent/get")(slide, atom); }; return slide.score = { addActionCorrect: addActionCorrect, addActionMistake: addActionMistake, addActionResolved: addActionResolved, addActionRetry: addActionRetry, getScoreEvent: getScoreEvent, log: log, logUnloggedAtoms: logUnloggedAtoms, totalScoredAtoms: function(){ return scores.length; } }; }; })(); shared/score/score/score.ls (function(){ return function(slide, atom){ var isLogged, score, ref$, addAction, addActionRetry, addActionResolved, addActionCorrect, addActionMistake, logScore; isLogged = false; if (!slide.lastScoreActionAt) { slide.lastScoreActionAt = slide.slideStartedAt; } score = { mistakes: 0, actions: [], levelPuid: slide.levelParams.puid, round: (ref$ = slide.levelPlayer) != null ? ref$.round : void 8, trainer: slide.trainerParams.trainer, level: inc("/../app01/lib/util/projectPath/path")(slide.levelParams.path) }; if (_.isArray(atom)) { score.atoms = atom; } else { score.atom = atom; } addAction = function(action){ var now; now = new Date(); action.position = _.round((new Date() - slide.levelPlayer.startedAt) / 100, 0); action.duration = _.round((now - slide.lastScoreActionAt) / 100, 0); slide.lastScoreActionAt = now; return score.actions.push(action); }; addActionRetry = function(a){ var a2; a2 = _.cloneDeep(a || {}); a2.retry = true; return addAction(a2); }; addActionResolved = function(a){ var a2; a2 = _.cloneDeep(a || {}); a2.resolved = true; return addAction(a2); }; addActionCorrect = function(a){ var a2; a2 = _.cloneDeep(a || {}); a2.correct = true; return addAction(a2); }; addActionMistake = function(a){ var a2; a2 = _.cloneDeep(a || {}); a2.correct = false; score.mistakes++; return addAction(a2); }; logScore = function(o){ var e, p, ref$, v; isLogged = true; e = { event: "score" }; if ((o != null ? o.unfinished : void 8) === true) { e.unfinished = true; } for (p in ref$ = score) { v = ref$[p]; if (!_.isFunction(v)) { e[p] = v; } } return slide.levelPlayer.log.log(e); }; return { addActionCorrect: addActionCorrect, addActionMistake: addActionMistake, addActionResolved: addActionResolved, addActionRetry: addActionRetry, log: logScore, isLogged: function(){ return isLogged; } }; }; })(); shared/scoreActionRow/_t.ls (function(){ return { secAbbrev: { de: "s", en: "s", fr: " sec", es: "s", pt: "s" } }; })(); shared/scoreActionRow/duration/duration.ls (function(){ return function(action){ var d, ref$; if (!action.duration) { return; } d = _.round(action.duration / 10, 1); d = d.toFixed(1); if ((ref$ = engine.guiLanguage) === "de" || ref$ === "fr") { d = d.replace(".", ","); } return Div({ position: "absolute", right: 0, top: 0, color: Color.grey[500], padding: "0.4em 0.6em" }).append(Div({ display: "inline-block" }).html(d + T("secAbbrev"))); }; })(); shared/scoreActionRow/iconScore/icon.ls (function(){ return function(action){ return SvgIcon({ svg: action.correct ? path("/../app01/lib/svg/illustration/feedback-correct.svg") : action.resolved ? path("/../app01/lib/svg/illustration/feedback-resolved.svg") : action.retry ? path("/../app01/lib/svg/illustration/feedback-retry.svg") : path("/../app01/lib/svg/illustration/feedback-wrong.svg") }).css({ position: "absolute", left: "0.4em", top: "0.57em" }); }; })(); shared/scoreActionRow/row.ls (function(){ return function(action){ return Div({ padding: "0.4em 3em 0.5em 1.8em", marginBottom: "0.4em", backgroundColor: Color.grey[150] }).append(inc("iconScore/icon")(action), inc("duration/duration")(action)); }; })(); shared/scoreActionRowFlex/_t.ls (function(){ return { secAbbrev: { de: "s", en: "s", fr: " sec", es: "s", pt: "s" } }; })(); shared/scoreActionRowFlex/duration/duration.ls (function(){ return function(action){ var d, ref$; if (!action.duration) { return; } d = _.round(action.duration / 10, 1); d = d.toFixed(1); if ((ref$ = engine.guiLanguage) === "de" || ref$ === "fr") { d = d.replace(".", ","); } return Div({ color: Color.grey[500], padding: "0.4em 0.6em" }).append(Div({ display: "inline-block" }).html(d + T("secAbbrev"))); }; })(); shared/scoreActionRowFlex/iconScore/icon.ls (function(){ return function(action){ return SvgIcon({ svg: action.correct ? path("/../app01/lib/svg/illustration/feedback-correct.svg") : action.resolved ? path("/../app01/lib/svg/illustration/feedback-resolved.svg") : path("/../app01/lib/svg/illustration/feedback-wrong.svg") }).css({ margin: "0.3em" }); }; })(); shared/scoreActionRowFlex/row.ls (function(){ return function(action, centerHtml){ var div; div = Div(); return div.css({ display: "flex", padding: "0.2em", marginBottom: "0.4em", backgroundColor: Color.grey[150] }).append(inc("iconScore/icon")(action), Div({ flex: "1 1 auto" }).append(centerHtml), inc("duration/duration")(action)); }; })(); shared/slide/calcTotalProgressElements/calc.ls (function(){ return function(slide){ return function(onDone){ var path, calcFunction; path = slide.trainerFolder + "/_calcTotalProgressElements/calc"; calcFunction = inc(path, { silentError: true }); if (_.isFunction(calcFunction)) { return calcFunction(slide, onDone); } else { return onDone(); } }; }; })(); shared/slide/finish/finish.ls (function(){ return function(slide){ var enableFinishSoundNext; enableFinishSoundNext = typeof deviceLog != 'undefined' && deviceLog !== null ? deviceLog['var']("finishSoundNext") : void 8; if (enableFinishSoundNext === "v1" || enableFinishSoundNext === "v2" || enableFinishSoundNext === "v3") { if (enableFinishSoundNext === "v1") { return inc("finishV1/finish")(slide); } if (enableFinishSoundNext === "v2") { return inc("finishV2/finish")(slide); } if (enableFinishSoundNext === "v3") { return inc("finishV3/finish")(slide); } } return function(onFinish){ var ref$, button, callback, playFinishSound, showFinishFeedback, showFinishButton; if ((ref$ = body.findFirst(".feedbackContainer")) != null && ref$.isVisible()) { slide.finishAfterFeedback = true; return; } button = null; callback = function(){ return (typeof onFinish == 'function' ? onFinish() : void 8) || slide.onFinishedSlide(); }; playFinishSound = function(){ var atom, ref$, finishSound, ref1$, voice; atom = (ref$ = slide.atom) != null && ref$.finishSound ? slide.atom : void 8; finishSound = slide.getParam("finishSound", atom); if (finishSound) { if ((ref1$ = slide.instruction) != null) { ref1$.stop(); } if (slide.finishButton === true) { setTimeout(showFinishButton, 3000); } voice = slide.getParam("voice", atom); return slide.sounds[finishSound + voice].play(showFinishFeedback); } else { return showFinishFeedback(); } }; showFinishFeedback = function(){ var atom, ref$, ref1$, feedback, ref2$; atom = (ref$ = slide.atom) != null && ((ref1$ = ref$.feedback) != null && ref1$.finish) ? slide.atom : void 8; feedback = (ref2$ = slide.getParam("feedback", atom)) != null ? ref2$.finish : void 8; if (feedback) { return inc("/shared/feedback/feedback")(feedback, slide, showFinishButton); } else { return showFinishButton(); } }; showFinishButton = function(){ if (!slide.finishButton) { slide.levelPlayer.page.bottom.empty().hide(); return callback(); } else if (button == null) { button = inc("/shared/continueButton/button")(callback); button.prepend(slide.divBeforeFinishButton); return button.showButton(); } }; return playFinishSound(); }; }; })(); shared/slide/finish/finishV1/continueSpeakerButton/button.ls (function(){ return function(sound, callback, label){ var children, bottom, tap, showButton, div, speaker; children = null; bottom = app.currentPage.bottom; tap = function(){ div.css({ pointerEvents: "none" }); return bottom.keyframeAnimate({ keyframes: { "0%": { transform: "translateY(0%)" }, "100%": { transform: "translateY(100%)" } }, duration: 400, delay: 100, onCompleted: function(){ sound.stop(); div.remove(); bottom.css({ transform: "" }).append(children); return callback(); } }); }; showButton = function(){ var h; if (app.currentPage.levelPlayer == null) { return; } children = bottom.childrenAll(); bottom.html(div).show(); h = div.height(); return div.keyframeAnimate({ keyframes: { "0%": { height: "0px" }, "100%": { height: h + "px" } }, duration: 500, onCompleted: function(){ return div.css({ height: "" }); } }); }; div = Div(); div.css({ textAlign: "center" }).addClass("continueSpeakerButton").html(Button(label).css({ margin: "0.8em", textAlign: "center", color: Color.grey[800] }).prepend(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ progressbarType: "below", progressBarFillDirection: "left", speakerType: "123", size: "1.8em" }).css({ marginRight: "0.5em" })).tap(tap).addClass("keyManager-enter").bind("keyManager", tap)); speaker.findFirst(".progressBarVolume").css({ backgroundColor: Color.grey[600] }); speaker.findFirst(".speaker").setColor(Color.grey[600]); div.showButton = showButton; div.speaker = speaker; return div; }; })(); shared/slide/finish/finishV1/finish.ls (function(){ return function(slide){ return function(onFinish){ var ref$, callback, playFinishSound, showFinishFeedback, showFinishButton; if ((ref$ = body.findFirst(".feedbackContainer")) != null && ref$.isVisible()) { slide.finishAfterFeedback = true; return; } callback = function(){ return (typeof onFinish == 'function' ? onFinish() : void 8) || slide.onFinishedSlide(); }; playFinishSound = function(){ return inc("playFinishSound/play")(slide, callback, showFinishFeedback, showFinishButton); }; showFinishFeedback = function(){ return inc("showFinishFeedback/show")(slide, callback, showFinishButton); }; showFinishButton = function(){ return inc("showFinishButton/show")(slide, callback); }; return playFinishSound(); }; }; })(); shared/slide/finish/finishV1/playFinishSound/play.ls (function(){ return function(slide, callback, showFinishFeedback, showFinishButton){ var atom, ref$, finishSound, ref1$, voice, sound; atom = (ref$ = slide.atom) != null && ref$.finishSound ? slide.atom : void 8; finishSound = slide.getParam("finishSound", atom); if (slide.getParam("feedback", atom)) { callback = showFinishFeedback; } if (finishSound) { if ((ref1$ = slide.instruction) != null) { ref1$.stop(); } voice = slide.getParam("voice", atom); sound = slide.sounds[finishSound + voice]; inc("../showFinishSound/show")(slide, sound, callback); return sound.play(callback, slide.speakerButton.speaker.update); } else { return showFinishFeedback(); } }; })(); shared/slide/finish/finishV1/showFinishButton/show.ls (function(){ return function(slide, callback){ var disableAnimation, ref$; if (!slide.finishButton) { slide.levelPlayer.page.bottom.empty().hide(); return callback(); } else if (slide.continuebutton == null) { disableAnimation = (ref$ = slide.speakerButton) != null ? ref$.isVisible() : void 8; slide.continuebutton = inc("/shared/continueButton/button")(callback, disableAnimation); slide.continuebutton.prepend(slide.divBeforeFinishButton); return slide.continuebutton.showButton(); } }; })(); shared/slide/finish/finishV1/showFinishFeedback/show.ls (function(){ return function(slide, callback, showFinishButton){ var atom, ref$, ref1$, feedback, ref2$; atom = (ref$ = slide.atom) != null && ((ref1$ = ref$.feedback) != null && ref1$.finish) ? slide.atom : void 8; feedback = (ref2$ = slide.getParam("feedback", atom)) != null ? ref2$.finish : void 8; if (feedback) { return inc("/shared/feedback/feedback")(feedback, slide, showFinishButton); } else if (slide.finishButton) { return showFinishButton(); } else { slide.levelPlayer.page.bottom.empty().hide(); return callback(); } }; })(); shared/slide/finish/finishV1/showFinishSound/calcLabel/calc.ls (function(){ return function(slide){ var atom, ref$; atom = (ref$ = slide.atom) != null && ref$.finishSound ? slide.atom : void 8; if (!slide.getParam("feedback", atom)) { return "Weiter"; } else { return null; } }; })(); shared/slide/finish/finishV1/showFinishSound/show.ls (function(){ return function(slide, sound, callback){ var label; label = inc("calcLabel/calc")(slide); slide.speakerButton = inc("../continueSpeakerButton/button")(sound, callback, label); slide.speakerButton.prepend(slide.divBeforeFinishButton); return slide.speakerButton.showButton(); }; })(); shared/slide/finish/finishV2/continueSpeakerButton/button.ls (function(){ return function(sound){ var children, bottom, showIcon, div, speaker; children = null; bottom = app.currentPage.bottom; showIcon = function(){ var h; if (app.currentPage.levelPlayer == null) { return; } children = bottom.childrenAll(); bottom.html(div).show(); h = div.height(); return div.keyframeAnimate({ keyframes: { "0%": { height: "0px" }, "100%": { height: h + "px" } }, duration: 500, onCompleted: function(){ return div.css({ height: "" }); } }); }; div = Div(); div.css({ margin: "0.8em", textAlign: "center", display: "flex" }).addClass("continueSpeakerButton").html(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ progressbarType: "below", progressBarFillDirection: "left", speakerType: "123", size: "1.8em" }).css({ marginRight: "0.5em" })); speaker.findFirst(".progressBarVolume").css({ backgroundColor: Color.grey[600] }); speaker.findFirst(".speaker").setColor(Color.grey[600]); div.showIcon = showIcon; div.speaker = speaker; return div; }; })(); shared/slide/finish/finishV2/finish.ls (function(){ return function(slide, enableFinishSoundNext){ return function(onFinish){ var ref$, callback, playFinishSound, showFinishFeedback, showFinishButton; if ((ref$ = body.findFirst(".feedbackContainer")) != null && ref$.isVisible()) { slide.finishAfterFeedback = true; return; } callback = function(){ return (typeof onFinish == 'function' ? onFinish() : void 8) || slide.onFinishedSlide(); }; playFinishSound = function(){ return inc("playFinishSound/play")(slide, callback, showFinishFeedback, showFinishButton); }; showFinishFeedback = function(){ return inc("showFinishFeedback/show")(slide, callback, showFinishButton); }; showFinishButton = function(){ return inc("showFinishButton/show")(slide, callback); }; return playFinishSound(); }; }; })(); shared/slide/finish/finishV2/playFinishSound/play.ls (function(){ return function(slide, callback, showFinishFeedback, showFinishButton){ var atom, ref$, finishSound, that, ref1$; atom = (ref$ = slide.atom) != null && ref$.finishSound ? slide.atom : void 8; finishSound = slide.getParam("finishSound", atom); if (slide.getParam("feedback", atom)) { callback = showFinishFeedback; } if (that = finishSound) { if ((ref1$ = slide.instruction) != null) { ref1$.stop(); } inc("showFinishButton/show")(slide, callback); return inc("playSound/play")(slide, showFinishFeedback, atom, that); } else { return showFinishFeedback(); } }; })(); shared/slide/finish/finishV2/playFinishSound/playSound/play.ls (function(){ return function(slide, showFinishFeedback, atom, finishSound){ var voice, sound, playSoundCb; voice = slide.getParam("voice", atom); sound = slide.sounds[finishSound + voice]; playSoundCb = function(){ inc("../../showFinishSound/show")(slide); return sound.play(showFinishFeedback, slide.speakerIcon.speaker.update); }; return inc("playIfNotMuted/play")(playSoundCb, showFinishFeedback); }; })(); shared/slide/finish/finishV2/playFinishSound/playSound/playIfNotMuted/play.ls (function(){ return function(playSoundCb, showFinishFeedback){ var antonVolumeMuted, deviceVolumeMuted, muteSwitchEnabled, calcIsMuted, calcDeviceVolume, calcMuteSwitchEnabled; calcIsMuted = function(){ if (antonVolumeMuted) { showFinishFeedback(); } if (window.SolocodePlugin) { return calcDeviceVolume(); } }; calcDeviceVolume = function(){ if (engine.isiOsApp) { return cordova.exec(function(volume){ deviceVolumeMuted = volume === 0; return calcMuteSwitchEnabled(); }, function(volume){ deviceVolumeMuted = volume === 0; return calcMuteSwitchEnabled(); }, "SolocodePlugin", "getVolume", []); } else { return SolocodePlugin.getVolume(function(volume, error){ deviceVolumeMuted = volume === 0; if (deviceVolumeMuted) { showFinishFeedback(); } else { return playSoundCb(); } }); } }; calcMuteSwitchEnabled = function(){ return SolocodePlugin.getMuteSwitchEnabled(function(isEnabled){ muteSwitchEnabled = isEnabled; if (muteSwitchEnabled && deviceVolumeMuted) { showFinishFeedback(); } else { return playSoundCb(); } }); }; return calcIsMuted(); }; })(); shared/slide/finish/finishV2/playFinishSound/showFinishButton/continueButton/button.ls (function(){ return function(callback){ var click, button; click = function(){ return callback(); }; return button = Button({ key: "enter", action: click, label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", state: "disabled" }).css({ margin: "0.8em", backgroundClip: "border-box" }); }; })(); shared/slide/finish/finishV2/playFinishSound/showFinishButton/show.ls (function(){ return function(slide, callback){ var atom, ref$, ref1$, ref2$; atom = (ref$ = slide.atom) != null && ((ref1$ = ref$.feedback) != null && ref1$.finish) ? slide.atom : void 8; if (slide.continueButton == null && !((ref2$ = slide.getParam("feedback", atom)) != null && ref2$.finish)) { slide.continueButton = inc("/shared/continueButton/button/button")(callback); slide.continueButton = inc("continueButton/button")(callback); return slide.speakerIcon.append(slide.continueButton); } }; })(); shared/slide/finish/finishV2/showFinishButton/show.ls (function(){ return function(slide, callback){ var atom, ref$, ref1$, ref2$, disableAnimation, ref3$; atom = (ref$ = slide.atom) != null && ((ref1$ = ref$.feedback) != null && ref1$.finish) ? slide.atom : void 8; if (!((ref2$ = slide.getParam("feedback", atom)) != null && ref2$.finish)) { slide.continueButton.setState("normal"); } if (!slide.finishButton) { slide.levelPlayer.page.bottom.empty().hide(); return callback(); } else if (slide.continuebutton == null) { disableAnimation = (ref3$ = slide.speakerButton) != null ? ref3$.isVisible() : void 8; slide.continuebutton = inc("/shared/continueButton/button")(callback, disableAnimation); slide.continuebutton.prepend(slide.divBeforeFinishButton); return slide.continuebutton.showButton(); } }; })(); shared/slide/finish/finishV2/showFinishFeedback/show.ls (function(){ return function(slide, callback, showFinishButton){ var atom, ref$, ref1$, feedback, ref2$; atom = (ref$ = slide.atom) != null && ((ref1$ = ref$.feedback) != null && ref1$.finish) ? slide.atom : void 8; feedback = (ref2$ = slide.getParam("feedback", atom)) != null ? ref2$.finish : void 8; if (feedback) { return inc("/shared/feedback/feedback")(feedback, slide, showFinishButton); } else if (slide.finishButton) { return slide.continueButton.setState("normal"); } else { slide.levelPlayer.page.bottom.empty().hide(); return callback(); } }; })(); shared/slide/finish/finishV2/showFinishSound/calcLabel/calc.ls (function(){ return function(slide){ var atom, ref$; atom = (ref$ = slide.atom) != null && ref$.finishSound ? slide.atom : void 8; if (!slide.getParam("feedback", atom)) { return "Weiter"; } else { return null; } }; })(); shared/slide/finish/finishV2/showFinishSound/show.ls (function(){ return function(slide, sound, callback){ slide.speakerIcon = inc("../continueSpeakerButton/button")(sound); slide.speakerIcon.prepend(slide.divBeforeFinishButton); return slide.speakerIcon.showIcon(); }; })(); shared/slide/finish/finishV3/finish.ls (function(){ return function(slide){ return function(onFinish){ var ref$, finishSlide, playFinishSound, showFinishFeedback, showFinishButton; if ((ref$ = body.findFirst(".feedbackContainer")) != null && ref$.isVisible()) { slide.finishAfterFeedback = true; return; } finishSlide = function(){ slide.levelPlayer.page.bottom.empty().hide(); return (typeof onFinish == 'function' ? onFinish() : void 8) || slide.onFinishedSlide(); }; playFinishSound = function(){ return inc("playFinishSound/play")(slide, finishSlide, showFinishFeedback, showFinishButton); }; showFinishFeedback = function(){ return inc("showFinishFeedback/show")(slide, finishSlide, showFinishButton); }; showFinishButton = function(){ return inc("showFinishButton/show")(slide, finishSlide); }; return playFinishSound(); }; }; })(); shared/slide/finish/finishV3/playFinishSound/play.ls (function(){ return function(slide, finishSlide, showFinishFeedback, showFinishButton){ var atom, ref$, finishSound, onDone, ref1$, voice, sound, speakerDiv, that; atom = (ref$ = slide.atom) != null && ref$.finishSound ? slide.atom : void 8; finishSound = slide.getParam("finishSound", atom); onDone = slide.getParam("feedback", atom) ? showFinishFeedback : slide.finishButton ? showFinishButton : finishSlide; if (finishSound) { if ((ref1$ = slide.instruction) != null) { ref1$.stop(); } voice = slide.getParam("voice", atom); sound = slide.sounds[finishSound + voice]; speakerDiv = inc("speakerDiv/div")(sound); if (that = slide.divBeforeFinishButton) { speakerDiv.prepend(that); } if (finishSound.split(" ").length > 1) { speakerDiv.showSpeaker(); } return sound.play(onDone, speakerDiv.speaker.update); } else { return onDone(); } }; })(); shared/slide/finish/finishV3/playFinishSound/speakerDiv/div.ls (function(){ return function(sound){ var div, speaker; div = Div({ textAlign: "center" }).html(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ progressbarType: "below", progressBarFillDirection: "left", speakerType: "123", size: "1.8em" }).css({ marginRight: "0.5em", margin: "0.8em", textAlign: "center", color: Color.grey[800] }).addClass("speaker")); div.speaker = speaker; div.showSpeaker = function(){ return inc("showSpeaker/show")(div); }; return div; }; })(); shared/slide/finish/finishV3/playFinishSound/speakerDiv/showSpeaker/show.ls (function(){ return function(div){ if (app.currentPage.levelPlayer == null) { return; } app.currentPage.bottom.html(div).show(); return div.keyframeAnimate({ keyframes: { "0%": { height: "0px" }, "100%": { height: div.height() + "px" } }, duration: 500, onCompleted: function(){ return div.css({ height: "" }); } }); }; })(); shared/slide/finish/finishV3/showFinishButton/show.ls (function(){ return function(slide, finishSlide){ var disableAnimation, ref$; if (!slide.finishButton) { return finishSlide(); } else if (slide.continuebutton == null) { disableAnimation = (ref$ = slide.speakerButton) != null ? ref$.isVisible() : void 8; slide.continuebutton = inc("/shared/continueButton/button")(finishSlide, disableAnimation); slide.continuebutton.prepend(slide.divBeforeFinishButton); return slide.continuebutton.showButton(); } }; })(); shared/slide/finish/finishV3/showFinishFeedback/show.ls (function(){ return function(slide, finishSlide, showFinishButton){ var atom, ref$, ref1$, feedback, ref2$, onDone; atom = (ref$ = slide.atom) != null && ((ref1$ = ref$.feedback) != null && ref1$.finish) ? slide.atom : void 8; feedback = (ref2$ = slide.getParam("feedback", atom)) != null ? ref2$.finish : void 8; onDone = slide.finishButton ? showFinishButton : finishSlide; if (feedback) { return inc("/shared/feedback/feedback")(feedback, slide, showFinishButton); } else { return onDone(); } }; })(); shared/slide/heapInfo/info.ls (function(){ return function(slide){ return inc("/../app01/lib/util/heapInfo/info")("trainer_slide_" + slide.trainerParams.trainer); }; })(); shared/slide/init/init.ls (function(){ return function(slide, folder){ return function(){ return inc(folder + "/init")(slide); }; }; })(); shared/slide/loadMediaFiles/_calcFileMasterEtag/calc.ls (function(){ return function(slide, fileId){ var fileType, levelMediaFiles, ref$, masterEtag, ref1$; fileType = fileId.split("/")[0]; levelMediaFiles = (ref$ = slide.levelParams.mediaFiles) != null ? ref$[fileType + "s"] : void 8; masterEtag = (ref1$ = _.find(levelMediaFiles, { fileId: fileId })) != null ? ref1$.etag : void 8; if (masterEtag) { return masterEtag; } else { return "latest"; } }; })(); shared/slide/loadMediaFiles/_calcMediaArray/calc.ls (function(){ return function(slide, type){ var path, a, project, file, items; path = slide.trainerFolder + ("/_media2/" + type + "/" + type); a = path.split("/"); project = a[2]; file = a.slice(3).join("/") + ".ls"; items = projects.documentCache[project][file] ? inc(path)(slide) : []; items = _.ensureArray(items); items = _.filter(items, function(i){ return i != null; }); items = _.uniqWith(items, _.isEqual); return items; }; })(); shared/slide/loadMediaFiles/_calcSubfolder/calc.ls (function(){ return function(slide){ var project, subfolder; project = slide.levelParams.path.split("/")[2]; return subfolder = _.startsWith(project, "LL-") ? "learnLists/" + project + "/" : "content/" + project + "/"; }; })(); shared/slide/loadMediaFiles/convertToOldMediaParams/convert.ls (function(){ return function(slide){ var mediaFiles, mediaParams; mediaFiles = slide.mediaFiles; mediaParams = { sounds: [], images: [], svgs: [], lsgs: {} }; inc("sounds/sounds")(mediaFiles, mediaParams); inc("images/images")(mediaFiles, mediaParams); inc("svgs/svgs")(mediaFiles, mediaParams); inc("lsgs/lsgs")(mediaFiles, mediaParams); return slide.mediaParams = mediaParams; }; })(); shared/slide/loadMediaFiles/convertToOldMediaParams/images/images.ls (function(){ return function(mediaFiles, mediaParams){ var i$, ref$, len$, image, a, results$ = []; for (i$ = 0, len$ = (ref$ = mediaFiles.images).length; i$ < len$; ++i$) { image = ref$[i$]; a = image.fileId.split("/"); results$.push(mediaParams.images.push({ id: a[1], base64: image.fileContent, url: image.url })); } return results$; }; })(); shared/slide/loadMediaFiles/convertToOldMediaParams/lsgs/lsgs.ls (function(){ return function(mediaFiles, mediaParams){ var i$, ref$, len$, lsg, path, results$ = []; for (i$ = 0, len$ = (ref$ = mediaFiles.lsgs).length; i$ < len$; ++i$) { lsg = ref$[i$]; path = "/../" + lsg.fileId.substr(4); results$.push(mediaParams.lsgs[path] = lsg.fileContent); } return results$; }; })(); shared/slide/loadMediaFiles/convertToOldMediaParams/sounds/calcMediaParamMultiSound/calc.ls (function(){ return function(sound, mediaFiles){ var mediaParamSound, childrenSounds, i$, len$, s, fileId, fileContent, e; mediaParamSound = inc("../calcMediaParamSound/calc")(sound); childrenSounds = inc("/../app01/lib/util/convertSoundString/convert")(mediaParamSound); for (i$ = 0, len$ = childrenSounds.length; i$ < len$; ++i$) { s = childrenSounds[i$]; fileId = "sound/" + s.voiceLang + "/" + s.voice + "/" + s.text; try { fileContent = _.find(mediaFiles.sounds, { fileId: fileId }).fileContent; } catch (e$) { e = e$; debug(fileId); } s.base64 = fileContent; } mediaParamSound.data = childrenSounds; return mediaParamSound; }; })(); shared/slide/loadMediaFiles/convertToOldMediaParams/sounds/calcMediaParamSound/calc.ls (function(){ return function(sound){ var fileId, a, voiceLang, voice, text, mediaParamSound; fileId = sound.fileId; a = fileId.split("/"); voiceLang = a[1]; voice = a[2]; text = fileId.substr(("sound/" + voice + "/" + voiceLang + "/").length); if (voice === "null") { voice = null; } return mediaParamSound = { text: text, voice: voice, voiceLang: voiceLang, data: sound.fileContent }; }; })(); shared/slide/loadMediaFiles/convertToOldMediaParams/sounds/sounds.ls (function(){ return function(mediaFiles, mediaParams){ var i$, ref$, len$, sound, results$ = []; for (i$ = 0, len$ = (ref$ = mediaFiles.sounds).length; i$ < len$; ++i$) { sound = ref$[i$]; if (!sound.isMultiSound) { results$.push(mediaParams.sounds.push(inc("calcMediaParamSound/calc")(sound))); } else if (sound.isMultiSound) { results$.push(mediaParams.sounds.push(inc("calcMediaParamMultiSound/calc")(sound, mediaFiles))); } } return results$; }; })(); shared/slide/loadMediaFiles/convertToOldMediaParams/svgs/svgs.ls (function(){ return function(mediaFiles, mediaParams){ var i$, ref$, len$, svg, path, results$ = []; for (i$ = 0, len$ = (ref$ = mediaFiles.svgs).length; i$ < len$; ++i$) { svg = ref$[i$]; path = "/../" + svg.fileId.substr(4); results$.push(mediaParams.svgs.push({ path: path, svgText: svg.fileContent })); } return results$; }; })(); shared/slide/loadMediaFiles/images/images.ls (function(){ return function(slide, onDone){ var mediaFiles, images, subfolder, totalDone, calcAdditionalImages, loadImages, onImageLoaded, finish; mediaFiles = slide.mediaFiles; images = inc("../_calcMediaArray/calc")(slide, "images"); subfolder = inc("../_calcSubfolder/calc")(slide); totalDone = 0; calcAdditionalImages = function(){ inc("/shared/calcAdditionalMedia/images/images")(slide, images); if (images.length === 0) { return onDone("images"); } else { return loadImages(); } }; loadImages = function(){ var i$, ref$, len$, image, results$ = []; for (i$ = 0, len$ = (ref$ = images).length; i$ < len$; ++i$) { image = ref$[i$]; results$.push(inc("loadImage/load")(image, slide, subfolder, onImageLoaded)); } return results$; }; onImageLoaded = function(){ totalDone++; if (totalDone === images.length) { return finish(); } }; finish = function(){ return onDone("images"); }; return calcAdditionalImages(); }; })(); shared/slide/loadMediaFiles/images/loadImage/load.ls (function(){ return function(image, slide, subfolder, onLoaded){ var mediaFiles, imageId, fileId, fileFolder, fileApi, etag, load, onImageLoaded, onImageError; mediaFiles = slide.mediaFiles; imageId = image.image || image; fileId = "image/" + imageId; fileFolder = subfolder + "_images"; fileApi = slide.fileApi; etag = inc("../../_calcFileMasterEtag/calc")(slide, fileId); load = function(){ return inc("/../app01/lib/util/downloadContentFile/download")({ fileId: fileId, fileFolder: fileFolder, fileApi: fileApi, etag: etag, returnFileContent: true, onLoaded: onImageLoaded, onError: onImageError }); }; onImageLoaded = function(image, details){ mediaFiles.images.push({ fileId: details.fileId, etag: details.responseEtag, url: details.url, fileContent: details.fileContent }); return onLoaded(); }; onImageError = function(error){ mediaFiles.errors.push(error); return onLoaded(); }; return load(); }; })(); shared/slide/loadMediaFiles/initFonts/getUsedLsgFonts/get.ls (function(){ return function(slide){ var fonts, id, ref$, lsg, i$, ref1$, len$, o, parts, ref2$, s; fonts = {}; for (id in ref$ = slide.mediaParams.lsgs) { lsg = ref$[id]; if (_.endsWith(id, ".lsr")) { continue; } for (i$ = 0, len$ = (ref1$ = _.filter(lsg.objects, { type: "text" })).length; i$ < len$; ++i$) { o = ref1$[i$]; o = _.pick(o, "font", "bold", "italic"); parts = []; if (o.bold) { parts.push("bold"); } if (o.italic) { parts.push("italic"); } parts.push("12px"); if ((ref2$ = o.font) !== "Source Sans Pro Solocode" && ref2$ !== "Solocode School") { if (o.font && o.font !== "Source Sans Pro") { debug("invalid font in lsg: " + o.font); } o.font = "Source Sans Pro Solocode"; } parts.push(o.font); s = parts.join(" "); fonts[s] = o; } } return fonts; }; })(); shared/slide/loadMediaFiles/initFonts/init.ls (function(){ return function(slide, onDone){ var fonts, totalFonts, totalDone, loadFonts, onLoaded, ref$; fonts = inc("getUsedLsgFonts/get")(slide); totalFonts = _.keys(fonts).length; totalDone = 0; loadFonts = function(){ var s, ref$, o, results$ = []; for (s in ref$ = fonts) { o = ref$[s]; results$.push(inc("loadFont/load")(s, o, onLoaded)); } return results$; }; onLoaded = function(){ totalDone++; if (totalDone === totalFonts) { return onDone(); } }; if (((ref$ = document.fonts) != null ? ref$.check : void 8) == null || engine.isBotMode) { return onDone(); } else if (totalFonts === 0) { return onDone(); } else { return loadFonts(); } }; })(); shared/slide/loadMediaFiles/initFonts/loadFont/load.ls (function(){ return function(s, o, onLoaded){ var startedAt, maxDuration, div, f; if (document.fonts.check(s)) { onLoaded(); return; } startedAt = new Date(); maxDuration = 2000; div = Div({ position: "absolute", top: "-1000px", font: s }).html("abc").appendTo(body); f = function(){ var age; age = new Date() - startedAt; if (document.fonts.check(s)) { div.remove(); return onLoaded(); } else if (age > maxDuration) { return div.remove(); } else { return setTimeout(f, 30); } }; return f(); }; })(); shared/slide/loadMediaFiles/load.ls (function(){ return function(slide){ slide.loadMediaFilesCallbacks == null && (slide.loadMediaFilesCallbacks = []); return function(p){ var totalDone, load, onLoaded, checkErrors, convertToOldMediaParams, initFonts, initSounds, finish, onError; totalDone = 0; load = function(){ slide.fileApi = p.fileApi; slide.mediaFiles = { images: [], sounds: [], lsgs: [], svgs: [], errors: [] }; inc("images/images")(slide, onLoaded); inc("lsgs/lsgs")(slide, onLoaded); inc("sounds/sounds")(slide, p.skipSounds, onLoaded); return inc("svgs/svgs")(slide, onLoaded); }; onLoaded = function(type){ totalDone++; if (totalDone === 4) { return checkErrors(); } }; checkErrors = function(){ if (slide.mediaFiles.errors.length > 0) { return onError(); } else { return convertToOldMediaParams(); } }; convertToOldMediaParams = function(){ inc("convertToOldMediaParams/convert")(slide); return initFonts(); }; initFonts = function(){ return inc("initFonts/init")(slide, initSounds); }; initSounds = function(){ slide.sounds = !p.skipSounds ? inc("/shared/soundsPre/soundsPre")(slide.mediaParams) : {}; return finish(); }; finish = function(){ var i$, ref$, len$, p2; slide.loadMediaFilesCompleted = true; for (i$ = 0, len$ = (ref$ = slide.loadMediaFilesCallbacks).length; i$ < len$; ++i$) { p2 = ref$[i$]; if (typeof p2.onDone == 'function') { p2.onDone(); } } return slide.loadMediaFilesCallbacks = []; }; onError = function(){ var i$, ref$, len$, p2; slide.loadMediaFilesCompleted = true; for (i$ = 0, len$ = (ref$ = slide.loadMediaFilesCallbacks).length; i$ < len$; ++i$) { p2 = ref$[i$]; if (typeof p2.onError == 'function') { p2.onError(slide.mediaFiles.errors); } } return slide.loadMediaFilesCallbacks = []; }; if (slide.loadMediaFilesCompleted && !slide.mediaFiles.errors.length > 0) { return typeof p.onDone == 'function' ? p.onDone() : void 8; } else { slide.loadMediaFilesCompleted = false; slide.loadMediaFilesCallbacks.push(p); if (slide.loadMediaFilesCallbacks.length === 1) { return load(); } } }; }; })(); shared/slide/loadMediaFiles/lsgs/loadLsgDescriptionMediaFiles/load.ls (function(){ return function(p){ var loadLsg, loadChildrenSvgs, loadChildrenImages, loadChildrenLsgs, finish; loadLsg = function(){ return inc("loadLsg/load")(p, loadChildrenSvgs); }; loadChildrenSvgs = function(){ return inc("loadChildrenSvgs/load")(p, loadChildrenImages); }; loadChildrenImages = function(){ return inc("loadChildrenImages/load")(p, loadChildrenLsgs); }; loadChildrenLsgs = function(){ return inc("loadChildrenLsgs/load")(p, finish); }; finish = function(){ return p.onDone(); }; return loadLsg(); }; })(); shared/slide/loadMediaFiles/lsgs/loadLsgDescriptionMediaFiles/loadChildrenImages/load.ls (function(){ return function(p, onDone){ var imageObjects, ref$, totalDone, loadImages, onImageLoaded, onImageError; imageObjects = _.filter((ref$ = p.lsg) != null ? ref$.objects : void 8, { type: "image" }); imageObjects = _.uniqBy(imageObjects, "image"); totalDone = 0; loadImages = function(){ var i$, ref$, len$, o, fileId, fileFolder, fileApi, etag, results$ = []; for (i$ = 0, len$ = (ref$ = imageObjects).length; i$ < len$; ++i$) { o = ref$[i$]; fileId = "image/" + o.image; fileFolder = p.subfolder + "_images"; fileApi = p.slide.fileApi; etag = inc("../../../_calcFileMasterEtag/calc")(p.slide, fileId); results$.push(inc("/../app01/lib/util/downloadContentFile/download")({ fileId: fileId, fileFolder: fileFolder, fileApi: fileApi, etag: etag, returnFileContent: true, onLoaded: onImageLoaded, onError: onImageError })); } return results$; }; onImageLoaded = function(image, details){ p.slide.mediaFiles.images.push({ fileId: details.fileId, etag: details.responseEtag, url: details.url, fileContent: image }); totalDone++; if (totalDone === imageObjects.length) { return onDone(); } }; onImageError = function(error){ p.slide.mediaFiles.errors.push(error); totalDone++; if (totalDone === imageObjects.length) { return onDone(); } }; if (imageObjects.length === 0) { return onDone(); } else { return loadImages(); } }; })(); shared/slide/loadMediaFiles/lsgs/loadLsgDescriptionMediaFiles/loadChildrenLsgs/load.ls (function(){ return function(p, onDone){ var lsgObjects, ref$, totalDone, loadLsgs, onLoaded; lsgObjects = _.filter((ref$ = p.lsg) != null ? ref$.objects : void 8, { type: "lsg" }); totalDone = 0; loadLsgs = function(){ var i$, ref$, len$, o, results$ = []; for (i$ = 0, len$ = (ref$ = lsgObjects).length; i$ < len$; ++i$) { o = ref$[i$]; results$.push(inc("../load")({ lsgDescription: o, slide: p.slide, subfolder: p.subfolder, onDone: onLoaded })); } return results$; }; onLoaded = function(){ totalDone++; if (totalDone === lsgObjects.length) { return onDone(); } }; if (lsgObjects.length === 0) { return onDone(); } else { return loadLsgs(); } }; })(); shared/slide/loadMediaFiles/lsgs/loadLsgDescriptionMediaFiles/loadChildrenSvgs/load.ls (function(){ return function(p, onDone){ var svgObjects, ref$, totalDone, loadSvgs, onSvgLoaded, onSvgError; svgObjects = _.filter((ref$ = p.lsg) != null ? ref$.objects : void 8, function(o){ var ref$; return o.type === "svg" && ((ref$ = o.svg) != null ? ref$.indexOf(" 50) { i2.html(instructionText.substr(0, 50) + "..."); } return (ref1$ = instruction.firstChild) != null ? ref1$.css({ margin: 0, padding: "0.5em 0.2em 0" }) : void 8; }; }; })(); shared/soundsPre/logDebugEvent/log.ls (function(){ return function(p){ return typeof log != 'undefined' && log !== null ? log.log({ event: "debugBase64SoundMissing", text: p.text, voice: p.voice, voiceLang: p.voiceLang }) : void 8; }; })(); shared/soundsPre/soundsPre.ls (function(){ return function(mediaParams){ var sounds, i$, ref$, len$, p, sound; sounds = {}; for (i$ = 0, len$ = (ref$ = mediaParams.sounds).length; i$ < len$; ++i$) { p = ref$[i$]; if (p.voiceLang == null) { debug("error, you must specify voiceLang"); } if (!p.data) { inc("logDebugEvent/log")(p); } sound = inc("/../app01/lib/util/sound/sound")({ base64: p.data, fileId: "sound/" + p.voiceLang + "/" + p.voice + "/" + p.text, enableAnalyser: true, volume: inc("/../app01/data/user/audioVolume/get")() }); sound.info = { text: p.text, voice: p.voice }; sounds[p.text + p.voice] = sound; sounds[p.text + p.voice + p.voiceLang] = sound; } return sounds; }; })(); shared/textA/text.ls (function(){ return function(slide){ var textAlign, isPlaying, tap; textAlign = slide.getParam("textAlign", slide.atom) || "center"; isPlaying = false; tap = function(){ var text, voice; text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); if (isPlaying) { slide.sounds[text + voice].stop(); return isPlaying = false; } else { isPlaying = true; return slide.sounds[text + voice].play(function(){ return isPlaying = false; }); } }; return Div({ display: textAlign === "left" ? "inline-flex" : "inline-block", textAlign: textAlign, alignItems: "flex-start" }).append(Span().html(slide.atom.a).tap(slide.getParam("soundMode", slide.atom) === "a" ? { up: tap, animation: "none" } : void 8)); }; })(); shared/topMessage/background/background.ls (function(){ return function(o){ return Div({ position: "absolute", top: 0, left: 0, right: 0, height: "var(--screenHeight)", backgroundColor: "rgba(0, 0, 0, 0.2)", pointerEvents: "auto" }).addClass("keyManagerScope gestureManagerScope").tap({ up: function(){ return o.close("background"); }, animation: "none" }).css({ cursor: "default" }).append(inc("keyDiv/div")(o.close)).hide(); }; })(); shared/topMessage/background/keyDiv/div.ls (function(){ return function(close){ return Div().addClass("keyManager-enter keyManager-esc").bind("keyManager", function(){ return close("keyboard"); }); }; })(); shared/topMessage/content/content.ls (function(){ return function(o){ var updateMaxHeight, div; updateMaxHeight = function(){ return o.scrollDiv.css({ maxHeight: body.height() * 0.7 + "px" }); }; div = Div({ display: "flex", pointerEvents: "auto", backgroundColor: Color.grey[75], border: "1px solid " + Color.grey[250], borderTop: "", hyphens: "auto", backgroundClip: "border-box" }).append(o.scrollDiv = ScrollDiv({ scrollbarMode: "show" }).css({ flex: o.contentAlign === "left" ? "1 1 auto" : "0 1 auto", textAlign: "left", lineHeight: "1.5em", padding: "0.85em 0.5em 0.8em" }).html(o.html).onWindowResize(updateMaxHeight)); updateMaxHeight(); return div; }; })(); shared/topMessage/topMessage.ls (function(){ return function(o){ var open, div, background, div2, content, ref$; o.isClosed = true; o.animationRunning = false; open = function(){ if (!o.isClosed || o.animationRunning) { return; } o.hasOpened = true; o.isClosed = false; o.animationRunning = true; background.fadeIn(300); div2.keyframeAnimate({ keyframes: { "70%": { transform: "translateY(10px)" }, "100%": { transform: "translateY(0px)" } }, duration: 300 }); return setTimeout(function(){ return o.animationRunning = false; }, 300); }; o.close = function(type){ if (o.isClosed || o.animationRunning) { return; } o.isClosed = true; o.animationRunning = true; background.fadeOut(300); return div2.keyframeAnimate({ keyframes: { "100%": { transform: "translateY(-" + content.height() + "px)" } }, duration: 300, timing: "ease-in", onCompleted: function(){ div.remove(); if (typeof o.onClose == 'function') { o.onClose(type); } return o.animationRunning = false; } }); }; div = Div({ position: "absolute", left: 0, right: 0, top: "calc(100%)", height: "calc(var(--screenHeight) - var(--topHeight)", overflow: "hidden", pointerEvents: "none", zIndex: 0 }).addClass("topMessage").html(background = inc("background/background")(o), div2 = Div({ width: "35em", maxWidth: "100%", margin: "0 auto", marginTop: "-200px", borderTop: "200px solid " + Color.grey[75] }).html(content = inc("content/content")(o))); if ((ref$ = app.currentPage.topbar) != null) { ref$.append(div); } div2.css({ transform: "translateY(-" + content.height() + "px)" }); div2.onWindowResize(function(){ if (o.isClosed) { return div2.css({ transform: "translateY(-" + content.height() + "px)" }); } }); open(); div.close = o.close; return div; }; })(); trainers/_t.ls (function(){ return { correct: { de: "Richtig!", en: "Correct!", fr: "Bonne réponse !", es: "Correcto", pt: "Correto!" }, solutionClicked: { de: "Lösung geklickt", en: "Solution clicked", fr: "Notre solution", es: "Nuestra solución", pt: "Nossa solução" }, wrong: { de: "Leider falsch!", en: "Wrong!", fr: "Mauvaise réponse !", es: "Incorrecto", pt: "Resposta errada!" }, 'true': { de: "Wahr", en: "True", fr: "Vrai", es: "Verdadero", pt: "Verdadeiro" }, 'false': { de: "Falsch", en: "False", fr: "Faux", es: "Falso", pt: "Falso" }, numTries: { de: "$1. Versuch — ", en: "$1. attempt — ", fr: "Essai n° $1 — ", es: "$1° intento — ", pt: "$1ª tentativa — " }, possibleSolution: { de: "Hier siehst du eine mögliche Lösung", en: "Here is a possible solution", fr: "Voici une solution", es: "Esta es una solución posible", pt: "Aqui você pode ver uma possível solução" } }; })(); trainers/buttons/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/buttons/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/buttons/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); texts = slide.atom.sound ? [slide.atom.sound] : soundMode === "b" ? _.map(_.filter(slide.choices, { correct: true }), function(c){ return c.text; }) : soundMode === "a" ? [slide.atom.a] : soundMode === "askSound" ? [slide.atom.a] : []; voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/buttons/_preview/preview.ls (function(){ return function(slide){ var lsg, width; if (slide.lsg) { lsg = slide.lsg.findFirst("svg"); width = lsg.css("width"); width = width.replace("em", "") * 0.4 + "em"; return lsg.css({ width: width }); } }; })(); trainers/buttons/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } return slide.div.append(Div({ margin: "2em 0", textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); }; })(); trainers/buttons/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/buttons/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return inc("../correct/correct")(action, slide); }; })(); trainers/buttons/_start/start.ls (function(){ return function(slide){ inc("../checkChoices/check")(slide.atoms); return slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.buttons, { padding: 10 }); }); }; })(); trainers/buttons/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).appendTo(slide.div); }; })(); trainers/buttons/buttons/button/button.ls (function(){ return function(slide, choice, i){ var click, onMistake, onCorrect, playSoundB, button; click = function(){ var choice; choice = slide.choices[i]; if (choice.correct) { return onCorrect(); } else { return onMistake(); } }; onMistake = function(){ var d1; slide.levelPlayer.progressBar.addElement().showRed(); button.setState("wrong"); d1 = new Date(); return slide.score.addActionMistake(slide.atom, { text: choice.text }, function(){ var duration; duration = new Date() - d1; return setTimeout(function(){ return button.setState("normal"); }, Math.max(0, 500 - duration)); }); }; onCorrect = function(){ slide.currentGreen++; button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); if (slide.currentGreen === slide.totalGreen) { slide.div.css({ pointerEvents: "none" }); } return playSoundB(choice, function(){ return slide.score.addActionCorrect(slide.atom, { text: choice.text }, function(){ var ref$; slide.finishedAtoms++; if (slide.finishedAtoms === slide.totalGreen) { if ((ref$ = slide.currentSound) != null) { ref$.stop(); } return slide.score.log(slide.atom, slide.finish); } }); }); }; playSoundB = function(choice, onDone){ if (slide.getParam("soundMode", slide.atom) === "b") { if (slide.trueFalseMode && !slide.atom.sound) { return setTimeout(function(){ return typeof onDone == 'function' ? onDone() : void 8; }, 500); } else { return setTimeout(function(){ var sound, voice; sound = slide.atom.sound || choice.text; voice = slide.getParam("voice", slide.atom); return slide.sounds[sound + voice].play(function(){ return typeof onDone == 'function' ? onDone() : void 8; }); }, 500); } } else { return setTimeout(function(){ return typeof onDone == 'function' ? onDone() : void 8; }, 500); } }; return button = Button({ label: choice.text, labelAllowWrap: true, action: click, icon: choice.icon === "correct" ? path("/../app01/lib/svg/icon/checkmark.svg") : choice.icon === "wrong" ? path("/../app01/lib/svg/icon/close.svg") : void 8 }).css({ margin: "0.5em", minWidth: "2em" }); }; })(); trainers/buttons/buttons/buttons.ls (function(){ return function(slide){ var i, choice; slide.totalGreen = _.filter(slide.choices, { correct: true }).length; slide.currentGreen = 0; slide.finishedAtoms = 0; return Div({ padding: "1em 1em 0 1em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { i = i$; choice = ref$[i$]; results$.push(inc("button/button")(slide, choice, i)); } return results$; }())).appendTo(slide.div); }; })(); trainers/buttons/calcChoices/automatic/calc.ls (function(){ return function(slide){ var choices, otherAtoms, totalButtons, i$, len$, atom; choices = [{ correct: true, text: slide.atom.b }]; otherAtoms = _.shuffleWithSeed(_.filter(slide.trainerParams.atoms, function(atom){ return atom.b !== slide.atom.b && !_.includes(atom.b, "++") && !_.includes(atom.b, "--"); })); otherAtoms = _.uniqBy(otherAtoms, "b"); totalButtons = slide.trainerParams.totalButtons || 3; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choices.push({ correct: false, text: atom.b }); } return choices; }; })(); trainers/buttons/calcChoices/calc.ls (function(){ return function(slide){ var choices, shuffleButtons, ref$; choices = slide.trueFalseMode ? inc("trueFalseChoices/choices")(slide) : _.includes(slide.atom.b, "++") || _.includes(slide.atom.b, "--") ? inc("plusplus/calc")(slide) : inc("automatic/calc")(slide); shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; if (shuffleButtons && !slide.trueFalseMode) { choices = _.shuffleWithSeed(choices); } return choices; }; })(); trainers/buttons/calcChoices/plusplus/calc.ls (function(){ return function(slide){ var choices; return choices = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); }; })(); trainers/buttons/calcChoices/trueFalseChoices/choices.ls (function(){ return function(slide){ var trueLabel, falseLabel, ref$, choices; trueLabel = slide.getParam("trueButtonLabel") || T("true"); falseLabel = slide.getParam("falseButtonLabel") || T("false"); if (engine.isDebug && ((ref$ = slide.atom.b) === "correct" || ref$ === "wrong")) { debug("Please use new trueFalseMode syntax b: true / b: false (see post in content channel)"); return []; } return choices = [ { icon: "correct", correct: (ref$ = slide.atom.b) === true || ref$ === "correct", text: trueLabel }, { icon: "wrong", correct: (ref$ = slide.atom.b) === false || ref$ === "wrong", text: falseLabel } ]; }; })(); trainers/buttons/checkChoices/check.ls (function(){ return function(atoms){ var plusMinusAtoms, l; plusMinusAtoms = _.filter(atoms, function(atom){ return _.includes(atom.b, "++") || _.includes(atom.b, "--"); }); l = plusMinusAtoms.length; if (l !== 0 && l !== atoms.length) { return debug("Buttons trainer warning: You're mixing automatic mode and ++/-- mode. This works, but should be an exception."); } }; })(); trainers/buttons/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.trueFalseMode = (ref1$ = slide.getParam("trueFalseMode")) != null ? ref1$ : false; slide.choices = inc("calcChoices/calc")(slide); slide.totalProgressElements = _.filter(slide.choices, { correct: true }).length; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/buttons/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/buttons/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.textA = inc("textA/text")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/buttons/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/buttons/lsg/lsg.ls (function(){ return function(slide){ var lsg, div; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); if (!div) { return; } div.appendTo(slide.div); return div; }; })(); trainers/buttons/textA/text.ls (function(){ return function(slide){ var image, lsg, div; if (slide.getParam("soundMode", slide.atom) === "askSound" || !slide.atom.a) { return; } image = slide.getParam("image", slide.atom); lsg = slide.getParam("lsg", slide.atom); div = inc("/shared/textA/text")(slide); return div.css({ maxWidth: "90%", width: "30em", padding: image || lsg ? "0.5em 1em" : "0 1em" }).appendTo(slide.div); }; })(); trainers/buttonsAnimation/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return [slide.getParam("lsg"), slide.getParam("pufferfish"), slide.getParam("shark")]; }; })(); trainers/buttonsAnimation/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom; sounds = []; for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "a")).length; i$ < len$; ++i$) { atom = ref$[i$]; sounds.push({ text: atom.sound || atom.a, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } return sounds; }; })(); trainers/buttonsAnimation/_preview/preview.ls (function(){ return function(slide){ var ref$, i, d; return slide.div.append(typeof (ref$ = slide.animation).preview == 'function' ? ref$.preview() : void 8, (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.footer.find(".buttonsDiv")).length; i$ < len$; ++i$) { i = i$; d = ref$[i$]; d.atom = slide.atoms[i]; results$.push(d.css({ backgroundColor: Color.grey[150], margin: "0.5em 0" }).show()); } return results$; }())); }; })(); trainers/buttonsAnimation/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, buttonsDivs, b, matchingActions, div, i, action, results$ = []; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; actions.push(a); } } if (actions.length > 0) { buttonsDivs = slide.div.findAll(".buttonsDiv"); for (i$ = 0, len$ = buttonsDivs.length; i$ < len$; ++i$) { b = buttonsDivs[i$]; matchingActions = _.filter(actions, fn$); div = Div({ margin: "1em 0", textAlign: "left" }).append((fn1$())); results$.push(b.after(div)); } return results$; } function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(b.atom); } function fn1$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = matchingActions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; } }; })(); trainers/buttonsAnimation/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/buttonsAnimation/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/buttonsAnimation/_start/start.ls (function(){ return function(slide){ inc("/../app01/lib/util/orientation/lock")("portrait-primary"); slide.levelPlayer.onAbort = function(){ return inc("/../app01/lib/util/orientation/unlock")(); }; slide.div.css({ opacity: 0 }); return inc("../instructionDiv/div")(slide); }; })(); trainers/buttonsAnimation/_t.ls (function(){ return { calculateFast: { de: "Rechne schnell genug, damit die Rakete nicht abstürzt!", en_gb: "Calculate quickly so that the rocket doesn't crash!", en: "Calculate fast so that the rocket doesn't crash!", fr: "Calcule vite pour que la fusée ne s'écrase pas !", es: "¡Calcula lo más rápido que puedas para que el cohete no se estrelle!", pt: "Calcule o mais rápido possível para que o foguete não bata!" }, letsgo: { de: "Los!", en: "Let’s go!", fr: "C'est parti !", es: "¡Vamos!", pt: "Vamos lá!" } }; })(); trainers/buttonsAnimation/animation/animation.ls (function(){ return function(slide){ var type, animation; type = slide.getParam("animation"); if (!type) { return; } animation = type === "rocket" ? inc("rocket/animate")(slide) : type === "shark" ? inc("shark/animate")(slide) : void 8; slide.div.append(animation); return animation; }; })(); trainers/buttonsAnimation/animation/rocket/animate.ls (function(){ return function(slide){ var y, onFinishTargets, running, timeout, duration, startTimeout, fall, onFinish, onGreen, start, div, rocket; y = null; onFinishTargets = null; running = false; timeout = null; duration = slide.getParam("duration") * 1 || 5; startTimeout = function(){ if (timeout) { return; } return timeout = setTimeout(function(){ if (app.currentPage.levelPlayer == null || !slide.div.isVisible()) { clearTimeout(timeout); return; } slide.currentElement.animateRed(); slide.levelPlayer.progressBar.showRed(); setTimeout(function(){ return slide.startNextElement(); }, 500); return timeout = null; }, duration * 1000); }; fall = function(){ return rocket.css({ transform: "translate(0, " + y + "px)", transition: duration + "s ease-in", webkitBackfaceVisibility: "hidden" }); }; onFinish = function(){ var i$, ref$, len$, t; clearTimeout(timeout); timeout = null; for (i$ = 0, len$ = (ref$ = onFinishTargets).length; i$ < len$; ++i$) { t = ref$[i$]; t.css({ "opacity": 1 }); } return rocket.css({ transform: "translate(0, -" + rocket.offset().height + "px)", transition: "500ms" }); }; onGreen = function(){ var i$, ref$, len$, t; clearTimeout(timeout); timeout = null; for (i$ = 0, len$ = (ref$ = onFinishTargets).length; i$ < len$; ++i$) { t = ref$[i$]; t.css({ "opacity": 1 }); } rocket.css({ transform: "translate(0, 0)", transition: "500ms" }); return setTimeout(function(){ return requestAnimationFrame(function(){ var i$, ref$, len$, t; startTimeout(); for (i$ = 0, len$ = (ref$ = onFinishTargets).length; i$ < len$; ++i$) { t = ref$[i$]; t.css({ "opacity": 0 }); } return fall(); }); }, 500); }; start = function(){ var i$, len$, t; running = true; onFinishTargets = rocket.findAll(".onFinish"); for (i$ = 0, len$ = onFinishTargets.length; i$ < len$; ++i$) { t = onFinishTargets[i$]; t.css({ "opacity": 0 }); } startTimeout(); y = div.height() - rocket.offset().height; return requestAnimationFrame(fall); }; div = Div({ position: "fixed", top: "2em", right: 0, left: 0, bottom: "-5em", transform: "translateZ(0)" }).append(rocket = inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg"), slide: slide })); div.start = start; div.onGreen = onGreen; div.onFinish = onFinish; div.preview = function(){ return rocket; }; div.isRunning = function(){ return running; }; return div; }; })(); trainers/buttonsAnimation/animation/shark/animate.ls (function(){ return function(slide){ var x, sharkSVG, svg, fart, shark, pufferfish, pufferfishSVG, running, duration, timeout, startTimeout, move, onFinish, onGreen, start, preview, div, pufferfishLSG, sharkLSG; x = null; sharkSVG = null; svg = null; fart = null; shark = null; pufferfish = null; pufferfishSVG = null; running = false; duration = slide.getParam("duration") * 1 || 5; timeout = null; startTimeout = function(){ return timeout = setTimeout(function(){ if (app.currentPage.levelPlayer == null || !div.isVisible()) { clearTimeout(timeout); return; } slide.currentElement.animateRed(); slide.levelPlayer.progressBar.showRed(); setTimeout(function(){ return slide.startNextElement(); }, 500); return timeout = null; }, duration * 1000); }; move = function(){ return sharkLSG.css({ transform: "translate(" + x + "px,0)", transition: duration + "s ease-in", webkitBackfaceVisibility: "hidden" }); }; onFinish = function(){ clearTimeout(timeout); timeout = null; fart.setAttribute("opacity", 1); return sharkLSG.css({ transform: "translate(0,-" + sharkLSG.offset().width + ")", transition: "500ms" }); }; onGreen = function(){ clearTimeout(timeout); timeout = null; fart.setAttribute("opacity", 1); sharkLSG.css({ transform: "translate(0,0)", transition: "500ms" }); return setTimeout(function(){ return requestAnimationFrame(function(){ startTimeout(); fart.setAttribute("opacity", 0); return move(); }); }, 500); }; start = function(){ running = true; sharkSVG = sharkLSG.findFirst("svg").parent(); shark = sharkSVG.findFirst(".shark"); pufferfishSVG = pufferfishLSG.findFirst("svg").parent(); pufferfish = pufferfishSVG.findFirst(".pufferfish"); fart = pufferfishSVG.findFirst(".fart"); fart.setAttribute("opacity", 0); startTimeout(); x = div.width() - (shark.offset().width / 2 + 30); return requestAnimationFrame(move); }; preview = function(){ return inc("preview/preview")(sharkLSG, pufferfishLSG); }; div = Div({ position: "fixed", top: "2em", right: 0, left: 0, bottom: 0 }).append(pufferfishLSG = inc("/shared/lsg/lsg")({ lsg: slide.getParam("pufferfish"), slide: slide }).css({ width: "4em", height: "auto", position: "absolute", top: "40%", right: 0 }), sharkLSG = inc("/shared/lsg/lsg")({ lsg: slide.getParam("shark"), slide: slide }).css({ width: "10em", height: "auto", position: "absolute", left: 0, top: "35%" })); div.start = start; div.preview = preview; div.onGreen = onGreen; div.onFinish = onFinish; div.isRunning = function(){ return running; }; return div; }; })(); trainers/buttonsAnimation/animation/shark/preview/preview.ls (function(){ return function(shark, pufferfish){ return Div({ display: "inline-block" }).append(shark.css({ position: "", margin: "0 1em" }), pufferfish.css({ position: "", margin: "0 1em" })); }; })(); trainers/buttonsAnimation/elements/calcChoices/automatic/calc.ls (function(){ return function(slide, atom){ var choices, otherAtoms, totalButtons, i$, len$; choices = [{ correct: true, text: atom.b }]; otherAtoms = _.shuffleWithSeed(_.filter(slide.trainerParams.atoms, function(a){ return a.b !== atom.b; })); totalButtons = slide.trainerParams.totalButtons || 3; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choices.push({ correct: false, text: atom.b }); } return choices; }; })(); trainers/buttonsAnimation/elements/calcChoices/calc.ls (function(){ return function(atom, slide){ var choices, shuffleButtons, ref$; choices = slide.trueFalseMode ? inc("trueFalseChoices/choices")(slide, atom) : _.includes(atom.b, "++") || _.includes(atom.b, "--") ? inc("plusplus/calc")(slide, atom) : inc("automatic/calc")(slide, atom); shuffleButtons = (ref$ = slide.getParam("shuffleButtons", atom)) != null ? ref$ : true; if (shuffleButtons && !slide.trueFalseMode) { choices = _.shuffleWithSeed(choices); } return choices; }; })(); trainers/buttonsAnimation/elements/calcChoices/plusplus/calc.ls (function(){ return function(slide, atom){ var choices; return choices = inc("/shared/convertPlusPlusString/convert")(atom.b); }; })(); trainers/buttonsAnimation/elements/calcChoices/trueFalseChoices/choices.ls (function(){ return function(slide, atom){ var trueLabel, falseLabel, ref$, choices; trueLabel = slide.getParam("trueButtonLabel") || T("true"); falseLabel = slide.getParam("falseButtonLabel") || T("false"); if (engine.isDebug && ((ref$ = atom.b) === "correct" || ref$ === "wrong")) { debug("Please use new trueFalseMode syntax b: true / b: false (see post in content channel)"); return []; } return choices = [ { icon: "correct", correct: (ref$ = atom.b) === true || ref$ === "correct", text: trueLabel }, { icon: "wrong", correct: (ref$ = atom.b) === false || ref$ === "wrong", text: falseLabel } ]; }; })(); trainers/buttonsAnimation/elements/element/buttonsDiv/button/button.ls (function(){ return function(slide, choice, i, atom){ var tap, onCorrect, onWrong, div; tap = function(){ if (choice.correct) { return onCorrect(); } else { return onWrong(); } }; onCorrect = function(){ slide.score.addActionCorrect(atom, { text: choice.text }); slide.score.log(atom); div.setState("correct"); div.parent().setDisabled(); slide.levelPlayer.progressBar.showGreen(); return setTimeout(function(){ return slide.startNextElement(); }, 500); }; onWrong = function(){ slide.score.addActionMistake(atom, { text: choice.text }); slide.levelPlayer.progressBar.addElement().showRed(); div.setState("wrong"); return setTimeout(function(){ var state; state = div.state; div.setState("normal"); if (state === "disabled") { return div.setState("disabled"); } }, 500); }; div = Button({ label: choice.text, icon: choice.icon === "correct" ? path("/../app01/lib/svg/icon/checkmark.svg") : choice.icon === "wrong" ? path("/../app01/lib/svg/icon/close.svg") : void 8 }).tap(tap).addClass("keyManager-" + (49 + i)).bind("keyManager", tap).css({ margin: "0.5em" }); div.tag = i; return div; }; })(); trainers/buttonsAnimation/elements/element/buttonsDiv/div.ls (function(){ return function(slide, choices, atom){ var setDisabled, setWrong, div, buttons, i, choice; setDisabled = function(){ var i$, ref$, len$, b, results$ = []; for (i$ = 0, len$ = (ref$ = buttons).length; i$ < len$; ++i$) { b = ref$[i$]; results$.push(b.setState("disabled")); } return results$; }; setWrong = function(){ var i$, ref$, len$, b, results$ = []; for (i$ = 0, len$ = (ref$ = buttons).length; i$ < len$; ++i$) { b = ref$[i$]; results$.push(b.setState("wrong")); } return results$; }; div = Div({ padding: "0.5em 1.5em" }).append(buttons = (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")(slide, choice, i, atom)); } return results$; }())); div.setDisabled = setDisabled; div.setWrong = setWrong; return div; }; })(); trainers/buttonsAnimation/elements/element/element.ls (function(){ return function(slide, atom, choices, i){ var start, stop, div, textA, buttonsDiv; start = function(){ var text, voice, ref$; if (slide.getParam("soundMode") === "a") { text = atom.sound || atom.a; voice = slide.getParam("voice", atom); if ((ref$ = slide.currentSound) != null) { ref$.stop(); } slide.currentSound = slide.sounds[text + voice]; slide.currentSound.play(); } return div.show(); }; stop = function(){ return div.hide(); }; slide.footer.append(div = Div().addClass("buttonsDiv").append(textA = inc("textA/textA")(atom), buttonsDiv = inc("buttonsDiv/div")(slide, choices, atom)).hide()); return { start: start, stop: stop, animateRed: buttonsDiv.setWrong }; }; })(); trainers/buttonsAnimation/elements/element/textA/textA.ls (function(){ return function(atom){ var div; return div = Div({ paddingTop: "1em" }).html(atom.a + ""); }; })(); trainers/buttonsAnimation/elements/elements.ls (function(){ return function(slide){ var i$, ref$, len$, i, atom, choices, el, results$ = []; slide.elements = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; choices = inc("calcChoices/calc")(atom, slide); el = inc("element/element")(slide, atom, choices, i); if (el) { results$.push(slide.elements.push(el)); } } return results$; }; })(); trainers/buttonsAnimation/footer/footer.ls (function(){ return function(){ var div; return div = Div({ textAlign: "center", minHeight: "5em" }).bind("touchstart touchmove touchend", function(e){ return e.preventDefault(); }); }; })(); trainers/buttonsAnimation/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.trueFalseMode = (ref$ = slide.getParam("trueFalseMode")) != null ? ref$ : false; slide.totalProgressElements = atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/buttonsAnimation/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.animation = inc("animation/animation")(slide); slide.footer = inc("footer/footer")(); inc("elements/elements")(slide); slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; return slide.realStart = function(){ return inc("realStart/start")(slide); }; }; })(); trainers/buttonsAnimation/instructionDiv/div.ls (function(){ return function(slide){ var clickStart, div, instruction; clickStart = function(){ div.remove(); instruction.stop(); slide.div.css({ opacity: 1 }); return slide.realStart(); }; if (slide.trainerParams.instruction == null) { slide.trainerParams.instruction = T("calculateFast"); } slide.levelPlayer.page.append(div = Div({ textAlign: "center", width: "100%" }).append(instruction = inc("/shared/instruction/instruction")(slide), Button().css({ minWidth: "3em", marginBottom: "1em" }).html(T("letsgo")).addClass("keyManager-enter").bind("keyManager", clickStart).tap(clickStart))); instruction.play(); return div; }; })(); trainers/buttonsAnimation/realStart/start.ls (function(){ return function(slide){ slide.levelPlayer.page.bottom.html(slide.footer).show(); slide.animation.start(); return slide.startNextElement(); }; })(); trainers/buttonsAnimation/startNextElement/start.ls (function(){ return function(slide){ var oldE, e, i$, ref$, len$, d; oldE = slide.elements[slide.currentIndex]; slide.currentIndex++; e = slide.elements[slide.currentIndex]; slide.currentElement = e; if (e) { if (oldE != null) { oldE.stop(); slide.animation.onGreen(); } return e.start(); } else { slide.animation.onFinish(); slide.div.css({ pointerEvents: "none" }); for (i$ = 0, len$ = (ref$ = slide.div.find(".buttonsDiv")).length; i$ < len$; ++i$) { d = ref$[i$]; d.css({ pointerEvents: "none" }); } inc("/../app01/lib/util/orientation/unlock")(); return setTimeout(slide.finish, 500); } }; })(); trainers/buttonsAnimationTime/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var backgroundLsg; return backgroundLsg = (function(){ switch (slide.getParam("backgroundType")) { case "emptyStreet": return inc("../../animation/background/lsg/emptyStreet.lsg"); case "crowdedStreet": return inc("../../animation/background/lsg/crowdedStreet.lsg"); case "universe": return inc("../../animation/background/lsg/universe.lsg"); case "sky": return inc("../../animation/background/lsg/sky.lsg"); case "ocean": return inc("../../animation/background/lsg/ocean.lsg"); default: return inc("../../animation/background/lsg/emptyStreet.lsg"); } }()); }; })(); trainers/buttonsAnimationTime/_preview/preview.ls (function(){ return function(slide){ var i, d; slide.animation.start(); return slide.div.append(slide.animation.css({ position: "relative", transform: "", height: "20em", overflow: "hidden", margin: "1em 0", left: 0, bottom: 0 }), Div({ margin: "2.5em 0" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.footer.find(".buttonsDiv")).length; i$ < len$; ++i$) { i = i$; d = ref$[i$]; d.atom = slide.atoms[i]; results$.push(d.css({ backgroundColor: Color.grey[150], margin: "0.5em 0" }).show()); } return results$; }()))); }; })(); trainers/buttonsAnimationTime/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/buttonsAnimationTime/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, actions, i$, ref$, len$, a, e, j$, len1$, buttonsDivs, b, matchingActions, div, i, action, results$ = []; scoreEvents = []; actions = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; actions.push(a); } } if (actions.length > 0) { buttonsDivs = slide.div.findAll(".buttonsDiv"); for (i$ = 0, len$ = buttonsDivs.length; i$ < len$; ++i$) { b = buttonsDivs[i$]; matchingActions = _.filter(actions, fn$); div = Div({ margin: "-0.1em 0 1em", textAlign: "left" }).append((fn1$())); results$.push(b.after(div)); } return results$; } function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(b.atom); } function fn1$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = matchingActions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(inc("actionDiv/div")(action, slide))); } return results$; } }; })(); trainers/buttonsAnimationTime/_start/start.ls (function(){ return function(slide){ inc("/../app01/lib/util/orientation/lock")("portrait-primary"); slide.levelPlayer.onAbort = function(){ return inc("/../app01/lib/util/orientation/unlock")(); }; slide.div.css({ opacity: 0 }); return slide.levelPlayer.page.append(inc("../instructionDiv/div")(slide)); }; })(); trainers/buttonsAnimationTime/_t.ls (function(){ return { calculateFast: { de: "Rechne so schnell wie möglich, damit du das Rennen gewinnst!", en_gb: "Calculate as quickly as possible to win the race!", en: "Calculate as fast as possible to win the race!", fr: "Calcule aussi vite que possible pour gagner la course !", es: "¡Calcula lo más rápido que puedas para ganar la carrera!", pt: "Calcule o mais rápido que puder para vencer a corrida!" }, whichColorCar: { de: "Welche Farbe soll dein Auto haben?", en_gb: "Which colour should your car be?", en: "Which color should your car be?", fr: "Choisis la couleur de ta voiture :", es: "¿De qué color quieres que sea tu automóvil?", pt: "Escolha a cor do seu carro." }, whichColorBike: { de: "Welche Farbe soll dein Fahrrad haben?", en_gb: "Which colour should your bike be?", en: "Which color should your bike be?", fr: "Choisis la couleur de ton vélo :", es: "¿De qué color quieres que sea tu bicicleta?", pt: "Escolha a cor da sua bicicleta." }, whichColorSpaceship: { de: "Welche Farbe soll dein Raumschiff haben?", en_gb: "Which colour should your spaceship be?", en: "Which color should your spaceship be?", fr: "Choisis la couleur de ton vaisseau spatial :", es: "¿De qué color quieres que sea tu nave espacial?", pt: "Escolha a cor da sua nave espacial." }, whichColorPaperplane: { de: "Welche Farbe soll dein Papierflieger haben?", en_gb: "Which colour should your paper plane be?", en: "Which color should your paper plane be?", fr: "Choisis la couleur de ton avion en papier :", es: "¿De qué color quieres que sea tu avión de papel?", pt: "Escolha a cor do seu aviãozinho de papel." }, whichColorFish: { de: "Welche Farbe soll dein Fisch haben?", en_gb: "Which colour should your fish be?", en: "Which color should your fish be?", fr: "Choisis la couleur de ton poisson :", es: "¿De qué color quieres que sea tu pez?", pt: "Escolha a cor do seu peixe." }, start: { de: "Start", en: "Start", fr: "Commencer", es: "Comenzar", pt: "Iniciar" }, won: { de: "Gewonnen!", en: "You won!", fr: "Gagné !", es: "¡Ganaste!", pt: "Você venceu!" }, bummer: { de: "Schade!", en: "Bummer!", fr: "Quel dommage !", es: "¡Chanfle!", pt: "Que pena!" } }; })(); trainers/buttonsAnimationTime/animation/animation.ls (function(){ return function(slide){ var animation, innerAnimation, resizeAnimation; animation = Div({ width: "100%", height: "var(--centerHeight)" }).html(innerAnimation = inc("innerAnimation/innerAnimation")(slide)).hide().appendTo(slide.div); resizeAnimation = function(){ var bounds, width, height, rotate, scaleX, scaleY, scale; bounds = { width: animation.clientWidth, height: animation.clientHeight }; width = bounds.width; height = bounds.height; if (innerAnimation.animationMayRotate) { if ((bounds.width > bounds.height && innerAnimation.animationWidth < innerAnimation.animationHeight) || (bounds.height > bounds.width && innerAnimation.animationHeight < innerAnimation.animationWidth)) { width = bounds.height; height = bounds.width; rotate = true; } } scaleX = width / innerAnimation.animationWidth; scaleY = height / innerAnimation.animationHeight; scale = innerAnimation.scaleMode === "aspectFit" ? Math.min(scaleX, scaleY) : Math.max(scaleX, scaleY); return innerAnimation.css({ left: (bounds.width - innerAnimation.animationWidth) / 2 + "px", top: (bounds.height - innerAnimation.animationHeight) / 2 + "px", transform: rotate ? "scale(" + scale + ", " + scale + ") rotate(90deg)" : "scale(" + scale + ", " + scale + ")" }); }; animation.onWindowResize(resizeAnimation); animation.start = function(){ animation.show(); inc("/../app01/lib/util/waitFrames/wait")(2, resizeAnimation); return innerAnimation.start(); }; animation.update = innerAnimation.update; return animation; }; })(); trainers/buttonsAnimationTime/animation/background/background.ls (function(){ return function(slide, animation){ var background, dy, speed, div, svg, ref$; if (!slide.getParam("backgroundType")) { debug("Please use property backgroundType, its mandatory now."); } background = (function(){ switch (slide.getParam("backgroundType")) { case "emptyStreet": return path("lsg/emptyStreet.lsg"); case "crowdedStreet": return path("lsg/crowdedStreet.lsg"); case "universe": return path("lsg/universe.lsg"); case "sky": return path("lsg/sky.lsg"); case "ocean": return path("lsg/ocean.lsg"); default: return path("lsg/emptyStreet.lsg"); } }()); dy = 0; speed = 0.1; div = Div({ position: "absolute", transform: "translate(0,0)", bottom: 0, left: 0, right: 0, height: 2 * animation.animationHeight + "px", willChange: "transform" }).append(svg = inc("/shared/lsg/lsg")({ lsg: background, slide: slide }).css({ position: "absolute", bottom: 0, left: 0, right: 0, height: "100%", width: "320px" })); if ((ref$ = svg.svgElement) != null) { ref$.attr({ preserveAspectRatio: "none" }); } div.update = function(dt){ dy += dt * speed; if (dy >= animation.animationHeight) { dy -= animation.animationHeight; } return div.css({ transform: "translate(0," + dy + "px)" }); }; return div; }; })(); trainers/buttonsAnimationTime/animation/background/lsg/crowdedStreet.lsg (function(){ return { version: 2, width: 300, height: 900, objects: [ { type: 'svg', svg: path('/../c-svg/2023/06/27-emptyStreet01.svg'), x: 0, y: 0, w: 300, align: 'top' }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview09.svg'), x: 239.69, y: 278.85, w: 20, h: 18, rotate: 90 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview09.svg'), x: 239.69, y: 727.85, w: 20, h: 18, rotate: 90 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview10.svg'), x: 236.2, y: 389.72, w: 20, h: 20, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview10.svg'), x: 236.2, y: 838.72, w: 20, h: 20, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview12.svg'), x: 227.19, y: 303.33, w: 21, h: 26, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview12.svg'), x: 227.19, y: 752.33, w: 21, h: 26, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview12.svg'), x: 225.85, y: 210.31, w: 20, h: 18, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview12.svg'), x: 225.85, y: 659.31, w: 20, h: 18, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview16.svg'), x: 228.6, y: 420.2, w: 20, h: 22, rotate: 90 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview16.svg'), x: 228.6, y: 869.2, w: 20, h: 22, rotate: 90 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview15.svg'), x: 225.6, y: 180.23, w: 20, h: 22, rotate: 90 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview15.svg'), x: 225.6, y: 629.23, w: 20, h: 22, rotate: 90 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview14.svg'), x: 231.68, y: 87.75, w: 21, h: 27, rotate: 110 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview14.svg'), x: 231.68, y: 536.75, w: 21, h: 27, rotate: 110 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview07.svg'), x: 233.13, y: 35.11, w: 20, h: 18, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview07.svg'), x: 233.13, y: 484.11, w: 20, h: 18, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview13.svg'), x: 231.01, y: 6.9, w: 23, h: 31, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview13.svg'), x: 232.18, y: 455.9, w: 23, h: 31, rotate: 270, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview11.svg'), x: 48.18, y: 246.71, w: 20, h: 18, rotate: 270 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview11.svg'), x: 49.18, y: 696.71, w: 20, h: 18, rotate: 270 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview13.svg'), x: 35.31, y: 208.09, w: 23, h: 31, rotate: 270 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview13.svg'), x: 35.31, y: 658.09, w: 23, h: 31, rotate: 270 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview07.svg'), x: 44.6, y: 153.69, w: 20, h: 18, rotate: 270 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview07.svg'), x: 44.6, y: 603.69, w: 20, h: 18, rotate: 270 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview12.svg'), x: 43.56, y: 83.9, w: 20, h: 22, rotate: 90, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview12.svg'), x: 43.56, y: 533.9, w: 20, h: 22, rotate: 90, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview08.svg'), x: 47.97, y: 12.25, w: 21, h: 28, rotate: 105, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview08.svg'), x: 47.97, y: 462.25, w: 21, h: 28, rotate: 105, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview09.svg'), x: 43.91, y: 428.52, w: 20, h: 18, rotate: -70 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview09.svg'), x: 43.91, y: 878.52, w: 20, h: 18, rotate: -70 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview15.svg'), x: 42.95, y: 400.22, w: 20, h: 22, rotate: 115, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview15.svg'), x: 42.95, y: 850.22, w: 20, h: 22, rotate: 115, flipX: true }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview10.svg'), x: 45.3, y: 371.5, w: 20, h: 20, rotate: 250 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview10.svg'), x: 45.3, y: 821.5, w: 20, h: 20, rotate: 250 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview06.svg'), x: 42.54, y: 317.06, w: 21, h: 26, rotate: 270 }, { type: 'svg', svg: path('/../c-svg/2023/05/17-peopletopview06.svg'), x: 42.54, y: 767.06, w: 21, h: 26, rotate: 270 } ] }; })(); trainers/buttonsAnimationTime/animation/background/lsg/emptyStreet.lsg (function(){ return { version: 2, width: 300, height: 900, objects: [ { type: 'svg', svg: path('/../c-svg/2023/06/27-emptyStreet01.svg'), x: 0, y: 0, w: 300, align: 'top' }, { type: 'rect', x: -14.24, y: -986.79, w: 50, h: 2015, color: Color.blue[400], lineSize: 0, lineColor: Color.black }, { type: 'rect', x: 263.76, y: -976.79, w: 50, h: 2015, color: Color.blue[400], lineSize: 0, lineColor: Color.black } ] }; })(); trainers/buttonsAnimationTime/animation/background/lsg/ocean.lsg (function(){ return { version: 2, width: 300, height: 900, objects: [ { type: 'svg', svg: path('/../c-svg/2023/06/27-underwater03.svg'), x: -10.53, y: 0, h: 450 }, { type: 'svg', svg: path('/../c-svg/2023/06/27-underwater03.svg'), x: -10.53, y: 449, h: 450 } ] }; })(); trainers/buttonsAnimationTime/animation/background/lsg/sky.lsg (function(){ return { version: 2, width: 300, height: 900, objects: [ { type: 'svg', svg: path('/../c-svg/2023/06/17-sky01.svg'), x: 0, y: 0, w: 300, h: 450 }, { type: 'svg', svg: path('/../c-svg/2023/06/17-sky01.svg'), x: 0, y: 449, w: 300, h: 450 }, { type: 'svg', svg: path('/../c-svg/2023/06/17-sky01.svg'), x: 0, y: 899, w: 300, h: 1, crop: true, align: 'topMiddle' } ] }; })(); trainers/buttonsAnimationTime/animation/background/lsg/universe.lsg (function(){ return { version: 2, width: 300, height: 900, objects: [ { type: 'svg', svg: path('/../c-svg/2023/06/12-universe-04.svg'), x: -75, y: 75, w: 450, h: 300, rotate: 90, crop: true, align: 'topMiddle' }, { type: 'svg', svg: path('/../c-svg/2023/06/12-universe-04.svg'), x: -75, y: 524, w: 450, h: 300, rotate: 90, crop: true, align: 'topMiddle' }, { type: 'svg', svg: path('/../c-svg/2023/06/12-universe-04.svg'), x: 149.5, y: 749.5, w: 1, h: 300, rotate: 90, crop: true, align: 'topMiddle' } ] }; })(); trainers/buttonsAnimationTime/animation/endText/endText.ls (function(){ return function(won){ var text, color, endText; if (won) { text = T("won"); color = Color.green[500]; } else { text = T("bummer"); color = Color.blueGrey[500]; } return endText = Div({ position: "absolute", left: 0, top: "1em", width: "100%", height: "100%" }).html(Div({ padding: "0.5em", color: "white", display: "inline-block", backgroundColor: color, border: "3px solid white", backgroundClip: "border-box", borderRadius: "10px", opacity: 0, transform: "scale(0.001, 0.001) rotateZ(180deg)" }).html(text).animation({ css: { opacity: 1, transform: "scale(1,1) rotateZ(360deg)" }, easing: "bounce" })); }; })(); trainers/buttonsAnimationTime/animation/finishLine/finishLine.ls (function(){ return function(slide, getFinishLinePosition, onAnimateDone, animationType){ var finishLineShowing, showLine, initialDy, div, svg, progressSpeed; finishLineShowing = false; showLine = function(o){ if (finishLineShowing) { return; } return finishLineShowing = true; }; initialDy = -480; div = Div({ position: "absolute", transform: "translate(0, " + initialDy + "px)", bottom: 0 }).html(svg = Svg({ svg: path("svg/finishLine_" + animationType + ".svg") }).css({ height: "100%", width: "320px" })); div.showLine = showLine; div.progress = 0; progressSpeed = 0.67; div.update = function(dt){ var dy; if (finishLineShowing && div.progress < 1) { div.progress += progressSpeed * dt / 1000; if (div.progress > 1) { div.progress = 1; onAnimateDone(); } dy = (-getFinishLinePosition()) * div.progress + initialDy * (1 - div.progress); return div.css({ transform: "translate(0, " + dy + "px)" }); } }; return div; }; })(); trainers/buttonsAnimationTime/animation/finishLine/svg/finishLine_bikes.svg trainers/buttonsAnimationTime/animation/finishLine/svg/finishLine_cars.svg trainers/buttonsAnimationTime/animation/finishLine/svg/finishLine_fish.svg trainers/buttonsAnimationTime/animation/finishLine/svg/finishLine_paperplanes.svg trainers/buttonsAnimationTime/animation/finishLine/svg/finishLine_spaceships.svg trainers/buttonsAnimationTime/animation/innerAnimation/innerAnimation.ls (function(){ return function(slide){ var animationType, div, freezeBackground, getFinishLinePosition, onAnimationDone, endAnimation, raceSvgPathRight, raceSvgPathLeft, background, object1, object2, finishLine; animationType = slide.getParam("animation"); if (!animationType) { return; } div = Div(); div.animationWidth = 320; div.animationHeight = 480; div.animationMayRotate = false; div.scaleMode = "aspectFit"; freezeBackground = false; getFinishLinePosition = function(){ return div.animationHeight - 130; }; onAnimationDone = function(){ if (finishLine.progress >= 1) { freezeBackground = true; if (slide.animationLogic.progressLoose >= 1) { if (object1.progress >= 1) { return endAnimation(); } } else if (slide.animationLogic.progressWin >= 1) { if (object2.progress >= 1) { return endAnimation(); } } else { return endAnimation(); } } }; endAnimation = function(){ var playerWon; playerWon = slide.animationLogic.progressWin >= slide.animationLogic.progressLoose; div.append(inc("../endText/endText")(playerWon)); return slide.animationLogic.onAnimationDone(); }; raceSvgPathRight = path("../raceObject/svg/" + animationType + "1.svg"); raceSvgPathLeft = animationType === "cars" ? path("../raceObject/svg/" + animationType + "2.svg") : raceSvgPathRight; div.css({ position: "absolute", width: div.animationWidth + "px", height: div.animationHeight + "px", overflow: "hidden" }).html(background = inc("../background/background")(slide, div), object1 = inc("../raceObject/raceObject")(raceSvgPathLeft, getFinishLinePosition, onAnimationDone, "left", Color.grey[400]), object2 = inc("../raceObject/raceObject")(raceSvgPathRight, getFinishLinePosition, onAnimationDone, "right"), finishLine = inc("../finishLine/finishLine")(slide, getFinishLinePosition, onAnimationDone, animationType)); div.update = function(dt){ if (!freezeBackground) { background.update(dt); } if (freezeBackground) { dt *= 2; } object1.update(dt, slide.animationLogic.progressLoose); object2.update(dt, slide.animationLogic.progressWin); if (slide.animationLogic.progressLoose >= 1 || slide.animationLogic.progressWin >= 1) { finishLine.showLine(); finishLine.update(dt); } }; div.start = function(){ if (slide.objectColor) { return object2.setColor(slide.objectColor); } }; return div; }; })(); trainers/buttonsAnimationTime/animation/raceObject/raceObject.ls (function(){ return function(svgPath, getFinishLinePosition, onAnimateDone, direction, color){ var div, raceObject, speed; div = Div({ position: "absolute", transform: "translate(0,0)", bottom: 0, left: "50%", zIndex: 2, marginLeft: direction === "left" ? "-88px" : "-5px", willChange: "transform" }).html(raceObject = Svg({ svg: svgPath, size: "100px" })); speed = 0.15; div.progress = 0; div.setColor = function(c){ var i$, ref$, len$, child, results$ = []; for (i$ = 0, len$ = (ref$ = raceObject.findAll(".color1")).length; i$ < len$; ++i$) { child = ref$[i$]; results$.push(child.attr({ fill: c })); } return results$; }; div.update = function(dt, targetProgress){ var dy; if (div.progress < targetProgress) { if (Math.abs(targetProgress - div.progress) < 0.005) { div.progress = targetProgress; onAnimateDone(); } else { div.progress += speed * Math.min(1, dt / 1000); if (div.progress >= 1) { div.progress = 1; onAnimateDone(); } } } dy = div.progress * (getFinishLinePosition() - 100); return div.css({ transform: "translate(0, " + (-dy) + "px)" }); }; if (color) { div.setColor(color); } return div; }; })(); trainers/buttonsAnimationTime/animation/raceObject/svg/bikes1.svg trainers/buttonsAnimationTime/animation/raceObject/svg/cars1.svg trainers/buttonsAnimationTime/animation/raceObject/svg/cars2.svg trainers/buttonsAnimationTime/animation/raceObject/svg/fish1.svg trainers/buttonsAnimationTime/animation/raceObject/svg/paperplanes1.svg trainers/buttonsAnimationTime/animation/raceObject/svg/spaceships1.svg trainers/buttonsAnimationTime/animationLogic/animationLogic.ls (function(){ return function(slide){ var maxTime, timePenalty, remainingTime, maxCorrect, correctCount, paused, lastTimeStamp, isGameover, isDone, animationLogic, update, gameOver; maxTime = slide.getParam("duration") * 1000 || 45000; timePenalty = maxTime / slide.totalProgressElements; remainingTime = maxTime; maxCorrect = slide.totalProgressElements; correctCount = 0; paused = false; lastTimeStamp = undefined; isGameover = false; isDone = false; animationLogic = { progressWin: 0, progressLoose: 0, onAnimationDone: function(){ if (isGameover) { isDone = true; return setTimeout(slide.finish, 1000); } } }; update = function(timestamp){ var dt; if (!slide.div.isVisible() || isDone) { return; } if (paused) { lastTimeStamp = undefined; return; } if (!lastTimeStamp) { lastTimeStamp = timestamp; requestAnimationFrame(update); return; } dt = timestamp - lastTimeStamp; lastTimeStamp = timestamp; if (!isGameover) { remainingTime -= dt; if (remainingTime < 0) { remainingTime = 0; } animationLogic.progressLoose = Math.min(1, 1 - remainingTime / maxTime); if (animationLogic.progressWin >= 1) { gameOver(true); } else if (animationLogic.progressLoose >= 1) { gameOver(false); } } slide.animation.update(dt); requestAnimationFrame(update); }; gameOver = function(didWin){ if (isGameover) { return; } return isGameover = true; }; animationLogic.start = function(){ var ref$; if (typeof (ref$ = slide.animation).start == 'function') { ref$.start(); } return requestAnimationFrame(update); }; animationLogic.onCorrect = function(){ if (isGameover) { return; } correctCount++; return animationLogic.progressWin = Math.min(1, correctCount / maxCorrect); }; animationLogic.winGame = function(){ return gameOver(true); }; animationLogic.onWrong = function(){ if (isGameover) { return; } return remainingTime = Math.max(0, remainingTime - timePenalty); }; animationLogic.togglePaused = function(){ paused = !paused; if (!paused) { return requestAnimationFrame(update); } }; return animationLogic; }; })(); trainers/buttonsAnimationTime/elements/calcChoices/automatic/calc.ls (function(){ return function(slide, atom){ var choices, otherAtoms, totalButtons, i$, len$; choices = [{ correct: true, text: atom.b }]; otherAtoms = _.shuffleWithSeed(_.filter(slide.trainerParams.atoms, function(a){ return a.b !== atom.b; })); totalButtons = slide.trainerParams.totalButtons || 3; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choices.push({ correct: false, text: atom.b }); } return choices; }; })(); trainers/buttonsAnimationTime/elements/calcChoices/calc.ls (function(){ return function(atom, slide){ var choices, shuffleButtons, ref$; choices = slide.trueFalseMode ? inc("trueFalseChoices/choices")(slide, atom) : _.includes(atom.b, "++") || _.includes(atom.b, "--") ? inc("plusplus/calc")(slide, atom) : inc("automatic/calc")(slide, atom); shuffleButtons = (ref$ = slide.getParam("shuffleButtons", atom)) != null ? ref$ : true; if (shuffleButtons && !slide.trueFalseMode) { choices = _.shuffleWithSeed(choices); } return choices; }; })(); trainers/buttonsAnimationTime/elements/calcChoices/plusplus/calc.ls (function(){ return function(slide, atom){ var choices; return choices = inc("/shared/convertPlusPlusString/convert")(atom.b); }; })(); trainers/buttonsAnimationTime/elements/calcChoices/trueFalseChoices/choices.ls (function(){ return function(slide, atom){ var trueLabel, falseLabel, choices; trueLabel = slide.getParam("trueButtonLabel") || T("true"); falseLabel = slide.getParam("falseButtonLabel") || T("false"); return choices = [ { icon: "correct", correct: atom.b === true, text: trueLabel }, { icon: "wrong", correct: atom.b === false, text: falseLabel } ]; }; })(); trainers/buttonsAnimationTime/elements/element/button/button.ls (function(){ return function(choice, i, tap){ var button; button = Button({ label: choice.text, action: tap, key: 49 + i, icon: choice.icon === "correct" ? path("/../app01/lib/svg/icon/checkmark.svg") : choice.icon === "wrong" ? path("/../app01/lib/svg/icon/close.svg") : void 8 }).css({ margin: "0.5em" }); button.tag = i; return button; }; })(); trainers/buttonsAnimationTime/elements/element/element.ls (function(){ return function(atom, i, choices, slide){ var animateRed, start, stop, tap, div, buttons, choice; animateRed = function(){ var i$, ref$, len$, b, results$ = []; for (i$ = 0, len$ = (ref$ = buttons).length; i$ < len$; ++i$) { b = ref$[i$]; results$.push(b.setState("wrong")); } return results$; }; start = function(){ return div.show(); }; stop = function(){ return div.hide(); }; tap = function(button){ var choice, i$, ref$, len$, b; choice = choices[button.tag]; if (choice.correct) { slide.score.addActionCorrect(atom, { text: choice.text }); slide.score.log(atom); slide.animationLogic.onCorrect(); button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); for (i$ = 0, len$ = (ref$ = buttons).length; i$ < len$; ++i$) { b = ref$[i$]; if (b !== button) { b.setState("disabled"); } } return setTimeout(function(){ return slide.startNextElement(); }, 500); } else { slide.score.addActionMistake(atom, { text: choice.text }); slide.animationLogic.onWrong(); slide.levelPlayer.progressBar.addElement().showRed(); button.setState("wrong"); return setTimeout(function(){ var state; state = button.state; button.setState("normal"); if (state === "disabled") { return button.setState("disabled"); } }, 500); } }; div = Div().addClass("buttonsDiv").html(inc("textA/textA")(slide, atom), Div({ padding: "0.5em 1.5em" }).html(buttons = (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")(choice, i, tap)); } return results$; }()))).hide().appendTo(slide.footer); return { start: start, stop: stop, animateRed: animateRed }; }; })(); trainers/buttonsAnimationTime/elements/element/textA/textA.ls (function(){ return function(slide, atom){ return Div({ paddingTop: "1em" }).html(atom.a); }; })(); trainers/buttonsAnimationTime/elements/elements.ls (function(){ return function(slide){ var elements, i$, ref$, len$, i, atom, choices, element, that; elements = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; choices = inc("calcChoices/calc")(atom, slide); element = inc("element/element")(atom, i, choices, slide); if (that = element) { elements.push(that); } } return elements; }; })(); trainers/buttonsAnimationTime/footer/footer.ls (function(){ return function(){ return Div({ textAlign: "center" }).bind("touchstart touchmove touchend", function(e){ return e.preventDefault(); }); }; })(); trainers/buttonsAnimationTime/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.trueFalseMode = (ref$ = slide.getParam("trueFalseMode")) != null ? ref$ : false; slide.totalProgressElements = slide.atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/buttonsAnimationTime/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.correctCount = 0; slide.wrongCount = 0; slide.penalty = 0; slide.animationLogic = inc("animationLogic/animationLogic")(slide); slide.animation = inc("animation/animation")(slide); slide.footer = inc("footer/footer")(slide); slide.elements = inc("elements/elements")(slide); slide.realStart = function(){ return inc("realStart/start")(slide); }; return slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; }; })(); trainers/buttonsAnimationTime/instructionDiv/colorButton/button.ls (function(){ return function(slide, onClick, color){ var tap; tap = function(){ slide.objectColor = color; return onClick(); }; return Div({ display: "inline-block", flex: "0 1 auto", width: "1.5em", height: "1.5em", margin: "0.5em", borderRadius: "50%", backgroundColor: color, whiteSpace: "pre-wrap", cursor: "default" }).tap(tap).addClass("keyManager-enter").bind("keyManager", tap); }; })(); trainers/buttonsAnimationTime/instructionDiv/div.ls (function(){ return function(slide){ var animationType, click, ref$, chooseColorLabel, colors, div, instruction, color; animationType = slide.getParam("animation"); if (!animationType) { return; } click = function(){ div.hide(); slide.div.css({ opacity: 1 }); return slide.realStart(); }; (ref$ = slide.trainerParams).instruction == null && (ref$.instruction = T("calculateFast")); chooseColorLabel = (function(){ switch (animationType) { case "cars": return T("whichColorCar"); case "bikes": return T("whichColorBike"); case "spaceships": return T("whichColorSpaceship"); case "paperplanes": return T("whichColorPaperplane"); case "fish": return T("whichColorFish"); } }()); colors = [Color.black, Color.red[500], Color.green[500], Color.blue[500], Color.orange[500], Color.pink.A700, Color.purple[500]]; div = Div({ textAlign: "center", width: "100%" }).html(Div({ padding: "1em" }).html(instruction = inc("/shared/instruction/instruction")(slide), chooseColorLabel), Div({ display: "flex" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = colors).length; i$ < len$; ++i$) { color = ref$[i$]; results$.push(inc("colorButton/button")(slide, click, color)); } return results$; }()))); instruction.childrenAll()[0].css({ fontStyle: "" }); instruction.play(); return div; }; })(); trainers/buttonsAnimationTime/realStart/start.ls (function(){ return function(slide){ slide.levelPlayer.page.bottom.html(slide.footer).show(); slide.animationLogic.start(); return slide.startNextElement(); }; })(); trainers/buttonsAnimationTime/startNextElement/start.ls (function(){ return function(slide){ var oldElement, that; oldElement = slide.elements[slide.currentIndex]; slide.currentIndex++; slide.currentElement = slide.elements[slide.currentIndex]; if (oldElement != null) { oldElement.stop(); } if (that = slide.currentElement) { return that.start(); } else { slide.levelPlayer.page.setBottomFreeze(0); return setTimeout(slide.animationLogic.winGame, 1000); } }; })(); trainers/buttonsText/_media2/images/images.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }; })(); trainers/buttonsText/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }; })(); trainers/buttonsText/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, progressAtoms, i$, len$, atom, soundMode, voiceLang, voice, texts, allChoices, correctChoices, correctTexts, j$, len1$, t, ref$, text; sounds = []; progressAtoms = _.filter(slide.atoms, function(atom){ return atom.b != null; }); for (i$ = 0, len$ = progressAtoms.length; i$ < len$; ++i$) { atom = progressAtoms[i$]; soundMode = slide.getParam("soundMode", atom); voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); texts = atom.sound ? [atom.sound] : soundMode === "a" ? [atom.a] : soundMode === "b" ? (allChoices = inc("/shared/convertPlusPlusString/convert")(atom.b), correctChoices = _.filter(allChoices, { correct: true }), correctTexts = _.map(correctChoices, fn$), correctTexts) : []; for (j$ = 0, len1$ = texts.length; j$ < len1$; ++j$) { t = texts[j$]; if (t != null) { sounds.push({ text: t, voiceLang: voiceLang, voice: voice }); } } } for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "text")).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.sound || atom.speaker) { text = atom.sound || atom.text; text = _.replaceAll(text, "\n", " "); sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "example")).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.example.sound) { text = atom.example.sound; text = _.replaceAll(text, "\n", " "); sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } return sounds; function fn$(c){ return c.text; } }; })(); trainers/buttonsText/_preview/preview.ls (function(){ return function(slide){ var footerDivs, otherDivs, buttonsIndex, otherIndex, i$, ref$, len$, atom, div, results$ = []; footerDivs = slide.footer.findAll(".footerDiv"); otherDivs = slide.content.childrenAll(); buttonsIndex = 0; otherIndex = 0; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.b != null) { slide.div.append(div = footerDivs[buttonsIndex].css({ backgroundColor: Color.grey[100], margin: "0.5em 0" }), div.atom = atom, div.show()); results$.push(buttonsIndex++); } else { slide.div.append(otherDivs[otherIndex].show()); results$.push(otherIndex++); } } return results$; }; })(); trainers/buttonsText/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/buttonsText/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, footerDivs, b, matchingActions, div, i, results$ = []; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; actions.push(a); } } if (actions.length > 0) { footerDivs = slide.div.find(".footerDiv"); for (i$ = 0, len$ = footerDivs.length; i$ < len$; ++i$) { b = footerDivs[i$]; matchingActions = _.filter(actions, fn$); div = Div({ margin: "1.5em 0", textAlign: "left" }).append((fn1$())); results$.push(b.after(div)); } return results$; } function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(b.atom); } function fn1$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = matchingActions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(a, i).append(inc("actionDiv/div")(a, slide))); } return results$; } }; })(); trainers/buttonsText/_skip/skip.ls (function(){ return function(slide){ if (slide.atoms[slide.currentIndex] == null) { return slide.onFinishedSlide(); } if (slide.atoms[slide.currentIndex].a) { slide.levelPlayer.progressBar.showGreen(); } slide.startNextElement(); return slide.levelPlayer.page.scrollElementIntoView(slide.curDiv, { padding: 50 }); }; })(); trainers/buttonsText/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.levelPlayer.page.bottom.html(slide.footer).show(); return slide.startNextElement(); }; })(); trainers/buttonsText/content/content.ls (function(){ return function(slide){ return Div({ width: "40em", margin: "0 auto 2em", maxWidth: "90%" }).appendTo(slide.div); }; })(); trainers/buttonsText/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); div.show(); return slide.div.css({ minHeight: slide.div.height() + "px" }); }; click = function(e){ var ref$, spans, i$, len$, s, results$ = []; div.hide(); slide.startNextElement(); if (slide.curDiv && !((ref$ = slide.atoms[slide.currentIndex]) != null && ref$.a) && slide.currentIndex !== slide.atoms.length) { slide.levelPlayer.page.scrollElementIntoView(slide.curDiv, { padding: 50 }); } spans = slide.div.find("span"); for (i$ = 0, len$ = spans.length; i$ < len$; ++i$) { s = spans[i$]; results$.push(s.css({ backgroundColor: "" })); } return results$; }; div = Button({ label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.7em" }).addClass("keyManager-enter").bind("keyManager", click).tap(click).appendTo(slide.footer).hide(); div.showButton = showButton; return div; }; })(); trainers/buttonsText/elements/element/buttons/buttons.ls (function(){ return function(atom, i, slide){ var choices, playSoundA, start, stop, div; choices = inc("calcChoices/calc")(slide, atom); slide.highlightSpan = inc("highlightSpan/update"); playSoundA = function(){ var text, voice, ref$; text = atom.sound || atom.a; voice = slide.getParam("voice", atom); if (slide.getParam("soundMode", atom) === "a") { if ((ref$ = slide.currentSound) != null) { ref$.stop(); } slide.currentSound = slide.sounds[text + voice]; return slide.currentSound.play(); } }; start = function(){ div.show(); return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: playSoundA }); }; stop = function(){ return div.hide(); }; slide.continueButton.before(div = Div().addClass("footerDiv").append(inc("title/title")(atom), inc("buttons/buttons")(slide, atom, choices)).hide()); return { start: start, stop: stop }; }; })(); trainers/buttonsText/elements/element/buttons/buttons/button/button.ls (function(){ return function(slide, atom, choice, i){ var onCorrect, onWrong, playSoundB, tap, div; onCorrect = function(){ var i$, ref$, len$, b; div.setState("correct"); for (i$ = 0, len$ = (ref$ = div.parent().childrenAll()).length; i$ < len$; ++i$) { b = ref$[i$]; if (b.state !== "correct") { b.setEnabled(false); } } slide.levelPlayer.progressBar.showGreen(); slide.highlightSpan(slide, atom); return playSoundB(function(){ return slide.score.addActionCorrect(atom, { text: choice.text }, function(){ return slide.score.log(atom, function(){ div.parent().css({ paddingBottom: "" }); return slide.continueButton.showButton(); }); }); }); }; onWrong = function(){ slide.score.addActionMistake(atom, { text: choice.text }); slide.levelPlayer.progressBar.addElement().showRed(); div.setState("wrong"); return setTimeout(function(){ return div.setState("normal"); }, 500); }; playSoundB = function(onDone){ if (slide.getParam("soundMode", atom) === "b") { if (slide.trueFalseMode && !atom.sound) { return setTimeout(onDone, 500); } else { return setTimeout(function(){ var text, voice; text = atom.sound || choice.text; voice = slide.getParam("voice", atom); return slide.sounds[text + voice].play(onDone); }, 500); } } else { return setTimeout(onDone, 500); } }; tap = function(){ if (choice.correct) { return onCorrect(); } else { return onWrong(); } }; return div = Button({ label: choice.text, key: 49 + i, action: tap, icon: choice.icon === "correct" ? path("/../app01/lib/svg/icon/checkmark.svg") : choice.icon === "wrong" ? path("/../app01/lib/svg/icon/close.svg") : void 8 }).css({ margin: "0.5em" }); }; })(); trainers/buttonsText/elements/element/buttons/buttons/buttons.ls (function(){ return function(slide, atom, choices){ var i, choice; return Div({ paddingBottom: "0.5em" }).append((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")(slide, atom, choice, i)); } return results$; }())); }; })(); trainers/buttonsText/elements/element/buttons/calcChoices/calc.ls (function(){ return function(slide, atom){ var choices, shuffleButtons, ref$; choices = slide.trueFalseMode ? inc("trueFalseChoices/choices")(slide, atom) : inc("plusplus/calc")(atom); shuffleButtons = (ref$ = slide.getParam("shuffleButtons", atom)) != null ? ref$ : true; if (shuffleButtons && !slide.trueFalseMode) { choices = _.shuffleWithSeed(choices); } return choices; }; })(); trainers/buttonsText/elements/element/buttons/calcChoices/plusplus/calc.ls (function(){ return function(atom){ return inc("/shared/convertPlusPlusString/convert")(atom.b); }; })(); trainers/buttonsText/elements/element/buttons/calcChoices/trueFalseChoices/choices.ls (function(){ return function(slide, atom){ var trueLabel, falseLabel, ref$, choices; trueLabel = slide.getParam("trueButtonLabel") || T("true"); falseLabel = slide.getParam("falseButtonLabel") || T("false"); if (engine.isDebug && ((ref$ = atom.b) === "correct" || ref$ === "wrong")) { debug("Please use new trueFalseMode syntax b: true / b: false (see post in content channel)"); return []; } return choices = [ { icon: "correct", correct: (ref$ = atom.b) === true || ref$ === "correct", text: trueLabel }, { icon: "wrong", correct: (ref$ = atom.b) === false || ref$ === "wrong", text: falseLabel } ]; }; })(); trainers/buttonsText/elements/element/buttons/highlightSpan/pulse/pulse.ls (function(){ return function(slide, classId, color1, duration1, waitTime, color2, duration2){ var spans, i$, len$, i, s; spans = slide.div.findAll("span." + classId); for (i$ = 0, len$ = spans.length; i$ < len$; ++i$) { i = i$; s = spans[i$]; if (i === 0) { slide.levelPlayer.page.scrollElementIntoView(s, { padding: 50 }); } s.css({ backgroundColor: color1, transition: duration1 + "ms background" }); } setTimeout(function(){ var i$, ref$, len$, s, results$ = []; for (i$ = 0, len$ = (ref$ = spans).length; i$ < len$; ++i$) { s = ref$[i$]; results$.push(s.css({ backgroundColor: color2, transition: duration2 + "ms background" })); } return results$; }, waitTime); return setTimeout(function(){ var i$, ref$, len$, s, results$ = []; for (i$ = 0, len$ = (ref$ = spans).length; i$ < len$; ++i$) { s = ref$[i$]; results$.push(s.css({ transition: "" })); } return results$; }, waitTime + duration2); }; })(); trainers/buttonsText/elements/element/buttons/highlightSpan/update.ls (function(){ return function(slide, atom){ if (atom.highlightSpanClass == null) { return; } return inc("pulse/pulse")(slide, atom.highlightSpanClass, Color.amber[200], 300, 300, Color.amber[75], 300); }; })(); trainers/buttonsText/elements/element/buttons/title/title.ls (function(){ return function(atom){ return Div({ display: "inline-block", padding: "0.7em 0.5em 0.4em", textAlign: "center" }).html(atom.a); }; })(); trainers/buttonsText/elements/element/element.ls (function(){ return function(atom, i, slide){ if (atom.title) { return inc("title/title")(atom, i, slide); } else if (atom.text) { return inc("text/text")(atom, i, slide); } else if (atom.example) { return inc("example/example")(atom, i, slide); } else if (atom.image) { return inc("image/image")(atom, i, slide); } else if (atom.lsg) { return inc("lsg/lsg")(atom, i, slide); } else if (atom.b != null) { return inc("buttons/buttons")(atom, i, slide); } else { debug("Atom-Typ " + _.keys(atom)[0] + " wird nicht unterstützt"); return null; } }; })(); trainers/buttonsText/elements/element/example/example.ls (function(){ return function(atom, i, slide){ var click, play, start, stop, div, speaker, textA, textB; slide.currentSound = null; click = function(){ var ref$; if ((ref$ = slide.currentSound) != null && (typeof ref$.isPlaying == 'function' && ref$.isPlaying())) { slide.currentSound.stop(); if (slide.currentSound !== speaker) { return play(); } } else { return play(); } }; play = function(){ var voice; slide.currentSound = speaker; voice = slide.getParam("voice", atom); return speaker.play(atom.example.sound + voice); }; start = function(){ div.hide(); div.fadeIn(800); slide.curDiv = div; if (slide.getParam("continueButton", atom) === false) { slide.startNextElement(); } else { slide.continueButton.showButton(); } if (atom.autoplay) { return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: click }); } }; stop = function(){ return slide.continueButton.hide(); }; slide.content.append(div = Div({ margin: "0.5em 0", padding: "0.8em", backgroundColor: Color.grey[200], textAlign: "left" }).append(atom.example.sound ? speaker = inc("speaker/speaker")(slide) : void 8, textA = inc("textA/textA")(slide, atom), textB = inc("textB/textB")(slide, atom)).hide()); if (atom.example.sound) { div.css({ paddingLeft: "2.2em", cursor: "pointer" }).addClass("speakerClickDiv").tap(click); } return { start: start, stop: stop }; }; })(); trainers/buttonsText/elements/element/example/speaker/speaker.ls (function(){ return function(slide){ var sounds, currentSound, isPlaying, play, stop, div; sounds = slide.sounds; currentSound = null; isPlaying = false; play = function(newText, onDone){ if (!isPlaying) { isPlaying = true; currentSound = sounds[newText]; return currentSound.play(function(){ return isPlaying = false; }, div.update); } }; stop = function(){ div.reset(); currentSound.stop(); return isPlaying = false; }; div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: "1.2em", outline: true }).css({ position: "absolute", top: "0.8em", left: "0.65em", pointerEvents: "none" }); div.play = play; div.stop = stop; div.isPlaying = function(){ return isPlaying; }; return div; }; })(); trainers/buttonsText/elements/element/example/textA/textA.ls (function(){ return function(slide, atom){ var label; label = atom.example.a || " "; return Div().html(label); }; })(); trainers/buttonsText/elements/element/example/textB/textB.ls (function(){ return function(slide, atom){ if (!atom.example.b) { return; } return Div({ paddingTop: "0.3em", fontStyle: "italic", color: Color.grey[650] }).html(atom.example.b); }; })(); trainers/buttonsText/elements/element/image/image.ls (function(){ return function(atom, i, slide){ var start, stop, div; start = function(){ div.hide(); div.fadeIn(800); slide.curDiv = div; return slide.startNextElement(); }; stop = function(){ return slide.continueButton.hide(); }; div = inc("/shared/image/image")({ image: slide.getParam("image", atom), slide: slide, parent: slide.content, wrapWithDiv: true }).appendTo(slide.content).hide(); return { start: start, stop: stop }; }; })(); trainers/buttonsText/elements/element/lsg/lsg.ls (function(){ return function(atom, i, slide){ var start, stop, div; start = function(){ div.hide(); div.fadeIn(800); slide.curDiv = div; return slide.startNextElement(); }; stop = function(){ return slide.continueButton.hide(); }; div = inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", atom), slide: slide, parent: slide.content, wrapWithDiv: true }).appendTo(slide.content).hide(); return { start: start, stop: stop }; }; })(); trainers/buttonsText/elements/element/text/sound/sound.ls (function(){ return function(slide){ var sounds, currentSound, isPlaying, play, stop, div; sounds = slide.sounds; currentSound = null; isPlaying = false; play = function(newText, onDone){ if (!isPlaying) { isPlaying = true; currentSound = sounds[newText]; return currentSound.play(function(){ return isPlaying = false; }, div.update); } }; stop = function(){ div.reset(); currentSound.stop(); return isPlaying = false; }; div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: "1.2em", outline: true }).css({ verticalAlign: "bottom", marginRight: "0.2em", pointerEvents: "none" }); div.play = play; div.stop = stop; div.isPlaying = function(){ return isPlaying; }; return div; }; })(); trainers/buttonsText/elements/element/text/text.ls (function(){ return function(atom, i, slide){ var voice, text, soundText, click, play, start, stop, div, sound; slide.currentSound = null; voice = null; text = atom.text; text = _.replaceAll(text, "\n", " "); soundText = atom.sound || text; click = function(){ var ref$; voice = slide.getParam("voice", atom); if ((ref$ = slide.currentSound) != null && (typeof ref$.isPlaying == 'function' && ref$.isPlaying())) { slide.currentSound.stop(); if (slide.currentSound !== sound) { return play(); } } else { return play(); } }; play = function(){ slide.currentSound = sound; return sound.play(soundText + voice); }; start = function(){ div.hide(); div.fadeIn(800); slide.curDiv = div; if (slide.getParam("continueButton", atom) === false) { slide.startNextElement(); } else { slide.continueButton.showButton(); } if (atom.autoplay) { return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: click }); } }; stop = function(){ return slide.continueButton.hide(); }; slide.content.append(div = Div({ paddingTop: "0.4em", textAlign: "left" }).html(atom.text).hide()); if (atom.speaker || atom.sound) { div.prepend(sound = inc("sound/sound")(slide)); div.tap(click); } return { start: start, stop: stop }; }; })(); trainers/buttonsText/elements/element/title/title.ls (function(){ return function(atom, i, slide){ var start, stop, div; start = function(){ div.show(); return slide.startNextElement(); }; stop = function(){}; slide.content.append(div = Div({ marginTop: "0.5em", marginBottom: "0.5em", fontSize: "1.3em" }).html(atom.title).hide()); return { start: start, stop: stop }; }; })(); trainers/buttonsText/elements/elements.ls (function(){ return function(slide){ var i, atom; return slide.elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; results$.push(inc("element/element")(atom, i, slide)); } return results$; }()); }; })(); trainers/buttonsText/footer/footer.ls (function(){ return function(slide){ var div; return div = Div({ minHeight: "2em", textAlign: "center" }).bind("touchstart touchmove touchend", function(e){ return e.preventDefault(); }); }; })(); trainers/buttonsText/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.trueFalseMode = (ref$ = slide.getParam("trueFalseMode")) != null ? ref$ : false; slide.totalProgressElements = _.filter(atoms, "a").length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/buttonsText/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.content = inc("content/content")(slide); slide.footer = inc("footer/footer")(slide); slide.continueButton = inc("continueButton/button")(slide); inc("elements/elements")(slide); return slide.startNextElement = inc("startNextElement/start")(slide); }; })(); trainers/buttonsText/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/buttonsText/startNextElement/start.ls (function(){ return function(slide){ return function(){ var oldElement, currentAtom, ref$; oldElement = slide.elements[slide.currentIndex]; if (oldElement != null) { oldElement.stop(); } slide.currentIndex++; slide.currentElement = slide.elements[slide.currentIndex]; currentAtom = slide.atoms[slide.currentIndex]; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, currentAtom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, currentAtom); } if (slide.currentIndex === slide.elements.length) { slide.div.css({ pointerEvents: "none" }); return slide.finish(); } else { return slide.currentElement.start(); } }; }; })(); trainers/content/_media2/images/images.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }; })(); trainers/content/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }; })(); trainers/content/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, text; sounds = []; for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "example")).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.example.sound != null) { sounds.push({ text: atom.example.sound, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "text")).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.sound || atom.speaker) { text = atom.sound || atom.text; text = _.replaceAll(text, "\n", " "); sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } return sounds; }; })(); trainers/content/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = slide.content.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.show()); } return results$; }; })(); trainers/content/_review/scoreActions/actions.ls (function(){ return function(slide){}; })(); trainers/content/_skip/skip.ls (function(){ return function(slide){ slide.userInteractionStarted = true; if (slide.elements[slide.currentIndex] == null) { return slide.onFinishedSlide(); } if (slide.atoms[slide.currentIndex].button) { slide.elements[slide.currentIndex].div.remove(); slide.levelPlayer.progressBar.showGreen(); } return slide.startNextElement(); }; })(); trainers/content/_start/start.ls (function(){ return function(slide){ slide.levelPlayer.progressBar.disableSounds(); slide.levelPlayer.page.enableFreezeMinHeight(); slide.instruction.play(); return slide.startNextElement(); }; })(); trainers/content/content/content.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ margin: "1em auto", width: "30em", maxWidth: "95%", padding: "0 1em" })); return div; }; })(); trainers/content/elements/element/button/button.ls (function(){ return function(slide, atom, i){ var start, click, label, div, button; start = function(){ var visibleAtoms, i$, ref$, atom, lastHintAtom; visibleAtoms = []; for (i$ = (ref$ = _.slice(slide.atoms, 0, i)).length - 1; i$ >= 0; --i$) { atom = ref$[i$]; if (atom.button) { break; } visibleAtoms.unshift(atom); } lastHintAtom = _.findLast(visibleAtoms, function(a){ return a.hint; }); if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, lastHintAtom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, lastHintAtom); } div.hide(); return div.fadeIn(); }; click = function(){ slide.userInteractionStarted = true; div.css({ pointerEvents: "none" }); slide.score.log(atom); slide.levelPlayer.progressBar.showGreen(); return setTimeout(function(){ div.remove(); return slide.startNextElement(); }, 500); }; label = atom.button || T("continueButton"); slide.content.append(div = Div({ padding: "1em 0" }).html(button = Button({ label: label, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter", labelAllowWrap: true }).css({ minWidth: "4em", maxWidth: "90%" })).hide()); return { start: start, div: div }; }; })(); trainers/content/elements/element/element.ls (function(){ return function(slide, atom, i){ var p, rowType; for (p in atom) { rowType = p; break; } return inc(rowType + "/" + rowType)(slide, atom, i); }; })(); trainers/content/elements/element/example/example.ls (function(){ return function(slide, atom, i){ var click, play, start, div, speaker, textA, textB; slide.currentSound = null; click = function(){ var ref$; if ((ref$ = slide.currentSound) != null && (typeof ref$.isPlaying == 'function' && ref$.isPlaying())) { slide.currentSound.stop(); if (slide.currentSound !== speaker) { return play(); } } else { return play(); } }; play = function(){ var voice; slide.currentSound = speaker; voice = slide.getParam("voice", atom); return speaker.play(atom.example.sound + voice); }; start = function(){ if (atom.example.autoplay) { slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: click }); } div.hide(); div.fadeIn(); return slide.startNextElement(); }; slide.content.append(div = Div({ margin: "0.5em 0", padding: "0.8em", backgroundColor: Color.grey[200], textAlign: "left" }).append(atom.example.sound ? speaker = inc("speaker/speaker")(slide) : void 8, textA = inc("textA/textA")(slide, atom), textB = inc("textB/textB")(slide, atom)).hide()); if (atom.example.sound) { div.css({ paddingLeft: "2.2em", cursor: "pointer" }).addClass("speakerClickDiv").tap(click); } return { start: start, div: div }; }; })(); trainers/content/elements/element/example/speaker/speaker.ls (function(){ return function(slide){ var sounds, currentSound, isPlaying, play, stop, div; sounds = slide.sounds; currentSound = null; isPlaying = false; play = function(newText, onDone){ if (!isPlaying) { isPlaying = true; currentSound = sounds[newText]; return currentSound.play(function(){ return isPlaying = false; }, div.update); } }; stop = function(){ div.reset(); currentSound.stop(); return isPlaying = false; }; div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: "1.2em", outline: true }).css({ position: "absolute", top: "0.8em", left: "0.65em", pointerEvents: "none" }); div.play = play; div.stop = stop; div.isPlaying = function(){ return isPlaying; }; return div; }; })(); trainers/content/elements/element/example/textA/textA.ls (function(){ return function(slide, atom){ var label; label = atom.example.a || " "; return Div().html(label); }; })(); trainers/content/elements/element/example/textB/textB.ls (function(){ return function(slide, atom){ if (!atom.example.b) { return; } return Div({ paddingTop: "0.3em", fontStyle: "italic", color: Color.grey[650] }).html(atom.example.b); }; })(); trainers/content/elements/element/image/image.ls (function(){ return function(slide, atom, i){ var start, div; start = function(){ if (typeof div != 'undefined' && div !== null) { div.hide().fadeIn(); } return slide.startNextElement(); }; div = inc("/shared/image/image")({ image: slide.getParam("image", atom), slide: slide, parent: slide.content, wrapWithDiv: true }).appendTo(slide.content).hide(); return { start: start, div: div }; }; })(); trainers/content/elements/element/list/list.ls (function(){ return function(slide, atom, i){ var start, list, style, listDiv, div, el; start = function(){ div.hide(); div.fadeIn(); return slide.startNextElement(); }; list = atom.list; style = list.style || "bullets"; listDiv = style === "bullets" ? Ul() : Ol(); div = Div({ textAlign: slide.getParam("textAlign", atom) || "left" }).append(listDiv.css({ display: "inline-block", margin: "0.5em 0", textAlign: list.textAlign || "left" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.ensureArray(list.elements)).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(Li().html(el)); } return results$; }()))).hide().appendTo(slide.content); return { start: start, div: div }; }; })(); trainers/content/elements/element/lsg/lsg.ls (function(){ return function(slide, atom, i){ var start, div; start = function(){ if (typeof div != 'undefined' && div !== null) { div.hide().fadeIn(); } return slide.startNextElement(); }; div = inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", atom), slide: slide, parent: slide.content, wrapWithDiv: true }).hide().appendTo(slide.content); return { start: start, div: div }; }; })(); trainers/content/elements/element/table/calcBackgroundColor/calc.ls (function(){ return function(cell, columnHeader, rowHeader, ri, ci){ var that; if (that = cell.color) { return that; } else if (columnHeader && ri === 0) { return Color.grey[100]; } else if (rowHeader && ci === 0) { return Color.grey[100]; } else { return Color.white; } }; })(); trainers/content/elements/element/table/parseLayout/parse.ls (function(){ return function(layout){ var layout2, i$, ref$, len$, ri, r, thick, row, j$, len1$, ci, id, cell, c; layout2 = []; for (i$ = 0, len$ = (ref$ = layout.split("\n")).length; i$ < len$; ++i$) { ri = i$; r = ref$[i$]; thick = false; layout2.push([]); r = r.trim(); row = r.split(/([\s-|])+/); for (j$ = 0, len1$ = row.length; j$ < len1$; ++j$) { ci = j$; id = row[j$]; if (ci % 2 !== 0) { thick = id === "|"; continue; } cell = { ci: ci, id: id }; if (thick) { cell.thick = true; } if (!(id === " " || id === "|")) { if (/_+/.test(id)) { c = _.findLast(layout2[ri], fn$); if (c != null) { c.colspan += 1; } cell.colspan = 0; } else { cell.colspan = 1; } } layout2[ri].push(cell); } } return layout2; function fn$(c){ return c.colspan > 0; } }; })(); trainers/content/elements/element/table/table.ls (function(){ return function(slide, atom, i){ var columnHeader, rowHeader, cells, layout, start, div, ri, row, cell, ci, id, d, c, v; columnHeader = atom.table.columnHeader; rowHeader = atom.table.rowHeader; cells = []; layout = inc("parseLayout/parse")(atom.table.layout); start = function(){ div.hide(); div.fadeIn(); return slide.startNextElement(); }; div = ScrollDiv({ enableScrollY: false, enableScrollX: true, scrollbarMode: "hide" }).append(Table().css({ backgroundColor: Color.grey[300], display: "inline-block", margin: "0.5em 0" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = layout).length; i$ < len$; ++i$) { ri = i$; row = ref$[i$]; results$.push(Tr().append((fn$()))); } return results$; function fn$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = row).length; i$ < len$; ++i$) { cell = ref$[i$]; ci = cell.ci; id = cell.id; if (cell.colspan === 0) { continue; } d = Td(); c = atom.table.data[id] || ""; v = c.text || c; d.addClass(id).attr({ colspan: cell.colspan }).css({ wordWrap: "break-word", hyphens: "auto", padding: "0.5em", backgroundColor: inc("calcBackgroundColor/calc")(c, columnHeader, rowHeader, ri, ci), minWidth: atom.table.columnWidth !== "small" ? "5em" : "2.5em", borderLeft: cell.thick ? "2px solid " + Color.grey[300] : void 8 }).html(v); cells.push(d); results$.push(d); } return results$; } }()))).appendTo(slide.content).hide(); return { start: start, div: div }; }; })(); trainers/content/elements/element/text/speaker/speaker.ls (function(){ return function(slide){ var currentSound, isPlaying, play, stop, div; currentSound = null; isPlaying = false; play = function(newText){ if (!isPlaying) { isPlaying = true; currentSound = slide.sounds[newText]; return currentSound.play(function(){ return isPlaying = false; }, div.update); } }; stop = function(){ div.reset(); currentSound.stop(); return isPlaying = false; }; div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: "1.2em", outline: true }).css({ verticalAlign: "-0.1em", marginRight: "0.2em", pointerEvents: "none" }); div.play = play; div.stop = stop; div.isPlaying = function(){ return isPlaying; }; return div; }; })(); trainers/content/elements/element/text/text.ls (function(){ return function(slide, atom, i){ var text, soundText, click, play, start, div, div2, sound; slide.currentSound = null; text = atom.text; text = _.replaceAll(text, "\n", " "); soundText = atom.sound || text; soundText = _.replaceAll(soundText, "\n", " "); click = function(){ var ref$; if ((ref$ = slide.currentSound) != null && (typeof ref$.isPlaying == 'function' && ref$.isPlaying())) { slide.currentSound.stop(); if (slide.currentSound !== sound) { return play(); } } else { return play(); } }; play = function(){ var voice; slide.currentSound = sound; voice = slide.getParam("voice", atom); return sound.play(soundText + voice); }; start = function(){ if (atom.autoplay) { slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: click }); } div.hide(); div.fadeIn(); return slide.startNextElement(); }; slide.content.append(div = Div({ padding: "0.5em 0", textAlign: slide.getParam("textAlign", atom) || "left" }).html(div2 = Span().html(text)).hide()); if (atom.speaker || atom.sound) { div2.prepend(sound = inc("speaker/speaker")(slide)); div.addClass("speakerClickDiv").tap(click); } return { start: start, div: div }; }; })(); trainers/content/elements/element/title/title.ls (function(){ return function(slide, atom, i){ var start, div; start = function(){ div.hide(); div.fadeIn(); return slide.startNextElement(); }; slide.content.append(div = Div({ textAlign: "center", padding: "0.5em" }).html(Span().css({ fontSize: "1.3em" }).html(atom.title)).hide()); return { start: start, div: div }; }; })(); trainers/content/elements/elements.ls (function(){ return function(slide){ var elements, i, a; return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; results$.push(inc("element/element")(slide, a, i)); } return results$; }()); }; })(); trainers/content/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, ref$; atoms = _.cloneDeep(_.ensureArray(trainerParams.atoms)); if (!atoms[atoms.length - 1].button) { atoms.push({ button: T("continueButton") }); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = _.filter(atoms, function(a){ return a.button != null; }).length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/content/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.content = inc("content/content")(slide); slide.elements = inc("elements/elements")(slide); return slide.startNextElement = inc("startNextElement/start")(slide); }; })(); trainers/content/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/content/startNextElement/start.ls (function(){ return function(slide){ return function(){ var e, i$, ref$, len$, el; if (!slide.div.isVisible()) { return; } slide.currentIndex++; e = slide.elements[slide.currentIndex]; if (e) { if (slide.userInteractionStarted) { slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(e.div, { padding: 50 }); }); } }); } return e.start(); } else { slide.div.css({ pointerEvents: "none" }); for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.div.hasClass("speakerClickDiv")) { el.div.css({ pointerEvents: "auto" }); } } return setTimeout(slide.finish, 500); } }; }; })(); trainers/contentCard/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/contentCard/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/contentCard/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { texts = [slide.atom.b]; } else if (soundMode === "a") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/contentCard/_preview/preview.ls (function(){ return function(slide){ var lsg, width; if (slide.lsg) { lsg = slide.lsg.findFirst("svg"); width = lsg.css("width"); width = width.replace("em", "") * 0.4 + "em"; return lsg.css({ width: width }); } }; })(); trainers/contentCard/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ margin: "2em 0", textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/contentCard/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/contentCard/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/contentCard/_start/start.ls (function(){ return function(slide){ slide.levelPlayer.progressBar.disableSounds(); slide.levelPlayer.page.enableFreezeMinHeight(); return slide.instruction.play(function(){ return inc("../playSound/play")(slide, function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.continueButton, { padding: 10 }); }); }); }; })(); trainers/contentCard/continueButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ div.remove(); slide.score.log(slide.atom); slide.levelPlayer.progressBar.showGreen(); slide.div.css({ pointerEvents: "none" }); return slide.finish(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter", label: T("continueButton") }).css({ marginBottom: "1em" }).appendTo(slide.div); }; })(); trainers/contentCard/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.soundMode = slide.getParam("soundMode", slide.atom); slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/contentCard/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/contentCard/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.title = inc("title/title")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.text = inc("text/text")(slide); return slide.continueButton = inc("continueButton/button")(slide); }; })(); trainers/contentCard/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/contentCard/lsg/lsg.ls (function(){ return function(slide){ var lsg, div; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); if (!div) { return; } div.appendTo(slide.div); return div; }; })(); trainers/contentCard/playSound/play.ls (function(){ return function(slide, onDone){ var autoplay, ref$, voice, soundMode, text, soundDiv; autoplay = (ref$ = slide.atom.autoplay) != null ? ref$ : true; voice = slide.getParam("voice", slide.atom); soundMode = slide.getParam("soundMode", slide.atom); text = slide.atom.sound || slide.atom[soundMode]; if (!text || !autoplay) { return typeof onDone == 'function' ? onDone() : void 8; } soundDiv = soundMode === "a" ? slide.textA : soundMode === "b" ? slide.textB : void 8; return setTimeout(function(){ if (!slide.isFinished) { return soundDiv.play(text + voice, function(){ return typeof onDone == 'function' ? onDone() : void 8; }); } }, 500); }; })(); trainers/contentCard/text/speaker/speaker.ls (function(){ return function(slide, large){ var sounds, currentSound, isPlaying, play, stop, div; sounds = slide.sounds; currentSound = null; isPlaying = false; play = function(newText, onDone){ if (!isPlaying) { isPlaying = true; currentSound = sounds[newText]; return currentSound.play(function(){ if (typeof onDone == 'function') { onDone(); } return isPlaying = false; }, div.update); } }; stop = function(){ div.reset(); currentSound.stop(); return isPlaying = false; }; div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: large ? "2.8em" : "1.2em", outline: !large }).css({ verticalAlign: "-0.15em", marginRight: "0.2em", pointerEvents: "none" }); div.play = play; div.stop = stop; div.isPlaying = function(){ return isPlaying; }; return div; }; })(); trainers/contentCard/text/text.ls (function(){ return function(slide){ var textAlign, div, layout, a, b; textAlign = slide.getParam("textAlign", slide.atom) || "center"; div = Div({ margin: "1.5em auto", width: "30em", maxWidth: "90%", textAlign: textAlign }).appendTo(slide.div); layout = slide.getParam("layout", slide.atom) || "ba"; a = inc("textA/textA")(slide); b = inc("textB/textB")(slide); if (layout === "ab") { div.append(a, b); if (a && b) { a.after(Span().html("
")); if (b != null) { b.css({ marginTop: "0.5em" }); } } } else if (layout === "ba") { div.append(b, a); if (a && b) { b.after(Span().html("
")); if (a != null) { a.css({ marginTop: "0.5em" }); } } } slide.textA = a; slide.textB = b; return div; }; })(); trainers/contentCard/text/textA/textA.ls (function(){ return function(slide){ var voice, soundText, click, div, large, speaker; voice = slide.getParam("voice", slide.atom); soundText = slide.atom.sound || slide.atom.a; if (slide.soundMode === "a") { if (!soundText) { return; } } else { if (!slide.atom.a) { return; } } click = function(){ if (speaker.isPlaying()) { return speaker.stop(); } else { return speaker.play(soundText + "" + voice); } }; div = Div({ display: "inline-block", padding: "0 1em", fontStyle: "italic" }).html(slide.atom.a); if (slide.soundMode === "a") { large = slide.atom.a == null || slide.atom.a === ""; div.prepend(speaker = inc("../speaker/speaker")(slide, large)).tap(click); } div.play = speaker != null ? speaker.play : void 8; return div; }; })(); trainers/contentCard/text/textB/textB.ls (function(){ return function(slide){ var voice, soundText, click, div, large, speaker; voice = slide.getParam("voice", slide.atom); soundText = slide.atom.sound || slide.atom.b; if (slide.soundMode === "b") { if (!soundText) { return; } } else { if (!slide.atom.b) { return; } } click = function(){ if (speaker.isPlaying()) { return speaker.stop(); } else { return speaker.play(soundText + "" + voice); } }; div = Div({ display: "inline-block", padding: "0 1em", fontSize: "1em" }).html(slide.atom.b); if (slide.soundMode === "b") { large = slide.atom.b == null || slide.atom.b === ""; div.prepend(speaker = inc("../speaker/speaker")(slide, large)).tap(click); } div.play = speaker != null ? speaker.play : void 8; return div; }; })(); trainers/contentCard/title/title.ls (function(){ return function(slide){ var div; if (!slide.atom.title) { return; } return div = Div({ margin: "0 auto 1em", width: "30em", maxWidth: "90%", fontSize: "1.3em" }).html(slide.atom.title).appendTo(slide.div); }; })(); trainers/contentPlayer/_media2/images/images.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }; })(); trainers/contentPlayer/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }; })(); trainers/contentPlayer/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, text, that; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; text = (that = atom.sound) ? that : atom.text && atom.speaker ? atom.text : (that = atom.duration) ? "ssml: " : void 8; if (text) { sounds.push({ text: text, voice: slide.getParam("voice", atom), voiceLang: slide.getParam("voiceLang", atom) }); } } return sounds; }; })(); trainers/contentPlayer/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, a, element, results$ = []; slide.previewMode = true; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; if (!a.text && a.sound && !_.startsWith(a.sound, "ssml")) { a.text = a.sound.replace(/]*>.*?<\/voice>/, ""); } } slide.content.css({ display: "flex", flexDirection: "column", margin: "1em 0" }); for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { element = ref$[i$]; results$.push(element.start()); } return results$; }; })(); trainers/contentPlayer/_review/scoreActions/actions.ls (function(){ return function(slide){}; })(); trainers/contentPlayer/_skip/skip.ls (function(){ return function(slide){ if (slide.elements[slide.currentIndex + 1] == null) { return slide.onFinishedSlide(); } slide.levelPlayer.progressBar.showGreen(); return slide.startElement(slide.currentIndex + 1); }; })(); trainers/contentPlayer/_start/start.ls (function(){ return function(slide){ slide.levelPlayer.progressBar.disableSounds(); slide.levelPlayer.page.bottom.html(slide.footer).show(); return slide.instruction.play(function(){ slide.instruction.remove(); return slide.startElement(slide.currentIndex + 1); }); }; })(); trainers/contentPlayer/calcSeparations/calc.ls (function(){ return function(slide){ var separations, last, i$, ref$, len$, i, atom, clickCl, hideCl; separations = []; last = -1; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; clickCl = atom.clickClasses; hideCl = atom.hideClasses; if (atom.continueButton || clickCl && _.intersection(hideCl, clickCl).length < 1) { separations.push(last); last = i; } } return separations; }; })(); trainers/contentPlayer/content/content.ls (function(){ return function(slide){ return Div({ width: "35em", maxWidth: "95%", margin: "0 auto" }).appendTo(slide.div); }; })(); trainers/contentPlayer/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ if (!slide.footer.isVisible()) { slide.footer.show(); } return div.show(); }; click = function(){ div.hide(); slide.footer.hide(); return setTimeout(function(){ slide.currentSeparationIndex++; return slide.startElement(slide.currentIndex + 1); }, 500); }; slide.footer.append(div = Button({ action: click, label: T("continueButton"), key: "enter", icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em 0.25em" }).hide()); div.showButton = showButton; return div; }; })(); trainers/contentPlayer/elements/element/element.ls (function(){ return function(slide, atom, i){ var lsg, image, text, first, div, play, onFinish, start, stop; first = true; div = Div({ display: "inline-block" }); play = function(){ var voice, ref$, sound, that, ref1$; voice = slide.getParam("voice", atom); if ((ref$ = slide.currentSound) != null) { ref$.stop(); } sound = (that = atom.duration) ? "ssml: " : atom.text && atom.speaker ? atom.text : atom.sound; if (!sound) { onFinish(); return; } slide.currentSound = slide.sounds[sound + voice]; return slide.currentSound.play(onFinish, text != null ? (ref1$ = text.speaker) != null ? ref1$.update : void 8 : void 8); }; onFinish = function(){ if (lsg != null && lsg.hasValidClickClasses()) { if (atom.continueButton) { debug("continueButton is not allowed in atoms with clickClasses"); } return slide.replayButton.showButton(); } else if (atom.continueButton) { slide.replayButton.showButton(); return slide.continueButton.showButton(); } else { return slide.startElement(slide.currentIndex + 1); } }; start = function(){ var ref$, ref1$, ref2$; if (first) { if ((ref$ = slide.levelPlayer) != null) { if (typeof (ref1$ = ref$.page).setTrainerHint == 'function') { ref1$.setTrainerHint(slide, atom); } } if ((ref1$ = slide.levelPlayer) != null) { if (typeof (ref2$ = ref1$.page).setCalculator == 'function') { ref2$.setCalculator(slide, atom); } } div.html(lsg = inc("lsg/lsg")(slide, atom), image = inc("image/image")(slide, atom), atom.text ? text = inc("text/text")(slide, atom) : void 8); if (lsg != null) { lsg.setClickZones(); } } first = false; slide.content.append(div); requestAnimationFrame(function(){ var ref$; return (ref$ = slide.levelPlayer) != null ? ref$.page.scrollElementIntoView(div, { instant: true, padding: 50 }) : void 8; }); if (!slide.previewMode) { return play(); } }; stop = function(){ return div != null ? div.remove() : void 8; }; return { start: start, stop: stop }; }; })(); trainers/contentPlayer/elements/element/image/image.ls (function(){ return function(slide, atom){ if (!atom.image) { return; } return inc("/shared/image/image")({ image: slide.getParam("image", atom), slide: slide, parent: slide.content, wrapWithDiv: true }); }; })(); trainers/contentPlayer/elements/element/lsg/iconCorrectTemp/icon.ls (function(){ return function(){ var showAt, div; showAt = function(x, y, onDone){ div.css({ left: x + "px", top: y + "px" }); div.show(); if (onDone != null) { return setTimeout(function(){ return div.fadeOut(300, onDone); }, 400); } }; div = Div({ display: "inline-block", position: "absolute", left: "50%", top: "50%", margin: "-0.75em" }).append(SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-correct.svg") }).css({ position: "absolute", width: "1.5em", height: "1.5em" })).hide(); div.showAt = showAt; return div; }; })(); trainers/contentPlayer/elements/element/lsg/lsg.ls (function(){ return function(slide, atom){ var clickClassesDone, clicked, hasValidClickClasses, click, setClickZones, lsg, i$, ref$, len$, c, j$, ref1$, len1$, t; if (!atom.lsg) { return; } clickClassesDone = {}; clicked = 0; hasValidClickClasses = function(){ if (!atom.lsg) { return false; } else if (!atom.clickClasses) { return false; } else if (_.intersection(atom.hideClasses, atom.clickClasses).length > 0) { return false; } else { return true; } }; click = function(e, c){ var icon, ref$, ref1$, ref2$; if (clickClassesDone[c] === true) { return; } clickClassesDone[c] = true; lsg.append(icon = inc("iconCorrectTemp/icon")()); icon.showAt(((ref$ = (ref1$ = e.touches) != null ? ref1$[0].pageX : void 8) != null ? ref$ : e.pageX) - lsg.offset().left, ((ref$ = (ref2$ = e.touches) != null ? ref2$[0].pageY : void 8) != null ? ref$ : e.pageY) - lsg.offset().top); inc("/../app01/lib/util/soundEffectPlay/soundEffectPlay")("correct"); if (_.every(_.values(clickClassesDone), function(v){ return v; })) { return setTimeout(function(){ slide.currentSeparationIndex++; return slide.startElement(slide.currentIndex + 1); }, 1000); } }; setClickZones = function(){ var i$, ref$, len$, results$ = []; if (atom.clickClasses) { for (i$ = 0, len$ = (ref$ = atom.clickClasses).length; i$ < len$; ++i$) { results$.push((fn$.call(this, ref$[i$]))); } return results$; } function fn$(c){ var i$, ref$, len$, t, results$ = []; clickClassesDone[c] = false; for (i$ = 0, len$ = (ref$ = lsg.findAll("." + c)).length; i$ < len$; ++i$) { t = ref$[i$]; results$.push(t.tap(fn$).css({ cursor: "initial" })); } return results$; function fn$(e){ return click(e, c); } } }; lsg = inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", atom), slide: slide, parent: slide.content, wrapWithDiv: true }); if (atom.hideClasses) { for (i$ = 0, len$ = (ref$ = atom.hideClasses).length; i$ < len$; ++i$) { c = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = lsg.findAll("." + c)).length; j$ < len1$; ++j$) { t = ref1$[j$]; t.css({ opacity: 0, pointerEvents: "none" }); } } } lsg.setClickZones = setClickZones; lsg.hasValidClickClasses = hasValidClickClasses; return lsg; }; })(); trainers/contentPlayer/elements/element/text/speaker/speaker.ls (function(){ return function(slide){ var div; return div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: "1.2em", outline: true }).css({ verticalAlign: "-0.1em", marginRight: "0.2em", pointerEvents: "none" }); }; })(); trainers/contentPlayer/elements/element/text/text.ls (function(){ return function(slide, atom){ var div, speaker; div = Div({ textAlign: slide.getParam("textAlign", atom) || "center" }).html(atom.text); if (atom.text && (atom.sound || atom.speaker)) { div.prepend(speaker = inc("speaker/speaker")(slide)); } div.speaker = speaker; return div; }; })(); trainers/contentPlayer/elements/elements.ls (function(){ return function(slide){ var elements, i, a; return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; results$.push(inc("element/element")(slide, a, i)); } return results$; }()); }; })(); trainers/contentPlayer/footer/footer.ls (function(){ return function(){ return Div({ minHeight: "2em", textAlign: "center" }).bind("touchstart touchmove touchend", function(e){ return e.preventDefault(); }).hide(); }; })(); trainers/contentPlayer/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/contentPlayer/init.ls (function(){ return function(slide){ slide.currentSeparationIndex = 0; slide.currentIndex = -1; slide.separations = inc("calcSeparations/calc")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.footer = inc("footer/footer")(slide); slide.replayButton = inc("replayButton/button")(slide); slide.continueButton = inc("continueButton/button")(slide); slide.content = inc("content/content")(slide); slide.elements = inc("elements/elements")(slide); return slide.startElement = inc("startElement/start")(slide); }; })(); trainers/contentPlayer/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/contentPlayer/replayButton/button.ls (function(){ return function(slide){ var click, showButton, div; click = function(){ div.hide(); slide.footer.hide(); return slide.startElement(slide.separations[slide.currentSeparationIndex] + 1, slide.currentIndex); }; showButton = function(){ if (!slide.footer.isVisible()) { slide.footer.show(); } return div.show(); }; slide.footer.append(div = Button({ action: click, icon: path("/../app01/lib/svg/icon/refresh.svg") }).css({ margin: "0.5em 0.25em" })); div.showButton = showButton; return div; }; })(); trainers/contentPlayer/startElement/start.ls (function(){ return function(slide){ return function(index, oldIndex){ var currentElement, repeatTimes, oldElement; if (!slide.div.isVisible()) { return; } slide.footer.hide(); currentElement = slide.elements[index]; if (currentElement) { if (oldIndex != null) { repeatTimes = oldIndex - index + 1; _.times(repeatTimes, function(){ return slide.levelPlayer.progressBar.removeLastAdded(); }); } else { oldIndex = index - 1; } slide.levelPlayer.progressBar.showGreen(); slide.score.log(slide.atoms[slide.currentIndex]); oldElement = slide.elements[oldIndex]; if (oldElement != null) { oldElement.stop(); } slide.currentIndex = index; return currentElement.start(); } else { slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); } }; }; })(); trainers/digitalClock/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/digitalClock/_preview/preview.ls (function(){ return function(slide){ var ref$, init; if ((ref$ = slide.debugTrigger) != null) { ref$.remove(); } init = slide.getParam("init", slide.atom) || "00:00"; return slide.interactive.set(init); }; })(); trainers/digitalClock/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, interactive, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.interactive.remove(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; interactive = inc("../../interactive/interactive")(slide); if (a.resolved) { interactive.solve(); } else { interactive.set(a.selectedValue); } results$.push(slide.div.append(Div({ margin: "3em 0" }).append(interactive, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))))); } return results$; } }; })(); trainers/digitalClock/_start/start.ls (function(){ return function(slide){ var init; slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); init = slide.getParam("init", slide.atom) || "00:00"; return slide.interactive.set(init); }; })(); trainers/digitalClock/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/digitalClock/buttons/buttons.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ margin: "1em 0" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.clearButton = inc("clearButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide))); return div; }; })(); trainers/digitalClock/buttons/checkButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ var result; slide.buttons.css({ pointerEvents: "none" }); result = slide.interactive.validate(); if (result.isCorrect) { slide.score.addActionCorrect(slide.atom, { selectedValue: result.selectedValue }); slide.score.log(slide.atom); div.setState("correct"); slide.levelPlayer.progressBar.showGreen(); return setTimeout(slide.finish, 1000); } else { slide.score.addActionMistake(slide.atom, { selectedValue: result.selectedValue }); div.setState("wrong"); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ div.setState("normal"); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } return slide.buttons.css({ pointerEvents: "" }); }, 500); } }; return div = Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).tap(click).css({ margin: "0.5em" }).addClass("keyManager-enter").bind("keyManager", click); }; })(); trainers/digitalClock/buttons/clearButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ return slide.interactive.clear(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/bin.svg"), action: click }).css({ margin: "0.5em" }); }; })(); trainers/digitalClock/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/digitalClock/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, parseSolution, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; parseSolution = function(ss){ var i$, len$, s, results$ = []; for (i$ = 0, len$ = ss.length; i$ < len$; ++i$) { s = ss[i$]; results$.push({ x: s.split(",")[0].trim(), y: s.split(",")[1].trim() }); } return results$; }; click = function(){ slide.buttons.css({ pointerEvents: "none" }); slide.interactive.css({ pointerEvents: "none" }); slide.interactive.solve(); slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom); slide.score.log(slide.atom); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); slide.clearButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); return slide.buttons.css({ pointerEvents: "" }); }, 500); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/digitalClock/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/digitalClock/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); slide.interactive = inc("interactive/interactive")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/digitalClock/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/digitalClock/interactive/column/column.ls (function(){ return function(type, i){ var div, number, up, down; div = Div({ display: "inline-block", width: type === "dummy" ? "10%" : "20%", margin: "1em auto", verticalAlign: "middle" }); number = Div({ textAlign: "center", width: "95%", fontSize: "3em", fontFamily: "monospace", backgroundColor: Color.grey[100] }); if (type !== "dummy") { up = inc("control/control")("up", number); down = inc("control/control")("down", number); } div.append(up, number, down); div.number = number; div.type = type; return div; }; })(); trainers/digitalClock/interactive/column/control/control.ls (function(){ return function(type, number){ var click, changeVal; click = function(){ return number.html(changeVal(number.textContent)); }; changeVal = function(v){ v *= 1; if (type === "down") { v -= 1; if (v < 0) { v = 9; } } else { v += 1; if (v > 9) { v = 0; } } return v; }; if (!(type === "down" || type === "up")) { return; } return Div({ display: "inline-block", width: "3em", height: "2.8em" }).append(SvgIcon({ svg: type === "up" ? path("/../app01/lib/svg/icon/arrow-up.svg") : path("/../app01/lib/svg/icon/arrow-down.svg"), color: Color.grey[400] }).css({ position: "absolute", left: "50%", bottom: 0, right: 0, top: "50%", width: "1.5em", height: "1.5em", marginTop: "-0.75em", marginLeft: "-0.85em" })).tap({ down: click }); }; })(); trainers/digitalClock/interactive/interactive.ls (function(){ return function(slide){ var o, validate, solve, get, set, clear, columns, types, div, i, t, c; o = {}; validate = function(){ return inc("validate/validate")(slide, o, columns); }; solve = function(){ return inc("solve/solve")(o, set, validate); }; get = function(){ var c, res$, i$, ref$, len$, col; res$ = []; for (i$ = 0, len$ = (ref$ = columns).length; i$ < len$; ++i$) { col = ref$[i$]; if (col.type !== "dummy") { res$.push(col.number.textContent * 1); } } c = res$; return c[0] + "" + c[1] + ":" + c[2] + c[3]; }; set = function(time){ var t1, t2, colonIndex, i$, len$, i, d, results$ = []; if (time === "random") { t1 = _.random(0, 23) + ""; t2 = _.random(0, 59) + ""; if (t1.length === 1) { t1 = "0" + t1; } if (t2.length === 1) { t2 = "0" + t2; } time = t1 + ":" + t2; } if (time.length !== 5) { debug("format: mm:ss"); return; } colonIndex = time.indexOf(":"); if (colonIndex !== 2) { debug("colon missing"); return; } for (i$ = 0, len$ = time.length; i$ < len$; ++i$) { i = i$; d = time[i$]; results$.push(columns[i].number.html(d)); } return results$; }; clear = function(){ return set("00:00"); }; columns = []; types = ["minTens", "minOnes", "dummy", "secTens", "secOnes"]; slide.div.append(div = Div().append(Div({ display: "inline-block", width: "20em", maxWidth: "95%", verticalAlign: "middle" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = types).length; i$ < len$; ++i$) { i = i$; t = ref$[i$]; c = inc("column/column")(t, i); columns.push(c); results$.push(c); } return results$; }())))); div.get = get; div.set = set; div.clear = clear; div.solve = solve; div.validate = validate; return div; }; })(); trainers/digitalClock/interactive/solve/solve.ls (function(){ return function(o, set, validate){ if (!o.solution) { validate(); } return set(_.ensureArray(o.solution)[0]); }; })(); trainers/digitalClock/interactive/validate/validate.ls (function(){ return function(slide, o, columns){ var c, res$, i$, len$, col, selectedValue, isCorrect; res$ = []; for (i$ = 0, len$ = columns.length; i$ < len$; ++i$) { col = columns[i$]; if (col.type !== "dummy") { res$.push(col.number.textContent * 1); } } c = res$; selectedValue = c[0] + "" + c[1] + ":" + c[2] + c[3]; if (!o.solution) { o.solution = _.ensureArray(slide.atom.b); } isCorrect = _.includes(o.solution, selectedValue); return { isCorrect: isCorrect, selectedValue: selectedValue }; }; })(); trainers/digitalClock/textA/text.ls (function(){ return function(slide){ var click, div, text; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } click = function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); } }; div = Div(); if (slide.atom.a) { div.append(text = Div({ margin: "1em 0.5em", padding: "0 0.5em", display: "inline-block" }).html(slide.atom.a).tap(click)); } slide.div.append(div); return div; }; })(); trainers/dragAndValidate/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var atom; return _.concat(slide.getParam("lsg", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }())); }; })(); trainers/dragAndValidate/_preview/preview.ls (function(){ return function(slide){ return slide.lsg.firstChild.css({ width: "100%", height: "100%" }); }; })(); trainers/dragAndValidate/_review/element/element.ls (function(){ return function(slide, atom, scale){ var lsg, wrapper, div; lsg = inc("../../elements/element/lsg/lsg")(atom, slide); requestAnimationFrame(function(){ return lsg.css({ width: lsg.width() * scale + "px", height: lsg.height() * scale + "px" }); }); wrapper = Div({ display: "inline-block", verticalAlign: "top" }).html(div = Div({ display: "inline-block", cursor: "pointer" }).addClass("dragAndValidateElement").html(lsg)); if (!atom.lsg) { div.css({ wordWrap: "break-word", backgroundColor: Color.grey[150], padding: "0.5em", backgroundClip: "border-box", boxShadow: '1px 1px 2px #bbb' }); } div.lsg = lsg; if (slide.validateMode !== "group") { div.value = +atom.b; } else { div.value = atom.b; } return wrapper; }; })(); trainers/dragAndValidate/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, atoms, lsg, w1, w2, scale, zones, j$, ref1$, len1$, j, r, k$, len2$, v, atom, el, results$ = []; e = slide.score.getScoreEvent(); if (!e) { return; } slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; atoms = _.cloneDeep(e.matchingTrainer.atoms); atoms = _.ensureArray(atoms); lsg = inc("../../lsg/lsg")(slide); w1 = lsg.firstChild.offset().width; lsg.firstChild.css({ width: "100%", height: "100%" }); w2 = lsg.firstChild.offset().width; scale = w2 / w1; zones = inc("../zones/zones")(slide, lsg); for (j$ = 0, len1$ = (ref1$ = a.results).length; j$ < len1$; ++j$) { j = j$; r = ref1$[j$]; for (k$ = 0, len2$ = r.length; k$ < len2$; ++k$) { v = r[k$]; if (_.isString(v)) { continue; } if (slide.validateMode === "group") { atom = _.find(atoms, fn$); } else { atom = _.find(atoms, fn1$); } if (atom != null) { atom.used = true; } el = inc("../element/element")(slide, atom, scale); zones[j].append(el); } } results$.push(Div({ margin: "3em 0" }).html(inc("/shared/scoreActionRow/row")(a, i).append(lsg)).appendTo(slide.div)); } return results$; function fn$(a){ return a.b.zone === v.zone && a.used !== true; } function fn1$(a){ return +a.b === v && a.used !== true; } }; })(); trainers/dragAndValidate/_review/zones/zone/flowCss/flowCss.ls (function(){ return function(zoneFlow, c){ var css, f; css = { "top-left": undefined, "top-right": { display: "flex", alignContent: "flex-start", justifyContent: "flex-start", flexFlow: "row-reverse wrap" }, "bottom-left": { display: "flex", alignContent: "flex-start", justifyContent: "flex-start", flexFlow: "row wrap-reverse" }, "bottom-right": { display: "flex", alignContent: "flex-start", justifyContent: "flex-start", flexFlow: "row-reverse wrap-reverse" }, "center": { display: "flex", alignContent: "center", justifyContent: "center", flexFlow: "row wrap" } }; if (_.isObject(zoneFlow)) { f = _.find(zoneFlow, { zone: c }); if (!f) { return; } return css[f.zoneFlow]; } else { return css[zoneFlow]; } }; })(); trainers/dragAndValidate/_review/zones/zone/zone.ls (function(){ return function(slide, targetCss, c){ var div; div = Div({ position: "absolute", textAlign: "left" }).css(targetCss).css(slide.zoneFlow ? inc("flowCss/flowCss")(slide.zoneFlow, c) : void 8); div.clear = function(){}; return div; }; })(); trainers/dragAndValidate/_review/zones/zones.ls (function(){ return function(slide, lsg){ var zones, zoneTargets, targetRects, i$, len$, i, z, classes, c, zone; zones = []; zoneTargets = lsg.findAll(".zone"); targetRects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(lsg, ".zone"); for (i$ = 0, len$ = zoneTargets.length; i$ < len$; ++i$) { i = i$; z = zoneTargets[i$]; classes = z.classes(); if (classes.length > 1) { c = _.find(classes, fn$); } zone = inc("zone/zone")(slide, targetRects[i], c).appendTo(lsg); zones.push(zone); } return zones; function fn$(o){ return o !== "zone"; } }; })(); trainers/dragAndValidate/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, el, solvable; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.start(); } slide.instruction.play(function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.checkButton, { padding: 20 }); }); solvable = inc("../validate/validate")(slide); if (!solvable) { debug("This task is not solvable"); } return slide.dragElementsActive = 0; }; })(); trainers/dragAndValidate/buttons/buttons.ls (function(){ return function(slide){ return Div({ margin: "1em 0" }).html(slide.solveButton = inc("solveButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide)).appendTo(slide.div); }; })(); trainers/dragAndValidate/buttons/checkButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ var results, z, i$, len$, i, result, resultElements; slide.buttons.css({ pointerEvents: "none" }); results = inc("../../validate/validate")(slide); if (z = slide.zoneParentAll) { if (_.every(results, function(r){ return r.correct; })) { z.showCorrect(); } else { z.showWrong(); } } else { for (i$ = 0, len$ = results.length; i$ < len$; ++i$) { i = i$; result = results[i$]; if (result.correct) { slide.zones[i + 1].setCorrect(); } else { slide.zones[i + 1].setWrong(); } } } resultElements = _.map(results, "elements"); if (!_.every(results, function(r){ return r.correct; })) { div.setState("wrong"); setTimeout(function(){ return div.setState("normal"); }, 500); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ slide.score.addActionMistake(slide.atoms, { results: resultElements }); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } return slide.buttons.css({ pointerEvents: "" }); }, 500); } else { div.setState("correct"); slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atoms, { results: resultElements }); slide.score.log(slide.atoms); slide.div.css({ pointerEvents: "none" }); return setTimeout(function(){ slide.finish(); return div.parent().remove(); }, 1000); } }; return div = Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/dragAndValidate/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(function(){ slide.finish(); return div.parent().remove(); }, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/dragAndValidate/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ var i$, ref$, len$, el, solveElements, res$, z; slide.buttons.css({ pointerEvents: "none" }); for (i$ = 0, len$ = (ref$ = slide.div.findAll(".dragAndValidateElement")).length; i$ < len$; ++i$) { el = ref$[i$]; el.css({ pointerEvents: "none" }); } inc("../../solve/solve")(slide); res$ = []; for (i$ = 0, len$ = (ref$ = slide.targetZones).length; i$ < len$; ++i$) { z = ref$[i$]; res$.push(_.map(z.findAll(".dragAndValidateElement"), fn$)); } solveElements = res$; slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atoms, { results: solveElements }); slide.score.log(slide.atoms); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); slide.buttons.css({ pointerEvents: "" }); return slide.lsg.css({ pointerEvents: "" }); }, 500); function fn$(el){ return el.value; } }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/dragAndValidate/checkParams/check.ls (function(){ return function(slide){ var flows, allowedZones, elements, i$, len$, el, zone, results$ = []; flows = ["top-left", "top", "top-right", "bottom-left", "bottom", "bottom-right", "left", "center", "right"]; if (_.isString(slide.zoneFlow) && !in$(slide.zoneFlow, flows)) { debug("zoneFlow may only be " + flows.join(", ")); } if (slide.maxPerZone && (!_.isInteger(slide.maxPerZone) || slide.maxPerZone < 1)) { debug("maxPerZone must be a whole number > 0"); } if (slide.validateMode === "group") { allowedZones = _.flatMap(slide.zones, function(z){ return z.classes(); }); elements = slide.div.findAll(".dragAndValidateElement"); for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { el = elements[i$]; zone = el.value.zone; if (zone && !in$(zone, allowedZones)) { results$.push(debug("The zone '" + zone + "' is not an allowed zone. Please use zone: \"\" if you want to define an element that doesn't belong in any zone.")); } } return results$; } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/dragAndValidate/elements/dummyElement/dummyElement.ls (function(){ return function(){ return Div().addClass("dummyElement").css({ verticalAlign: "top", width: 1, height: 1, visibility: "hidden" }); }; })(); trainers/dragAndValidate/elements/element/element.ls (function(){ return function(slide, atom, index){ var start, wrapper, div, lsg, i$, ref$, len$, c; start = function(){ return inc("enableDrag/enable")(slide, wrapper, div); }; wrapper = Div({ display: "inline-block", verticalAlign: "top", margin: "0.1em" }).html(div = Div({ display: "inline-block", cursor: "pointer", zIndex: 1 }).addClass("dragAndValidateElement").html(lsg = inc("lsg/lsg")(atom, slide))); for (i$ = 0, len$ = (ref$ = lsg.findAll("text")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ cursor: "pointer" }); } if (!atom.lsg) { div.css({ wordWrap: "break-word", backgroundColor: Color.grey[150], padding: "0.5em", backgroundClip: "border-box", boxShadow: '1px 1px 2px #bbb' }); } div.lastZoneIndex = 0; div.currentZoneIndex = -1; div.lsg = lsg; div.index = index; div.atom = atom; div.value = slide.validateMode === "group" ? atom.b : +atom.b; wrapper.start = start; return wrapper; }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animate.ls (function(){ return function(slide, onEnd, wrapper, div){ var currentZoneIndex, targetZone, otherElements; currentZoneIndex = div.currentZoneIndex; div.css({ pointerEvents: "none" }); targetZone = slide.zones[currentZoneIndex]; otherElements = _.filter(targetZone != null ? targetZone.findAll(".dragAndValidateElement") : void 8, function(c){ return c !== div; }); if (slide.maxPerZone != null && currentZoneIndex !== 0 && otherElements.length === slide.maxPerZone) { targetZone = slide.zones[slide.dragStartZone]; } if (targetZone == null || targetZone.hasClass("startZone")) { return inc("animateToStart/animate")(slide, onEnd, div); } else { return inc("animateToZone/animate")(slide, div, wrapper, targetZone); } }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToStart/animate.ls (function(){ return function(slide, onEnd, div){ var dummy, zone, animateChildren, i$, len$, c; div.target = null; dummy = slide.div.findFirst(".dragDummy_" + div.index); if (dummy) { zone = div.closest(".targetZone"); animateChildren = _.filter(zone.find(".dragAndValidateElement"), function(c){ return c !== div; }); animateChildren.push(div); for (i$ = 0, len$ = animateChildren.length; i$ < len$; ++i$) { c = animateChildren[i$]; c.offsetSave(); c.css({ transform: "" }); } dummy.replaceWith(div); for (i$ = 0, len$ = animateChildren.length; i$ < len$; ++i$) { c = animateChildren[i$]; c.offsetAnimate(); } } else { onEnd.animateToStart(); } return setTimeout(function(){ return div.css({ pointerEvents: "" }); }, 500); }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/animate.ls (function(){ return function(slide, div, wrapper, targetZone){ var animateChildren, isNewTarget, insertElement; animateChildren = targetZone.find(".dragAndValidateElement"); isNewTarget = inc("isNewTarget/calc")(div, targetZone); insertElement = inc("calcInsertElement/calc")(slide, div, targetZone); inc("insertDummy/insert")(slide, div, wrapper); inc("saveOffsets/save")(div, animateChildren, isNewTarget); insertElement.after(div); inc("animateOffsets/animate")(div, animateChildren, isNewTarget); return setTimeout(function(){ return div.css({ width: "", pointerEvents: "" }); }, 500); }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/animateOffsets/animate.ls (function(){ return function(div, animateChildren, isNewTarget){ var i$, len$, c; for (i$ = 0, len$ = animateChildren.length; i$ < len$; ++i$) { c = animateChildren[i$]; c.offsetAnimate(); } if (isNewTarget) { return div.offsetAnimate(); } }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/calcInsertElement/calc.ls (function(){ return function(slide, div, targetZone){ var children, insertIndex, insertElement; children = inc("calcChildren/calc")(div, targetZone); insertIndex = inc("calcInsertIndex/calc")(slide, children, div); return insertElement = children[insertIndex]; }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/calcInsertElement/calcChildren/calc.ls (function(){ return function(div, targetZone){ return _.filter(targetZone.find(".dragAndValidateElement,.dummyStart"), function(c){ return c !== div; }); }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/calcInsertElement/calcInsertIndex/calc.ls (function(){ return function(slide, children, div){ var minDist, minIndex, minCX, minDivX, touches, i$, len$, i, c, dist; minDist = null; minIndex = null; minCX = -1; minDivX = -1; touches = false; if (!_.some(children, function(c){ return slide.checkCollision(c, div); })) { return children.length - 1; } for (i$ = 0, len$ = children.length; i$ < len$; ++i$) { i = i$; c = children[i$]; dist = slide.calcDist(div, c); if (minDist == null || dist < minDist) { minDist = dist; minIndex = i; minCX = c.offset().left + c.width() / 2; minDivX = div.offset().left + div.width() / 2; } } if ((_.endsWith(slide.zoneFlow, "right") && minDivX > minCX) || (_.endsWith(slide.zoneFlow, "left") && minDivX < minCX)) { minIndex--; } if (minIndex < 0) { minIndex = 0; } return minIndex; }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/insertDummy/insert.ls (function(){ return function(slide, div, wrapper){ var index; index = div.index; if (!slide.div.findFirst(".dragDummy_" + index)) { return wrapper.append(Div().css({ width: div.width() + "px", height: div.height() + "px" }).addClass("dragDummy_" + index)); } }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/isNewTarget/calc.ls (function(){ return function(div, targetZone){ var newTargetZoneClassName, currentTargetZoneClassName, ref$; newTargetZoneClassName = targetZone.classes()[1]; currentTargetZoneClassName = (ref$ = div.target) != null ? ref$.classes()[1] : void 8; if (newTargetZoneClassName === currentTargetZoneClassName) { return false; } else { div.target = targetZone; return true; } }; })(); trainers/dragAndValidate/elements/element/enableDrag/_animate/animateToZone/saveOffsets/save.ls (function(){ return function(div, animateChildren, isNewTarget){ var i$, len$, c, results$ = []; div.offsetSave(); if (isNewTarget) { div.css({ transform: "" }); } for (i$ = 0, len$ = animateChildren.length; i$ < len$; ++i$) { c = animateChildren[i$]; c.offsetSave(); if (!isNewTarget) { results$.push(c.css({ transform: "" })); } } return results$; }; })(); trainers/dragAndValidate/elements/element/enableDrag/_detectZoneCollision/calcNearestZone/calc.ls (function(){ return function(collisionZonesIndices, slide, div){ var minDist, minIndex, i$, len$, i, zone, otherZones, res$, j$, ref$, len1$, j, dist; minDist = null; minIndex = null; div.centerDiv == null && (div.centerDiv = Div({ position: "absolute", width: "1px", height: "1px", left: "50%", top: "50%" }).appendTo(div)); for (i$ = 0, len$ = collisionZonesIndices.length; i$ < len$; ++i$) { i = collisionZonesIndices[i$]; zone = slide.zones[i]; res$ = []; for (j$ = 0, len1$ = (ref$ = _.without(collisionZonesIndices, i)).length; j$ < len1$; ++j$) { j = ref$[j$]; res$.push(slide.zones[j]); } otherZones = res$; otherZones = _.filter(otherZones, fn$); if (_.every(otherZones, fn1$)) { return i; } dist = slide.calcDist(div, zone); if (minDist == null || dist < minDist) { minDist = dist; minIndex = i; } } return minIndex; function fn$(zone){ return slide.checkSurrounds(zone, div.centerDiv); } function fn1$(zone2){ return slide.checkSurrounds(zone2, zone); } }; })(); trainers/dragAndValidate/elements/element/enableDrag/_detectZoneCollision/detect.ls (function(){ return function(div, slide){ var collisionZonesIndices, res$, i$, ref$, len$, i, zone, nearestZone; res$ = []; for (i$ = 0, len$ = (ref$ = slide.zones).length; i$ < len$; ++i$) { i = i$; zone = ref$[i$]; if (slide.checkCollision(div, zone)) { res$.push(i); } } collisionZonesIndices = res$; return nearestZone = collisionZonesIndices.length > 1 ? inc("calcNearestZone/calc")(collisionZonesIndices, slide, div) : collisionZonesIndices.length === 1 ? collisionZonesIndices[0] : -1; }; })(); trainers/dragAndValidate/elements/element/enableDrag/calcDist/calc.ls (function(){ return function(div1, div2){ var o1, o2, div1X, div1Y, div2X, div2Y, dist; o1 = div1.offset(); o2 = div2.offset(); div1X = o1.left + div1.width() / 2; div1Y = o1.top + div1.height() / 2; div2X = o2.left + div2.width() / 2; div2Y = o2.top + div2.height() / 2; return dist = Math.sqrt(Math.pow(div2X - div1X, 2) + Math.pow(div2Y - div1Y, 2)); }; })(); trainers/dragAndValidate/elements/element/enableDrag/checkCollision/check.ls (function(){ return function(div1, div2){ var o1, o2, pos1, pos2; o1 = div1.offset(); o2 = div2.offset(); pos1 = { top: o1.top, left: o1.left, bottom: o1.top + div1.height(), right: o1.left + div1.width() }; pos2 = { top: o2.top, left: o2.left, bottom: o2.top + div2.height(), right: o2.left + div2.width() }; if (pos1.right < pos2.left) { return false; } else if (pos1.left > pos2.right) { return false; } else if (pos1.top > pos2.bottom) { return false; } else if (pos1.bottom < pos2.top) { return false; } else { return true; } }; })(); trainers/dragAndValidate/elements/element/enableDrag/checkSurrounds/check.ls (function(){ return function(div1, div2){ var o1, o2, pos1, pos2; o1 = div1.offset(); o2 = div2.offset(); pos1 = { top: o1.top, left: o1.left, bottom: o1.top + div1.height(), right: o1.left + div1.width() }; pos2 = { top: o2.top, left: o2.left, bottom: o2.top + div2.height(), right: o2.left + div2.width() }; if (pos1.left > pos2.left) { return false; } else if (pos1.right < pos2.right) { return false; } else if (pos1.bottom < pos2.bottom) { return false; } else if (pos1.top > pos2.top) { return false; } else { return true; } }; })(); trainers/dragAndValidate/elements/element/enableDrag/enable.ls (function(){ return function(slide, wrapper, div){ var onStart, onMove, onEnd; slide.checkCollision = function(d1, d2){ return inc("checkCollision/check")(d1, d2); }; slide.calcDist = function(d1, d2){ return inc("calcDist/calc")(d1, d2); }; slide.checkSurrounds = function(d1, d2){ return inc("checkSurrounds/check")(d1, d2); }; onStart = function(){ inc("onStart/on")(slide, div); return slide.dragElementsActive++; }; onMove = function(o){ return inc("onMove/on")(slide, o, div); }; onEnd = function(onEnd){ inc("onEnd/on")(slide, div, wrapper, onEnd); return slide.dragElementsActive--; }; inc("/../app01/lib/util/waitFrames/wait")(4, function(){ var psw, ref$; psw = slide.levelPlayer.page.pageScrollWrapper; if (psw.isScrollableY) { slide.pageIsScrollable = true; } return (ref$ = div.maxScrollTop) != null ? ref$ : div.maxScrollTop = psw.scrollHeight - psw.clientHeight - 30; }); return div.drag({ onStart: onStart, onMove: onMove, onEnd: onEnd, shouldStart: function(){ return slide.dragElementsActive === 0; }, animation: "none", boundingDiv: slide.div }).bind("touchstart touchmove mousedown", function(e){ return e.preventDefault(); }); }; })(); trainers/dragAndValidate/elements/element/enableDrag/onEnd/on.ls (function(){ return function(slide, div, wrapper, onEnd){ var fakeTap; fakeTap = function(){ return inc("tap/tap")(slide, div, wrapper, onEnd); }; div.scrollDirection = null; div.currentZoneIndex = inc("../_detectZoneCollision/detect")(div, slide); if (_.isEqual(div.offset(), slide.dragStartPos)) { return fakeTap(onEnd); } else { return inc("../_animate/animate")(slide, onEnd, wrapper, div); } }; })(); trainers/dragAndValidate/elements/element/enableDrag/onEnd/tap/tap.ls (function(){ return function(slide, div, wrapper, onEnd){ var ref$, otherZoneIndex; div.currentZoneIndex = inc("../../_detectZoneCollision/detect")(div, slide); if (!((ref$ = slide.zones[div.currentZoneIndex]) != null && ref$.hasClass("startZone"))) { otherZoneIndex = _.findIndex(slide.zones, function(z){ return z.hasClass("startZone"); }); } else if (slide.zones.length === 2) { otherZoneIndex = div.currentZoneIndex === 1 ? 0 : 1; } div.currentZoneIndex = otherZoneIndex; if (otherZoneIndex == null) { return; } slide.dragStartPos = div.offset(); return inc("../../_animate/animate")(slide, onEnd, wrapper, div); }; })(); trainers/dragAndValidate/elements/element/enableDrag/onMove/on.ls (function(){ return function(slide, o, div){ if (slide.pageIsScrollable) { return inc("scroll/scroll")(slide, o, div); } }; })(); trainers/dragAndValidate/elements/element/enableDrag/onMove/scroll/scroll.ls (function(){ return function(slide, o, div){ var y, psw, pageTop, pageBottom, scroll; y = o.clientPosition.y; psw = slide.levelPlayer.page.pageScrollWrapper; pageTop = slide.levelPlayer.page.top.height() + 50; pageBottom = window.innerHeight - slide.levelPlayer.page.bottom.height() - 50; scroll = function(){ if (div.scrollDirection === "up" && psw.scrollTop > 0) { slide.levelPlayer.page.pageScrollWrapper.scrollTop -= 5; o.updateTranslation({ y: -5, x: 0 }); return setTimeout(scroll, 50); } else if (div.scrollDirection === "down") { if (div.maxScrollTop <= psw.scrollTop) { div.scrollDirection = null; return; } slide.levelPlayer.page.pageScrollWrapper.scrollTop += 5; o.updateTranslation({ y: 5, x: 0 }); return setTimeout(scroll, 50); } }; if (y > pageBottom) { div.scrollDirection = "down"; return scroll(); } else if (y < pageTop) { div.scrollDirection = "up"; return scroll(); } else { return div.scrollDirection = null; } }; })(); trainers/dragAndValidate/elements/element/enableDrag/onStart/on.ls (function(){ return function(slide, div){ var i$, ref$, len$, z; slide.dragStartPos = div.offset(); for (i$ = 0, len$ = (ref$ = slide.targetZones).length; i$ < len$; ++i$) { z = ref$[i$]; z.clear(); } if ((ref$ = slide.zoneParentAll) != null) { ref$.hide(); } div.currentZoneIndex = inc("../_detectZoneCollision/detect")(div, slide); return slide.dragStartZone = div.currentZoneIndex; }; })(); trainers/dragAndValidate/elements/element/lsg/lsg.ls (function(){ return function(atom, slide){ var lsg; lsg = slide.getParam("lsg", atom); lsg.width *= slide.lsgScale; return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }); }; })(); trainers/dragAndValidate/elements/elements.ls (function(){ return function(slide){ var elements, res$, i$, ref$, len$, i, atom, el; res$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; res$.push(inc("element/element")(slide, atom, i)); } elements = res$; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { el = elements[i$]; slide.startZone.prepend(el); } return elements; }; })(); trainers/dragAndValidate/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.validateMode = slide.getParam("validateMode"); slide.totalProgressElements = 1; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/dragAndValidate/init.ls (function(){ return function(slide){ slide.elements = []; slide.zones = []; slide.currentSum = 0; slide.zoneFlow = slide.getParam("zoneFlow") || "top-left"; slide.maxPerZone = slide.getParam("maxPerZone"); slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.zones = inc("zones/zones")(slide); slide.buttons = inc("buttons/buttons")(slide); slide.elements = inc("elements/elements")(slide); return inc("checkParams/check")(slide); }; })(); trainers/dragAndValidate/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/dragAndValidate/lsg/lsg.ls (function(){ return function(slide){ var lsgD, lsg, fontScale, width, ref$; lsgD = slide.getParam("lsg"); lsg = inc("/shared/lsg/lsg")({ lsg: lsgD, slide: slide, parent: slide.div, wrapWithDiv: true }).css({ display: "inline-block", maxWidth: "100%", margin: "" }).appendTo(slide.div); if (typeof lsg.updateLayout == 'function') { lsg.updateLayout(); } fontScale = inc("/../app01/lib/util/fontSize/calcFontScale/calc")(); width = (ref$ = lsgD.width) != null ? ref$ : 250; slide.lsgScale = lsg.width() / (width * fontScale); return lsg; }; })(); trainers/dragAndValidate/solve/calcZoneData/calc.ls (function(){ return function(slide){ var mode, atomSum, modeSum, ref$, zones, i, z, elements; mode = slide.validateMode; atomSum = _.sumBy(slide.atoms, function(a){ return +a.b; }); modeSum = +((ref$ = /(\d+)$/.exec(mode)) != null ? ref$[1] : void 8); return zones = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.zones).length; i$ < len$; ++i$) { i = i$; z = ref$[i$]; elements = z.findAll(".dragAndValidateElement"); results$.push({ div: z, elements: elements, index: i, maxElements: i > 0 ? (ref1$ = slide.maxPerZone) != null ? ref1$ : 99999999 : 99999999, value: mode !== "group" ? _.sumBy(elements, "value") : void 8, sharedValue: i > 0 && _.startsWith(mode, "sumAll"), targetValue: mode === "equal" ? i > 0 ? atomSum / slide.targetZones.length : 0 : _.startsWith(mode, "sumAll") ? i > 0 ? modeSum : atomSum - modeSum : _.startsWith(mode, "sum") ? i > 0 ? modeSum : atomSum - slide.targetZones.length * modeSum : void 8 }); } return results$; }()); }; })(); trainers/dragAndValidate/solve/solve.ls (function(){ return function(slide){ var i$, ref$, len$, z, zones, solution, e, zone, lresult$, j$, ref1$, len1$, el, results$ = []; for (i$ = 0, len$ = (ref$ = slide.targetZones).length; i$ < len$; ++i$) { z = ref$[i$]; z.clear(); } if ((ref$ = slide.zoneParentAll) != null) { ref$.hide(); } zones = inc("calcZoneData/calc")(slide); solution = (function(){ try { if (slide.validateMode === "group") { return inc("solveGroup/solve")(zones); } else { return inc("solveOther/solve")(_.cloneDeep(zones), true) || inc("solveOther/solve")(zones); } } catch (e$) { e = e$; if (_.isString(e)) { debug(e); return undefined; } else { throw e; } } }()); if (!solution) { debug("no solution found"); return; } for (i$ = 0, len$ = solution.length; i$ < len$; ++i$) { zone = solution[i$]; lresult$ = []; for (j$ = 0, len1$ = (ref1$ = zone.elements).length; j$ < len1$; ++j$) { el = ref1$[j$]; if (!zone.div.contains(el)) { el.offsetSave(); el.appendTo(zone.div); lresult$.push(el.offsetAnimate()); } } results$.push(lresult$); } return results$; }; })(); trainers/dragAndValidate/solve/solveGroup/solve.ls (function(){ return function(zones){ var elements, i$, len$, z, el, shouldZoneId, shouldZone; elements = _.flatMap(zones, "elements"); for (i$ = 0, len$ = zones.length; i$ < len$; ++i$) { z = zones[i$]; z.elements = []; } for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { el = elements[i$]; shouldZoneId = el.value.zone; shouldZone = _.find(zones, fn$) || zones[0]; shouldZone.elements.push(el); } return zones; function fn$(z){ return _.includes(z.div.classes(), shouldZoneId); } }; })(); trainers/dragAndValidate/solve/solveOther/solve.ls (function(){ return function(zones, startFromCurrentState){ var maxIterations, startZone, elements, sumSharedValues, i$, len$, b, z, targetZones, sumElements, sumZones, didAddSharedValue, i, solveSum, targetValue, ref$, putInBucket, removeLastFromBucket, usedElements, element, j$, len1$, bucket, pairs, j, element2, pair, fullContainers, iteration, putInZones; startFromCurrentState == null && (startFromCurrentState = false); maxIterations = 10000000; if (startFromCurrentState) { startZone = _.first(zones); elements = startZone.elements; startZone.elements = []; startZone.value = 0; sumSharedValues = 0; for (i$ = 0, len$ = zones.length; i$ < len$; ++i$) { b = zones[i$]; if (b.sharedValue) { sumSharedValues += b.value; } } for (i$ = 0, len$ = zones.length; i$ < len$; ++i$) { b = zones[i$]; if (b.sharedValue) { b.value = sumSharedValues; } } } else { elements = _.flatMap(zones, "elements"); for (i$ = 0, len$ = zones.length; i$ < len$; ++i$) { z = zones[i$]; z.elements = []; z.value = 0; } } elements = _.orderBy(elements, "value", "desc"); targetZones = _.orderBy(zones, "targetValue", "asc"); sumElements = _.sumBy(elements, "value") + _.sumBy(targetZones, function(t){ return _.sumBy(t.elements, "value"); }); sumZones = 0; didAddSharedValue; for (i$ = 0, len$ = targetZones.length; i$ < len$; ++i$) { b = targetZones[i$]; if (!b.sharedValue) { sumZones += b.targetValue; } else if (!didAddSharedValue) { didAddSharedValue = true; sumZones += b.targetValue; } } if (sumElements < sumZones) { throw "not enough items (" + sumElements + ") for a solution (" + sumZones + ")"; } if (sumElements > sumZones) { throw "too many items (" + sumElements + ") for a solution (" + sumZones + ")"; } for (i$ = 0, len$ = targetZones.length; i$ < len$; ++i$) { i = i$; z = targetZones[i$]; if (z.value > z.targetValue || z.elements.length > z.maxElements) { return undefined; } } solveSum = function(targetSum, elements){ var solutionSum, solve; if (targetSum === 0) { return true; } solutionSum = 0; solve = function(index){ var i$, ref$, len$, i, element; index == null && (index = -1); if (solutionSum === targetSum) { return true; } for (i$ = 0, len$ = (ref$ = elements).length; i$ < len$; ++i$) { i = i$; element = ref$[i$]; if (i > index && solutionSum + element.value <= targetSum) { solutionSum += element.value; if (solve(i)) { return true; } solutionSum -= element.value; } } return false; }; return solve(); }; for (targetValue in ref$ = _.groupBy(targetZones, "targetValue")) { zones = ref$[targetValue]; if (!solveSum(+targetValue, elements)) { if (startFromCurrentState) { return undefined; } else { throw "unsolvable targetValue: " + targetValue; } } } putInBucket = function(element, bucket){ var i$, ref$, len$, b; if (bucket.sharedValue) { for (i$ = 0, len$ = (ref$ = targetZones).length; i$ < len$; ++i$) { b = ref$[i$]; if (b.sharedValue) { b.value += element.value; } } } else { bucket.value += element.value; } return bucket.elements.push(element); }; removeLastFromBucket = function(bucket){ var element, i$, ref$, len$, b, results$ = []; element = bucket.elements.pop(); if (bucket.sharedValue) { for (i$ = 0, len$ = (ref$ = targetZones).length; i$ < len$; ++i$) { b = ref$[i$]; if (b.sharedValue) { results$.push(b.value -= element.value); } } return results$; } else { return bucket.value -= element.value; } }; usedElements = {}; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { i = i$; element = elements[i$]; for (j$ = 0, len1$ = targetZones.length; j$ < len1$; ++j$) { bucket = targetZones[j$]; if (element.value + bucket.value === bucket.targetValue && bucket.elements.length < bucket.maxElements) { putInBucket(element, bucket); usedElements[i] = true; break; } } } pairs = []; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { i = i$; element = elements[i$]; if (!usedElements[i]) { for (j$ = 0, len1$ = elements.length; j$ < len1$; ++j$) { j = j$; element2 = elements[j$]; if (j > i && !usedElements[j]) { pairs.push({ el1: element, el2: element2, index1: i, index2: j, value: element.value + element2.value }); } } } } for (i$ = 0, len$ = pairs.length; i$ < len$; ++i$) { pair = pairs[i$]; if (!usedElements[pair.index1] && !usedElements[pair.index2]) { for (j$ = 0, len1$ = targetZones.length; j$ < len1$; ++j$) { bucket = targetZones[j$]; if (pair.value + bucket.value === bucket.targetValue && bucket.elements.length < bucket.maxElements - 1) { putInBucket(pair.el1, bucket); putInBucket(pair.el2, bucket); usedElements[pair.index1] = true; usedElements[pair.index2] = true; break; } } } } elements = _.filter(elements, function(element, i){ return !usedElements[i]; }); ref$ = _.partition(targetZones, function(z){ return z.value === z.targetValue; }), fullContainers = ref$[0], targetZones = ref$[1]; iteration = 0; putInZones = function(elements){ var element, i$, ref$, len$, bucket; if (elements.length === 0) { return true; } if (iteration > maxIterations) { throw "couldn't find a solution in " + maxIterations + " steps"; } iteration += 1; element = elements.shift(); for (i$ = 0, len$ = (ref$ = targetZones).length; i$ < len$; ++i$) { bucket = ref$[i$]; if ((bucket.targetValue == null || bucket.value + element.value <= bucket.targetValue) && bucket.elements.length < bucket.maxElements) { putInBucket(element, bucket); if (putInZones(elements)) { return true; } removeLastFromBucket(bucket); } } elements.push(element); return false; }; if (!putInZones(elements)) { return undefined; } targetZones = _.concat(targetZones, fullContainers); return targetZones; }; })(); trainers/dragAndValidate/validate/validate.ls (function(){ return function(slide){ var mode, n; mode = slide.validateMode; if (!mode) { return; } if (mode === "equal") { return inc("validateEqual/validate")(slide); } else if (_.startsWith(mode, "sumAll")) { n = +mode.split("sumAll")[1]; if (!n) { debug("Invalid mode '" + mode + "', missing value."); return; } return inc("validateSumAll/validate")(slide, n); } else if (_.startsWith(mode, "sum")) { n = +mode.split("sum")[1]; if (!n) { debug("Invalid mode '" + mode + "', missing value."); return; } return inc("validateSum/validate")(slide, n); } else if (mode === "group") { return inc("validateGroup/validate")(slide); } }; })(); trainers/dragAndValidate/validate/validateEqual/validate.ls (function(){ return function(slide){ var zones, totalSum, totalPerZone, i$, len$, z, elements, j$, ref$, len1$, e, correct, results$ = []; zones = slide.targetZones; totalSum = _.sum(_.map(slide.atoms, function(atom){ return +atom.b; })); if (totalSum % zones.length > 0) { return null; } totalPerZone = totalSum / zones.length; for (i$ = 0, len$ = zones.length; i$ < len$; ++i$) { z = zones[i$]; elements = []; for (j$ = 0, len1$ = (ref$ = z.findAll(".dragAndValidateElement")).length; j$ < len1$; ++j$) { e = ref$[j$]; elements.push(e.value); } correct = _.sum(elements) === totalPerZone; results$.push({ correct: correct, elements: elements }); } return results$; }; })(); trainers/dragAndValidate/validate/validateGroup/validate.ls (function(){ return function(slide){ var zones, i$, len$, zone, zoneResults, j$, ref$, len1$, el, value, targetValue, results$ = []; zones = slide.targetZones; for (i$ = 0, len$ = zones.length; i$ < len$; ++i$) { zone = zones[i$]; zoneResults = []; for (j$ = 0, len1$ = (ref$ = slide.div.findAll(".dragAndValidateElement")).length; j$ < len1$; ++j$) { el = ref$[j$]; value = el.value.zone; targetValue = _.find(zone.classes(), fn$); zoneResults.push(value === targetValue ? zone.contains(el) : !zone.contains(el)); } results$.push({ correct: _.every(zoneResults, fn1$), elements: _.map(zone.findAll(".dragAndValidateElement"), "value") }); } return results$; function fn$(c){ return !_.startsWith(c, "targetZone"); } function fn1$(r){ return r; } }; })(); trainers/dragAndValidate/validate/validateSum/validate.ls (function(){ return function(slide, totalSum){ var zones, possibleSum, i$, len$, z, elements, j$, ref$, len1$, e, correct, results$ = []; zones = slide.targetZones; possibleSum = _.sum(_.map(slide.div.findAll(".dragAndValidateElement"), "value")); if (possibleSum < totalSum * zones.length) { return; } for (i$ = 0, len$ = zones.length; i$ < len$; ++i$) { z = zones[i$]; elements = []; for (j$ = 0, len1$ = (ref$ = z.findAll(".dragAndValidateElement")).length; j$ < len1$; ++j$) { e = ref$[j$]; elements.push(e.value); } correct = _.sum(elements) === totalSum; results$.push({ correct: correct, elements: elements }); } return results$; }; })(); trainers/dragAndValidate/validate/validateSumAll/calcSum/calcSum.ls (function(){ return function(targetZones){ return _.sumBy(targetZones, function(zone){ return _.sum(_.map(zone.findAll(".dragAndValidateElement"), "value")); }); }; })(); trainers/dragAndValidate/validate/validateSumAll/validate.ls (function(){ return function(slide, targetSum){ var possibleSum, sum, results, z, elements, element; possibleSum = _.sum(_.map(slide.div.findAll(".dragAndValidateElement"), "value")); if (possibleSum < targetSum) { return; } sum = inc("calcSum/calcSum")(slide.targetZones); return results = (function(){ var i$, ref$, len$, res$, j$, ref1$, len1$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.targetZones).length; i$ < len$; ++i$) { z = ref$[i$]; res$ = []; for (j$ = 0, len1$ = (ref1$ = z.findAll(".dragAndValidateElement")).length; j$ < len1$; ++j$) { element = ref1$[j$]; res$.push(element.value); } elements = res$; results$.push({ elements: elements, correct: sum === targetSum }); } return results$; }()); }; })(); trainers/dragAndValidate/zones/startZone/zone.ls (function(){ return function(slide){ var div; Div().html(div = Div({ display: "inline-block", padding: "0.5em 0.2em", width: "30em", maxWidth: "100%" }).addClass("startZone")).appendTo(slide.div); return div; }; })(); trainers/dragAndValidate/zones/targetZone/flowCss/flowCss.ls (function(){ return function(zoneFlow, c){ var css, f; css = { "top-left": undefined, "top": { display: "flex", alignContent: "flex-start", justifyContent: "center", flexFlow: "row-reverse wrap" }, "top-right": { display: "flex", alignContent: "flex-start", justifyContent: "flex-start", flexFlow: "row-reverse wrap" }, "bottom-left": { display: "flex", alignContent: "flex-start", justifyContent: "flex-start", flexFlow: "row wrap-reverse" }, "bottom": { display: "flex", alignContent: "flex-start", justifyContent: "center", flexFlow: "row wrap-reverse" }, "bottom-right": { display: "flex", alignContent: "flex-start", justifyContent: "flex-start", flexFlow: "row-reverse wrap-reverse" }, "left": { display: "flex", alignContent: "center", justifyContent: "flex-start", flexFlow: "row wrap" }, "center": { display: "flex", alignContent: "center", justifyContent: "center", flexFlow: "row wrap" }, "right": { display: "flex", alignContent: "center", justifyContent: "flex-start", flexFlow: "row-reverse wrap" } }; if (_.isObject(zoneFlow)) { f = _.find(_.ensureArray(zoneFlow), { zone: c }); if (!f) { return debug("please define zoneFlow for zone " + c); } else { return css[f.zoneFlow]; } } else { return css[zoneFlow]; } }; })(); trainers/dragAndValidate/zones/targetZone/zone.ls (function(){ return function(slide, targetCss, zParent, c, i){ var zParentStrokeWidth, zParentStroke, clear, set, setCorrect, setWrong, div; zParentStrokeWidth = (zParent != null ? zParent.attr("stroke-width") : void 8) || 0; zParentStroke = (zParent != null ? zParent.attr("stroke") : void 8) || "transparent"; clear = function(){ if (zParent != null) { zParent.css({ outline: "" }).attr({ "stroke-width": zParentStrokeWidth, "stroke": zParentStroke }); } return div.css({ outline: "" }); }; set = function(color){ var ref$; if (!zParent) { return div.css({ outline: "4px solid " + color }); } else if ((ref$ = zParent.tagName) === "svg" || ref$ === "g") { return zParent.css({ outline: "4px solid " + color }); } else { return zParent.attr({ "stroke-width": 4, "stroke": color }); } }; setCorrect = function(){ clear(); return set(Color.green[500]); }; setWrong = function(){ clear(); return set(Color.red[500]); }; div = Div().addClass("targetZone targetZone_" + i + " " + c).css(targetCss).css({ position: "absolute", textAlign: "left" }).css(slide.zoneFlow ? inc("flowCss/flowCss")(slide.zoneFlow, c) : void 8); div.clear = clear; div.setCorrect = setCorrect; div.setWrong = setWrong; return div; }; })(); trainers/dragAndValidate/zones/zoneParentAll/zoneParentAll.ls (function(){ return function(slide){ var div, show; div = slide.lsg.findFirst(".zoneParentAll").attr({ "stroke-width": 3 }).hide(); show = function(c){ return div.show().attr({ stroke: c, fill: "transparent" }); }; div.showCorrect = function(){ return show(Color.green[500]); }; div.showWrong = function(){ return show(Color.red[500]); }; return div; }; })(); trainers/dragAndValidate/zones/zones.ls (function(){ return function(slide){ var zones, zoneTargets, targetRects, i$, len$, i, z, classes, c, zoneParent, zone; zones = []; slide.targetZones = []; zones.push(slide.startZone = inc("startZone/zone")(slide)); zoneTargets = slide.lsg.findAll(".zone"); targetRects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(slide.lsg, ".zone"); for (i$ = 0, len$ = zoneTargets.length; i$ < len$; ++i$) { i = i$; z = zoneTargets[i$]; classes = z.classes(); if (classes.length > 1) { c = _.find(classes, fn$); zoneParent = slide.lsg.findFirst(".zoneParent." + c); if (zoneParent != null) { zoneParent.css({ overflow: "auto" }); } } zone = inc("targetZone/zone")(slide, targetRects[i], zoneParent, c, i).append(inc("../elements/dummyElement/dummyElement")().addClass("dummyStart"), inc("../elements/dummyElement/dummyElement")().addClass("dummyEnd")).appendTo(slide.lsg); slide.targetZones.push(zone); zones.push(zone); } if (slide.lsg.findFirst(".zoneParentAll")) { slide.zoneParentAll = inc("zoneParentAll/zoneParentAll")(slide); } return zones; function fn$(o){ return o !== "zone"; } }; })(); trainers/dragCard/_media2/images/images.ls (function(){ return function(slide){ var images, res$, i$, ref$, len$, atom; res$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; res$.push(slide.getParam("image", atom)); } images = res$; return images = _.compact(images); }; })(); trainers/dragCard/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var lsgs, i$, ref$, len$, atom; lsgs = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; lsgs.push(slide.getParam("lsg", atom)); } return lsgs; }; })(); trainers/dragCard/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, p, calcSound, i$, ref$, len$, atom, soundMode; sounds = []; p = slide.getParam; calcSound = function(atom, c){ var cU, text, voice, voiceLang; cU = c.toUpperCase(); text = atom["sound" + cU] || atom.sound || atom[c]; if (text) { voice = p("voice" + cU, atom) || p("voice", atom); voiceLang = p("voiceLang" + cU, atom) || p("voiceLang", atom); return sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } }; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = p("soundMode", atom); if (soundMode === "a" || soundMode === "ab" || soundMode === "askSound") { calcSound(atom, "a"); } if (soundMode === "b" || soundMode === "ab") { calcSound(atom, "b"); } } return sounds; }; })(); trainers/dragCard/_preview/preview.ls (function(){ return function(slide){ var stack, i$, ref$, len$, el, results$ = []; stack = slide.div.findFirst(".cardStack"); stack.css({ margin: "1.5em" }); for (i$ = 0, len$ = (ref$ = stack.findAll(".dragElement")).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(el.css({ left: 0 })); } return results$; }; })(); trainers/dragCard/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action, that; scoreEvent = slide.score.getScoreEvent(); if (scoreEvent != null && scoreEvent.actions) { slide.buttons.remove(); return slide.div.append(Div({ margin: "2em 0", textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(Div({ display: "inline-block" }).append(inc("div/div")(slide, slide.atoms[action.atomIndex].a), (that = slide.atoms[action.atomIndex].b) ? [" / ", inc("div/div")(slide, that)] : void 8))); } return results$; }()))); } }; })(); trainers/dragCard/_review/scoreActions/div/div.ls (function(){ return function(slide, o){ var css, text, div; if (!o) { return; } css = { width: "1.3em", height: "1.3em", margin: "0 0.2em" }; if (_.isString(o) || o.text) { text = o.text || o; div = Div().secureHtml("'" + text + "'"); } else if (o.sound) { div = SvgIcon({ svg: path("/../app01/lib/svg/shape/speaker.svg") }).css({ top: "0.15em" }); } return div.css({ display: "inline-block" }); }; })(); trainers/dragCard/_skip/skip.ls (function(){ return function(slide){ slide.stack.turnCard(); return slide.stack.moveCardOut(); }; })(); trainers/dragCard/_start/start.ls (function(){ return function(slide){ var p; p = slide.getParam; if (_.find(slide.atoms, "b") && p("soundMode") === "askSound") { debug("soundMode askSound in dragCard works only with atom.a"); return; } if (!_.find(slide.atoms, "b") && p("soundMode") !== "askSound") { debug("spell dragCards without atom.b only works with soundMode askSound"); return; } if (!_.find(slide.atoms, "b") && p("switchAB")) { debug("switchAB only works with atom.a and b"); return; } slide.levelPlayer.page.enableFreezeMinHeight(); slide.instruction.play(); slide.stack.start(); slide.buttons.start(); slide.setState("flip"); slide.levelPlayer.page.bottom.empty().append(slide.buttons).show(); return inc("../updateCardSizes/update")(slide); }; })(); trainers/dragCard/_t.ls (function(){ return { practiseAgain: { de: "Nochmal", en_gb: "Practise again", en: "Practice again", fr: "À revoir", es: "Otra vez", pt: "Tentar de novo" }, alreadyLearned: { de: "Kann ich!", en: "I know it already!", fr: "Je connais !", es: "¡Ya lo aprendí!", pt: "Já aprendi!" }, flip: { de: "Drehen", en_gb: "Turn", en: "Flip", fr: "Retourner", es: "Girar", pt: "Girar" }, viewCount: { de: "$1. Wiederholung", en: "$1. try", fr: "Essai n° $1", es: "$1º intento", pt: "$1ª tentativa" } }; })(); trainers/dragCard/buttons/buttonArrow/button.ls (function(){ return function(click, type){ var wideDisplay, justify, padding, svgPath, svgColor, text, key; wideDisplay = body.width() > 500; justify = "center"; padding = "1.1em 0.4em"; if (type === "right") { svgPath = path("/../app01/lib/svg/shape/thumb-up.svg"); svgColor = Color.green[400]; text = T("alreadyLearned"); key = "keyManager-right"; if (wideDisplay) { justify = "flex-start"; padding = "1.1em 0 1.1em 3em"; } } else { svgPath = path("/../app01/lib/svg/shape/thumb-down.svg"); svgColor = Color.orange[300]; text = T("practiseAgain"); key = "keyManager-left"; if (wideDisplay) { justify = "flex-end"; padding = "1.1em 3em 1.1em 0"; } } return Div({ display: "flex", flex: "1 1 50%", justifyContent: justify }).html(Div({ display: "inline-flex", padding: padding }).append(SvgIcon({ svg: svgPath, color: svgColor, width: "1.5em", height: "1.5em" }).css({ flex: "0 0 auto", marginTop: "0.2em", marginBottom: "0.1em" }), Div({ flex: "0 0 auto", margin: "0.2em 0.2em 0.2em 0.6em" }).html(text))).tap(click).addClass(key).bind("keyManager", click); }; })(); trainers/dragCard/buttons/buttonFlip/button.ls (function(){ return function(click){ return Div({ display: "flex", flex: "1 0 auto", verticalAlign: "top", padding: "1.2em" }).html(SvgIcon({ svg: path("/../app01/lib/svg/icon/refresh-big.svg"), color: Color.grey[600], width: "1.3em", height: "1.3em" }).css({ flex: "0 0 auto", marginTop: "0.1em", marginBottom: "0.2em" }), Div({ flex: "0 0 auto", margin: "0.2em 0.2em 0.2em 0.6em" }).html(T("flip"))).tap(click).addClass("keyManager-enter keyManager-space keyManager-left keyManager-right").bind("keyManager", click); }; })(); trainers/dragCard/buttons/buttons.ls (function(){ return function(slide){ var clickLeft, clickRight, clickFlip, start, div, buttonFlip, buttonLeft, buttonRight; clickLeft = function(){ return slide.stack.moveCardToBack(); }; clickRight = function(){ return slide.stack.moveCardOut(); }; clickFlip = function(){ return slide.stack.turnCard(); }; start = function(){ return div.css({ pointerEvents: "" }); }; div = Div({ display: "flex", justifyItems: "space-evenly", pointerEvents: "none" }).html(buttonFlip = inc("buttonFlip/button")(clickFlip), buttonLeft = inc("buttonArrow/button")(clickLeft, "left").hide(), buttonRight = inc("buttonArrow/button")(clickRight, "right").hide()); div.buttonLeft = buttonLeft; div.buttonRight = buttonRight; div.buttonFlip = buttonFlip; div.start = start; return div; }; })(); trainers/dragCard/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.visibleLearnListItemsInfos = {}; slide.atoms = atoms; slide.totalProgressElements = atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/dragCard/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.stack = inc("stack/stack")(slide); slide.buttons = inc("buttons/buttons")(slide); slide.setState = inc("setState/set")(slide); return slide.div.onWindowResize(function(){ return inc("updateCardSizes/update")(slide); }); }; })(); trainers/dragCard/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/dragCard/setState/set.ls (function(){ return function(slide){ return function(state){ if (state === "flip") { slide.stackState = "flip"; slide.buttons.buttonFlip.show(); slide.buttons.buttonLeft.hide(); return slide.buttons.buttonRight.hide(); } else if (state === "drag") { slide.stackState = "drag"; slide.buttons.buttonFlip.hide(); slide.buttons.buttonLeft.show(); return slide.buttons.buttonRight.show(); } }; }; })(); trainers/dragCard/stack/stack.ls (function(){ return function(slide){ var onCorrect, onWrong, onDone, div; onCorrect = function(i){ slide.levelPlayer.progressBar.showGreen(); return slide.score.addActionCorrect(slide.atoms, { atomIndex: i }); }; onWrong = function(i){ return slide.score.addActionRetry(slide.atoms, { atomIndex: i }); }; onDone = function(){ var ref$; slide.score.log(slide.atoms); if ((ref$ = slide.buttons) != null) { ref$.hide(); } return setTimeout(slide.finish, 1000); }; return div = inc("stack/stack")({ slide: slide, atoms: slide.atoms, onCorrect: onCorrect, onWrong: onWrong, onDone: onDone, insertAfterXCards: slide.getParam("insertAfterXCards") }).appendTo(slide.div); }; })(); trainers/dragCard/stack/stack/card/animateOut/animate.ls (function(){ return function(slide, div, onCardMovedOut, onCardMoveOutStarted){ return function(right, translation){ var dx, dy, r, opacity; div.css({ pointerEvents: "none" }); onCardMoveOutStarted(); if (right) { dx = translation.x + div.width(); dy = translation.y; r = 30; opacity = 0; } else { dx = Math.min(translation.x, -div.width()); dy = translation.y; r = -20; opacity = 1; } return div.animation({ css: { transform: "translate(" + dx + "px, " + dy + "px) rotate(" + r + "deg)", opacity: opacity }, onCompleted: function(){ inc("../setDragHighlight/set")(slide, div, 0); return onCardMovedOut(right); }, duration: 300 }); }; }; })(); trainers/dragCard/stack/stack/card/card.ls (function(){ return function(slide, atom, i, onCardMovedOut, onCardMoveOutStarted){ var rotation, viewCount, isDragging, flip, onMove, onEnd, tap, div, frontFace, backFace, animateOut; rotation = 4 - _.random(8); viewCount = 0; isDragging = false; flip = function(d, flipSpeed){ flipSpeed == null && (flipSpeed = 500); d.flipped -= 180; d.css({ zIndex: Math.abs(d.flipped) % 360 === 0 ? 2 : 1 }); return d.css({ transform: "rotateY(" + d.flipped + "deg)", transition: "transform " + flipSpeed + "ms" }); }; onMove = function(gr){ var rot; inc("setDragHighlight/set")(slide, div, gr.translation.x); isDragging = true; rot = rotation + Math.max(-20, Math.min(20, gr.translation.x * 0.1)); return div.css({ transform: "translate(" + gr.translation.x + "px, " + gr.translation.y + "px) rotate(" + rot + "deg)" }); }; onEnd = function(gr){ var velocity, minVelocity; inc("setDragHighlight/set")(slide, div, 0); requestAnimationFrame(function(){ if (Math.abs(gr.translation.x) < 5 && isDragging && slide.stackState === "flip") { div.turn(); } return isDragging = false; }); velocity = Math.abs(gr.velocity.x); minVelocity = 0.5; if (gr.translation.x > div.width() / 4 || (gr.translation.x > 0 && velocity > minVelocity)) { return animateOut(true, gr.translation); } else if (gr.translation.x < -div.width() / 4 || (gr.translation.x < 0 && velocity > minVelocity)) { return animateOut(false, gr.translation); } else { return gr.animateToStart(); } }; tap = function(){ if (isDragging || slide.animationRunning) { return; } if (slide.stackState === "flip") { return div.turn(); } else { return inc("../playSound/play")(slide, atom, div.frontShowing); } }; slide.toggleSpeaker = inc("toggleSpeaker/toggle")(slide); div = Div({ display: "inline-flex", position: "absolute", top: 0, height: "20em", width: "15em", borderRadius: "4px", transform: "rotate(" + rotation + "deg)", pointerEvents: "none", perspective: "500px", zIndex: 0 }).html(frontFace = inc("face/face")(slide, atom, true), backFace = inc("face/face")(slide, atom, false)).drag({ onMove: onMove, onEnd: onEnd, shouldStart: function(){ return slide.stackState === "drag" && !slide.animationRunning && !isDragging; } }).tap({ up: tap, animation: "none" }).addClass("keyManager-32").bind("keyManager", function(){ if (slide.stackState === "flip") { return div.turn(); } }).bind("touchstart", function(e){ return e.preventDefault(); }); animateOut = inc("animateOut/animate")(slide, div, onCardMovedOut, onCardMoveOutStarted); div.updateLayout = function(maxHeight){ var h, w; if (div.height() < maxHeight) { h = inc("/../app01/lib/util/emToPx/emToPx")(20); w = 0.75 * h; return div.css({ height: h + "px", width: w + "px", left: body.width() / 2 - w / 2 + "px", top: 0, fontSize: "1em" }); } else { h = maxHeight - 40; w = 0.75 * h; return div.css({ height: h + "px", width: w + "px", left: body.width() / 2 - w / 2 + "px", top: "20px", fontSize: "0.8em" }); } }; div.moveToStart = function(zeroRotation){ rotation = zeroRotation ? 0 : 4 - _.random(8); div.animation({ css: { transform: "rotate(" + rotation + "deg)" }, duration: 300 }); return setTimeout(function(){ if (!div.frontShowing) { flip(frontFace, 0); flip(backFace, 0); div.frontShowing = true; } viewCount++; return frontFace.findFirst(".viewCount").html(T("viewCount", viewCount)); }, 300); }; div.moveOut = function(right){ var x; x = right ? 1 : -1; inc("setDragHighlight/set")(slide, div, x); div.css({ pointerEvents: "none" }); return animateOut(right, { x: right ? div.width() : -1.5 * div.width(), y: 0 }); }; div.turn = function(){ var frontShowing; if (slide.trainerParams.learnListMode) { slide.visibleLearnListItemsInfos[slide.currentIndex] = "ab"; } div.frontShowing = !div.frontShowing; flip(frontFace, 500); flip(backFace, 500); frontShowing = div.frontShowing; slide.setState("drag"); return setTimeout(function(){ if (div === slide.currentCard) { return inc("../playSound/play")(slide, atom, frontShowing); } }, 500); }; div.zeroRotation = function(animated){ var css; rotation = 0; css = { transform: "rotate(" + rotation + "deg)" }; if (animated) { return div.animation({ css: css, duration: 300 }); } else { return div.css(css); } }; frontFace.flipped = 0; backFace.flipped = -180; div.atom = atom; div.frontFace = frontFace; div.backFace = backFace; div.frontShowing = true; div.index = i; div.isDragging = function(){ return isDragging; }; return div; }; })(); trainers/dragCard/stack/stack/card/face/cardFace/cardFace.ls (function(){ return function(slide, part){ if (part.image || part.lsg) { if (part.text) { return inc("faceType/imageText")({ slide: slide, image: part.image, lsg: part.lsg, text: part.text }); } else if (part.sound) { return inc("faceType/imageSound")({ slide: slide, image: part.image, lsg: part.lsg, sound: part.sound, toggleSpeaker: slide.toggleSpeaker }); } else { return inc("faceType/image")({ slide: slide, image: part.image, lsg: part.lsg }); } } else if (part.sound) { return inc("faceType/sound")({ mediaParams: slide.mediaParams, sound: part.sound, toggleSpeaker: slide.toggleSpeaker }); } else { return inc("faceType/text")({ slide: slide, mediaParams: slide.mediaParams, text: part.text }); } }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/image.ls (function(){ return function(o){ var div, imageWrapper; div = Div({ display: "flex", alignItems: "flex-start", width: "100%", height: "100%", overflow: "hidden", backgroundColor: "white" }).html(imageWrapper = Div({ margin: "1.5em auto 0", width: "9em", height: "9em", border: "6px solid white" }).html(inc("imageOrLsg/imageOrLsg")(o).css({ width: "100%", height: "100%" }))); return div; }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/imageOrLsg/imageOrLsg.ls (function(){ return function(o){ if (o.lsg) { return inc("/shared/lsg/lsg")({ lsg: o.lsg, slide: o.slide }); } else if (o.image) { return inc("/shared/image/image")({ image: o.image, slide: o.slide }); } }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/imageSound.ls (function(){ return function(o){ var div, imageWrapper, speaker; return div = Div({ display: "flex", flexDirection: "column", justifyContent: "stretch", alignItems: "stretch", width: "100%", height: "100%", overflow: "hidden", backgroundColor: "white" }).html(Div({ flex: "0 1 auto" }).html(imageWrapper = Div({ margin: "1.5em auto 0", width: "9em", height: "9em", border: "6px solid white" }).html(inc("imageOrLsg/imageOrLsg")(o).css({ width: "100%", height: "100%" }))), Div({ display: "flex", flex: "1 0 auto" }).html(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "3em", speakerType: "123" }).addClass("cardSpeaker")).bind("mousedown touchstart", function(e){ return e.stopPropagation(); }).tap(function(){ return o.toggleSpeaker(); })); }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/imageText.ls (function(){ return function(o){ var texts, maxTextHeight, adjustLayout, div, imageWrapper, textsDiv, i, t; texts = _.ensureArray(o.text); maxTextHeight = inc("/../app01/lib/util/emToPx/emToPx")(7); adjustLayout = function(){ if (textsDiv.offsetHeight > maxTextHeight) { return imageWrapper.css({ width: "5em", height: "5em" }); } }; div = Div({ display: "flex", flexDirection: "column", justifyContent: "stretch", alignItems: "stretch", width: "100%", height: "100%", overflow: "hidden", backgroundColor: "white" }).html(Div({ flex: "0 1 auto" }).html(imageWrapper = Div({ margin: "1.5em auto 0", width: "9em", height: "9em", border: "6px solid white" }).html(inc("imageOrLsg/imageOrLsg")(o).css({ width: "100%", height: "100%" }))), textsDiv = Div({ display: "flex", flex: "1 0 auto", flexDirection: "column" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = texts).length; i$ < len$; ++i$) { i = i$; t = ref$[i$]; results$.push([ texts.length > 1 && i !== 0 ? inc("separator/separator")() : void 8, Div({ overflow: "hidden", wordBreak: "break-word", hyphens: "auto" }).secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(t) : t) ]); } return results$; }()))).onDomAppendAndVisible(adjustLayout); return div; }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/separator/separator.ls (function(){ return function(){ return Div({ textAlign: "center" }).append(Div({ display: "inline-block", width: "5em", height: "1px", backgroundColor: Color.grey[300], margin: "calc(0.6em - 1px) 0 0.4em" })); }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/sound.ls (function(){ return function(o){ var div, speaker; return div = Div({ display: "flex", width: "100%", height: "100%" }).append(Div({ display: "inline-flex", maxWidth: "100%" }).html(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "3em", speakerType: "123" }).addClass("cardSpeaker").css({ margin: "0.2em 0.25em 0 0.2em" })).bind("mousedown touchstart", function(e){ return e.stopPropagation(); }).tap(function(){ return o.toggleSpeaker(); })); }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/soundText.ls (function(){ return function(o){ var speaker; return Div({ display: "flex", width: "100%", height: "100%" }).append(Div({ maxWidth: "95%" }).html(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "3em", speakerType: "123" }).addClass("cardSpeaker").css({ margin: "0.2em 0.25em -0.2em 0.2em" }).bind("mousedown touchstart", function(e){ return e.stopPropagation(); }).tap(function(){ return o.toggleSpeaker(); }), inc("separator/separator")().css({ marginBottom: "0.2em" }), Div({ overflow: "hidden", wordBreak: "break-word", hyphens: "auto" }).secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(o.text[0]) : o.text[0]))); }; })(); trainers/dragCard/stack/stack/card/face/cardFace/faceType/text.ls (function(){ return function(o){ var texts, i, t; texts = _.ensureArray(o.text); return Div({ display: "flex", width: "100%", height: "100%", backgroundColor: Color.white }).append(Div({ width: "95%" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = texts).length; i$ < len$; ++i$) { i = i$; t = ref$[i$]; results$.push([ texts.length > 1 && i !== 0 ? inc("separator/separator")() : void 8, Div({ overflow: "hidden", wordBreak: "break-word", hyphens: "auto" }).secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(t) : t) ]); } return results$; }()))); }; })(); trainers/dragCard/stack/stack/card/face/face.ls (function(){ return function(slide, atom, isFront){ var soundMode, front, back, soundFront, part, that; soundMode = slide.getParam("soundMode", atom); front = atom.a; back = atom.b; soundFront = atom.soundA || atom.sound || front; part = { text: [] }; if (soundMode === "askSound") { if (that = atom.image) { part.image = that; } if (that = atom.lsg) { part.lsg = that; } if (isFront) { part.sound = soundFront; } else { part.text.push(front); } } else { if (that = atom.image) { part.image = that; } if (that = atom.lsg) { part.lsg = that; } if (front) { part.text.push(front); } if (!isFront) { part.text.push(back); } } if (part.text.length === 0) { delete part.text; } return Div({ position: "absolute", left: 0, top: 0, padding: "6px", width: "100%", height: "100%", fontSize: "1.2em", backgroundColor: Color.white, zIndex: isFront ? 2 : 1, transform: "rotateY(" + (isFront ? 0 : -180) + "deg)", backfaceVisibility: "hidden", webkitBackfaceVisibility: "hidden", boxShadow: "0px 0px 16px -1px rgba(0, 0, 0, 0.06666)" }).append(inc("cardFace/cardFace")(slide, part).css({ backgroundColor: Color.grey[100] }), isFront ? inc("viewCount/viewCount")() : void 8); }; })(); trainers/dragCard/stack/stack/card/face/viewCount/viewCount.ls (function(){ return function(){ return Div().addClass("viewCount").css({ position: "absolute", top: "0.6em", left: "2em", right: "2em", height: "2em", fontSize: "0.7em", color: Color.grey[550] }); }; })(); trainers/dragCard/stack/stack/card/setDragHighlight/set.ls (function(){ return function(slide, card, x){ var c1, c2, l, r; c1 = "transparent"; c2 = Color.grey[200]; l = slide.buttons.buttonLeft; r = slide.buttons.buttonRight; l.css({ backgroundColor: x >= 0 ? c1 : c2 }); r.css({ backgroundColor: x <= 0 ? c1 : c2 }); return card.backFace.css({ transition: "background 200ms", backgroundColor: x === 0 ? Color.white : x < 0 ? Color.orange[200] : Color.green[200] }); }; })(); trainers/dragCard/stack/stack/card/toggleSpeaker/toggle.ls (function(){ return function(slide){ return function(){ var reset, ref$, ref1$, atom, voice, text, sound, speaker; reset = function(){ slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; }; if ((ref$ = slide.currentSound) != null) { ref$.stop(); } if ((ref1$ = slide.currentSpeaker) != null) { ref1$.reset(); } atom = slide.currentCard.atom; voice = slide.getParam("voice", atom); text = atom.soundA || atom.sound || atom.a; sound = slide.sounds[text + voice]; slide.currentSound = sound; if (!sound) { return; } if (text === slide.currentSoundText) { return reset(); } else { speaker = slide.currentCard.frontShowing ? slide.currentCard.frontFace.findFirst(".cardSpeaker") : slide.currentCard.backFace.findFirst(".cardSpeaker"); sound.play(reset, speaker != null ? speaker.update : void 8); slide.currentSpeaker = speaker; return slide.currentSoundText = text; } }; }; })(); trainers/dragCard/stack/stack/moveCard/move.ls (function(){ return function(slide, cards){ return function(type){ var ref$, card; if (slide.stackState === "flip" || slide.animationRunning || slide.currentCard.isDragging()) { return; } slide.animationRunning = true; if ((ref$ = cards[cards.length - 2]) != null) { ref$.zeroRotation(true); } card = _.last(cards); card.css({ pointerEvents: "none" }); return card.moveOut(type === "back" ? false : true); }; }; })(); trainers/dragCard/stack/stack/playSound/play.ls (function(){ var lastPlayStarted; return function(slide, atom, frontShowing){ var p, soundMode, front, back, text, voice, voiceLang, ref$, ref1$; p = slide.getParam; soundMode = p("soundMode", atom); front = atom.soundA || atom.sound || atom.a; back = atom.soundB || atom.sound || atom.b; text = (soundMode === "a" || soundMode === "ab" || soundMode === "askSound") && frontShowing ? front : (soundMode === "b" || soundMode === "ab") && !frontShowing ? back : void 8; if (text) { if (text === front && frontShowing) { voice = p("voiceA", atom); voiceLang = p("voiceLangA", atom); } else { voice = p("voiceB", atom); voiceLang = p("voiceLangB", atom); } voice == null && (voice = p("voice", atom)); voiceLang == null && (voiceLang = p("voiceLang", atom)); if (lastPlayStarted && new Date() - lastPlayStarted < 1000) { return; } if ((ref$ = slide.currentSound) != null) { ref$.stop(); } if ((ref1$ = slide.currentSpeaker) != null) { ref1$.reset(); } if (frontShowing && soundMode === "askSound") { return slide.toggleSpeaker(); } else { lastPlayStarted = new Date(); slide.currentSound = slide.sounds[text + voice + voiceLang]; return slide.currentSound.play(); } } }; })(); trainers/dragCard/stack/stack/stack.ls (function(){ return function(o){ var numVisibleCards, ref$, insertAfterXCards, atoms, slide, onCardMovedOut, onCardMoveOutStarted, updateCardVisibility, stack, cards, i, atom, startCard, moveCard; numVisibleCards = (ref$ = o.numVisibleCards) != null ? ref$ : 5; insertAfterXCards = (ref$ = o.insertAfterXCards) != null ? ref$ : 4; atoms = o.atoms; slide = o.slide; onCardMovedOut = function(rightSide){ var card, i, nextCard; slide.animationRunning = false; card = cards.pop(); card.css({ pointerEvents: "none" }); card.css({ zIndex: 0 }); if (rightSide) { card.remove(); } else { i = insertAfterXCards; if (i > cards.length) { i = cards.length + 1; } cards.splice(cards.length - i + 1, 0, card); stack.insertBefore(card, stack.childrenAll()[cards.length - i]); card.moveToStart(cards.length === 1); } updateCardVisibility(); if (rightSide) { if (typeof o.onCorrect == 'function') { o.onCorrect(card.index); } } else { if (typeof o.onWrong == 'function') { o.onWrong(card.index); } } nextCard = _.last(cards); if (nextCard) { slide.setState("flip"); return startCard(nextCard); } else { return typeof o.onDone == 'function' ? o.onDone() : void 8; } }; onCardMoveOutStarted = function(){ var ref$; slide.animationRunning = true; return (ref$ = cards[cards.length - 2]) != null ? ref$.zeroRotation(true) : void 8; }; updateCardVisibility = function(){ var i$, ref$, len$, i, card, results$ = []; for (i$ = 0, len$ = (ref$ = cards).length; i$ < len$; ++i$) { i = i$; card = ref$[i$]; if (i === 0 || i >= cards.length - numVisibleCards) { results$.push(card.show()); } else { results$.push(card.hide()); } } return results$; }; stack = Div({ height: "20em" }).addClass("cardStack").append(cards = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms.slice().reverse()).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; results$.push(inc("card/card")(slide, atom, i, onCardMovedOut, onCardMoveOutStarted)); } return results$; }())); startCard = inc("startCard/start")(slide); moveCard = inc("moveCard/move")(slide, cards); stack.moveCardToBack = function(){ return moveCard("back"); }; stack.moveCardOut = function(){ return moveCard("out"); }; stack.turnCard = inc("turnCard/turn")(slide, cards); stack.start = inc("start/start")(cards, startCard); updateCardVisibility(); _.last(cards).zeroRotation(false); stack.cards = cards; return stack; }; })(); trainers/dragCard/stack/stack/start/start.ls (function(){ return function(cards, startCard){ return function(){ return startCard(_.last(cards)); }; }; })(); trainers/dragCard/stack/stack/startCard/start.ls (function(){ return function(slide){ return function(card){ var ref$, key$; slide.currentCard = card; card.css({ pointerEvents: "inherit" }); slide.currentIndex = _.findIndex(slide.atoms, card.atom); if (slide.trainerParams.learnListMode) { (ref$ = slide.visibleLearnListItemsInfos)[key$ = slide.currentIndex] == null && (ref$[key$] = "a"); } return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: function(){ return setTimeout(function(){ return inc("../playSound/play")(slide, card.atom, card.frontShowing); }, 500); } }); }; }; })(); trainers/dragCard/stack/stack/turnCard/turn.ls (function(){ return function(slide, cards){ return function(){ if (slide.stackState === "drag") { return; } return _.last(cards).turn(); }; }; })(); trainers/dragCard/updateCardSizes/update.ls (function(){ return function(slide){ var page, ref$, maxHeight, h, i$, ref1$, len$, card, results$ = []; page = (ref$ = slide.levelPlayer) != null ? ref$.page : void 8; if (!page) { return; } maxHeight = body.height() - page.topbar.height() - page.bottom.height(); h = slide.stack.height() > maxHeight ? maxHeight - 40 + "px" : "20em"; slide.stack.css({ height: h }); for (i$ = 0, len$ = (ref1$ = slide.stack.cards).length; i$ < len$; ++i$) { card = ref1$[i$]; results$.push(card.updateLayout(maxHeight)); } return results$; }; })(); trainers/dragGroup/_media2/images/images.ls (function(){ return function(slide){ var atom, cat; return _.concat((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }()), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.cats).length; i$ < len$; ++i$) { cat = ref$[i$]; results$.push(cat.image); } return results$; }())); }; })(); trainers/dragGroup/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var atom, cat; return _.concat((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }()), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.cats).length; i$ < len$; ++i$) { cat = ref$[i$]; results$.push(cat.lsg); } return results$; }())); }; })(); trainers/dragGroup/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, voiceLang, voice, text, ref1$, j$, ref2$, len1$, cat; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); text = atom.sound; if (text == null && (soundMode === "a" || soundMode === "b")) { text = atom.b; if (!text && ((ref1$ = app.currentPage) != null ? ref1$.levelPlayer : void 8) != null) { debug("Achtung, du hast soundMode: \"" + soundMode + "\", aber keinen text angegeben, der ausgesprochen werden kann.", atom); } } if (text) { sounds.push({ text: text, voiceLang: voiceLang, voice: voice }); } for (j$ = 0, len1$ = (ref2$ = slide.cats).length; j$ < len1$; ++j$) { cat = ref2$[j$]; if (cat.sound) { sounds.push({ text: cat.sound, voiceLang: voiceLang, voice: voice }); } } } return sounds; }; })(); trainers/dragGroup/_preview/preview.ls (function(){ return function(slide){ slide.content.css({ height: slide.div.width() + "px" }); slide.div.append(inc("../zones/zones")(slide)); inc("../elements/optimizeWidth/optimize")(slide); return inc("/shared/randomizePositions/randomize")(slide.elements, slide.content); }; })(); trainers/dragGroup/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, i, action; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.originalAtom = e.atom; actions.push(a); } } if (actions.length === 0) { return; } return slide.div.css({ height: "" }).append(Div({ margin: "1em 0", textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.sortBy(actions, "position")).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); }; })(); trainers/dragGroup/_review/scoreActions/correct/_shared/image/image.ls (function(){ return function(slide, atom){ var image; image = slide.getParam("image", atom); return inc("/shared/image/image")({ image: image, slide: slide }).css({ flex: "0 0 auto", display: "inline-flex", height: "1.5em", width: "1.5em", margin: "0.1em 0.1em 0", verticalAlign: "-0.5em" }); }; })(); trainers/dragGroup/_review/scoreActions/correct/_shared/lsg/lsg.ls (function(){ return function(slide, atom){ var lsg; lsg = slide.getParam("lsg", atom); return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ flex: "0 0 auto", display: "inline-flex", height: "1.5em", width: "1.5em", margin: "0.1em 0.1em 0", verticalAlign: "-0.5em" }); }; })(); trainers/dragGroup/_review/scoreActions/correct/_shared/speaker/speaker.ls (function(){ return function(slide, atom){ var voice, voiceLang, text, isPlaying, tap, div, speaker; voice = slide.getParam("voice", atom); voiceLang = slide.getParam("voiceLang", atom); text = atom.sound + voice + voiceLang; isPlaying = false; tap = function(){ var ref$; if (isPlaying) { isPlaying = false; delete slide.currentButton; speaker.reset(); return slide.sounds[text].stop(); } else { isPlaying = true; if ((ref$ = slide.currentButton) != null) { ref$.toggle(); } slide.currentButton = div; return slide.sounds[text].play(function(){ var ref$; isPlaying = false; return ref$ = slide.currentButton, delete slide.currentButton, ref$; }, function(c, t, l){ return speaker.update(c, t, l); }); } }; div = Div({ flex: "0 0 auto", display: "inline-flex", height: "1.5em", width: "1.5em", verticalAlign: "-0.4em", pointerEvents: "auto" }).append(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "1.4em", progressbarType: "none", speakerType: "123" }).css({ position: "absolute", top: "0.15em" })).tap(tap); div.toggle = tap; return div; }; })(); trainers/dragGroup/_review/scoreActions/correct/_shared/text/text.ls (function(){ return function(text){ return "'" + text + "'"; }; })(); trainers/dragGroup/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ var left, right, div; left = inc("left/left")(slide, action.originalAtom); right = inc("right/right")(slide, action.cat); return div = Div({ display: "inline" }).append(left, " → ", right); }; })(); trainers/dragGroup/_review/scoreActions/correct/left/left.ls (function(){ return function(slide, atom){ if (atom.lsg) { return inc("../_shared/lsg/lsg")(slide, atom); } else if (atom.image) { return inc("../_shared/image/image")(slide, atom); } else if (atom.sound) { return inc("../_shared/speaker/speaker")(slide, atom); } else if (atom.b) { return inc("../_shared/text/text")(atom.b); } }; })(); trainers/dragGroup/_review/scoreActions/correct/right/right.ls (function(){ return function(slide, cat){ var c; c = slide.cats[cat]; return [c.sound ? inc("../_shared/speaker/speaker")(slide, c) : void 8, c.text != null || _.isString(c) ? inc("../_shared/text/text")(c.text || c) : void 8, c.lsg != null ? inc("../_shared/lsg/lsg")(slide, c) : void 8, c.image != null ? inc("../_shared/image/image")(slide, c) : void 8]; }; })(); trainers/dragGroup/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return inc("../correct/correct")(action, slide); }; })(); trainers/dragGroup/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, el; slide.instruction.play(); for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.start(); } return slide.levelPlayer.page.bottom.html(slide.zonesDiv).show(); }; })(); trainers/dragGroup/adjustLayout/adjust.ls (function(){ return function(slide){ return inc("/../app01/lib/util/waitFrames/wait")(4, function(){ return inc("/shared/randomizePositions/layoutForce/layout")({ elements: slide.elements, parentOffset: slide.content.offset(), margin: 5, animated: false }); }); }; })(); trainers/dragGroup/content/content.ls (function(){ return function(slide){ return Div({ flex: "0 1 400px", alignSelf: "center", width: "35em", maxWidth: "95%", margin: "1em 0" }).appendTo(slide.div); }; })(); trainers/dragGroup/elements/element/element.ls (function(){ return function(slide, atom, i){ var start, div, image, lsg, speaker; start = function(){ return inc("enableDrag/enable")(slide, atom, div); }; div = Div({ cursor: "move", position: "absolute", top: 0, left: 0, display: "inline-block", backgroundClip: "border-box", boxShadow: '1px 1px 2px #bbb', backgroundColor: "white" }); div.html(atom.image ? image = inc("image/image")(atom, slide) : atom.lsg ? lsg = inc("lsg/lsg")(atom, slide) : atom.b ? Span().html(atom.b) : atom.sound ? speaker = inc("speaker/speaker")(atom, slide) : void 8); if (!atom.image && !atom.lsg) { inc("fixTextLayout/fix")(div); } slide.content.append(div); div.atom = atom; div.start = start; if (speaker != null) { div.speaker = speaker; } return div; }; })(); trainers/dragGroup/elements/element/enableDrag/check/check.ls (function(){ return function(slide, i, atom, onCorrect, onWrong){ var ref$, ref1$; if ((ref$ = slide.currentSound) != null) { ref$.stop(); } if ((ref1$ = slide.currentSpeaker) != null) { ref1$.reset(); } slide.currentSound = null; slide.currentSpeaker = null; slide.currentSoundText = null; if (atom.cat === i) { onCorrect(); return true; } onWrong(); return false; }; })(); trainers/dragGroup/elements/element/enableDrag/detectCollision/calcNearestZone/calc.ls (function(){ return function(collisionZones, slide, div){ var divX, divY, minDist, minIndex, i$, len$, i, zone, zoneX, zoneY, dist; divX = div.offset().left + div.width() / 2; divY = div.offset().top + div.height() / 2; minDist = null; minIndex = -1; for (i$ = 0, len$ = collisionZones.length; i$ < len$; ++i$) { i = collisionZones[i$]; zone = slide.zones[i]; zoneX = zone.offset().left + zone.width() / 2; zoneY = zone.offset().top + zone.height() / 2; dist = Math.sqrt(Math.pow(zoneX - divX, 2) + Math.pow(zoneY - divY, 2)); if (minDist != null) { if (dist < minDist) { minDist = dist; minIndex = i; } } else { minDist = dist; minIndex = i; } } return minIndex; }; })(); trainers/dragGroup/elements/element/enableDrag/detectCollision/detect.ls (function(){ return function(div, slide){ var divOffset, divPosition, collisionZones, res$, i$, ref$, len$, i, zone, zoneOffset, zonePosition; divOffset = div.offset(); divPosition = { top: divOffset.top, left: divOffset.left, bottom: divOffset.top + div.height(), right: divOffset.left + div.width() }; res$ = []; for (i$ = 0, len$ = (ref$ = slide.zones).length; i$ < len$; ++i$) { i = i$; zone = ref$[i$]; zoneOffset = zone.offset(); zonePosition = { top: zoneOffset.top, left: zoneOffset.left, bottom: zoneOffset.top + zone.height(), right: zoneOffset.left + zone.width() }; if (divPosition.right < zonePosition.left) { continue; } else if (divPosition.left > zonePosition.right) { continue; } else if (divPosition.top > zonePosition.bottom) { continue; } else if (divPosition.bottom < zonePosition.top) { continue; } else { res$.push(i); } } collisionZones = res$; if (collisionZones.length === 0) { return -1; } if (collisionZones.length === 1) { return collisionZones[0]; } else { return inc("calcNearestZone/calc")(collisionZones, slide, div); } }; })(); trainers/dragGroup/elements/element/enableDrag/enable.ls (function(){ return function(slide, atom, div){ var currentZone, lastOnEndCallback, dragStartAt, dragStart, dragMove, dragEnd, onCorrect, onWrong; currentZone = -1; lastOnEndCallback = null; dragStartAt = null; dragStart = function(){ var newZone; dragStartAt = new Date(); newZone = inc("detectCollision/detect")(div, slide); currentZone = newZone; return div.css({ boxShadow: '2px 2px 6px #bbb', zIndex: 3 }); }; dragMove = function(){ var newZone, ref$; newZone = inc("detectCollision/detect")(div, slide); if (newZone !== currentZone) { if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } if ((ref$ = slide.zones[currentZone]) != null) { ref$.unmark(); } } currentZone = newZone; if (currentZone > -1) { return slide.zones[currentZone].mark(); } }; dragEnd = function(onEnd){ var isCorrect; if (new Date() - dragStartAt < 200) { inc("playSoundA/play")(slide, atom, div); } lastOnEndCallback = onEnd; if (currentZone > -1) { isCorrect = inc("check/check")(slide, currentZone, atom, onCorrect, onWrong); } else { onEnd.updateAbsolutePosition(); inc("ensureDivInsideBounds/ensure")(div, slide.div.offset()); } if (currentZone === -1 || !isCorrect) { div.css({ boxShadow: '1px 1px 2px #bbb', zIndex: 3 }); if (currentZone !== isCorrect && currentZone !== -1) { return inc("resetZIndex/reset")(div, currentZone, isCorrect); } } }; onCorrect = function(){ slide.score.addActionCorrect(atom, { cat: currentZone }); return inc("finish/finish")(div, currentZone, atom, slide, lastOnEndCallback); }; onWrong = function(){ lastOnEndCallback.animateToStart(); slide.score.addActionMistake(atom, { cat: currentZone }); inc("feedbackWrong/feedback")(slide, div, atom, currentZone); return slide.levelPlayer.progressBar.addElement().showRed(); }; return div.drag({ onStart: dragStart, onMove: dragMove, onEnd: dragEnd }).bind("touchstart", function(e){ return e.preventDefault(); }); }; })(); trainers/dragGroup/elements/element/enableDrag/ensureDivInsideBounds/ensure.ls (function(){ return function(div, bounds){ var offset, parentOff, left, top; offset = div.offset(); parentOff = div.parent().offset(); left = offset.left < bounds.left ? bounds.left : offset.right > bounds.right ? bounds.right - offset.width : offset.left; top = offset.top < bounds.top ? bounds.top : offset.bottom > bounds.bottom ? bounds.bottom - offset.height : offset.top; if (left !== offset.left || top !== offset.top) { left -= parentOff.left; top -= parentOff.top; return div.animation({ css: { left: left + "px", top: top + "px", transform: "", transition: "" }, duration: 100 }); } }; })(); trainers/dragGroup/elements/element/enableDrag/feedbackWrong/feedback.ls (function(){ return function(slide, div, atom, currentZone){ div.css({ pointerEvents: "none" }); slide.zones[currentZone].unmark(); if (atom.image || atom.lsg) { inc("overlayAnimation/animation")(div); } else { inc("textAnimation/animation")(div); } return setTimeout(function(){ return div.css({ pointerEvents: "", transition: "" }); }, 600); }; })(); trainers/dragGroup/elements/element/enableDrag/feedbackWrong/overlayAnimation/animation.ls (function(){ return function(div){ var overlay; overlay = Div({ position: "absolute", bottom: 0, top: 0, right: 0, left: 0, backgroundColor: "transparent", opacity: 1, outline: "5px solid " + Color.red[500] }); div.append(overlay); return setTimeout(function(){ return overlay.css({ opacity: 0, transition: "opacity 200ms" }); }, 400); }; })(); trainers/dragGroup/elements/element/enableDrag/feedbackWrong/textAnimation/animation.ls (function(){ return function(div){ var c; c = div.css("backgroundColor"); div.css({ backgroundColor: Color.red[500] }); return setTimeout(function(){ return div.css({ backgroundColor: c, transition: "background-color 200ms" }); }, 400); }; })(); trainers/dragGroup/elements/element/enableDrag/finish/disappear/disappear.ls (function(){ return function(slide, div, zoneIndex, atom, onEndCallback, onDone){ var disappear, divX, divY, zone, zoneX, zoneY, x, y; disappear = function(){ div.css({ opacity: 0, transform: "translate3d(" + x + "px," + y + "px,0) scale(0.1)", transition: "500ms" }); zone.unmark(); zone.addGreen(); return inc("../../playSoundB/play")(slide, atom, onDone); }; onEndCallback.updateAbsolutePosition(); divX = div.offset().left + div.width() / 2; divY = div.offset().top + div.height() / 2; zone = slide.zones[zoneIndex]; zoneX = zone.offset().left + zone.width() / 2; zoneY = zone.offset().top + zone.height() / 2; x = zoneX - divX; y = zoneY - divY; div.css({ pointerEvents: "none" }); return setTimeout(disappear, 300); }; })(); trainers/dragGroup/elements/element/enableDrag/finish/finish.ls (function(){ return function(div, zoneIndex, atom, slide, onEndCallback){ var onFinish; onFinish = function(){ return slide.score.log(atom, function(){ slide.correctElements++; if (slide.correctElements === slide.totalProgressElements) { slide.div.css({ pointerEvents: "none" }); slide.score.logUnloggedAtoms("unsolvable"); return setTimeout(function(){ slide.div.css({ height: "" }); return slide.finish(); }, 1000); } }); }; slide.levelPlayer.progressBar.showGreen(); if (atom.image || atom.lsg) { inc("overlayAnimation/animation")(div); } else { inc("textAnimation/animation")(div); } return inc("disappear/disappear")(slide, div, zoneIndex, atom, onEndCallback, onFinish); }; })(); trainers/dragGroup/elements/element/enableDrag/finish/overlayAnimation/animation.ls (function(){ return function(div){ return div.css({ outline: "5px solid " + Color.green[500] }); }; })(); trainers/dragGroup/elements/element/enableDrag/finish/textAnimation/animation.ls (function(){ return function(div){ return div.css({ backgroundColor: Color.green[500] }); }; })(); trainers/dragGroup/elements/element/enableDrag/playSoundA/play.ls (function(){ return function(slide, atom, div){ var voice, text, sound, ref$; if (slide.currentSound) { slide.currentSound.stop(); } if (slide.currentSpeaker) { slide.currentSpeaker.reset(); } voice = slide.getParam("voice", atom); text = atom.sound || atom.b; sound = slide.sounds[text + voice]; if (!sound) { return; } if (slide.getParam("soundMode", atom) === "a") { sound.play(); return slide.currentSound = sound; } else if (!(atom.lsg || atom.image || atom.b)) { if (text !== slide.currentSoundText) { sound.play(function(){ slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; }, (ref$ = div.speaker) != null ? ref$.update : void 8); slide.currentSound = sound; slide.currentSoundText = text; return slide.currentSpeaker = div.speaker; } else { slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; } } }; })(); trainers/dragGroup/elements/element/enableDrag/playSoundB/play.ls (function(){ return function(slide, atom, onDone){ var voice, text; if (slide.getParam("soundMode", atom) === "b") { voice = slide.getParam("voice", atom); text = atom.sound || atom.b; return slide.sounds[text + voice].play(onDone); } else { return onDone(); } }; })(); trainers/dragGroup/elements/element/enableDrag/resetZIndex/reset.ls (function(){ return function(div){ return setTimeout(function(){ return div.css({ zIndex: "auto" }); }, 250); }; })(); trainers/dragGroup/elements/element/enableDrag2/calcStatus/calc.ls (function(){ return function(currentZone, atom){ if (currentZone === -1) { return "noZone"; } else if (atom.cat === currentZone) { return "correct"; } else { return "wrong"; } }; })(); trainers/dragGroup/elements/element/enableDrag2/check/check.ls (function(){ return function(slide, i, atom, onCorrect, onWrong){ var ref$, ref1$; if ((ref$ = slide.currentSound) != null) { ref$.stop(); } if ((ref1$ = slide.currentSpeaker) != null) { ref1$.reset(); } slide.currentSound = null; slide.currentSpeaker = null; slide.currentSoundText = null; if (atom.cat === i) { onCorrect(); return true; } onWrong(); return false; }; })(); trainers/dragGroup/elements/element/enableDrag2/detectCollision/calcNearestZone/calc.ls (function(){ return function(collisionZones, slide, div){ var divX, divY, minDist, minIndex, i$, len$, i, zone, zoneX, zoneY, dist; divX = div.offset().left + div.width() / 2; divY = div.offset().top + div.height() / 2; minDist = null; minIndex = -1; for (i$ = 0, len$ = collisionZones.length; i$ < len$; ++i$) { i = collisionZones[i$]; zone = slide.zones[i]; zoneX = zone.offset().left + zone.width() / 2; zoneY = zone.offset().top + zone.height() / 2; dist = Math.sqrt(Math.pow(zoneX - divX, 2) + Math.pow(zoneY - divY, 2)); if (minDist != null) { if (dist < minDist) { minDist = dist; minIndex = i; } } else { minDist = dist; minIndex = i; } } return minIndex; }; })(); trainers/dragGroup/elements/element/enableDrag2/detectCollision/detect.ls (function(){ return function(div, slide){ var divPosition, collisionZones, res$, i$, ref$, len$, i, zone, zonePosition; divPosition = { top: div.offset().top, left: div.offset().left, bottom: div.offset().top + div.height(), right: div.offset().left + div.width() }; res$ = []; for (i$ = 0, len$ = (ref$ = slide.zones).length; i$ < len$; ++i$) { i = i$; zone = ref$[i$]; zonePosition = { top: zone.offset().top, left: zone.offset().left, bottom: zone.offset().top + zone.height(), right: zone.offset().left + zone.width() }; if (divPosition.right < zonePosition.left) { continue; } else if (divPosition.left > zonePosition.right) { continue; } else if (divPosition.top > zonePosition.bottom) { continue; } else if (divPosition.bottom < zonePosition.top) { continue; } else { res$.push(i); } } collisionZones = res$; if (collisionZones.length === 0) { return -1; } if (collisionZones.length === 1) { return collisionZones[0]; } else { return inc("calcNearestZone/calc")(collisionZones, slide, div); } }; })(); trainers/dragGroup/elements/element/enableDrag2/enable.ls (function(){ return function(slide, atom, div){ var currentZone, lastOnEndCallback, dragStartAt, dragStartOffset, dragStart, dragMove, dragEnd; currentZone = -1; lastOnEndCallback = null; dragStartAt = null; dragStartOffset = null; dragStart = function(){ var newZone; dragStartAt = new Date(); dragStartOffset = div.offset(); newZone = inc("detectCollision/detect")(div, slide); currentZone = newZone; return div.css({ boxShadow: '2px 2px 6px #bbb', zIndex: 3, top: dragStartOffset.top + "px", left: dragStartOffset.left + "px", textAlign: "center" }).appendTo(app.currentPage.pageWrapper); }; dragMove = function(){ var newZone, ref$; newZone = inc("detectCollision/detect")(div, slide); if (newZone !== currentZone) { if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } if ((ref$ = slide.zones[currentZone]) != null) { ref$.unmark(); } } currentZone = newZone; if (currentZone > -1) { return slide.zones[currentZone].mark(); } }; dragEnd = function(onEnd){ if (new Date() - dragStartAt < 200) { inc("playSoundA/play")(slide, atom, div); } lastOnEndCallback = onEnd; if (currentZone === -1) { return inc("onNoZone/on")(slide, div, dragStartOffset, lastOnEndCallback); } else if (atom.cat === currentZone) { return inc("onCorrect/on")(slide, div, atom, currentZone, lastOnEndCallback); } else { return inc("onWrong/on")(slide, div, atom, currentZone, lastOnEndCallback, dragStartOffset); } }; return div.drag({ onStart: dragStart, onMove: dragMove, onEnd: dragEnd }).bind("touchstart", function(e){ return e.preventDefault(); }); }; })(); trainers/dragGroup/elements/element/enableDrag2/feedbackWrong/feedback.ls (function(){ return function(slide, div, atom, currentZone){ div.css({ pointerEvents: "none" }); slide.zones[currentZone].unmark(); if (atom.image || atom.lsg) { inc("overlayAnimation/animation")(div); } else { inc("textAnimation/animation")(div); } return setTimeout(function(){ return div.css({ pointerEvents: "", transition: "" }); }, 600); }; })(); trainers/dragGroup/elements/element/enableDrag2/feedbackWrong/overlayAnimation/animation.ls (function(){ return function(div){ var overlay; overlay = Div({ position: "absolute", bottom: 0, top: 0, right: 0, left: 0, backgroundColor: "transparent", opacity: 1, outline: "5px solid " + Color.red[500] }); div.append(overlay); return setTimeout(function(){ return overlay.css({ opacity: 0, transition: "opacity 200ms" }); }, 400); }; })(); trainers/dragGroup/elements/element/enableDrag2/feedbackWrong/textAnimation/animation.ls (function(){ return function(div){ var c; c = div.css("backgroundColor"); div.css({ backgroundColor: Color.red[500] }); return setTimeout(function(){ return div.css({ backgroundColor: c, transition: "background-color 200ms" }); }, 400); }; })(); trainers/dragGroup/elements/element/enableDrag2/finish/disappear/disappear.ls (function(){ return function(slide, div, zoneIndex, atom, onEndCallback, onDone){ var disappear, divX, divY, zone, zoneX, zoneY, x, y; disappear = function(){ div.css({ opacity: 0, transform: "translate3d(" + x + "px," + y + "px,0) scale(0.1)", transition: "500ms" }); zone.unmark(); zone.addGreen(); return inc("../../playSoundB/play")(slide, atom, onDone); }; onEndCallback.updateAbsolutePosition(); divX = div.offset().left + div.width() / 2; divY = div.offset().top + div.height() / 2; zone = slide.zones[zoneIndex]; zoneX = zone.offset().left + zone.width() / 2; zoneY = zone.offset().top + zone.height() / 2; x = zoneX - divX; y = zoneY - divY; div.css({ pointerEvents: "none" }); return setTimeout(disappear, 300); }; })(); trainers/dragGroup/elements/element/enableDrag2/finish/finish.ls (function(){ return function(div, zoneIndex, atom, slide, onEndCallback){ var onFinish; onFinish = function(){ return slide.score.log(atom, function(){ slide.correctElements++; if (slide.correctElements === slide.totalProgressElements) { slide.div.css({ pointerEvents: "none" }); slide.score.logUnloggedAtoms("unsolvable"); return setTimeout(function(){ slide.div.css({ height: "" }); return slide.finish(); }, 1000); } }); }; slide.levelPlayer.progressBar.showGreen(); if (atom.image || atom.lsg) { inc("overlayAnimation/animation")(div); } else { inc("textAnimation/animation")(div); } return inc("disappear/disappear")(slide, div, zoneIndex, atom, onEndCallback, onFinish); }; })(); trainers/dragGroup/elements/element/enableDrag2/finish/overlayAnimation/animation.ls (function(){ return function(div){ return div.css({ outline: "5px solid " + Color.green[500] }); }; })(); trainers/dragGroup/elements/element/enableDrag2/finish/textAnimation/animation.ls (function(){ return function(div){ return div.css({ backgroundColor: Color.green[500] }); }; })(); trainers/dragGroup/elements/element/enableDrag2/onCorrect/on.ls (function(){ return function(slide, div, atom, currentZone, lastOnEndCallback){ slide.score.addActionCorrect(atom, { cat: currentZone }); return inc("../finish/finish")(div, currentZone, atom, slide, lastOnEndCallback); }; })(); trainers/dragGroup/elements/element/enableDrag2/onNoZone/ensureDivInsideBounds/ensure.ls (function(){ return function(div, bounds){ var offset, parentOff, left, top; offset = div.offset(); parentOff = div.parent().offset(); left = offset.left < bounds.left ? bounds.left : offset.right > bounds.right ? bounds.right - offset.width : offset.left; top = offset.top < bounds.top ? bounds.top : offset.bottom > bounds.bottom ? bounds.bottom - offset.height : offset.top; if (left !== offset.left || top !== offset.top) { left -= parentOff.left; top -= parentOff.top; return div.animation({ css: { left: left + "px", top: top + "px", transform: "", transition: "" }, duration: 100 }); } }; })(); trainers/dragGroup/elements/element/enableDrag2/onNoZone/on.ls (function(){ return function(slide, div, dragStartOffset, lastOnEndCallback){ var o, o2; o = div.offset(); o2 = slide.content.offset(); div.css({ boxShadow: '1px 1px 2px #bbb', zIndex: "auto", left: o.left - o2.left + "px", top: o.top - o2.top + "px", transform: "" }).appendTo(slide.content); return inc("ensureDivInsideBounds/ensure")(div, slide.div.offset()); }; })(); trainers/dragGroup/elements/element/enableDrag2/onWrong/on.ls (function(){ return function(slide, div, atom, currentZone, lastOnEndCallback, dragStartOffset){ div.css({ boxShadow: '1px 1px 2px #bbb' }); lastOnEndCallback.animateToStart(function(){ var o, o2; o = div.offset(); o2 = slide.content.offset(); return div.css({ zIndex: "auto", left: o.left - o2.left + "px", top: o.top - o2.top + "px" }).appendTo(slide.content); }); inc("../feedbackWrong/feedback")(slide, div, atom, currentZone); slide.levelPlayer.progressBar.addElement().showRed(); return slide.score.addActionMistake(atom, { cat: currentZone }); }; })(); trainers/dragGroup/elements/element/enableDrag2/playSoundA/play.ls (function(){ return function(slide, atom, div){ var voice, text, sound, ref$; if (slide.currentSound) { slide.currentSound.stop(); } if (slide.currentSpeaker) { slide.currentSpeaker.reset(); } voice = slide.getParam("voice", atom); text = atom.sound || atom.b; sound = slide.sounds[text + voice]; if (!sound) { return; } if (slide.getParam("soundMode", atom) === "a") { sound.play(); return slide.currentSound = sound; } else if (!(atom.lsg || atom.image || atom.b)) { if (text !== slide.currentSoundText) { sound.play(function(){ slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; }, (ref$ = div.speaker) != null ? ref$.update : void 8); slide.currentSound = sound; slide.currentSoundText = text; return slide.currentSpeaker = div.speaker; } else { slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; } } }; })(); trainers/dragGroup/elements/element/enableDrag2/playSoundB/play.ls (function(){ return function(slide, atom, onDone){ var voice, text; if (slide.getParam("soundMode", atom) === "b") { voice = slide.getParam("voice", atom); text = atom.sound || atom.b; return slide.sounds[text + voice].play(onDone); } else { return onDone(); } }; })(); trainers/dragGroup/elements/element/fixTextLayout/fix.ls (function(){ return function(div){ var minPx; div.css({ wordWrap: "break-word", backgroundColor: Color.grey[150], padding: "0.5em" }); minPx = inc("/../app01/lib/util/emToPx/emToPx")(3); return requestAnimationFrame(function(){ if (div.height() <= minPx || div.width() <= minPx) { return div.css({ wordWrap: "", display: "inline-flex", minWidth: "3em", minHeight: "3em" }); } }); }; })(); trainers/dragGroup/elements/element/image/image.ls (function(){ return function(atom, slide){ var image; image = slide.getParam("image", atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.content }).css(!image.width ? { width: "5em", height: "5em" } : void 8); }; })(); trainers/dragGroup/elements/element/lsg/lsg.ls (function(){ return function(atom, slide){ var lsg; lsg = slide.getParam("lsg", atom); if (!lsg) { return; } return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.content }).css(!lsg.width ? { width: "5em", height: "5em" } : void 8); }; })(); trainers/dragGroup/elements/element/speaker/speaker.ls (function(){ return function(atom, slide){ return inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "3em", speakerType: "123" }).css({ margin: "0.2em 0.25em 0 0.2em" }); }; })(); trainers/dragGroup/elements/elements.ls (function(){ return function(slide){ var elements, i, atom; return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.shuffleWithSeed(slide.atoms)).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; results$.push(inc("element/element")(slide, atom, i)); } return results$; }()); }; })(); trainers/dragGroup/elements/optimizeWidth/optimize.ls (function(){ return function(slide){ var i$, ref$, len$, e, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { e = ref$[i$]; if (!e.atom.lsg && !e.atom.image) { results$.push(e.css({ maxWidth: "10em" })); } } return results$; }; })(); trainers/dragGroup/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = _.filter(atoms, function(a){ return a.cat != null; }).length; slide.cats = _.ensureArray(trainerParams.cats); slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/dragGroup/init.ls (function(){ return function(slide){ slide.correctElements = 0; slide.zones = []; slide.div.css({ display: "flex", height: "var(--centerHeight)", flexDirection: "column", alignItems: "stretch" }); slide.instruction = inc("instruction/instruction")(slide); slide.content = inc("content/content")(slide); slide.div.onWindowResize(function(){ return inc("adjustLayout/adjust")(slide); }); requestAnimationFrame(function(){ inc("elements/optimizeWidth/optimize")(slide); inc("/shared/randomizePositions/randomize")(slide.elements, slide.content); return requestAnimationFrame(function(){ return inc("adjustLayout/adjust")(slide); }); }); slide.elements = inc("elements/elements")(slide); return slide.zonesDiv = inc("zones/zones")(slide); }; })(); trainers/dragGroup/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/dragGroup/zones/zone/_shared/playSound/play.ls (function(){ return function(slide, cat, div){ var onDone, ref$, ref1$, voice, text, sound, ref2$; onDone = function(){ var ref$; delete slide.currentSound; delete slide.currentSpeaker; return ref$ = slide.currentSoundText, delete slide.currentSoundText, ref$; }; if ((ref$ = slide.currentSound) != null) { ref$.stop(); } if ((ref1$ = slide.currentSpeaker) != null) { ref1$.reset(); } voice = slide.getParam("voice", cat); text = cat.sound; sound = slide.sounds[text + voice]; if (!sound) { return; } if (text !== slide.currentSoundText) { sound.play(onDone, (ref2$ = div.speaker) != null ? ref2$.update : void 8); slide.currentSound = sound; slide.currentSoundText = text; return slide.currentSpeaker = div.speaker; } else { return onDone(); } }; })(); trainers/dragGroup/zones/zone/image/zone.ls (function(){ return function(slide, cat, i, total){ var width, div, overlay; width = 200; width = Math.min(width, (body.width() / total) * 0.9); width = Math.min(width, body.height() * 0.25); div = inc("/shared/image/image")({ image: cat.image, slide: slide }).css({ width: width + "px", height: width + "px", margin: "0.3em 0.15em" }).append(overlay = Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0, backgroundColor: "rgba(0, 0, 0, 0.07)" }).hide()); div.mark = function(){ return overlay.show(); }; div.unmark = function(){ return overlay.hide(); }; return div; }; })(); trainers/dragGroup/zones/zone/lsg/zone.ls (function(){ return function(slide, cat, i, total){ var width, div, overlay; width = 200; width = Math.min(width, (body.width() / total) * 0.9); width = Math.min(width, body.height() * 0.25); div = inc("/shared/lsg/lsg")({ lsg: cat.lsg, slide: slide }).css({ width: width + "px", height: width + "px", margin: "0.3em 0.15em" }).append(overlay = Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0, backgroundColor: "rgba(0, 0, 0, 0.07)" }).hide()); div.mark = function(){ return overlay.show(); }; div.unmark = function(){ return overlay.hide(); }; return div; }; })(); trainers/dragGroup/zones/zone/sound/zone.ls (function(){ return function(slide, cat, i, total){ var scale, size, padding, div, speaker, overlay; scale = body.width() / 700 - 3 / 7; scale = Math.min(Math.max(scale, 0), 1); size = 2.5 + 1.5 * scale; padding = 0.5 + 1.5 * scale; div = Div({ margin: "0.2em 0.4em", padding: padding + "em", border: "2px dashed " + Color.grey[400] }).html(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: size + "em", speakerType: "123" }), overlay = Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0, backgroundColor: "rgba(0, 0, 0, 0.07)" }).hide()); div.mark = function(){ return overlay.show(); }; div.unmark = function(){ return overlay.hide(); }; div.speaker = speaker; return div; }; })(); trainers/dragGroup/zones/zone/text/zone.ls (function(){ return function(slide, cat, i, total){ var text, div; text = (cat != null ? cat.text : void 8) || cat; div = Div().append(Span().html(text)).css({ textAlign: "center", display: "flex", backgroundColor: Color.grey[100], padding: "1em 0.7em", cursor: "default", boxSizing: "border-box", flexGrow: "1", flexShrink: "1", border: "2px dashed " + Color.grey[400], margin: "-2px" }).css({ flexBasis: total === 2 || total === 4 ? "50%" : "33%" }); div.mark = function(){ return div.css({ backgroundColor: Color.grey[250] }); }; div.unmark = function(){ return div.css({ backgroundColor: Color.grey[100] }); }; return div; }; })(); trainers/dragGroup/zones/zone/zone.ls (function(){ return function(slide, cat, i, total){ var addGreen, zone, points; addGreen = function(){ return points.append(Div({ display: "inline-block", backgroundColor: Color.green[500], width: "7px", height: "7px", borderRadius: "50%", margin: "0.1em 0 0 0.1em" })); }; zone = cat.image ? inc("image/zone")(slide, cat, i, total) : cat.lsg ? inc("lsg/zone")(slide, cat, i, total) : _.isString(cat) || cat.text ? inc("text/zone")(slide, cat, i, total) : cat.sound ? inc("sound/zone")(slide, cat, i, total) : void 8; zone.append(points = Div({ display: "inline-block", textAlign: "left", position: "absolute", left: "0.05em", right: "0.05em", top: "0.05em", lineHeight: "0.2em" })).tap(cat != null && cat.sound ? function(){ return inc("_shared/playSound/play")(slide, cat, zone); } : void 8); zone.addGreen = addGreen; zone.type = _.isString(cat) ? "text" : _.keys(cat)[0]; return zone; }; })(); trainers/dragGroup/zones/zones.ls (function(){ return function(slide){ var cats, div, that, i$, len$, i, cat, zone; cats = slide.cats; if (cats.length < 1 || cats.length > 4) { alert("There must be between 1 and 4 categories!"); return; } div = Div({ display: "flex", alignItems: "stretch", flexWrap: "wrap", maxWidth: "100%" }); if (that = _.find(slide.atoms, function(a){ return a.cat > cats.length - 1; })) { debug("Warning: Don't define atoms whose target cat doesn't exist. To define dummy elements, don't define a cat for that element.", that); } for (i$ = 0, len$ = cats.length; i$ < len$; ++i$) { i = i$; cat = cats[i$]; div.append(zone = inc("zone/zone")(slide, cat, i, cats.length)); slide.zones.push(zone); } return div; }; })(); trainers/dragMatch/_media2/images/images.ls (function(){ return function(slide){ var images, i$, ref$, len$, atom, j$, ref1$, len1$, c, image; images = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = ["a", "b"]).length; j$ < len1$; ++j$) { c = ref1$[j$]; image = slide.getParam("image", atom[c]); if (image != null) { images.push(image); } } } return images; }; })(); trainers/dragMatch/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var lsgDescriptions, i$, ref$, len$, atom, j$, ref1$, len1$, c, ref2$, lsgDescription; lsgDescriptions = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = ["a", "b"]).length; j$ < len1$; ++j$) { c = ref1$[j$]; if ((ref2$ = atom[c]) != null && ref2$.lsg) { lsgDescription = slide.getParam("lsg", atom[c]); if (lsgDescription) { lsgDescriptions.push(lsgDescription); } } } } return lsgDescriptions; }; })(); trainers/dragMatch/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, j$, ref1$, len1$, c, val, voiceLang, voice, soundMode, text, ref2$; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = ["a", "b"]).length; j$ < len1$; ++j$) { c = ref1$[j$]; val = atom[c]; if (!val) { continue; } voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); soundMode = slide.getParam("soundMode", atom); text = val.sound; if (text == null && (soundMode === "a" || soundMode === "b")) { text = (ref2$ = atom.sound) != null ? ref2$ : (ref2$ = val.sound) != null ? ref2$ : (ref2$ = val.text) != null ? ref2$ : val; } if (_.isString(text)) { sounds.push({ text: text, voiceLang: voiceLang, voice: voice }); } } } return sounds; }; })(); trainers/dragMatch/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/dragMatch/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, slide){ var left, right; left = inc("div/div")(slide, action.divs.active); right = inc("div/div")(slide, action.divs.passive); return Div({ display: "inline" }).append(left, " → ", right); }; })(); trainers/dragMatch/_review/scoreActions/actionDiv/div/div.ls (function(){ return function(slide, o){ if (_.isString(o) || o.text) { return inc("text/text")(o); } else if (o.image) { return inc("image/image")(slide, o); } else if (o.lsg) { return inc("lsg/lsg")(slide, o); } else if (o.sound) { return inc("speaker/speaker")(slide, o); } }; })(); trainers/dragMatch/_review/scoreActions/actionDiv/div/image/image.ls (function(){ return function(slide, o){ return inc("/shared/image/image")({ image: o.image, slide: slide }).css({ flex: "0 0 auto", display: "inline-flex", height: "1.5em", width: "1.5em", margin: "0.1em 0.1em 0", verticalAlign: "-0.5em" }); }; })(); trainers/dragMatch/_review/scoreActions/actionDiv/div/lsg/lsg.ls (function(){ return function(slide, o){ var lsg, ref$; lsg = slide.getParam("lsg", o); return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide })) != null ? ref$.css({ flex: "0 0 auto", display: "inline-flex", height: "1.5em", width: "1.5em", margin: "0.1em 0.1em 0", verticalAlign: "-0.5em" }) : void 8; }; })(); trainers/dragMatch/_review/scoreActions/actionDiv/div/speaker/speaker.ls (function(){ return function(slide, atom){ var voice, voiceLang, text, isPlaying, tap, div, speaker; voice = slide.getParam("voice", slide.atom); voiceLang = slide.getParam("voiceLang", slide.atom); text = atom.sound + voice + voiceLang; isPlaying = false; tap = function(){ var ref$; if (isPlaying) { isPlaying = false; delete slide.currentButton; speaker.reset(); return slide.sounds[text].stop(); } else { isPlaying = true; if ((ref$ = slide.currentButton) != null) { ref$.toggle(); } slide.currentButton = div; return slide.sounds[text].play(function(){ var ref$; isPlaying = false; return ref$ = slide.currentButton, delete slide.currentButton, ref$; }, function(c, t, l){ return speaker.update(c, t, l); }); } }; div = Div({ flex: "0 0 auto", display: "inline-flex", height: "1.5em", width: "1.5em", verticalAlign: "-0.4em", pointerEvents: "auto" }).append(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "1.4em", progressbarType: "none", speakerType: "123" }).css({ position: "absolute", top: "0.1em" })).tap(tap); div.toggle = tap; return div; }; })(); trainers/dragMatch/_review/scoreActions/actionDiv/div/text/text.ls (function(){ return function(o){ return "'" + (o.text || o) + "'"; }; })(); trainers/dragMatch/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, i, action; slide.div.css({ height: "" }); scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; actions.push(a); } } if (actions.length > 0) { return slide.div.append(Div({ margin: "2em 0", textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.sortBy(actions, "position")).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(inc("actionDiv/div")(action, slide))); } return results$; }()))); } }; })(); trainers/dragMatch/_start/checkSoundB/check.ls (function(){ return function(slide){ var i$, ref$, len$, atom, lresult$, j$, ref1$, len1$, o, text, ref2$, results$ = []; if (slide.getParam("soundMode") !== "b") { return; } for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; lresult$ = []; for (j$ = 0, len1$ = (ref1$ = [atom.a, atom.b]).length; j$ < len1$; ++j$) { o = ref1$[j$]; if (!o) { continue; } text = (ref2$ = atom.sound) != null ? ref2$ : (ref2$ = o.sound) != null ? ref2$ : (ref2$ = o.text) != null ? ref2$ : o; if (!_.isString(text)) { lresult$.push(debug("soundMode b specified, but no sound found for atom. Please specify a custom sound for: ", o)); } } results$.push(lresult$); } return results$; }; })(); trainers/dragMatch/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, el; slide.instruction.play(); for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.start(); } slide.dragElementsActive = 0; return inc("checkSoundB/check")(slide); }; })(); trainers/dragMatch/allowMatchSameType/check.ls (function(){ return function(slide){ var i$, ref$, v; for (i$ in ref$ = slide.typesByAtomIndex) { v = ref$[i$]; if (v.a === v.b) { return true; } } return false; }; })(); trainers/dragMatch/content/content.ls (function(){ return function(slide){ return Div({ flex: "0 1 400px", alignSelf: "center", width: "35em", maxWidth: "95%", margin: "1em 0" }).appendTo(slide.div); }; })(); trainers/dragMatch/elements/element/element.ls (function(){ return function(slide, atom, value, answer, type){ var start, div, speaker; start = function(){ return inc("enableDrag/enable")(slide, div); }; div = Div({ display: "inline-block", position: "absolute", left: 0, top: 0, cursor: "move", backgroundClip: "border-box", backgroundColor: Color.white, boxShadow: "1px 1px 2px " + Color.grey[400] }).html(type === "sound" ? speaker = inc("speaker/speaker")(atom, slide) : type === "image" ? inc("image/image")(slide, value) : type === "lsg" ? inc("lsg/lsg")(slide, value) : type === "text" ? Span().css({ pointerEvents: "none" }).html(_.isString(value) ? value : value.text) : void 8); if (type !== "image" && type !== "lsg") { inc("fixTextLayout/fix")(div, value); } slide.content.append(div); if (speaker != null) { div.speaker = speaker; } div.atom = atom; div.value = value; div.answer = answer; div.type = type; div.start = start; return div; }; })(); trainers/dragMatch/elements/element/enableDrag/check/check.ls (function(){ return function(slide, div, closest, onCorrect, onWrong){ var stopSound, otherDiv; stopSound = function(){ if (slide.currentSound) { slide.currentSound.stop(); } if (slide.currentSpeaker) { slide.currentSpeaker.reset(); } slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; }; stopSound(); otherDiv = slide.elements[closest]; if (!slide.allowMatchSameType && div.type === otherDiv.type) {} else if (div.atom === otherDiv.atom) { return onCorrect(); } else if (_.isEqual(div.answer, otherDiv.value)) { return onCorrect(); } else if (_.isEqual(div.value, otherDiv.answer)) { return onCorrect(); } else { return onWrong(); } }; })(); trainers/dragMatch/elements/element/enableDrag/detectCollision/calcNearestElement/calc.ls (function(){ return function(collisionElements, slide, div){ var divX, divY, minDist, minIndex, i$, len$, i, e, x, y, dist; divX = div.offset().left + div.width() / 2; divY = div.offset().top + div.height() / 2; minDist = null; minIndex = -1; for (i$ = 0, len$ = collisionElements.length; i$ < len$; ++i$) { i = collisionElements[i$]; e = slide.elements[i]; x = e.offset().left + e.width() / 2; y = e.offset().top + e.height() / 2; dist = Math.sqrt(Math.pow(x - divX, 2) + Math.pow(y - divY, 2)); if (minDist != null) { if (dist < minDist) { minDist = dist; minIndex = i; } } else { minDist = dist; minIndex = i; } } return minIndex; }; })(); trainers/dragMatch/elements/element/enableDrag/detectCollision/detect.ls (function(){ return function(slide, div){ var divPosition, collisionElements, res$, i$, ref$, len$, i, e, elementPosition; divPosition = div.offset(); res$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { i = i$; e = ref$[i$]; if (!e.isVisible()) { continue; } if (e === div) { continue; } if (!slide.allowMatchSameType) { if (e.type === div.type) { continue; } } elementPosition = e.offset(); if (divPosition.right < elementPosition.left) { continue; } else if (divPosition.left > elementPosition.right) { continue; } else if (divPosition.top > elementPosition.bottom) { continue; } else if (divPosition.bottom < elementPosition.top) { continue; } else { res$.push(i); } } collisionElements = res$; if (collisionElements.length === 0) { return -1; } if (collisionElements.length === 1) { return collisionElements[0]; } else { return inc("calcNearestElement/calc")(collisionElements, slide, div); } }; })(); trainers/dragMatch/elements/element/enableDrag/disappear/disappear.ls (function(){ return function(slide, div, closest, lastOnEndCallback){ var el, o; el = slide.elements[closest]; if (!el) { div.remove(); return; } o = el.offset(); lastOnEndCallback.animateToTarget({ targetScale: 0, targetOpacity: 0, targetPosition: { x: o.left + o.width / 2, y: o.top + o.height / 2 } }); el.css({ transform: "scale(0.001)", opacity: 0, transition: "500ms", transitionProperty: "transform, opacity" }); return setTimeout(function(){ div.remove(); return el.remove(); }, 500); }; })(); trainers/dragMatch/elements/element/enableDrag/enable.ls (function(){ return function(slide, div){ var closest, lastOnEndCallback, dragStartAt, mark, unmark, dragStart, dragMove, dragEnd, onCorrect, onWrong; closest = -1; lastOnEndCallback = null; dragStartAt = null; mark = function(d){ return d != null ? d.css({ outline: "5px solid " + Color.grey[400] }) : void 8; }; unmark = function(d){ return d != null ? d.css({ outline: "", boxShadow: '1px 1px 2px #bbb' }) : void 8; }; dragStart = function(){ slide.dragElementsActive++; dragStartAt = new Date(); closest = inc("detectCollision/detect")(slide, div); return mark(div); }; dragMove = function(){ var newClosest; newClosest = inc("detectCollision/detect")(slide, div); if (newClosest !== closest) { if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } unmark(slide.elements[closest]); } closest = newClosest; if (closest > -1) { if (slide.allowMatchSameType || div.type !== slide.elements[closest].type) { return mark(slide.elements[closest]); } } }; dragEnd = function(onEnd){ slide.dragElementsActive--; if (new Date() - dragStartAt < 200) { inc("playSoundA/play")(slide, div); } lastOnEndCallback = onEnd; unmark(slide.elements[closest]); unmark(div); if (closest > -1) { return inc("check/check")(slide, div, closest, onCorrect, onWrong); } else { return onEnd.updateAbsolutePosition(); } }; onCorrect = function(){ div.css({ pointerEvents: "none" }); slide.elements[closest].css({ pointerEvents: "none" }); inc("feedbackCorrect/feedback")(slide, div, closest); setTimeout(function(){ return inc("disappear/disappear")(slide, div, closest, lastOnEndCallback); }, 300); return inc("playSoundBAndFinish/play")(slide, div); }; onWrong = function(){ lastOnEndCallback.animateToStart(); return inc("feedbackWrong/feedback")(slide, div, closest); }; return div.drag({ onStart: dragStart, onMove: dragMove, onEnd: dragEnd, boundingDiv: slide.div, shouldStart: function(){ return slide.dragElementsActive === 0; } }).bind("touchstart touchmove mousedown", function(e){ return e.preventDefault(); }); }; })(); trainers/dragMatch/elements/element/enableDrag/feedbackCorrect/feedback.ls (function(){ return function(slide, div, closestElement){ var divs, i$, ref$, len$, d, results$ = []; divs = { active: div.value, passive: slide.elements[closestElement].value }; slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(div.atom, { divs: divs }); for (i$ = 0, len$ = (ref$ = [div, slide.elements[closestElement]]).length; i$ < len$; ++i$) { d = ref$[i$]; results$.push(inc("outlineAnimation/animation")(d)); } return results$; }; })(); trainers/dragMatch/elements/element/enableDrag/feedbackCorrect/outlineAnimation/animation.ls (function(){ return function(div){ return div.css({ outline: "5px solid " + Color.green[500] }); }; })(); trainers/dragMatch/elements/element/enableDrag/feedbackWrong/feedback.ls (function(){ return function(slide, div, closest){ var divs; divs = { active: div.value, passive: slide.elements[closest].value }; slide.score.addActionMistake(div.atom, { divs: divs }); slide.levelPlayer.progressBar.addElement().showRed(); if (closest > -1) { inc("shake/shake")(slide.elements[closest], div.atom); } div.css({ outline: "5px solid " + Color.red[500] }); slide.elements[closest].css({ outline: "5px solid " + Color.red[500] }); return setTimeout(function(){ div.css({ outline: "" }); return slide.elements[closest].css({ pointerEvents: "", outline: "", transition: "" }); }, 500); }; })(); trainers/dragMatch/elements/element/enableDrag/feedbackWrong/shake/shake.ls (function(){ return function(div, atom){ var rest; rest = function(){ var ms; ms = 150; div.css({ transition: "transform " + ms + "ms" }); div.css({ transform: "translate(-7px,0)" }); setTimeout(function(){ return div.css({ transform: "translate(7px,0)" }); }, ms); return setTimeout(function(){ return div.css({ transform: "translate(0px,0)", pointerEvents: "" }); }, 2 * ms); }; div.css({ pointerEvents: "none" }); return rest(); }; })(); trainers/dragMatch/elements/element/enableDrag/playSoundA/play.ls (function(){ return function(slide, div){ var voice, text, ref$, sound, ref1$, ref2$; voice = slide.getParam("voice", div.atom); text = (ref$ = div.atom.sound) != null ? ref$ : (ref$ = div.value.sound) != null ? ref$ : (ref$ = div.value.text) != null ? ref$ : div.value; sound = slide.sounds[text + voice]; if (!sound) { return; } if (div.type !== "sound") { if (slide.getParam("soundMode", div.atom) === "a") { return sound.play(); } } else { if ((ref$ = slide.currentSound) != null) { ref$.stop(); } if ((ref1$ = slide.currentSpeaker) != null) { ref1$.reset(); } slide.currentSound = sound; text = (ref2$ = div.atom.sound) != null ? ref2$ : div.value.sound; sound = slide.sounds[text + voice]; if (text === slide.currentSoundText) { slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; } else { sound.play(function(){ slide.currentSound = null; slide.currentSpeaker = null; return slide.currentSoundText = null; }, (ref2$ = div.speaker) != null ? ref2$.update : void 8); slide.currentSpeaker = div.speaker; return slide.currentSoundText = text; } } }; })(); trainers/dragMatch/elements/element/enableDrag/playSoundBAndFinish/play.ls (function(){ return function(slide, div){ var finish; finish = function(){ return slide.score.log(div.atom, function(){ slide.correctElements++; if (slide.correctElements === slide.totalProgressElements) { slide.score.logUnloggedAtoms("unsolvable"); slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); } }); }; return setTimeout(function(){ var voice, text, ref$; if (slide.getParam("soundMode") === "b") { voice = slide.getParam("voice", div.atom); text = (ref$ = div.atom.sound) != null ? ref$ : (ref$ = div.value.sound) != null ? ref$ : (ref$ = div.value.text) != null ? ref$ : div.value; return slide.sounds[text + voice].play(finish); } else { return finish(); } }, 300); }; })(); trainers/dragMatch/elements/element/fixTextLayout/fix.ls (function(){ return function(div, value){ var text, minPx; text = value.text || value; div.css({ backgroundColor: Color.grey[150], padding: "0.5em", maxWidth: !_.includes(text, ">> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/dragOrder/buttonsDiv/checkButton/highlightZone/highlight.ls (function(){ return function(slide, correct){ var div; div = Div({ position: "absolute", top: "-3px", bottom: "-3px", left: "-3px", right: "-3px", border: "4px solid " + (correct ? Color.green[500] : Color.red[500]), borderRadius: "10px" }).appendTo(slide.endZone); return setTimeout(function(){ return div.fadeOut(250); }, 400); }; })(); trainers/dragOrder/buttonsDiv/checkButton/playSoundB/play.ls (function(){ return function(slide){ return function(callback){ var endZoneElements, voice, playList, that, text; endZoneElements = slide.endZone.find(".dragOrderElement"); voice = slide.getParam("voice", slide.atom); playList = function(index){ var that; if (that = endZoneElements[index]) { return setTimeout(function(){ return slide.sounds[that.value + voice].play(function(){ return playList(index + 1); }); }, 500); } else { return setTimeout(callback, 500); } }; if (slide.getParam("soundMode", slide.atom) === "b") { if (that = slide.atom.sound) { return setTimeout(function(){ return slide.sounds[that + voice].play(callback); }, 500); } else { if (slide.listMode === "flow") { text = _.map(endZoneElements, function(c){ return c.value; }).join(" "); return setTimeout(function(){ return slide.sounds[text + voice].play(callback); }, 500); } else { return playList(0); } } } else { return setTimeout(callback, 1000); } }; }; })(); trainers/dragOrder/buttonsDiv/div.ls (function(){ return function(slide){ return Div({ display: "inline-block", width: "100%", textAlign: "center" }).append(slide.startZone, "
", slide.solveButton = inc("solveButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide)); }; })(); trainers/dragOrder/buttonsDiv/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ if (div.isVisible()) { return; } return div.fadeIn(); }; click = function(){ var i$, ref$, len$, el, voice, text; for (i$ = 0, len$ = (ref$ = slide.endZone.find(".dragOrderElement")).length; i$ < len$; ++i$) { el = ref$[i$]; el.setColor(Color.grey[250]); } slide.buttonsDiv.css({ pointerEvents: "none" }); voice = twitch({ de: "f5", en_gb: "f3", en: "f8Us", fr: "f1", es: "f1EsUs", pt: "f6" }); text = T("possibleSolution"); slide.sounds[text + voice].play(function(){ return setTimeout(slide.finish, 500); }); slide.finishButton = true; slide.startZone.css({ pointerEvents: "none" }); slide.endZone.css({ pointerEvents: "none" }); return setTimeout(function(){ var words, res$, i$, ref$, len$, el; slide.solve(); res$ = []; for (i$ = 0, len$ = (ref$ = slide.endZone.findAll(".dragOrderElement")).length; i$ < len$; ++i$) { el = ref$[i$]; res$.push(el.value); } words = res$; slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom, { words: words }); slide.score.log(slide.atom); slide.startZone.hide(); return slide.buttonsDiv.hide(); }, 250); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).tap(click).css({ margin: "0.2em 0.5em 0.8em", backgroundColor: Color.grey[250] }).appendTo(slide.startZone).hide(); div.showButton = showButton; return div; }; })(); trainers/dragOrder/calcCollision/calc.ls (function(){ return function(){ return function(div1, div2){ var o1, o2; o1 = div1.offset(); o2 = div2.offset(); if (o1.right < o2.left) { return false; } else if (o1.left > o2.right) { return false; } else if (o1.top > o2.bottom) { return false; } else if (o1.bottom < o2.top) { return false; } else { return true; } }; }; })(); trainers/dragOrder/calcDragSolutions/calc.ls (function(){ return function(slide){ var dragOrders, solution, index; return dragOrders = (function(){ var i$, ref$, len$, lresult$, j$, ref1$, len1$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.solutions).length; i$ < len$; ++i$) { solution = ref$[i$]; lresult$ = []; for (j$ = 0, len1$ = (ref1$ = solution).length; j$ < len1$; ++j$) { index = ref1$[j$]; lresult$.push(slide.atom.elements[index]); } results$.push(lresult$); } return results$; }()); }; })(); trainers/dragOrder/calcSolutionSequences/calc.ls (function(){ return function(slide){ var i$, ref$, len$, i, o, lresult$, j$, len1$, j, results$ = []; for (i$ = 0, len$ = (ref$ = slide.solutions).length; i$ < len$; ++i$) { i = i$; o = ref$[i$]; lresult$ = []; for (j$ = 0, len1$ = o.length; j$ < len1$; ++j$) { j = o[j$]; lresult$.push(slide.atom.elements[j]); } results$.push(lresult$); } return results$; }; })(); trainers/dragOrder/capitalizeFirstLetter/capitalize.ls (function(){ return function(slide){ return function(div){ var elements, i$, len$, i, el, v, tempValue; elements = slide.endZone.findAll(".dragOrderElement"); for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { i = i$; el = elements[i$]; if (i === 0) { v = el.value; tempValue = _.capitalize(v[0]) + v.slice(1); el.findFirst(".elementLabel").html(tempValue); } else { el.findFirst(".elementLabel").html(el.value); } } if (div && !_.includes(elements, div)) { return div.findFirst(".elementLabel").html(div.value); } }; }; })(); trainers/dragOrder/debugSolutionDiv/debugButton/button.ls (function(){ return function(slide, solutionsDiv){ return Div({ display: "flex", color: Color.grey[300], margin: "1em 0em" }).html(inc("icon/icon")(), "Solutions").tap(inc("tap/tap")(slide, solutionsDiv)); }; })(); trainers/dragOrder/debugSolutionDiv/debugButton/icon/icon.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/shape/debug.svg"), color: Color.grey[300] }).css({ marginRight: "0.2em" }); }; })(); trainers/dragOrder/debugSolutionDiv/debugButton/tap/tap.ls (function(){ return function(slide, solutionsDiv){ return function(){ if (solutionsDiv.isVisible()) { return solutionsDiv.fadeOut(); } else { return solutionsDiv.fadeIn(); } }; }; })(); trainers/dragOrder/debugSolutionDiv/div.ls (function(){ return function(slide){ var div, solutionsDiv; if (!engine.isDebug) { return; } div = Div().html(solutionsDiv = Div().html(inc("solutions/solutions")(slide)).hide()).appendTo(slide.div); div.prepend(inc("debugButton/button")(slide, solutionsDiv)); return div; }; })(); trainers/dragOrder/debugSolutionDiv/solutions/solutions.ls (function(){ return function(slide){ var i$, ref$, len$, i, solution, results$ = []; for (i$ = 0, len$ = (ref$ = slide.dragSolutions).length; i$ < len$; ++i$) { i = i$; solution = ref$[i$]; results$.push(Div({ fontSize: "0.8em", padding: "0.4em", color: Color.grey[400] }).html(slide.listMode === "flow" ? _.join(solution, " ") : _.join(solution, "
"))); } return results$; }; })(); trainers/dragOrder/elements/_arrow/arrow.ls (function(){ return function(slide, contentDiv){ var ref$; if ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets") { return inc("list/arrow")(contentDiv); } else { return inc("flow/arrow")(); } }; })(); trainers/dragOrder/elements/_arrow/flow/arrow.ls (function(){ return function(){ return Div({ position: "absolute", right: "7px", top: 0, bottom: 0 }).html(SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-down.svg") }).css({ position: "absolute", top: "-17px" }), SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-up.svg") }).css({ position: "absolute", bottom: "-17px" })).hide(); }; })(); trainers/dragOrder/elements/_arrow/list/arrow.ls (function(){ return function(contentDiv){ var div, line; div = Div({ position: "absolute", left: "-18px", bottom: "-11px" }).html(line = Div({ position: "absolute", top: "-8px", left: "18px", width: "0px", height: "2px", background: Color.blue[300] })).hide(); div.setWidth = inc("setWidth/set")(line); div.onDomAppend(function(){ return div.setWidth(contentDiv.width()); }); return div; }; })(); trainers/dragOrder/elements/_arrow/list/setWidth/set.ls (function(){ return function(line){ return function(width){ return line.css({ width: width + "px" }); }; }; })(); trainers/dragOrder/elements/dummyElement/dummyElement.ls (function(){ return function(slide){ var div, arrow, ref$; div = Div({ verticalAlign: "top", display: "inline-block", width: 0, height: "2em" }); div.append(arrow = inc("../_arrow/arrow")(slide, div)); if ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets") { div.css({ height: "1em" }); } div.arrow = arrow; return div; }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/calcLabel/calc.ls (function(){ return function(text){ if (text === " ") { return " "; } else { return text; } }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/div.ls (function(){ return function(slide, text){ var div, enumeratorDiv, box, arrow; div = Div({ display: "inline-flex", justifyContent: "flex-start" }).html(enumeratorDiv = inc("enumeratorDiv/div")(slide), box = Div({ display: "inline-block", cursor: "pointer", backgroundColor: Color.grey[250], padding: "0.3em", minWidth: "2em", maxWidth: "15em", textAlign: "center" })); box.html(Span().addClass("elementLabel").html(inc("calcLabel/calc")(text)), arrow = inc("../../../_arrow/arrow")(slide, div)); div.enumeratorDiv = enumeratorDiv; div.box = box; div.arrow = arrow; return div; }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/enumeratorDiv/calcCss/calc.ls (function(){ return function(slide){ var css; css = { position: "absolute", left: 0 }; if (slide.atom.elements.length > 9) { css.width = "1.25em"; css.textAlign = "right"; } return css; }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/enumeratorDiv/div.ls (function(){ return function(slide){ var css, div; css = inc("calcCss/calc")(slide); div = Div(css).addClass("dragOrderEnumerator"); div.hideEnum = inc("hideEnum/hide")(div); div.showEnum = inc("showEnum/show")(slide, div); return div; }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/enumeratorDiv/hideEnum/hide.ls (function(){ return function(div){ return function(){ return div.css({ transition: "300ms", transform: "translate(0, 0)", opacity: 0 }); }; }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/enumeratorDiv/showEnum/animateEnum/animate.ls (function(){ return function(div, transform){ return div.css({ transition: "300ms", transform: transform, opacity: 1 }); }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/enumeratorDiv/showEnum/calcTransform/calc.ls (function(){ return function(slide){ var listMode; listMode = slide.listMode; if (listMode === "bullets") { return "translate(-0.75em, 0)"; } else if (listMode === "numbers") { if (slide.atom.elements.length > 9) { return "translate(-1.75em, 0)"; } else { return "translate(-1.25em, 0)"; } } }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/enumeratorDiv/showEnum/show.ls (function(){ return function(slide, div){ var transform; transform = inc("calcTransform/calc")(slide); return function(){ inc("updateEnum/update")(slide, div); return inc("animateEnum/animate")(div, transform); }; }; })(); trainers/dragOrder/elements/element/dragDiv/contentDiv/enumeratorDiv/showEnum/updateEnum/update.ls (function(){ return function(slide, div){ var index; index = _.indexOf(slide.endZone.find(".dragOrderEnumerator"), div); return div.html(slide.listMode === "bullets" ? "•" : (index + 1) + ". "); }; })(); trainers/dragOrder/elements/element/dragDiv/div.ls (function(){ return function(slide, text, index, element){ var dragDiv, contentDiv; dragDiv = Div({ zIndex: 2, display: "inline-block", verticalAlign: "middle" }).html(contentDiv = inc("contentDiv/div")(slide, text)).addClass("dragOrderElement"); inc("savePlaceholderSize/save")(dragDiv, element); dragDiv.currentZone = -1; dragDiv.lastZone = -1; dragDiv.lastInsertIndex = -1; dragDiv.index = index; dragDiv.value = text; dragDiv.element = element; dragDiv.arrow = contentDiv.arrow; dragDiv.box = contentDiv.box; dragDiv.showEnum = contentDiv.enumeratorDiv.showEnum; dragDiv.hideEnum = contentDiv.enumeratorDiv.hideEnum; dragDiv.setColor = function(color){ return contentDiv.box.css({ backgroundColor: color }); }; return dragDiv; }; })(); trainers/dragOrder/elements/element/dragDiv/savePlaceholderSize/save.ls (function(){ return function(dragDiv, element){ return element.onDomAppend(function(){ return dragDiv.dummySize = { width: element.width(), height: element.height() }; }); }; })(); trainers/dragOrder/elements/element/element.ls (function(){ return function(slide, text, index){ var element, dragDiv; element = Div({ display: "inline-block", verticalAlign: "top", border: "1px solid " + Color.grey[250], margin: "0.2em", minWidth: "2em" }); element.html(dragDiv = inc("dragDiv/div")(slide, text, index, element)); element.start = function(){ return inc("enableDrag/enable")(slide, dragDiv); }; return element; }; })(); trainers/dragOrder/elements/element/enableDrag/_hideInsertPoint/hide.ls (function(){ return function(slide, dragDiv){ var children, i$, len$, c, results$ = []; children = _.filter(slide.endZone.find(".dragOrderElement,.dummyStart"), function(c){ return c !== dragDiv; }); for (i$ = 0, len$ = children.length; i$ < len$; ++i$) { c = children[i$]; results$.push(c.arrow.hide()); } return results$; }; })(); trainers/dragOrder/elements/element/enableDrag/enable.ls (function(){ return function(slide, dragDiv){ var page; page = slide.levelPlayer.page; return dragDiv.drag({ onStart: inc("onStart/on")(slide, dragDiv), onMove: inc("onMove/on")(slide, dragDiv, page), onEnd: inc("onEnd/on")(slide, dragDiv, page), preventDefault: true, shouldStart: function(){ return slide.dragElementsActive === 0; }, animation: { start: function(){ return dragDiv.box.css({ boxShadow: "1px 1px 4px rgba(0,0,0,0.2)" }); }, end: function(){ return dragDiv.box.css({ boxShadow: "" }); } } }).bind("touchstart touchmove mousedown", function(e){ return e.preventDefault(); }); }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animate.ls (function(){ return function(slide, dragDiv, onEnd){ if (dragDiv.currentZone === 0) { inc("animateToZone/animate")(slide, dragDiv); } else { inc("animateToStart/animate")(slide, dragDiv, onEnd); } if (slide.getParam("firstLetterBig") && slide.listMode === "flow") { return slide.capitalizeFirstLetter(dragDiv); } }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToStart/animate.ls (function(){ return function(slide, dragDiv, onEnd){ var dummy, filteredDragElements; dummy = body.findFirst(".dragOrderDummy_" + dragDiv.index); if (dummy) { filteredDragElements = inc("calcFilteredDragElements/calc")(slide, dragDiv); inc("saveOffsets/save")(filteredDragElements); inc("animateDivToStart/animate")(slide, dragDiv, dummy); inc("animateNewOrder/animate")(slide, dragDiv, filteredDragElements); } else { onEnd.animateToStart(); } if (slide.endZone.find(".dragOrderElement").length === 0) { return slide.endZone.showLabel(); } }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToStart/animateDivToStart/animate.ls (function(){ return function(slide, dragDiv, dummy){ var isList, ref$, endZoneDummy; isList = (ref$ = slide.listMode) === "numbers" || ref$ === "bullets"; if (isList) { dragDiv.after(endZoneDummy = Div({ width: 0, height: "2em" })); dragDiv.hideEnum(); } dragDiv.css({ margin: "0" }).offsetSave(); dragDiv.css({ transform: "" }); dummy.replaceWith(dragDiv); if (isList) { endZoneDummy.css({ transition: "350ms", height: 0 }); } dragDiv.offsetAnimate(350); dragDiv.lastInsertIndex = -1; if (isList) { return setTimeout(function(){ return endZoneDummy.remove(); }, 400); } }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToStart/animateNewOrder/animate.ls (function(){ return function(slide, dragDiv, filteredDragElements){ var i$, len$, element, ref$, results$ = []; for (i$ = 0, len$ = filteredDragElements.length; i$ < len$; ++i$) { element = filteredDragElements[i$]; if (element !== dragDiv && ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets")) { element.showEnum(); } results$.push(element.offsetAnimate(350)); } return results$; }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToStart/calcFilteredDragElements/calc.ls (function(){ return function(slide, dragDiv){ return _.filter(slide.endZone.find(".dragOrderElement"), function(element){ return element !== dragDiv; }); }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToStart/saveOffsets/save.ls (function(){ return function(filteredDragElements){ var i$, len$, element, results$ = []; for (i$ = 0, len$ = filteredDragElements.length; i$ < len$; ++i$) { element = filteredDragElements[i$]; results$.push(element.offsetSave()); } return results$; }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToZone/animate.ls (function(){ return function(slide, dragDiv){ var animateChildren, index, i$, len$, c; animateChildren = slide.endZone.find(".dragOrderElement"); index = dragDiv.index; if (!in$(dragDiv, animateChildren)) { animateChildren.push(dragDiv); } inc("prepareAnimation/prepare")(slide, animateChildren, dragDiv); inc("appendDivToZone/append")(slide, dragDiv); for (i$ = 0, len$ = animateChildren.length; i$ < len$; ++i$) { c = animateChildren[i$]; inc("animateDiv/animate")(slide, dragDiv, c); } if (slide.endZone.find(".dragOrderElement").length > 0) { slide.endZone.hideLabel(); } return setTimeout(function(){ return dragDiv.css({ zIndex: 2 }); }, 350); }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToZone/animateDiv/animate.ls (function(){ return function(slide, dragDiv, c){ var index, ref$; index = dragDiv.index; if (c === dragDiv && !body.findFirst(".dragOrderDummy_" + index)) { inc("setDragElementMargin/set")(slide, dragDiv); inc("insertDummyToStart/insert")(dragDiv, index); } if ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets") { c.showEnum(); } return c.offsetAnimate(350); }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToZone/animateDiv/insertDummyToStart/insert.ls (function(){ return function(dragDiv, index){ var savedOffset; if (!body.findFirst(".dragOrderDummy_" + index)) { savedOffset = dragDiv.dummySize; return dragDiv.element.append(Div().addClass("dragOrderDummy_" + index).css({ width: (savedOffset.width - 2) + "px", height: (savedOffset.height - 2) + "px" })); } }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToZone/animateDiv/setDragElementMargin/calcMargin/calc.ls (function(){ return function(slide){ var ref$; if ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets") { return "0.2em 0"; } else { return "0.2em"; } }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToZone/animateDiv/setDragElementMargin/set.ls (function(){ return function(slide, dragDiv){ var margin, maxHeight; margin = inc("calcMargin/calc")(slide); maxHeight = dragDiv.dummySize.height; return dragDiv.css({ maxHeight: maxHeight + "px", margin: margin }); }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToZone/appendDivToZone/append.ls (function(){ return function(slide, dragDiv){ var children, insertElement; children = _.filter(slide.endZone.find(".dragOrderElement,.dummyStart"), function(c){ return c !== dragDiv; }); insertElement = children[dragDiv.lastInsertIndex]; insertElement == null && (insertElement = children[children.length - 1]); return insertElement.after(dragDiv); }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/_animate/animateToZone/prepareAnimation/prepare.ls (function(){ return function(slide, animateChildren, dragDiv){ var i$, len$, c, results$ = []; if (slide.listMode === "flow") { dragDiv.css({ margin: "0.2em" }); } if (!body.findFirst(".dragOrderDummy_" + dragDiv.index)) { dragDiv.css({ maxHeight: 0 }); } for (i$ = 0, len$ = animateChildren.length; i$ < len$; ++i$) { c = animateChildren[i$]; c.offsetSave(); results$.push(c.css({ transform: "" })); } return results$; }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/enableDragElements/enable.ls (function(){ return function(slide, dragDiv){ setTimeout(function(){ return slide.dragElementsActive--; }, 250); return setTimeout(function(){ return dragDiv.isAnimating = false; }, 500); }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/on.ls (function(){ return function(slide, dragDiv, page){ return function(onEnd){ if (slide.startZone.offset().top < slide.endZone.offset().bottom && slide.listMode === "flow") { page.scrollElementIntoView(slide.endZone); } if (new Date() - slide.dragStartTime < 200) { inc("tap/tap")(slide, dragDiv, onEnd); setTimeout(function(){ return page.scrollElementIntoView(dragDiv, { padding: 100, duration: 250 }); }, 250); } else { inc("_animate/animate")(slide, dragDiv, onEnd); } dragDiv.isAnimating = true; inc("../_hideInsertPoint/hide")(slide, dragDiv); return inc("enableDragElements/enable")(slide, dragDiv); }; }; })(); trainers/dragOrder/elements/element/enableDrag/onEnd/tap/tap.ls (function(){ return function(slide, dragDiv, onEnd){ dragDiv.currentZone = dragDiv.currentZone === 1 ? 0 : 1; return inc("../_animate/animate")(slide, dragDiv, onEnd); }; })(); trainers/dragOrder/elements/element/enableDrag/onMove/detectZoneCollision/detect.ls (function(){ return function(dragDiv, slide){ if (slide.calcCollision(dragDiv, slide.startZone)) { return 1; } if (slide.calcCollision(dragDiv, slide.endZone)) { return 0; } return 1; }; })(); trainers/dragOrder/elements/element/enableDrag/onMove/on.ls (function(){ return function(slide, dragDiv, page){ return function(o){ dragDiv.currentZone = inc("detectZoneCollision/detect")(dragDiv, slide); if (dragDiv.currentZone === 0) { inc("setInsertPoint/set")(slide, dragDiv); } else { inc("../_hideInsertPoint/hide")(slide, dragDiv); } dragDiv.lastZone = dragDiv.currentZone; if (page.pageScrollWrapper.scrollContainerDiv.css("overflowY") !== "hidden") { return inc("scroll/scroll")(slide, o, dragDiv); } }; }; })(); trainers/dragOrder/elements/element/enableDrag/onMove/scroll/scroll.ls (function(){ return function(slide, o, dragDiv){ var page, psw, y, scroll; page = slide.levelPlayer.page; psw = page.pageScrollWrapper; if (!slide.pageBottom) { slide.pageTop = page.top.height(); slide.pageBottom = window.innerHeight - page.bottom.height(); } slide.maxScrollTop = psw.scrollHeight - psw.clientHeight - 31; y = o.clientPosition.y; scroll = function(){ if (dragDiv.isAnimating) { return; } if (dragDiv.scrollDirection === "up" && psw.scrollTop > 0) { psw.scrollTop -= 2; if (dragDiv.parent() === slide.endZone) { o.updateTranslation({ y: -2, x: 0 }); } } else if (dragDiv.scrollDirection === "down") { if (psw.scrollTop >= slide.maxScrollTop || dragDiv.isAnimating === 0) { dragDiv.scrollDirection = null; return; } psw.scrollTop += 2; if (dragDiv.parent() === slide.endZone) { o.updateTranslation({ y: +2, x: 0 }); } } return setTimeout(scroll, 50); }; if (slide.pageBottom - 75 < y && y < slide.pageBottom) { dragDiv.scrollDirection = "down"; return scroll(); } else if (y < slide.pageTop + 50) { dragDiv.scrollDirection = "up"; return scroll(); } else { return dragDiv.scrollDirection = null; } }; })(); trainers/dragOrder/elements/element/enableDrag/onMove/setInsertPoint/calcInsertPoint/calc.ls (function(){ return function(slide, children, dragDiv){ var ref$; if ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets") { return inc("list/calc")(slide, children, dragDiv); } else { return inc("flow/calc")(slide, children, dragDiv); } }; })(); trainers/dragOrder/elements/element/enableDrag/onMove/setInsertPoint/calcInsertPoint/flow/calc.ls (function(){ return function(slide, children, dragDiv){ var minDist, minIndex, minCX, minCursorX, divOffset, i$, len$, i, c, cX, cY, dist; if (!_.some(children, function(c){ return slide.calcCollision(dragDiv, c); })) { return children.length - 1; } minDist = null; minIndex = null; minCX = -1; minCursorX = -1; divOffset = dragDiv.offset(); for (i$ = 0, len$ = children.length; i$ < len$; ++i$) { i = i$; c = children[i$]; cX = c.offset().left + c.width() / 2; cY = c.offset().top + c.height() / 2; dist = Math.sqrt(Math.pow(cX - divOffset.left, 2) + Math.pow(cY - divOffset.top, 2)); if (minDist == null || dist < minDist) { minDist = dist; minIndex = i; minCX = c.offset().left + c.width() / 2; minCursorX = divOffset.left + divOffset.width / 2; } } if (minCursorX < minCX) { minIndex--; } if (minIndex < 0) { minIndex = 0; } return minIndex; }; })(); trainers/dragOrder/elements/element/enableDrag/onMove/setInsertPoint/calcInsertPoint/list/calc.ls (function(){ return function(slide, children, dragDiv){ var divOffset, childrenOffsets, minIndex; divOffset = dragDiv.offset(); childrenOffsets = _.map(children, function(child){ return child.offset(); }); minIndex = _.findLastIndex(childrenOffsets, function(childOffset){ return childOffset.top + childOffset.height / 2 < divOffset.top + divOffset.height / 2; }); if (minIndex === -1) { minIndex = 0; } return minIndex; }; })(); trainers/dragOrder/elements/element/enableDrag/onMove/setInsertPoint/set.ls (function(){ return function(slide, dragDiv){ var lastInsertIndex, lastZone, currentZone, childrenAll, children, currentInsertIndex, ref$, insertElement, i$, len$, c; lastInsertIndex = dragDiv.lastInsertIndex; lastZone = dragDiv.lastZone; currentZone = dragDiv.currentZone; childrenAll = slide.endZone.find(".dragOrderElement,.dummyStart"); children = _.filter(childrenAll, function(c){ return c !== dragDiv; }); currentInsertIndex = inc("calcInsertPoint/calc")(slide, children, dragDiv); if (currentInsertIndex !== lastInsertIndex || currentZone !== lastZone) { if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } } if (currentInsertIndex !== lastInsertIndex || currentZone !== lastZone || ((ref$ = slide.listMode) === "bullets" || ref$ === "numbers")) { insertElement = children[currentInsertIndex]; for (i$ = 0, len$ = children.length; i$ < len$; ++i$) { c = children[i$]; if (c !== insertElement) { c.arrow.hide(); } else { if (currentInsertIndex === 0 && ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets")) { if (children.length === 1) { c.arrow.setWidth(0); } else { c.arrow.setWidth(childrenAll[1].box.width()); } } c.arrow.show(); } } } return dragDiv.lastInsertIndex = currentInsertIndex; }; })(); trainers/dragOrder/elements/element/enableDrag/onStart/on.ls (function(){ return function(slide, dragDiv){ return function(o){ var i$, ref$, len$, el; slide.dragElementsActive++; for (i$ = 0, len$ = (ref$ = slide.endZone.find(".dragOrderElement")).length; i$ < len$; ++i$) { el = ref$[i$]; el.setColor(Color.grey[250]); } dragDiv.currentZone = dragDiv.parent() === slide.endZone ? 0 : 1; if (dragDiv.currentZone === 0 && ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets")) { dragDiv.hideEnum(); } return slide.dragStartTime = new Date(); }; }; })(); trainers/dragOrder/elements/elements.ls (function(){ return function(slide){ var elements, res$, i$, ref$, len$, i, el; res$ = []; for (i$ = 0, len$ = (ref$ = slide.atom.elements).length; i$ < len$; ++i$) { i = i$; el = ref$[i$]; res$.push(inc("element/element")(slide, el, i)); } elements = res$; for (i$ = 0, len$ = (ref$ = _.shuffleWithSeed(elements)).length; i$ < len$; ++i$) { el = ref$[i$]; slide.startZone.prepend(el); } return elements; }; })(); trainers/dragOrder/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide, solutions; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; solutions = slide.atom.solutions || slide.atom.orders; slide.solutions = _.isArray(solutions[0]) ? solutions : [solutions]; slide.dragSolutions = inc("calcDragSolutions/calc")(slide); slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; results$.push(slide); } return results$; }()); }; })(); trainers/dragOrder/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/dragOrder/init.ls (function(){ return function(slide){ var ref$; slide.listMode = slide.getParam("listMode"); if ((ref$ = slide.listMode) !== "flow" && ref$ !== "bullets" && ref$ !== "numbers") { debug("you must define a listMode (flow, numbers or bullets) to use this trainer"); slide.listMode = "flow"; } if (slide.getParam("firstLetterBig") && slide.listMode !== "flow") { debug("firstLetterBig only works with listMode: \"flow\""); return; } if (_.ensureArray(slide.atom.elements).length === 1) { debug("please have a minimum of two elements"); } slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.image = inc("image/image")(slide); slide.textA = inc("textA/text")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.zones = inc("zones/zones")(slide); slide.debugSolutionDiv = inc("debugSolutionDiv/div")(slide); slide.buttonsDiv = inc("buttonsDiv/div")(slide); slide.elements = inc("elements/elements")(slide); slide.validate = inc("validate/validate")(slide); slide.solve = inc("solve/solve")(slide); slide.calcCollision = inc("calcCollision/calc")(); return slide.capitalizeFirstLetter = inc("capitalizeFirstLetter/capitalize")(slide); }; })(); trainers/dragOrder/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/dragOrder/lsg/lsg.ls (function(){ return function(slide){ var lsg, div; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); if (!div) { return; } div.appendTo(slide.div); return div; }; })(); trainers/dragOrder/solve/applyMargin/apply.ls (function(){ return function(slide, el){ var margin; margin = inc("calcMargin/calc")(slide); if (el.currentZone === -1) { return el.css({ margin: margin }); } }; })(); trainers/dragOrder/solve/applyMargin/calcMargin/calc.ls (function(){ return function(slide){ var ref$; if ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets") { return "0.2em 0"; } else { return "0.2em"; } }; })(); trainers/dragOrder/solve/calcSolutionElements/calc.ls (function(){ return function(slide, elements){ var closestOrderIndex, order, foundElements, i$, len$, i, n, t, el; elements = slide.endZone.findAll(".dragOrderElement").concat(slide.startZone.findAll(".dragOrderElement")); closestOrderIndex = Math.max(inc("../findClosestOrder/find")(slide), 0); order = slide.solutions[closestOrderIndex]; foundElements = []; for (i$ = 0, len$ = order.length; i$ < len$; ++i$) { i = i$; n = order[i$]; t = slide.atom.elements[n]; el = inc("findMatchingElement/find")(t, elements, foundElements); foundElements.push(el); } return foundElements; }; })(); trainers/dragOrder/solve/calcSolutionElements/findMatchingElement/find.ls (function(){ return function(text, elements, foundElements){ var endElement; endElement = _.find(elements, function(el){ return el.value === text && !in$(el, foundElements); }); return endElement; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/dragOrder/solve/findClosestOrder/calcOverlap/calc.ls (function(){ return function(arr1, arr2){ var i$, to$, i; for (i$ = 0, to$ = arr1.length; i$ < to$; ++i$) { i = i$; if (arr1[i] !== arr2[i]) { break; } } return i; }; })(); trainers/dragOrder/solve/findClosestOrder/find.ls (function(){ return function(slide){ var elements, res$, i$, ref$, len$, el, maxI, maxN, i, o, overlap; res$ = []; for (i$ = 0, len$ = (ref$ = slide.endZone.findAll(".dragOrderElement")).length; i$ < len$; ++i$) { el = ref$[i$]; res$.push(el.value); } elements = res$; maxI = -1; maxN = 0; for (i$ = 0, len$ = (ref$ = slide.dragSolutions).length; i$ < len$; ++i$) { i = i$; o = ref$[i$]; overlap = inc("calcOverlap/calc")(o, elements); if (overlap > maxN) { maxN = overlap; maxI = i; } } return maxI; }; })(); trainers/dragOrder/solve/removeObsoleteElements/remove.ls (function(){ return function(slide, solutionElements){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = slide.endZone.findAll(".dragOrderElement")).length; i$ < len$; ++i$) { el = ref$[i$]; if (!_.includes(solutionElements, el)) { results$.push(el.remove()); } } return results$; }; })(); trainers/dragOrder/solve/reorderElements/reorder.ls (function(){ return function(slide, animateElements, i){ var el, prevEl; el = animateElements[i]; prevEl = animateElements[i - 1]; if (i === 0) { return slide.endZone.findFirst(".dummyStart").after(el); } else { return prevEl.after(el); } }; })(); trainers/dragOrder/solve/solve.ls (function(){ return function(slide){ return function(){ var solutionElements, i$, len$, el, i, ref$; solutionElements = inc("calcSolutionElements/calc")(slide); for (i$ = 0, len$ = solutionElements.length; i$ < len$; ++i$) { el = solutionElements[i$]; inc("applyMargin/apply")(slide, el); el.offsetSave(); } inc("removeObsoleteElements/remove")(slide, solutionElements); for (i$ = 0, len$ = solutionElements.length; i$ < len$; ++i$) { i = i$; el = solutionElements[i$]; inc("reorderElements/reorder")(slide, solutionElements, i); el.offsetAnimate(350); } if ((ref$ = slide.listMode) === "bullets" || ref$ === "numbers") { for (i$ = 0, len$ = (ref$ = slide.endZone.findAll(".dragOrderElement")).length; i$ < len$; ++i$) { el = ref$[i$]; el.showEnum(); } } if (slide.getParam("firstLetterBig") && slide.listMode === "flow") { return slide.capitalizeFirstLetter(); } }; }; })(); trainers/dragOrder/textA/text.ls (function(){ return function(slide){ var p, click, image, lsg; p = slide.getParam; if (p("soundMode", slide.atom) === "askSound") { return; } if (!slide.atom.a) { return; } click = function(){ var text, voice; if (p("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = p("voice", slide.atom); return slide.sounds[text + voice].play(); } }; image = p("image", slide.atom); lsg = p("lsg", slide.atom); return Div({ margin: "0 auto", width: "30em", maxWidth: "90%", textAlign: p("textAlign", slide.atom) || "center" }).html(Div(image || lsg ? { padding: "0.5em" } : { padding: "0 0.5em" }).css({ display: "inline-block" }).html(slide.atom.a).tap(click)).appendTo(slide.div); }; })(); trainers/dragOrder/validate/ordered/validate.ls (function(){ return function(slide){ return function(){ var elements, dragOrder, res$, i$, len$, el, correct; elements = slide.endZone.findAll(".dragOrderElement"); res$ = []; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { el = elements[i$]; res$.push(el.value); } dragOrder = res$; if (_.some(slide.solutions, function(o){ return _.uniq(o).length !== o.length; })) { debug("warning, a correct order contains duplicate entries"); } correct = _.some(slide.dragSolutions, function(o){ return _.isEqual(o, dragOrder); }); return correct; }; }; })(); trainers/dragOrder/validate/unordered/validate.ls (function(){ return function(slide){ return function(){ var elements, dragOrder, res$, i$, len$, el, correct; elements = slide.endZone.findAll(".dragOrderElement"); res$ = []; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { el = elements[i$]; res$.push(el.value); } dragOrder = res$; if (_.some(slide.solutions, function(o){ return _.uniq(o).length !== o.length; })) { debug("warning, a correct order contains duplicate entries"); } correct = _.some(slide.dragSolutions, function(solution){ return solution.length === dragOrder.length && _.every(dragOrder, function(el){ return in$(el, solution); }); }); return correct; }; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/dragOrder/validate/validate.ls (function(){ return function(slide){ if (slide.listMode === "bullets") { return inc("unordered/validate")(slide); } else { return inc("ordered/validate")(slide); } }; })(); trainers/dragOrder/zones/endZone/adjustHeight/adjust.ls (function(){ return function(slide){ return slide.endZone.css({ minHeight: slide.startZone.height() + "px" }); }; })(); trainers/dragOrder/zones/endZone/flow/zone.ls (function(){ return function(slide){ var div, label; div = Div({ textAlign: "left", margin: "0.8em auto 0", width: "30em", maxWidth: "90%", border: "1px dashed " + Color.grey[300], borderRadius: "10px" }).append(label = inc("../label/label")()); div.hideLabel = function(){ return label.fadeOut(200); }; div.showLabel = function(){ return label.fadeIn(200); }; return div; }; })(); trainers/dragOrder/zones/endZone/label/label.ls (function(){ return function(){ return Div({ display: "flex", position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }).append(Div({ flex: "0 0 auto", color: Color.grey[350] }).html(T("dragBlocksHere"))); }; })(); trainers/dragOrder/zones/endZone/list/calcPaddingLeft/calc.ls (function(){ return function(slide){ var listMode; listMode = slide.listMode; if (listMode === "bullets") { return "1.75em"; } else if (listMode === "numbers") { if (slide.atom.elements.length > 9) { return "2.25em"; } else { return "2em"; } } }; })(); trainers/dragOrder/zones/endZone/list/zone.ls (function(){ return function(slide){ var paddingLeft, div, label; paddingLeft = inc("calcPaddingLeft/calc")(slide); div = Div({ display: "flex", flexDirection: "column", alignItems: "flex-start", textAlign: "left", margin: "0.8em auto 0", paddingLeft: paddingLeft, width: "30em", maxWidth: "90%", border: "1px dashed " + Color.grey[300], borderRadius: "10px" }).append(label = inc("../label/label")()); div.hideLabel = function(){ return label.fadeOut(500); }; div.showLabel = function(){ return label.fadeIn(500); }; return div; }; })(); trainers/dragOrder/zones/endZone/zone.ls (function(){ return function(slide){ var ref$; if ((ref$ = slide.listMode) === "numbers" || ref$ === "bullets") { return inc("list/zone")(slide); } else { return inc("flow/zone")(slide); } }; })(); trainers/dragOrder/zones/startZone/zone.ls (function(){ return function(){ return Div({ width: "50em", maxWidth: "90%", margin: "0 auto", padding: "0.5em 0.2em" }).addClass("startZone"); }; })(); trainers/dragOrder/zones/zones.ls (function(){ return function(slide){ var zones; zones = []; zones.push(slide.endZone = inc("endZone/zone")(slide), slide.startZone = inc("startZone/zone")()); slide.endZone.append(inc("../elements/dummyElement/dummyElement")(slide).addClass("dummyStart").css({ marginBottom: "0.2em" }), inc("../elements/dummyElement/dummyElement")(slide).addClass("dummyEnd")).appendTo(slide.div); return zones; }; })(); trainers/dragPunc/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/dragPunc/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/dragPunc/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, voiceLang, voice, texts, that, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); texts = (that = slide.atom.sound) ? [that] : soundMode === "a" || soundMode === "askSound" ? [slide.atom.a] : soundMode === "b" ? inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: slide.atom.b }) : []; for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/dragPunc/_preview/preview.ls (function(){ return function(slide){ return slide.div.append(slide.buttonsDiv.css({ marginTop: "1em" })); }; })(); trainers/dragPunc/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, lresult$, textB, gaps, j$, ref1$, len1$, sol, solVal, v, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.textB.remove(); slide.buttonsDiv.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; lresult$ = []; slide.div.append(Div({ textAlign: "left" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))); textB = slide.textB.clone().css({ marginBottom: "1em", border: !a.correct && !a.resolved ? "2px solid " + Color.red[500] : void 8 }).appendTo(slide.div); gaps = textB.findAll(".gap"); if (a.resolved) { for (j$ = 0, len1$ = (ref1$ = slide.solutions).length; j$ < len1$; ++j$) { i = j$; sol = ref1$[j$]; solVal = _.map(sol, fn$).join(""); if (sol.length > 0) { lresult$.push(gaps[i].css({ border: "1px solid " + Color.grey[250] }).html(solVal)); } } } else { for (i in ref1$ = a.values) { v = ref1$[i]; lresult$.push(gaps[i].html(v.value.join("")).css({ backgroundColor: _.every(v.correct, fn1$) ? Color.green[500] : Color.red[500] })); } } results$.push(lresult$); } return results$; } function fn$(s){ return s[0].value; } function fn1$(c){ return c; } }; })(); trainers/dragPunc/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, el, results$ = []; slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); slide.levelPlayer.page.bottom.empty().append(slide.footer = Div().append(slide.buttonsDiv, slide.checkAndSolveButtonsDiv).bind("touchstart touchmove touchend", function(e){ return e.preventDefault(); })).show(); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.textB, { padding: 50 }); } }); for (i$ = 0, len$ = (ref$ = slide.dragElements).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(el.enable()); } return results$; }; })(); trainers/dragPunc/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/dragPunc/buttonsDiv/div.ls (function(){ return function(slide){ var choices, shuffleButtons, ref$, c; choices = _.filter(slide.parts, function(p){ return p.gap && !p.solved && p.choices[0].text !== ""; }); choices = _.flatMap(choices, "choices"); choices = _.sortBy(choices); if (slide.mergeButtons) { choices = _.uniqBy(choices, "text"); } shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; if (shuffleButtons) { choices = _.shuffleWithSeed(choices); } return Div({ maxWidth: "90%", width: "30em", margin: "0.2em auto", textAlign: "center" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = choices).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(inc("dragWrapper/wrapper")(slide, c)); } return results$; }())); }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/element.ls (function(){ return function(slide, value, wrapper){ var enable, div, label, icon; enable = function(){ return inc("enableDrag/enable")(slide, wrapper, div); }; div = Div().addClass("dragElement").css({ display: "inline-block", zIndex: 2, cursor: "pointer" }).html(label = Div().addClass("label").css({ padding: "0.3em 0.7em", border: "1px solid " + Color.grey[350], boxShadow: "1px 1px 2px " + Color.grey[300], backgroundColor: "white", backgroundClip: "border-box" }).html(value), icon = SvgIcon({ svg: path("/../app01/lib/svg/shape/place.svg"), color: Color.blue[100] }).addClass("icon").css({ position: "absolute", bottom: "-2.5em", left: "-0.4em", width: "2.5em", height: "2.5em", transform: "rotate(180deg)" }).hide()); div.label = label; div.wrapper = wrapper; div.setLayout = inc("setLayout/set")(div); div.enable = enable; div.pos = inc("../../../calcDefaultPosition/calc")(value); div.value = value; return div; }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/animate/animate.ls (function(){ return function(slide, currentGap, div, onEnd){ if ((currentGap != null ? currentGap.gapIndex : void 8) === "home" || currentGap == null) { return inc("animateToHome/animate")(slide, div, onEnd); } else { return inc("animateToElement/animate")(slide, div, onEnd, currentGap); } }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/animate/animateToElement/animate.ls (function(){ return function(slide, div, onEnd, currentGap){ var gap, animateDragElement, animateSpace, resetAndResizeSpace, mergeButtons, appendDragElementToGap; gap = slide.gaps[currentGap.gapIndex]; if (!gap) { return; } animateDragElement = function(){ var dragElementsWidth, dragElementXCorrection, newX, newY; div.setLayout("gap", 100); dragElementsWidth = _.map(gap.findAll(".dragElement"), function(el){ return el.width(); }); dragElementXCorrection = _.sum(dragElementsWidth.slice(0, currentGap.childIndex)); newX = gap.offset().left - div.offset().left + dragElementXCorrection; newY = gap.offset().top - div.offset().top; return div.css({ transform: "translate(" + newX + "px, " + newY + "px)", transition: "200ms" }); }; animateSpace = function(){ return setTimeout(function(){ return gap.space.css({ transition: "100ms", transitionTimingFunction: "linear", width: div.width() + "px" }); }, 100); }; resetAndResizeSpace = function(){ if (gap.pos === "before") { gap.prepend(gap.space); } else if (gap.pos === "after") { gap.append(gap.space); } gap.space.offset(); gap.space.css({ transition: "100ms", width: "0.2em" }); return setTimeout(function(){ gap.space.css({ transition: "" }); return div.css({ pointerEvents: "" }); }, 100); }; mergeButtons = function(){ var div2; div2 = inc("../../../../dragElement/element")(slide, div.text().trim(), div.wrapper); div2.enable(); if (!div.oldParent.hasClass("gap")) { return div.oldParent.empty().append(div2); } }; appendDragElementToGap = function(){ return setTimeout(function(){ slide.checkAndSolveButtonsDiv.css({ pointerEvents: "" }); div.css({ position: "relative", left: "", top: "", transform: "", transition: "", fontSize: "" }); gap.space.css({ width: 0 }).replaceWith(div); resetAndResizeSpace(); if (slide.mergeButtons) { return mergeButtons(); } }, 200); }; slide.checkAndSolveButtonsDiv.css({ pointerEvents: "none" }); onEnd.updateAbsolutePosition(); animateDragElement(); animateSpace(); return appendDragElementToGap(); }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/animate/animateToHome/animate.ls (function(){ return function(slide, div, onEnd){ var wrapper, newX, newY; wrapper = div.wrapper; if (div.oldParent === wrapper) { onEnd.updateAbsolutePosition(); newX = wrapper.offset().left - div.offset().left; newY = wrapper.offset().top - div.offset().top; div.css({ transform: "translate(" + newX + "px, " + newY + "px)", transition: "500ms" }); setTimeout(function(){ wrapper.empty(); return div.appendTo(wrapper); }, 500); } else if (div.oldParent.hasClass("gap")) { onEnd.updateAbsolutePosition(); newX = wrapper.offset().left - div.offset().left; newY = wrapper.offset().top - div.offset().top; div.css({ transform: "translate(" + newX + "px, " + newY + "px)", transition: "500ms" }); setTimeout(function(){ return wrapper.empty().append(div); }, 500); } slide.checkAndSolveButtonsDiv.css({ pointerEvents: "none" }); return setTimeout(function(){ slide.checkAndSolveButtonsDiv.css({ pointerEvents: "" }); return div.css({ position: "relative", left: "", top: "", transition: "", transform: "", fontSize: "", pointerEvents: "" }); }, 500); }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/animateStart/animate.ls (function(){ return function(slide, div, wrapper){ div.oldParent = div.parent(); div.css({ position: "absolute", left: div.offset().left + "px", top: div.offset().top + "px", transform: "translate(0, 0)" }).appendTo(body); if (div.oldParent === wrapper) { inc("../insertDummy/insert")(slide, div, wrapper); } if (div.oldParent.pos === "middle") { return div.oldParent.append(div.oldParent.space); } }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/detectCollision/calcNearestChild/calc.ls (function(){ return function(slide, div, divOffset, pos, gapIndex){ var gap, children, childrenPosX, divPosX, index, i$, len$, i, childPosX; gap = slide.gaps[gapIndex]; children = _.without(gap.childrenAll(), gap.space); childrenPosX = _.map(children, function(child){ var cO; cO = child.offset(); return cO.left + cO.width / 2; }); divPosX = divOffset.left + divOffset.width / 2; index = 0; for (i$ = 0, len$ = childrenPosX.length; i$ < len$; ++i$) { i = i$; childPosX = childrenPosX[i$]; if (divPosX > childPosX) { index = i + 1; } else { break; } } return index; }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/detectCollision/calcNearestElement/calc.ls (function(){ return function(slide, div, pos){ var divX, divY, minDist, minIndex, i$, ref$, len$, i, gap, gapX, gapY, dist; divX = div.offset().left + div.width() / 2; divY = div.offset().top + div.height() / 2; minDist = null; minIndex = -1; for (i$ = 0, len$ = (ref$ = slide.gaps).length; i$ < len$; ++i$) { i = i$; gap = ref$[i$]; if (!gap.isEnabled()) { continue; } if (pos !== gap.pos) { continue; } if (gap.pos === "middle" && !gap.contains(gap.space)) { continue; } gapX = gap.offset().left + gap.width() / 2; gapY = gap.offset().top + gap.height() / 2; dist = Math.sqrt(Math.pow(gapX - divX, 2) + Math.pow(gapY - divY, 2)); if (minDist != null) { if (dist < minDist) { minDist = dist; minIndex = i; } } else { minDist = dist; minIndex = i; } } return minIndex; }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/detectCollision/detect.ls (function(){ return function(slide, div, wrapper){ var pos, wrapperOffset, divOffset, textBOffset, bottomBarOffset, collision, i; pos = div.pos; div = div.findFirst(".label"); wrapperOffset = wrapper.offset(); divOffset = div.offset(); textBOffset = slide.textB.offset(); bottomBarOffset = slide.levelPlayer.page.bottom.offset(); collision = function(pos1, pos2){ if (pos1.right < pos2.left) { return false; } else if (pos1.left > pos2.right) { return false; } else if (pos1.top > pos2.bottom) { return false; } else if (pos1.bottom < pos2.top) { return false; } else { return true; } }; if (collision(divOffset, bottomBarOffset)) { return { gapIndex: "home" }; } else if (collision(divOffset, textBOffset)) { i = inc("calcNearestElement/calc")(slide, div, pos); return { gapIndex: i, childIndex: inc("calcNearestChild/calc")(slide, div, divOffset, pos, i) }; } else {} }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/enable.ls (function(){ return function(slide, wrapper, div){ var currentGap, lastGap, startGap, lastOnEnd, dragStartTime, dragLayout, dragActive, dragStart, dragMove, dragEnd, tap, abort; dragLayout = false; dragActive = false; dragStart = function(o){ dragActive = true; dragStartTime = new Date(); slide.textB.setFeedback(null); inc("animateStart/animate")(slide, div, wrapper); currentGap = inc("detectCollision/detect")(slide, div, wrapper); startGap = currentGap; return inc("setGapHighlight/set")(slide, currentGap, lastGap, dragActive); }; dragMove = function(o){ if (!dragActive) { return; } if (!dragLayout && (Math.abs(o.translation.x) > 10 || Math.abs(o.translation.y) > 10)) { div.setLayout("drag", 200); dragLayout = true; if (!inc("/../app01/lib/util/isDesktop/isDesktop")()) { inc("updateTranslation/update")(o, div); } } currentGap = inc("detectCollision/detect")(slide, div, wrapper); inc("setGapHighlight/set")(slide, currentGap, lastGap, dragActive); lastGap = currentGap; if (slide.pageIsScrollable) { return inc("scroll/scroll")(slide, o, div); } }; dragEnd = function(onEnd){ var diff; if (!dragActive) { return; } dragActive = false; dragLayout = false; div.css({ pointerEvents: "none" }); div.scrollDirection = null; div.findFirst(".icon").hide(); lastOnEnd = onEnd; inc("setGapHighlight/set")(slide, null, lastGap, dragActive); diff = new Date() - dragStartTime; if (diff < 200 && div.oldParent.hasClass("gap") && _.isEqual(startGap, currentGap)) { return tap(); } else { inc("animate/animate")(slide, currentGap, div, onEnd); return lastGap = null; } }; tap = function(){ inc("setGapHighlight/set")(slide, null, currentGap, dragActive, true); currentGap.gapIndex = "home"; div.setLayout("home"); return inc("animate/animate")(slide, currentGap, div, lastOnEnd); }; abort = function(){ var div2; if (!dragActive) { return; } dragActive = false; inc("setGapHighlight/set")(slide, null, lastGap, dragActive); div2 = inc("../element")(slide, div.text().trim(), wrapper); if (!div.oldParent.hasClass("gap")) { div.oldParent.empty().append(div2); } div2.enable(); return div.remove(); }; inc("/../app01/lib/util/waitFrames/wait")(4, function(){ var params; params = { onStart: dragStart, onMove: dragMove, onEnd: dragEnd, preventDefault: true, tapZone: "0.3em" }; if (slide.levelPlayer.page.pageScrollWrapper.scrollContainerDiv.css("overflowY") !== "hidden") { slide.pageIsScrollable = true; if (!inc("/../app01/lib/util/isDesktop/isDesktop")()) { params.cancelStartOnScroll = 100; } } return div.drag(params).bind("touchstart mousedown", function(e){ return e.preventDefault(); }); }); return div.addClass("keyManager-esc").bind("keyManager", abort); }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/insertDummy/insert.ls (function(){ return function(slide, div, wrapper){ var dummy; return wrapper.append(dummy = Div().addClass("dummyElement").css({ height: div.height() + "px", padding: "0.3em 0.7em", backgroundClip: "border-box", border: slide.mergeButtons ? "1px solid " + Color.grey[350] : "1px solid transparent", backgroundColor: slide.mergeButtons ? "white" : Color.grey[250], boxShadow: slide.mergeButtons ? "1px 1px 2px " + Color.grey[300] : void 8 }).html(slide.mergeButtons ? div.text() : " ")); }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/scroll/scroll.ls (function(){ var maxScrollTop, pageTop, pageBottom, page, psw; return function(slide, o, div){ var y, scroll, dragAreaTop; if (!psw) { page = slide.levelPlayer.page; psw = page.pageScrollWrapper; pageTop = page.top.height(); pageBottom = window.innerHeight - page.bottom.height(); maxScrollTop = psw.scrollHeight - psw.height(); } y = o.clientPosition.y; scroll = function(){ if (div.scrollDirection === "up" && psw.scrollTop > 0) { psw.scrollTop -= 5; if (div.parent().hasClass("gap")) { o.updateTranslation({ y: -5, x: 0 }); } return setTimeout(scroll, 50); } else if (div.scrollDirection === "down") { if (psw.scrollTop > maxScrollTop) { div.scrollDirection = null; return; } psw.scrollTop += 5; if (div.parent().hasClass("gap")) { o.updateTranslation({ y: 5, x: 0 }); } return setTimeout(scroll, 50); } }; dragAreaTop = inc("/../app01/lib/util/isTouchDevice/isTouchDevice")() ? 75 : 50; if (pageBottom - dragAreaTop < y && y < pageBottom) { div.scrollDirection = "down"; return scroll(); } else if (y < pageTop + 50) { div.scrollDirection = "up"; return scroll(); } else { return div.scrollDirection = null; } }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/setGapHighlight/set.ls (function(){ return function(slide, currentGap, lastGap, dragActive, isTap){ var gapElementLast, gapElementCurrent, children, currentChild; gapElementLast = slide.gaps[lastGap != null ? lastGap.gapIndex : void 8]; gapElementCurrent = slide.gaps[currentGap != null ? currentGap.gapIndex : void 8]; if (gapElementCurrent) { children = _.without(gapElementCurrent.childrenAll(), gapElementCurrent.space); currentChild = children[currentGap != null ? currentGap.childIndex : void 8]; if (currentChild) { gapElementCurrent.insertBefore(gapElementCurrent.space, currentChild); } else { gapElementCurrent.append(gapElementCurrent.space); } } if (gapElementLast && gapElementLast !== gapElementCurrent) { gapElementLast.setHighlight(false); if (dragActive) { if (gapElementLast.pos === "before") { gapElementLast.prepend(gapElementLast.space); } else { gapElementLast.append(gapElementLast.space); } } } if (currentGap && !_.isEqual(currentGap, lastGap) && currentGap.gapIndex !== "home") { gapElementCurrent.setHighlight(true); return typeof vibrate == 'function' ? vibrate(VIBRATION_TYPES.selection) : void 8; } }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/enableDrag/updateTranslation/update.ls (function(){ return function(o, div){ div.css({ transition: "transform 100ms" }); o.updateTranslation({ x: 5, y: -60 }); return setTimeout(function(){ return div.css({ transition: "" }); }, 100); }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/dragElement/setLayout/set.ls (function(){ return function(div){ return function(layout, transitionDuration){ var label, icon, value; label = div.findFirst(".label"); icon = div.findFirst(".icon"); if (transitionDuration) { label.css({ transition: transitionDuration + "ms" }); setTimeout(function(){ return label.css({ transition: "" }); }, transitionDuration); } if (layout === "gap" || layout === "solved") { value = label.text(); label.css({ padding: 0, textAlign: "center", border: "1px solid " + Color.white, backgroundColor: "rgb(200, 230, 252)", boxShadow: "" }); if (layout === "solved") { return label.css({ border: "1px solid " + Color.grey[300], backgroundColor: Color.white }); } } else if (layout === "drag" || layout === "home") { label.css({ padding: "0.3em 0.7em", border: "1px solid " + Color.grey[350], boxShadow: "1px 1px 2px " + Color.grey[300], backgroundColor: "white" }); if (layout === "drag" && inc("/../app01/lib/util/isTouchDevice/isTouchDevice")()) { return icon.show(); } } }; }; })(); trainers/dragPunc/buttonsDiv/dragWrapper/wrapper.ls (function(){ return function(slide, choice){ var value, wrapper, el; value = choice.text; wrapper = Div().addClass("dragWrapper").css({ display: "inline-block", verticalAlign: "top", margin: "0.4em 0.6em" }); wrapper.append(el = inc("dragElement/element")(slide, value, wrapper), slide.dragElements.push(el), el); return wrapper; }; })(); trainers/dragPunc/calcDefaultPosition/calc.ls (function(){ return function(value){ if (value === "(" || value === "[" || value === "„" || value === "“" || value === "‚" || value === "‘") { return "before"; } else if (value === "“" || value === "”" || value === "'" || value === "’" || value === ")" || value === "]" || value === "," || value === ";" || value === "." || value === "!" || value === "?" || value === ":" || value === "…") { return "after"; } else if (value === "–" || value === "«" || value === "»" || value === "—") { return "middle"; } }; })(); trainers/dragPunc/calcParts/calc.ls (function(){ return function(atom){ var value, parts, i$, ref$, len$, p, choices, i, ref1$; value = _.replaceAll(atom.b, ")))", "⟫))"); value = _.replaceAll(value, "(((", "((⟪"); parts = inc("/shared/convertGapString/convert")(value); for (i$ = 0, len$ = (ref$ = _.filter(parts, "gap")).length; i$ < len$; ++i$) { p = ref$[i$]; p.gap = _.replaceAll(p.gap, "⟪", "("); p.gap = _.replaceAll(p.gap, "⟫", ")"); choices = inc("calcChoices/calc")(p); if (choices[0].solved) { p.solved = true; } p.choices = choices; } if (_.first(parts).word != null) { parts.unshift({ space: true }); } if (_.last(parts).word != null) { parts.push({ space: true }); } for (i$ = 0, len$ = parts.length; i$ < len$; ++i$) { i = i$; p = parts[i$]; if (p.space && ((ref$ = parts[i + 1]) != null && ref$.gap)) { p['delete'] = true; } if (p.space && ((ref1$ = parts[i - 1]) != null && ref1$.gap)) { p['delete'] = true; } } parts = _.filter(parts, function(p){ return !p['delete']; }); return parts; }; })(); trainers/dragPunc/calcParts/calcChoices/calc.ls (function(){ return function(part){ var s, parts, defaultCorrect, choices, p; if (part.space) { return [{ text: "", correct: true }]; } s = part.gap; parts = s.split(" "); defaultCorrect = !_.includes(s, "++"); return choices = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = parts).length; i$ < len$; ++i$) { p = ref$[i$]; p = _.replaceAll(p, " ", " "); 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 if (p.substring(0, 2) === "**") { results$.push({ text: p.substring(2), correct: true, optional: true }); } else { results$.push({ text: p, correct: defaultCorrect }); } } return results$; }()); }; })(); trainers/dragPunc/checkAndSolveButtonsDiv/checkButton/button.ls (function(){ return function(slide){ var finish, onCorrect, onWrong, click, div; finish = function(){ slide.footer.remove(); return slide.finish(); }; onCorrect = function(actionValues){ div.css({ backgroundColor: Color.green[500] }); slide.levelPlayer.progressBar.showGreen(); slide.solveButton.css({ pointerEvents: "none" }); slide.div.css({ pointerEvents: "none" }); slide.footer.css({ pointerEvents: "none" }); return inc("../../playSoundB/play")(slide, function(){ return slide.score.addActionCorrect(slide.atom, { values: actionValues }, function(){ return slide.score.log(slide.atom, finish); }); }); }; onWrong = function(actionValues){ div.css({ backgroundColor: Color.red[500] }); slide.levelPlayer.progressBar.addElement().showRed(); slide.score.addActionMistake(slide.atom, { values: actionValues }); return setTimeout(function(){ div.css({ backgroundColor: Color.grey[250], pointerEvents: "" }); if (!slide.solveButton.isVisible()) { return slide.solveButton.show(); } }, 500); }; click = function(){ var values, result, allCorrect, i$, ref$, len$, i, solGap, j$, len1$, j, g, actionValues, value; values = _.map(slide.gaps, function(gap, i){ return _.map(gap.findAll(".dragElement"), "value"); }); result = []; allCorrect = true; for (i$ = 0, len$ = (ref$ = slide.solutions).length; i$ < len$; ++i$) { i = i$; solGap = ref$[i$]; if (solGap.length === 0 && values[i].length === 0) { result[i] = [true]; continue; } if (solGap.length === 0 && values[i].length > 0) { result[i] = [false]; allCorrect = false; continue; } if (solGap.length > 0 && values[i].length === 0) { if (solGap[0][0].optional) { result[i] = [true]; } else { result[i] = [false]; allCorrect = false; } continue; } result[i] = []; for (j$ = 0, len1$ = solGap.length; j$ < len1$; ++j$) { j = j$; g = solGap[j$]; if (!in$(values[i][j], _.map(g, "value"))) { result[i].push(false); allCorrect = false; } else { result[i].push(true); } } } actionValues = {}; for (i$ = 0, len$ = values.length; i$ < len$; ++i$) { i = i$; value = values[i$]; if (slide.gaps[i].isEnabled() && value.length > 0) { actionValues[i] = { value: value, correct: result[i] }; } } slide.textB.setFeedback(result); div.css({ pointerEvents: "none" }); if (allCorrect) { onCorrect(actionValues); } else { onWrong(actionValues); } slide.result = result; return slide.values = values; }; return div = Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.2em 0.5em", backgroundColor: Color.grey[250] }).tap(click); }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/dragPunc/checkAndSolveButtonsDiv/div.ls (function(){ return function(slide){ return Div({ maxWidth: "90%", width: "30em", textAlign: "center", margin: "0.5em auto" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide)); }; })(); trainers/dragPunc/checkAndSolveButtonsDiv/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ if (div.isVisible()) { return; } return div.fadeIn(); }; click = function(){ slide.levelPlayer.progressBar.showGrey(); slide.div.css({ pointerEvents: "none" }); slide.footer.css({ pointerEvents: "none" }); slide.finishButton = true; inc("solve/solve")(slide, div); return setTimeout(function(){ slide.footer.remove(); return inc("../../playSoundB/play")(slide, function(){ return slide.score.addActionResolved(slide.atom, void 8, function(){ return slide.score.log(slide.atom, slide.finish); }); }); }, 1000); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.2em 0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/dragPunc/checkAndSolveButtonsDiv/solveButton/solve/solve.ls (function(){ return function(slide, button){ var solveGap, i$, ref$, len$, i, r, gap, results$ = []; solveGap = function(i){ var solution, sol, gap, dummyWrapper, dragElement, newX, newY; solution = slide.solutions[i]; if (solution.length === 0) { return; } sol = _.map(solution, function(s){ return s[0].value; }).join(""); gap = slide.gaps[i]; dummyWrapper = slide.buttonsDiv.firstChild; dragElement = inc("../../../buttonsDiv/dragWrapper/dragElement/element")(slide, sol, dummyWrapper).css({ position: "absolute", left: button.offset().left + "px", top: button.offset().top + "px", transform: "translate(0, 0)", pointerEvents: "none" }).appendTo(body); newX = gap.offset().left - dragElement.offset().left; newY = gap.offset().top - dragElement.offset().top; dragElement.css({ transform: "translate(" + newX + "px, " + newY + "px)", transition: "500ms" }); dragElement.setLayout("solved"); return setTimeout(function(){ return gap.css({ padding: 0 }).html(dragElement.css({ position: "relative", left: "", top: "", transform: "", transition: "" })); }, 500); }; slide.textB.setFeedback(null); for (i$ = 0, len$ = (ref$ = slide.result).length; i$ < len$; ++i$) { i = i$; r = ref$[i$]; gap = slide.gaps[i]; gap.reset(); results$.push(solveGap(i)); } return results$; }; })(); trainers/dragPunc/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.parts = inc("calcParts/calc")(atom); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton")) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/dragPunc/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/dragPunc/init.ls (function(){ return function(slide){ var ref$; slide.mergeButtons = (ref$ = slide.getParam("mergeButtons", slide.atom)) != null ? ref$ : false; slide.gaps = []; slide.gapsBefore = []; slide.gapsAfter = []; slide.dragElements = []; slide.elements = []; slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.image = inc("image/image")(slide); slide.textA = inc("textA/text")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textB = inc("textB/text")(slide); slide.buttonsDiv = inc("buttonsDiv/div")(slide); return slide.checkAndSolveButtonsDiv = inc("checkAndSolveButtonsDiv/div")(slide); }; })(); trainers/dragPunc/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/dragPunc/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/dragPunc/playSoundB/play.ls (function(){ return function(slide, onDone){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "b") { slide.solvedStrings = inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: slide.atom.b }); text = slide.atom.sound || slide.textB.calcCorrectValue(); voice = slide.getParam("voice", slide.atom); slide.instruction.stop(); return setTimeout(function(){ var e; try { return slide.sounds[text + voice].play(onDone); } catch (e$) { e = e$; onDone(); throw e; } }, 700); } else { return setTimeout(onDone, 1000); } }; })(); trainers/dragPunc/textA/text.ls (function(){ return function(slide){ var click, div, image, lsg; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } click = function(){ var text, voice; text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); }; div = Div(); image = slide.getParam("image", slide.atom); lsg = slide.getParam("lsg", slide.atom); if (slide.atom.a) { slide.div.append(div.append(Div(image || lsg ? { padding: "0.5em" } : { padding: "0 0.3em" }).css({ maxWidth: "90%", width: "30em", margin: "0 auto", textAlign: slide.getParam("textAlign", slide.atom) || "center" }).html(slide.atom.a).tap(slide.getParam("soundMode", slide.atom) === "a" ? click : void 8))); } return div; }; })(); trainers/dragPunc/textB/calcCorrectValue/calc.ls (function(){ return function(slide, div){ return function(){ var solvedParts, res$, i$, ref$, len$, el, s, solvedPartsCollapsed, i, part, solvedString; res$ = []; for (i$ = 0, len$ = (ref$ = slide.textB.findAll(".gap,.word")).length; i$ < len$; ++i$) { el = ref$[i$]; res$.push(s = el.text().trim()); } solvedParts = res$; solvedPartsCollapsed = []; for (i$ = 0, len$ = solvedParts.length; i$ < len$; ++i$) { i = i$; part = solvedParts[i$]; if (part !== "") { solvedPartsCollapsed.push(part.replace(/[ \n]/g, "")); } if (part === "" && solvedParts[i - 1] !== "") { solvedPartsCollapsed.push(" "); } } solvedString = solvedPartsCollapsed.join("").trim(); return solvedString; }; }; })(); trainers/dragPunc/textB/calcSolutions/calc.ls (function(){ return function(slide){ var solutions, addSolutions, j, i$, ref$, len$, i, el, choices1, choices2, choices3; solutions = []; addSolutions = function(i, choices){ var i$, cs, ss, j$, ref$, len$, c, s, results$ = []; solutions[i] = []; for (i$ in choices) { cs = choices[i$]; ss = []; for (j$ = 0, len$ = (ref$ = _.filter(cs, fn$)).length; j$ < len$; ++j$) { c = ref$[j$]; s = { value: c.value }; if (c.type === "optional") { s.optional = true; } ss.push(s); } if (ss.length > 0) { results$.push(solutions[i].push(ss)); } } return results$; function fn$(c){ var ref$; return (ref$ = c.type) === "correct" || ref$ === "optional" || ref$ === "solved"; } }; j = 0; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { i = i$; el = ref$[i$]; choices1 = el.gapBefore.getChoices(); addSolutions(j++, choices1); choices2 = el.gapAfter.getChoices(); addSolutions(j++, choices2); choices3 = el.gapMiddle.getChoices(); addSolutions(j++, choices3); } return solutions; }; })(); trainers/dragPunc/textB/createParts/appendAndCombine/appendAndCombine.ls (function(){ return function(div, el, lastEl, lastP, p){ var combiner; if ((p.gap || p.space) && (lastP != null && lastP.word)) { combiner = inc("combiner/combiner")(); lastEl.wrap(combiner); return lastEl.after(el); } else { return div.append(el); } }; })(); trainers/dragPunc/textB/createParts/appendAndCombine/combiner/combiner.ls (function(){ return function(){ return Div({ display: "inline-block", whiteSpace: "nowrap", lineHeight: "inherit" }); }; })(); trainers/dragPunc/textB/createParts/create.ls (function(){ return function(slide, div){ var i$, ref$, len$, i, part, el, j$, ref1$, len1$, c, v, pos, gap, ref2$, ref3$, ref4$; for (i$ = 0, len$ = (ref$ = slide.parts).length; i$ < len$; ++i$) { i = i$; part = ref$[i$]; if (part.word) { el = inc("element/element")(slide, part, i).appendTo(div); slide.elements.push(el); } else if (part['break']) { div.append(inc("linebreak/linebreak")()); } else if (part.gap) { slide.elements.push({ toParse: true, part: part }); } } for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { i = i$; el = ref$[i$]; if (el.toParse) { part = el.part; for (j$ = 0, len1$ = (ref1$ = part.choices).length; j$ < len1$; ++j$) { c = ref1$[j$]; v = c.text; pos = inc("../../calcDefaultPosition/calc")(v[0]); gap = pos === "after" ? (ref2$ = _.findLast(_.slice(slide.elements, 0, i), fn$)) != null ? ref2$.gapAfter : void 8 : pos === "before" ? (ref3$ = _.find(_.slice(slide.elements, i), fn1$)) != null ? ref3$.gapBefore : void 8 : pos === "middle" ? (ref4$ = _.findLast(_.slice(slide.elements, 0, i), fn2$)) != null ? ref4$.gapMiddle : void 8 : void 8; if (!pos) { debug("Achtung, das Zeichen " + v + " ist (noch) nicht zulässig."); } else if (!gap) { debug("Achtung, es konnte kein Wort gefunden werden, zu der deine Gap zugeordnet werden konnte."); debug("Gap:", part.choices); debug("Achte darauf, dass DragElemente, die Wörter prefixen, immer ein Folgewort haben und solche, die Wörter suffixen, immer ein Wort davor haben."); } if (c.solved) { gap.addChoice(v, i, "solved"); } else if (c.correct && c.optional) { gap.addChoice(v, i, "optional"); } else if (c.correct) { gap.addChoice(v, i, "correct"); } else { gap.addChoice(v, i, "wrong"); } } } } return slide.elements = _.filter(slide.elements, function(el){ return !el.toParse; }); function fn$(el){ return !el.toParse; } function fn1$(el){ return !el.toParse; } function fn2$(el){ return !el.toParse; } }; })(); trainers/dragPunc/textB/createParts/element/element.ls (function(){ return function(slide, part, i){ var div, gapBefore, gapAfter, gapMiddle; div = Div({ display: "inline-block" }).html(gapBefore = inc("gap/gap")(slide, "before"), inc("word/word")(part), gapAfter = inc("gap/gap")(slide, "after"), gapMiddle = inc("gap/gap")(slide, "middle")); slide.gaps.push(gapBefore, gapAfter, gapMiddle); div.gapBefore = gapBefore; div.gapAfter = gapAfter; div.gapMiddle = gapMiddle; return div; }; })(); trainers/dragPunc/textB/createParts/element/gap/gap.ls (function(){ return function(slide, pos){ var defaultValue, choices, setHighlight, solved, addChoice, div, space; defaultValue = " "; choices = {}; setHighlight = function(enable){ return space.css({ backgroundColor: enable ? Color.grey[400] : "" }); }; solved = false; addChoice = function(value, i, type){ if (choices[i] == null) { choices[i] = []; } choices[i].push({ type: type, value: value }); if (type === "solved") { solved = true; return div.html(value); } }; div = Div({ display: "inline-flex", position: "relative" }).addClass("gap").html(space = Div({ width: "0.2em" }).addClass("space").html(" ")); div.isEnabled = function(){ return !solved; }; div.setHighlight = setHighlight; div.reset = function(){ return div.html(defaultValue); }; div.pos = pos; div.addChoice = addChoice; div.getChoices = function(){ return choices; }; div.space = space; return div; }; })(); trainers/dragPunc/textB/createParts/element/word/word.ls (function(){ return function(part){ return Div({ display: "inline-block", textDecoration: part.underline ? "underline" : void 8, backgroundColor: part.markColor, color: part.textColor, fontWeight: part.bold ? "bold" : void 8, fontStyle: part.italic ? "italic" : void 8 }).addClass("word").html(part.word); }; })(); trainers/dragPunc/textB/createParts/linebreak/linebreak.ls (function(){ return function(slide, part){ return "
"; }; })(); trainers/dragPunc/textB/createParts/space/space.ls (function(){ return function(){ return " "; }; })(); trainers/dragPunc/textB/setFeedback/set.ls (function(){ return function(slide, div){ var solutions; return function(result){ var i$, ref$, len$, gap, j$, ref1$, len1$, el, allCorrect, values, i, value, correct, j, ref2$; if (!result) { div.css({ outline: "" }); for (i$ = 0, len$ = (ref$ = slide.gaps).length; i$ < len$; ++i$) { gap = ref$[i$]; if (gap.isEnabled()) { for (j$ = 0, len1$ = (ref1$ = gap.findAll(".dragElement")).length; j$ < len1$; ++j$) { el = ref1$[j$]; el.setLayout("gap"); } } } return; } allCorrect = true; values = _.map(slide.gaps, function(gap, i){ return _.map(gap.findAll(".dragElement"), "value"); }); for (i$ = 0, len$ = (ref$ = slide.gaps).length; i$ < len$; ++i$) { i = i$; gap = ref$[i$]; value = values[i]; correct = result[i]; if (!_.every(correct, fn$)) { allCorrect = false; } if (value.length > 0) { for (j$ = 0, len1$ = (ref1$ = gap.findAll(".dragElement")).length; j$ < len1$; ++j$) { j = j$; el = ref1$[j$]; if ((ref2$ = el.label) != null) { ref2$.css({ backgroundColor: !correct[j] ? Color.red[500] : Color.green[500] }); } } } } if (!allCorrect) { return slide.textB.css({ outline: "4px solid " + Color.red[500] }); } function fn$(b){ return b === true; } }; }; })(); trainers/dragPunc/textB/text.ls (function(){ return function(slide){ var div; div = Div({ maxWidth: "90%", width: "30em", margin: "0.7em auto", padding: "0.3em", textAlign: slide.getParam("textAlign", slide.atom) || "left", lineHeight: "2em" }).appendTo(slide.div); inc("createParts/create")(slide, div); slide.solutions = inc("calcSolutions/calc")(slide); div.setFeedback = inc("setFeedback/set")(slide, div); div.calcCorrectValue = inc("calcCorrectValue/calc")(slide, div); return div; }; })(); trainers/dragPuzzle/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var atom; return _.concat(slide.getParam("lsg", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }())); }; })(); trainers/dragPuzzle/_preview/preview.ls (function(){ return function(slide){ return slide.lsg.firstChild.css({ width: "100%", height: "100%" }); }; })(); trainers/dragPuzzle/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, elements, i$, ref$, len$, index, action, lsg, j$, ref1$, len1$, result, elClone; e = slide.score.getScoreEvent(); if (!e) { return; } slide.buttons.remove(); elements = slide.div.findAll(".dragPuzzleElement"); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { index = i$; action = ref$[i$]; lsg = inc("../../lsg/lsg")(slide).css({ overflow: "hidden" }); for (j$ = 0, len1$ = (ref1$ = action.results).length; j$ < len1$; ++j$) { result = ref1$[j$]; if (result.element != null) { return; } elClone = elements[result.index].cloneNode(true); elClone.appendTo(lsg).css({ position: "absolute", left: result.position.left + "px", top: result.position.top + "px" }); } slide.div.append(Div({ margin: "3em 0" }).append(inc("/shared/scoreActionRow/row")(action, index).append(lsg))); } }; })(); trainers/dragPuzzle/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, el; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.start(); } return slide.instruction.play(function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.checkButton, { padding: 20 }); }); }; })(); trainers/dragPuzzle/animate/animateToZone/animate.ls (function(){ return function(slide){ return function(div, targetZone){ if (!slide.div.findFirst(".dragPuzzleDummy_" + div.index)) { div.wrapper.append(Div().addClass("dragPuzzleDummy_" + div.index).css({ width: div.width() + "px", height: div.height() + "px" })); } div.offsetSave(); div.css({ transform: "" }); targetZone.append(div); div.offsetAnimate(); return setTimeout(function(){ return div.css({ width: "", pointerEvents: "" }); }, 500); }; }; })(); trainers/dragPuzzle/animate/init.ls (function(){ return function(slide){ slide.animateToZone = inc("animateToZone/animate")(slide); slide.setCorrect = function(){ return slide.lsg.css({ outline: "4px solid green" }); }; slide.setWrong = function(){ return slide.lsg.css({ outline: "4px solid red" }); }; return slide.clearOutline = function(){ return slide.lsg.css({ outline: "none" }); }; }; })(); trainers/dragPuzzle/buttons/buttons.ls (function(){ return function(slide){ return Div({ margin: "1em 0" }).html(slide.solveButton = inc("solveButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide)).appendTo(slide.div); }; })(); trainers/dragPuzzle/buttons/checkButton/button.ls (function(){ return function(slide){ var div; return div = Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: slide.validate, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/dragPuzzle/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, div; showButton = function(){ div.hide(); return div.fadeIn(); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(slide.solve).hide(); div.showButton = showButton; return div; }; })(); trainers/dragPuzzle/calcClosestZone/calc.ls (function(){ return function(slide){ var calcDist; calcDist = function(div1, div2){ var o1, o2, div1X, div1Y, div2X, div2Y; o1 = div1.offset(); o2 = div2.offset(); div1X = o1.left + div1.width() / 2; div1Y = o1.top + div1.height() / 2; div2X = o2.left + div2.width() / 2; div2Y = o2.top + div2.height() / 2; return Math.sqrt(Math.pow(div2X - div1X, 2) + Math.pow(div2Y - div1Y, 2)); }; return function(div){ return _(slide.zones).map(function(zone, i){ return { distance: calcDist(div, zone), zone: zone, index: i }; }).sortBy("distance").value()[0]; }; }; })(); trainers/dragPuzzle/elements/dummyElement/dummyElement.ls (function(){ return function(){ return Div().addClass("dummyElement").css({ verticalAlign: "top", display: "inline-block", width: 1, height: 1, visibility: "hidden" }); }; })(); trainers/dragPuzzle/elements/element/element.ls (function(){ return function(slide, atom, index){ var start, wrapper, div, lsg, i$, ref$, len$, c; start = function(){ return inc("enableDrag/enable")(slide, wrapper, div, index); }; wrapper = Div({ display: "inline-block", verticalAlign: "top", margin: "0.1em" }).html(div = Div({ display: "inline-block", cursor: "pointer", zIndex: 1 }).addClass("dragPuzzleElement").append(lsg = inc("lsg/lsg")(atom, slide))); for (i$ = 0, len$ = (ref$ = lsg.findAll("text")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ cursor: "pointer" }); } if (!atom.lsg) { div.css({ wordWrap: "break-word", backgroundColor: Color.grey[150], padding: "0.5em", backgroundClip: "border-box", boxShadow: '1px 1px 2px #bbb' }); } div.lastZone = 0; div.lsg = lsg; div.index = index; div.atom = atom; div.zone = atom.zone; div.wrapper = wrapper; wrapper.start = start; return wrapper; }; })(); trainers/dragPuzzle/elements/element/enableDrag/enable.ls (function(){ return function(slide, wrapper, div, index){ var dragStart, dragMove, dragEnd; dragStart = function(){ slide.clearOutline(); return slide.dragStartPos = div.offset(); }; dragMove = function(o){ if (slide.pageIsScrollable) { return inc("scroll/scroll")(slide, o, div); } }; dragEnd = function(){ return div.scrollDirection = null; }; inc("/../app01/lib/util/waitFrames/wait")(4, function(){ var psw, ref$; psw = slide.levelPlayer.page.pageScrollWrapper; if (psw.isScrollableY) { slide.pageIsScrollable = true; } return (ref$ = div.maxScrollTop) != null ? ref$ : div.maxScrollTop = psw.scrollHeight - psw.clientHeight - 30; }); return div.drag({ onStart: dragStart, onMove: dragMove, onEnd: dragEnd, animation: "none", boundingDiv: slide.div }).bind("touchstart touchmove mousedown", function(e){ return e.preventDefault(); }); }; })(); trainers/dragPuzzle/elements/element/enableDrag/scroll/scroll.ls (function(){ return function(slide, o, div){ var y, psw, pageTop, pageBottom, scroll; y = o.clientPosition.y; psw = slide.levelPlayer.page.pageScrollWrapper; pageTop = slide.levelPlayer.page.top.height() + 50; pageBottom = window.innerHeight - slide.levelPlayer.page.bottom.height() - 50; scroll = function(){ if (div.scrollDirection === "up" && psw.scrollTop > 0) { slide.levelPlayer.page.pageScrollWrapper.scrollTop -= 5; o.updateTranslation({ y: -5, x: 0 }); return setTimeout(scroll, 50); } else if (div.scrollDirection === "down") { if (div.maxScrollTop <= psw.scrollTop) { div.scrollDirection = null; return; } slide.levelPlayer.page.pageScrollWrapper.scrollTop += 5; o.updateTranslation({ y: 5, x: 0 }); return setTimeout(scroll, 50); } }; if (y > pageBottom) { div.scrollDirection = "down"; return scroll(); } else if (y < pageTop) { div.scrollDirection = "up"; return scroll(); } else { return div.scrollDirection = null; } }; })(); trainers/dragPuzzle/elements/element/lsg/lsg.ls (function(){ return function(atom, slide){ var lsg; lsg = slide.getParam("lsg", atom); lsg.width *= slide.lsgScale; return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }); }; })(); trainers/dragPuzzle/elements/elements.ls (function(){ return function(slide){ var elements, res$, i$, ref$, len$, i, atom, el; res$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; res$.push(inc("element/element")(slide, atom, i)); } elements = res$; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { el = elements[i$]; slide.startZone.prepend(el); } return elements; }; })(); trainers/dragPuzzle/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = 1; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/dragPuzzle/init.ls (function(){ return function(slide){ slide.elements = []; slide.zones = []; inc("animate/init")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.validate = inc("validate/validate")(slide); slide.solve = inc("solve/solve")(slide); slide.calcClosestZone = inc("calcClosestZone/calc")(slide); slide.zones = inc("zones/zones")(slide); slide.buttons = inc("buttons/buttons")(slide); return slide.elements = inc("elements/elements")(slide); }; })(); trainers/dragPuzzle/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/dragPuzzle/lsg/lsg.ls (function(){ return function(slide){ var lsgD, lsg, fontScale, width, ref$; lsgD = slide.getParam("lsg"); lsg = inc("/shared/lsg/lsg")({ lsg: lsgD, slide: slide, parent: slide.div, wrapWithDiv: true }).css({ display: "inline-block", maxWidth: "100%", margin: "" }).appendTo(slide.div); fontScale = inc("/../app01/lib/util/fontSize/calcFontScale/calc")(); width = (ref$ = lsgD.width) != null ? ref$ : 250; slide.lsgScale = lsg.width() / (width * fontScale); return lsg; }; })(); trainers/dragPuzzle/solve/solve.ls (function(){ return function(slide){ return function(){ var solveElements, parentOffset, i$, ref$, len$, i, el, zone; slide.clearOutline(); solveElements = []; parentOffset = slide.lsg.offset(); for (i$ = 0, len$ = (ref$ = slide.div.findAll(".dragPuzzleElement")).length; i$ < len$; ++i$) { i = i$; el = ref$[i$]; el.css({ pointerEvents: "none" }); zone = _.find(slide.targetZones, fn$); slide.animateToZone(el, zone); solveElements.push({ index: i, position: { left: zone.offset().left - parentOffset.left, top: zone.offset().top - parentOffset.top } }); } slide.buttons.css({ pointerEvents: "none" }); slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atoms, { results: solveElements }); slide.score.log(slide.atoms); return setTimeout(function(){ slide.finish(); slide.solveButton.hide(); slide.checkButton.hide(); return slide.lsg.css({ pointerEvents: "none" }); }, 500); function fn$(zone){ return zone.targetZoneClass === el.zone; } }; }; })(); trainers/dragPuzzle/validate/validate.ls (function(){ return function(slide){ var precisionPercentage, precision; precisionPercentage = slide.getParam("precision") || 10; precision = slide.lsg.width() * precisionPercentage / 100; return function(){ var parentOffset, results, res$, i$, ref$, len$, i, element, closest, elOffset; parentOffset = slide.lsg.offset(); res$ = []; for (i$ = 0, len$ = (ref$ = slide.div.findAll(".dragPuzzleElement")).length; i$ < len$; ++i$) { i = i$; element = ref$[i$]; closest = slide.calcClosestZone(element); elOffset = element.offset(); if (closest.zone.targetZoneClass === element.zone && closest.distance <= precision) { slide.animateToZone(element, closest.zone); res$.push({ correct: true, index: i, position: { left: elOffset.left - parentOffset.left, top: elOffset.top - parentOffset.top } }); } else { res$.push({ correct: false, index: i, position: { left: elOffset.left - parentOffset.left, top: elOffset.top - parentOffset.top } }); } } results = res$; if (_.every(results, "correct")) { slide.setCorrect(); slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atoms, { results: results }); slide.score.log(slide.atoms); slide.lsg.css({ pointerEvents: "none" }); slide.checkButton.hide(); slide.solveButton.hide(); return setTimeout(slide.finish, 500); } else { slide.levelPlayer.progressBar.addElement().showRed(); slide.score.addActionMistake(slide.atoms, { results: results }); slide.setWrong(); return slide.solveButton.showButton(); } }; }; })(); trainers/dragPuzzle/zones/startZone/zone.ls (function(){ return function(slide){ var div; Div().html(div = Div({ display: "inline-block", padding: "0.5em 0.2em", width: "30em", maxWidth: "100%" }).addClass("startZone")).appendTo(slide.div); return div; }; })(); trainers/dragPuzzle/zones/targetZone/zone.ls (function(){ return function(slide, targetCss, c, i){ var div; div = Div(targetCss).css({ position: "absolute", textAlign: "left", display: "flex", alignContent: "center", justifyContent: "center", flexFlow: "row wrap" }).addClass("targetZone targetZone_" + i + " " + c); div.targetZoneClass = c; return div; }; })(); trainers/dragPuzzle/zones/zones.ls (function(){ return function(slide){ var zones, zoneTargets, targetRects, i$, len$, i, z, classes, c, zone; zones = []; slide.targetZones = []; zones.push(slide.startZone = inc("startZone/zone")(slide)); zoneTargets = slide.lsg.findAll(".zone"); targetRects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(slide.lsg, ".zone"); for (i$ = 0, len$ = zoneTargets.length; i$ < len$; ++i$) { i = i$; z = zoneTargets[i$]; classes = z.classes(); if (classes.length > 1) { c = _.find(classes, fn$); } zone = inc("targetZone/zone")(slide, targetRects[i], c, i).append(inc("../elements/dummyElement/dummyElement")().addClass("dummyStart"), inc("../elements/dummyElement/dummyElement")().addClass("dummyEnd")).appendTo(slide.lsg); slide.targetZones.push(zone); zones.push(zone); } return zones; function fn$(o){ return o !== "zone"; } }; })(); trainers/dragSort/_media2/images/images.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }; })(); trainers/dragSort/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var atom; return _.concat(slide.getParam("lsg"), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }())); }; })(); trainers/dragSort/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, voiceLang, voice, text; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); text = atom.sound ? atom.sound : soundMode === "a" ? atom.text : void 8; if (text) { sounds.push({ text: text, voiceLang: voiceLang, voice: voice }); } } return sounds; }; })(); trainers/dragSort/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/dragSort/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, elements, k, j, label, results$ = []; e = slide.score.getScoreEvent(); if (e) { slide.content.empty(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; elements = a.resolved ? _.sortBy(slide.elements, fn$) : (fn1$()); results$.push(slide.content.append(Div({ display: "flex", flexDirection: "column", margin: "1em 0 3em" }).append(label = Div({ margin: "0 0 1em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong"))), elements))); } return results$; } function fn$(el){ return _.indexOf(slide.atoms, el.atom); } function fn1$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = a.indices).length; i$ < len$; ++i$) { k = i$; j = ref$[i$]; e = _.find(slide.elements, fn$); e = e.clone(); if (k === j) { results$.push(e.css({ borderLeft: "4px solid " + Color.green[500] })); } else { results$.push(e.css({ borderLeft: "4px solid " + Color.red[500] })); } } return results$; function fn$(e){ return e.atom === slide.atoms[j]; } } }; })(); trainers/dragSort/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, el; slide.instruction.play(); slide.dragElementsActive = 0; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.start(); } return slide.levelPlayer.page.bottom.append(slide.buttons).show(); }; })(); trainers/dragSort/buttons/buttons.ls (function(){ return function(slide){ return Div({ textAlign: "center" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide)); }; })(); trainers/dragSort/buttons/checkButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ var results, res$, i$, ref$, len$, i, c, indexArray, r; if (slide.disableButtons) { return; } res$ = []; for (i$ = 0, len$ = (ref$ = slide.content.find(".normalElement")).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; res$.push({ element: c, correct: c.atom === slide.atoms[i] }); } results = res$; res$ = []; for (i$ = 0, len$ = results.length; i$ < len$; ++i$) { r = results[i$]; res$.push(_.indexOf(slide.atoms, r.element.atom)); } indexArray = res$; for (i$ = 0, len$ = results.length; i$ < len$; ++i$) { r = results[i$]; if (r.correct) { r.element.setCorrect(); } else { r.element.setWrong(); } } if (results.every(function(o){ return o.correct === true; })) { slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atoms, { indices: indexArray }); slide.score.log(slide.atoms); slide.div.css({ pointerEvents: "none" }); div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 1000); } else { if (!slide.solveButton.isVisible()) { slide.solveButton.show(); } slide.levelPlayer.progressBar.addElement().showRed(); return slide.score.addActionMistake(slide.atoms, { indices: indexArray }); } }; return div = Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click }).css({ margin: "0.7em 0" }); }; })(); trainers/dragSort/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ if (slide.disableButtons) { return; } slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atoms); slide.score.log(slide.atoms); slide.buttons.css({ pointerEvents: "none" }); slide.content.css({ pointerEvents: "none" }); inc("../../solve/solve")(slide); slide.finishButton = true; return setTimeout(slide.finish, 1000); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/dragSort/content/content.ls (function(){ return function(slide){ return Div({ display: "inline-block", maxWidth: "90%", verticalAlign: "top", margin: "1em 0" }).appendTo(slide.div); }; })(); trainers/dragSort/elements/dummyStart/dummyStart.ls (function(){ return function(slide){ var div; div = Div().addClass("dummyElement").addClass("dummyStart"); inc("../element/insertArrows/arrows")(div, true); return div; }; })(); trainers/dragSort/elements/element/element.ls (function(){ return function(slide, atom, i){ var start, div, icon; start = function(){ return inc("enableDrag/enable")(slide, atom, i, div); }; div = Div().addClass("normalElement").css({ cursor: "move", padding: "0.5em 0.5em 0.5em 1.5em", backgroundColor: Color.grey[150], backgroundClip: "border-box", borderLeft: "4px solid " + Color.grey[150], marginBottom: "7px", boxShadow: "1px 1px 2px " + Color.grey[400] }).append(atom.image ? inc("image/image")(slide, atom, i) : atom.lsg ? inc("lsg/lsg")(slide, atom, i) : atom.text ? inc("text/text")(slide, atom, i) : void 8).appendTo(slide.content); icon = inc("icon/icon")(div); if (!atom.image && !atom.lsg) { div.css({ wordWrap: "break-word" }); } inc("insertArrows/arrows")(div); div.setWrong = icon.setWrong; div.setCorrect = icon.setCorrect; div.removeFeedback = icon.removeFeedback; div.atom = atom; div.start = start; return div; }; })(); trainers/dragSort/elements/element/enableDrag/animate/animate.ls (function(){ return function(slide, div, insertIndex, onEnd){ var i$, ref$, len$, c, elements, insertElement, dummyNewPosition; for (i$ = 0, len$ = (ref$ = slide.content.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ pointerEvents: "none" }); } div.css({ pointerEvents: "none" }); elements = slide.content.findAll(".normalElement, .dummyStart"); insertElement = _.filter(elements, function(el){ return el !== div; })[insertIndex]; inc("animateDiv/animate")(div, insertElement, insertIndex, slide, onEnd); dummyNewPosition = inc("animateInsert/animate")(insertElement, div); inc("animateRemove/animate")(div); return setTimeout(function(){ var i$, ref$, len$, c, el, results$ = []; dummyNewPosition.remove(); div.css({ position: "relative", left: "", top: "", transform: "", transition: "", pointerEvents: "" }); insertElement.after(div); for (i$ = 0, len$ = (ref$ = slide.content.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ pointerEvents: "" }); } for (i$ = 0, len$ = (ref$ = body.findAll(".dummyAnimate")).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(el.remove()); } return results$; }, 400); }; })(); trainers/dragSort/elements/element/enableDrag/animate/animateDiv/animate.ls (function(){ return function(div, insertElement, insertIndex, slide, onEnd){ var correction; correction = slide.dragStartPosition.top > insertElement.offset().top || insertIndex === 0 ? div.height() : -5; if (insertIndex === 0) { correction += 5; } div.css({ position: "absolute" }); return onEnd.animateToTarget({ targetOpacity: 1, targetScale: 1, targetPosition: { x: insertElement.offset().left + div.width() / 2, y: insertElement.offset().top + div.height() / 2 + insertElement.height() - correction } }); }; })(); trainers/dragSort/elements/element/enableDrag/animate/animateInsert/animate.ls (function(){ return function(insertElement, div){ var dummy; dummy = Div({ position: "relative", verticalAlign: "top", width: div.width() + "px", height: 0 }); insertElement.after(dummy); return dummy.css({ height: div.height() + 5 + "px", transition: "height 400ms" }); }; })(); trainers/dragSort/elements/element/enableDrag/animate/animateRemove/animate.ls (function(){ return function(div){ var dummy; dummy = Div().addClass("dummyAnimate").css({ width: div.width() + "px", height: div.height() + 5 + "px", verticalAlign: "top" }); div.after(dummy); return requestAnimationFrame(function(){ return dummy.css({ height: 0, transition: "400ms" }); }); }; })(); trainers/dragSort/elements/element/enableDrag/animatePseudo/animate.ls (function(){ return function(slide, insertIndex, div, dummy){ var i$, ref$, len$, a, elements, insertElement; for (i$ = 0, len$ = (ref$ = body.find(".insertArrow")).length; i$ < len$; ++i$) { a = ref$[i$]; a.hide(); } elements = slide.content.findAll(".normalElement, .dummyStart"); insertElement = _.filter(elements, function(el){ return el !== div; })[insertIndex]; return insertElement != null ? (ref$ = insertElement.arrows) != null ? ref$.show() : void 8 : void 8; }; })(); trainers/dragSort/elements/element/enableDrag/calcDist/calc.ls (function(){ return function(div1, div2){ var div1X, div1Y, div2X, div2Y, dist; div1X = div1.offset().left + div1.width() / 2; div1Y = div1.offset().top + div1.height() / 2; div2X = div2.offset().left + div2.width() / 2; div2Y = div2.offset().top + div2.height() / 2; return dist = Math.sqrt(Math.pow(div2X - div1X, 2) + Math.pow(div2Y - div1Y, 2)); }; })(); trainers/dragSort/elements/element/enableDrag/calcInsertIndex/calc.ls (function(){ return function(slide, div, originIndex){ var minDist, minIndex, minCY, minDivY, children, i$, len$, i, c, dist; minDist = null; minIndex = null; minCY = -1; minDivY = -1; children = slide.content.findAll(".normalElement, .dummyStart"); children = _.filter(children, function(c){ return c !== div; }); for (i$ = 0, len$ = children.length; i$ < len$; ++i$) { i = i$; c = children[i$]; dist = slide.calcDist(div, c); if (minDist == null || dist < minDist) { minDist = dist; minIndex = i; minCY = c.offset().top + c.height() / 2; minDivY = div.offset().top + div.height() / 2; } } if (minDivY < minCY) { minIndex--; } if (minIndex < 0) { minIndex = 0; } return minIndex; }; })(); trainers/dragSort/elements/element/enableDrag/enable.ls (function(){ return function(slide, atom, i, div){ var dummy, lastInsertIndex, insertIndex, originIndex, lastStartAt, lastMoveAt, lastOnEndCallback, psw, dragStart, dragMove, dragEnd; dummy = null; lastInsertIndex = -1; insertIndex = -1; originIndex = -1; lastStartAt = null; lastMoveAt = null; lastOnEndCallback = null; psw = slide.levelPlayer.page.pageScrollWrapper; slide.calcCollision = function(d1, d2){ return inc("calcCollision/calc")(d1, d2); }; slide.calcDist = function(d1, d2){ return inc("calcDist/calc")(d1, d2); }; dragStart = function(){ var i$, ref$, len$, el; slide.disableButtons = true; slide.dragElementsActive++; lastStartAt = new Date(); slide.dragStartPosition = div.offset(); inc("playSoundA/play")(slide, atom); for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.removeFeedback(); } insertIndex = slide.content.childrenAll().indexOf(div) - 1; originIndex = insertIndex; if (insertIndex !== lastInsertIndex) { inc("animatePseudo/animate")(slide, insertIndex, div, dummy); return lastInsertIndex = insertIndex; } }; dragMove = function(o){ lastMoveAt = new Date(); insertIndex = inc("calcInsertIndex/calc")(slide, div, originIndex); if (insertIndex !== lastInsertIndex) { if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } inc("animatePseudo/animate")(slide, insertIndex, div, dummy); lastInsertIndex = insertIndex; } if (slide.pageIsScrollable) { return inc("scroll/scroll")(slide, o, div); } }; dragEnd = function(onEnd){ var i$, ref$, len$, a, results$ = []; setTimeout(function(){ return slide.disableButtons = false; }, 400); slide.dragElementsActive--; div.scrollDirection = null; lastOnEndCallback = onEnd; div.css({ boxShadow: "1px 1px 2px " + Color.grey[400] }); if (lastMoveAt > lastStartAt) { inc("animate/animate")(slide, div, insertIndex, onEnd); } else { onEnd.animateToStart(); } for (i$ = 0, len$ = (ref$ = body.find(".insertArrow")).length; i$ < len$; ++i$) { a = ref$[i$]; results$.push(a.hide()); } return results$; }; inc("/../app01/lib/util/waitFrames/wait")(4, function(){ var ref$; if (psw.isScrollableY) { slide.pageIsScrollable = true; } return (ref$ = div.maxScrollTop) != null ? ref$ : div.maxScrollTop = psw.scrollHeight - psw.clientHeight - 31; }); return div.drag({ onStart: dragStart, onMove: dragMove, onEnd: dragEnd, preventDefault: true, shouldStart: function(){ return slide.dragElementsActive === 0; } }).bind("touchstart touchmove mousedown", function(e){ return e.preventDefault(); }); }; })(); trainers/dragSort/elements/element/enableDrag/playSoundA/play.ls (function(){ var currentSound; currentSound = null; return function(slide, atom){ var voice, text, newSound; if (slide.getParam("soundMode") !== "a") { return; } voice = slide.getParam("voice", atom); text = atom.sound || atom.text; newSound = slide.sounds[text + voice]; if (currentSound != null) { currentSound.stop(); } if (newSound !== currentSound) { currentSound = newSound; return currentSound.play(); } else { return currentSound = null; } }; })(); trainers/dragSort/elements/element/enableDrag/scroll/scroll.ls (function(){ return function(slide, o, div){ var y, psw, pageTop, pageBottom, scroll; y = o.clientPosition.y; psw = slide.levelPlayer.page.pageScrollWrapper; pageTop = slide.levelPlayer.page.top.height() + 50; pageBottom = window.innerHeight - slide.levelPlayer.page.bottom.height() - 50; scroll = function(){ if (div.scrollDirection === "up" && psw.scrollTop > 0) { slide.levelPlayer.page.pageScrollWrapper.scrollTop -= 5; o.updateTranslation({ y: -5, x: 0 }); return setTimeout(scroll, 50); } else if (div.scrollDirection === "down") { if (div.maxScrollTop <= psw.scrollTop) { div.scrollDirection = null; return; } slide.levelPlayer.page.pageScrollWrapper.scrollTop += 5; o.updateTranslation({ y: 5, x: 0 }); return setTimeout(scroll, 50); } }; if (y > pageBottom) { div.scrollDirection = "down"; return scroll(); } else if (y < pageTop) { div.scrollDirection = "up"; return scroll(); } else { return div.scrollDirection = null; } }; })(); trainers/dragSort/elements/element/icon/icon.ls (function(){ return function(parent){ var setCorrect, setWrong, removeFeedback, div; setCorrect = function(){ return parent.css({ borderLeft: "4px solid " + Color.green[500] }); }; setWrong = function(){ return parent.css({ borderLeft: "4px solid " + Color.red[500] }); }; removeFeedback = function(){ return parent.css({ borderLeft: "4px solid " + Color.grey[150] }); }; div = SvgIcon({ svg: path("/../app01/lib/svg/icon/move-y.svg"), color: Color.grey[400] }).css({ position: "absolute", left: "0.2em", top: "50%", marginTop: "-0.5em", width: "1em", height: "1em" }).appendTo(parent); div.setCorrect = setCorrect; div.setWrong = setWrong; div.removeFeedback = removeFeedback; return div; }; })(); trainers/dragSort/elements/element/image/image.ls (function(){ return function(slide, atom, i){ var image; image = slide.getParam("image", atom); return inc("/shared/image/image")({ image: image, slide: slide }).css(!image.width ? { width: "8em", height: "8em" } : void 8); }; })(); trainers/dragSort/elements/element/insertArrows/arrows.ls (function(){ return function(div, isDummy){ requestAnimationFrame(function(){ var arrows; div.append(arrows = Div().addClass("insertArrow").append(SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-right.svg") }).css({ position: "absolute", top: isDummy ? "-0.45em" : 0, left: isDummy ? "-1.1em" : "-2.8em", width: "1em", height: "1em" }), SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-left.svg") }).css({ position: "absolute", top: isDummy ? "-0.45em" : 0, right: isDummy ? "-1.1em" : "-1.6em", width: "1em", height: "1em" })).hide()); return div.arrows = arrows; }); return div; }; })(); trainers/dragSort/elements/element/lsg/lsg.ls (function(){ return function(slide, atom, i){ var lsg, div; lsg = slide.getParam("lsg", atom); div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }); if (!lsg.width) { div.css({ width: "8em", height: "8em" }); } return div; }; })(); trainers/dragSort/elements/element/text/text.ls (function(){ return function(slide, atom, i){ return Div({ width: "15em", maxWidth: "100%", textAlign: "left" }).html(atom.text); }; })(); trainers/dragSort/elements/elements.ls (function(){ return function(slide){ var atoms, i$, len$, i, atom, e, results$ = []; slide.elements = []; slide.content.append(inc("dummyStart/dummyStart")(slide)); atoms = slide.atoms; if (_.uniqWith(atoms, _.isEqual).length > 1) { do { atoms = _.shuffleWithSeed(atoms); } while (_.every(atoms, fn$)); } for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { i = i$; atom = atoms[i$]; e = inc("element/element")(slide, atom, i); results$.push(slide.elements.push(e)); } return results$; function fn$(a, i){ return _.isEqual(a, slide.atoms[i]); } }; })(); trainers/dragSort/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = 1; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/dragSort/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.content = inc("content/content")(slide); slide.buttons = inc("buttons/buttons")(slide); return inc("elements/elements")(slide); }; })(); trainers/dragSort/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/dragSort/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/dragSort/solve/solve.ls (function(){ return function(slide){ var sorted, i$, len$, el, results$ = []; sorted = _.sortBy(slide.elements, function(el){ return _.indexOf(slide.atoms, el.atom); }); for (i$ = 0, len$ = sorted.length; i$ < len$; ++i$) { el = sorted[i$]; el.removeFeedback(); el.offsetSave(); } slide.content.append(sorted); for (i$ = 0, len$ = sorted.length; i$ < len$; ++i$) { el = sorted[i$]; results$.push(el.offsetAnimate(700)); } return results$; }; })(); trainers/dragSpell/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/dragSpell/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/dragSpell/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, voiceLang, voice, texts, i$, ref$, len$, s, letter, t; sounds = []; if (slide.getParam("soundMode", slide.atom) === "a") { voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); texts = []; if (slide.atom.sounds) { for (i$ = 0, len$ = (ref$ = slide.atom.sounds).length; i$ < len$; ++i$) { s = ref$[i$]; texts.push(s); } } else { for (i$ = 0, len$ = (ref$ = slide.word).length; i$ < len$; ++i$) { letter = ref$[i$]; texts.push(letter.trim()); } } for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { t = texts[i$]; sounds.push({ text: t, voiceLang: voiceLang, voice: voice }); } } return sounds; }; })(); trainers/dragSpell/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/dragSpell/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } return slide.div.append(Div({ margin: "2em 0", textAlign: "left" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(inc("row/row")(action, scoreEvent.atom))); } return results$; }()))); }; })(); trainers/dragSpell/_review/scoreActions/row/left/left.ls (function(){ return function(action){ return "'" + action.letter + "'"; }; })(); trainers/dragSpell/_review/scoreActions/row/right/right.ls (function(){ return function(action, atom){ return Div({ display: "inline-flex", width: "1.3em", height: "1.3em", border: "1px dashed rgb(187,187,187)" }).html(Div({ padding: "0.1em" }).html(atom.word.split(" ")[action.zone])); }; })(); trainers/dragSpell/_review/scoreActions/row/row.ls (function(){ return function(action, atom){ return Div({ display: "inline" }).append(inc("left/left")(action), action.zone != null ? [ Div({ display: "inline" }).html(" → "), inc("right/right")(action, atom) ] : void 8); }; })(); trainers/dragSpell/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, el; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.start(); } slide.instruction.play(function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.content, { padding: 10 }); }); if (slide.word.length > 12) { return debug("Dein Wort darf nicht länger als 12 Buchstaben sein, bitte definiere ein kürzeres Wort!"); } }; })(); trainers/dragSpell/content/content.ls (function(){ return function(slide){ return Div({ width: "30em", maxWidth: "100%", flex: "0 1 300px", alignSelf: "center", marginBottom: "0.5em" }).appendTo(slide.div); }; })(); trainers/dragSpell/elements/element/element.ls (function(){ return function(slide, label, i){ var start, div, letter; start = function(){ return inc("enableDrag/enable")(slide, label, i, div); }; div = Div({ display: "inline-flex", position: "absolute", cursor: "move", padding: "0.2em", backgroundColor: Color.grey[150], boxShadow: '1px 1px 2px #bbb', zIndex: 1, justifyContent: "center" }).addClass("normalElement").html(letter = Div({ display: "inline-block", alignSelf: "center", color: Color.grey[550], pointerEvents: "none" }).html(label)).appendTo(slide.content); div.label = label; div.letter = letter; div.start = start; return div; }; })(); trainers/dragSpell/elements/element/enableDrag/animateBack/animate.ls (function(){ return function(slide, div){ div.css({ pointerEvents: "none", top: div.divStartPosition.top + "px", left: div.divStartPosition.left + "px", transition: "500ms" }); return setTimeout(function(){ return div.css({ pointerEvents: "", transition: "" }); }, 500); }; })(); trainers/dragSpell/elements/element/enableDrag/check/check.ls (function(){ return function(slide, currentZone, div, solve, wrong){ var zone; zone = slide.zones[currentZone]; if (zone.solved) { return; } zone.css({ backgroundColor: "" }); if (div.label === zone.label) { return solve(); } else { return wrong(); } }; })(); trainers/dragSpell/elements/element/enableDrag/detectCollision/calcNearestZone/calc.ls (function(){ return function(collisionZones, slide, div){ var divX, divY, minDist, minIndex, i$, len$, i, zone, zoneX, zoneY, dist; divX = div.offset().left + div.width() / 2; divY = div.offset().top + div.height() / 2; minDist = null; minIndex = -1; for (i$ = 0, len$ = collisionZones.length; i$ < len$; ++i$) { i = collisionZones[i$]; zone = slide.zones[i]; zoneX = zone.offset().left + zone.width() / 2; zoneY = zone.offset().top + zone.height() / 2; dist = Math.sqrt(Math.pow(zoneX - divX, 2) + Math.pow(zoneY - divY, 2)); if (minDist != null) { if (dist < minDist) { minDist = dist; minIndex = i; } } else { minDist = dist; minIndex = i; } } return minIndex; }; })(); trainers/dragSpell/elements/element/enableDrag/detectCollision/detect.ls (function(){ return function(div, slide){ var scrollTop, divPosition, collisionZones, res$, i$, ref$, len$, i, zone, zonePosition; scrollTop = slide.levelPlayer.page.pageScrollWrapper.scrollTop; divPosition = { top: div.offset().top + scrollTop, left: div.offset().left, bottom: div.offset().top + div.height() + scrollTop, right: div.offset().left + div.width() }; res$ = []; for (i$ = 0, len$ = (ref$ = slide.zones).length; i$ < len$; ++i$) { i = i$; zone = ref$[i$]; zonePosition = slide.zonePositions[i]; if (divPosition.right < zonePosition.left) { continue; } else if (divPosition.left > zonePosition.right) { continue; } else if (divPosition.top > zonePosition.bottom) { continue; } else if (divPosition.bottom < zonePosition.top) { continue; } else { res$.push(i); } } collisionZones = res$; if (collisionZones.length === 0) { return -1; } if (collisionZones.length === 1) { return collisionZones[0]; } else { return inc("calcNearestZone/calc")(collisionZones, slide, div); } }; })(); trainers/dragSpell/elements/element/enableDrag/enable.ls (function(){ return function(slide, letter, i, div){ var currentZone, isDoubleTap, dragStart, dragMove, dragEnd, solve, wrong, doubleWrong, doubleTap; currentZone = -1; isDoubleTap = false; dragStart = function(){ var psw; psw = slide.levelPlayer.page.pageScrollWrapper; div.pageMaxScrollTop == null && (div.pageMaxScrollTop = psw.scrollHeight - psw.clientHeight); slide.zonePositions = inc("../../../zones/calcZonePositions/calc")(slide); div.divStartPosition = div.position(); div.appendTo(slide.content); div.css({ boxShadow: '2px 2px 6px #bbb' }); setTimeout(function(){ if (!isDoubleTap) { return inc("playSoundA/play")(slide, letter, i); } }, 350); return slide.dragStarted = true; }; dragMove = function(o){ var newZone, z, ref$, ref1$; newZone = inc("detectCollision/detect")(div, slide); if (newZone !== currentZone) { z = slide.zones[currentZone]; if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } if (z != null && !z.solved) { z.css({ backgroundColor: "" }); z.arrow.css({ visibility: "hidden" }); if ((ref$ = z.tooltip) != null) { ref$.css({ visibility: "hidden" }); } } } currentZone = newZone; if (currentZone > -1 && !slide.zones[currentZone].solved) { slide.zones[currentZone].css({ backgroundColor: Color.grey[150] }); slide.zones[currentZone].arrow.css({ visibility: "visible" }); if ((ref1$ = slide.zones[currentZone].tooltip) != null) { ref1$.css({ visibility: "visible" }); } } if (slide.pageIsScrollable) { return inc("scroll/scroll")(slide, o, div); } }; dragEnd = function(onEnd){ var ref$; onEnd.updateAbsolutePosition(); div.css({ boxShadow: '1px 1px 2px #bbb' }); if (currentZone > -1) { inc("check/check")(slide, currentZone, div, solve, wrong); slide.zones[currentZone].arrow.css({ visibility: "hidden" }); if ((ref$ = slide.zones[currentZone].tooltip) != null) { ref$.css({ visibility: "hidden" }); } } currentZone = -1; return slide.dragStarted = false; }; solve = function(){ slide.score.addActionCorrect(slide.atom, { letter: letter, zone: currentZone }); return inc("solve/solve")(div, currentZone, letter, slide); }; wrong = function(){ inc("animateBack/animate")(slide, div); inc("../../../zones/pulse/pulse")(slide, currentZone, Color.red[500]); slide.score.addActionMistake(slide.atom, { letter: letter, zone: currentZone }); return slide.levelPlayer.progressBar.addElement().showRed(); }; doubleWrong = function(){ var offset, newX, newY; offset = slide.zones[currentZone].offset(); newX = offset.left - div.offset().left; newY = offset.top - div.offset().top + offset.height / 3; div.css({ pointerEvents: "none", transform: "translate(" + newX + "px, " + newY + "px)", transition: "500ms" }); return setTimeout(function(){ div.css({ transform: "", pointerEvents: "", transition: "" }); return wrong(); }, 500); }; doubleTap = function(){ var firstEmptyIndex; firstEmptyIndex = _.findIndex(slide.zones, function(z){ return !z.solved; }); if (firstEmptyIndex === -1) { return; } isDoubleTap = true; currentZone = firstEmptyIndex; div.divStartPosition = div.position(); inc("check/check")(slide, currentZone, div, solve, doubleWrong); return setTimeout(function(){ currentZone = -1; return isDoubleTap = false; }, 1000); }; inc("/../app01/lib/util/waitFrames/wait")(4, function(){ if (slide.levelPlayer.page.pageScrollWrapper.isScrollableY) { return slide.pageIsScrollable = true; } }); return div.drag({ onStart: dragStart, onMove: dragMove, onEnd: dragEnd, animation: "none", boundingDiv: slide.div }).gestureTapSequence({ tapSequence: "..", maxDelay: 150, onEnded: doubleTap }).bind("touchstart mousedown", function(e){ return e.preventDefault(); }); }; })(); trainers/dragSpell/elements/element/enableDrag/playSoundA/play.ls (function(){ return function(slide, letter, i){ var text, ref$, voice, ref1$; if (slide.getParam("soundMode", slide.atom) === "a") { text = ((ref$ = slide.atom.sounds) != null ? ref$[i] : void 8) || letter; text = text.trim(); if (text) { voice = slide.getParam("voice", slide.atom); return (ref1$ = slide.sounds[text + voice]) != null ? ref1$.play() : void 8; } } }; })(); trainers/dragSpell/elements/element/enableDrag/scroll/scroll.ls (function(){ var prevHeight, pageTopHeight, pageBottom; return function(slide, o, div){ var page, psw, prevSlides, sl, scroll, y; page = slide.levelPlayer.page; psw = page.pageScrollWrapper; if (prevHeight == null) { prevSlides = page.findAll(".slide").slice(0, -1); pageTopHeight = page.top.height(); pageBottom = window.innerHeight - page.bottom.height() - 50; prevHeight = _.sum((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = prevSlides).length; i$ < len$; ++i$) { sl = ref$[i$]; results$.push(sl.height()); } return results$; }())); } scroll = function(){ if (!slide.dragStarted || !div.scrollDirection) { return; } if (psw.scrollTop > div.pageMaxScrollTop - pageTopHeight && div.scrollDirection !== "up") { div.scrollDirection = null; return; } if (div.scrollDirection === "up" && psw.scrollTop > prevHeight) { psw.scrollTop -= 5; o.updateTranslation({ y: -5, x: 0 }); } else if (div.scrollDirection === "down") { psw.scrollTop += 5; o.updateTranslation({ y: 5, x: 0 }); } return setTimeout(scroll, 50); }; y = o.clientPosition.y; if (y > pageBottom) { div.scrollDirection = "down"; return scroll(); } else if (y < pageTopHeight + 50) { div.scrollDirection = "up"; return scroll(); } else { return div.scrollDirection = null; } }; })(); trainers/dragSpell/elements/element/enableDrag/solve/animateIn/animate.ls (function(){ return function(div, currentZone, slide){ var zone; zone = slide.zones[currentZone]; zone.solved = true; div.css({ padding: 0, width: div.width() + "px", height: div.height() + "px", minWidth: "" }); div.css({ pointerEvents: "none", top: zone.offset().top - slide.content.offset().top + "px", left: zone.offset().left - slide.content.offset().left + "px", width: zone.width() + "px", height: zone.height() + "px", transition: "500ms" }); div.letter.css({ fontSize: zone.letter.css("fontSize"), transition: "500ms" }); return setTimeout(function(){ div.remove(); zone.css({ backgroundColor: Color.grey[150], border: "" }); return zone.letter.css({ color: Color.grey[550], opacity: 1 }); }, 500); }; })(); trainers/dragSpell/elements/element/enableDrag/solve/solve.ls (function(){ return function(div, currentZone, letter, slide){ slide.levelPlayer.progressBar.showGreen(); inc("animateIn/animate")(div, currentZone, slide); if (slide.zones.every(function(z){ return z.solved; })) { slide.score.log(slide.atom); slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 1000); } }; })(); trainers/dragSpell/elements/elements.ls (function(){ return function(slide){ var i$, ref$, len$, i, letter, e, results$ = []; slide.elements = []; for (i$ = 0, len$ = (ref$ = slide.word).length; i$ < len$; ++i$) { i = i$; letter = ref$[i$]; e = inc("element/element")(slide, letter, i); results$.push(slide.elements.push(e)); } return results$; }; })(); trainers/dragSpell/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide, i; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, j$, ref1$, len1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.word = atom.word.split(" "); for (j$ = 0, len1$ = (ref1$ = _.findAllIndices(slide.word, fn$)).length; j$ < len1$; ++j$) { i = ref1$[j$]; slide.word[i] = " "; } slide.totalProgressElements = slide.word.length; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; function fn$(w){ return w === "_"; } }()); }; })(); trainers/dragSpell/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/dragSpell/init.ls (function(){ return function(slide){ slide.zones = []; slide.div.css({ display: "flex", height: "var(--centerHeight)", flexDirection: "column", alignItems: "stretch" }); slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.image = inc("image/image")(slide); slide.zoneWrapper = inc("zones/zones")(slide); slide.content = inc("content/content")(slide); inc("elements/elements")(slide); slide.div.onWindowResize(function(){ return inc("onWindowResize/resize")(slide); }); return requestAnimationFrame(function(){ inc("optimizeLayout/optimize")(slide); return inc("/shared/randomizePositions/randomize")(slide.elements, slide.content); }); }; })(); trainers/dragSpell/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/dragSpell/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/dragSpell/onWindowResize/resize.ls (function(){ return function(slide){ return inc("/../app01/lib/util/waitFrames/wait")(2, function(){ inc("../randomizePositions/randomize")(slide); return inc("../optimizeLayout/optimize")(slide); }); }; })(); trainers/dragSpell/optimizeLayout/optimize.ls (function(){ return function(slide){ var pw, total, i$, ref$, len$, element, length, m, sZone, sEl, fontSizeZone, fontSizeEl, el, w, i, z, minW, ref1$; pw = body.width(); total = slide.word.length; for (i$ = 0, len$ = (ref$ = slide.word).length; i$ < len$; ++i$) { element = ref$[i$]; length = element.replace(/<[^>]+>/g, '').length; if (length > 1) { total += 0.15 * element.length; } } m = inc("/../app01/lib/util/emToPx/emToPx")(0.4) + 3; sZone = Math.max(Math.min(pw / total - m, 70), 19); sEl = Math.max(Math.min(pw / total - m, 70), 57); fontSizeZone = sZone * 0.7; fontSizeEl = sEl * 0.7; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; el.letter.css({ fontSize: fontSizeEl + "px" }); w = el.label.length > 1 ? el.letter.width() + 15 : sEl; el.css({ width: sEl + "px", height: sEl + "px", minWidth: w + "px" }); } for (i$ = 0, len$ = (ref$ = slide.zones).length; i$ < len$; ++i$) { i = i$; z = ref$[i$]; z.letter.css({ fontSize: fontSizeZone + "px" }); minW = z.label.length > 1 ? z.letter.width() + 15 : sZone; z.css({ width: sZone + "px", height: sZone + "px", minWidth: minW + "px" }); if ((ref1$ = z.tooltip) != null) { ref1$.css({ top: "-" + (sZone + z.arrow.height() + 10) + "px", left: 0, width: minW + "px", height: sZone + "px", fontSize: fontSizeZone + "px" }); } } if (slide.content.height() < inc("/../app01/lib/util/emToPx/emToPx")(3)) { slide.div.css({ height: "" }); slide.content.css({ flex: "0 1 200px" }); return inc("../randomizePositions/randomize")(slide); } }; })(); trainers/dragSpell/randomizePositions/randomize.ls (function(){ return function(slide){ return inc("/shared/randomizePositions/layoutForce/layout")({ elements: slide.elements, parentOffset: slide.content.offset(), margin: 5, animated: false }); }; })(); trainers/dragSpell/zones/calcZonePositions/calc.ls (function(){ return function(slide){ var scrollTop, i$, ref$, len$, z, zOffset, results$ = []; scrollTop = slide.levelPlayer.page.pageScrollWrapper.scrollTop; for (i$ = 0, len$ = (ref$ = slide.zones).length; i$ < len$; ++i$) { z = ref$[i$]; zOffset = z.offset(); results$.push({ top: zOffset.top + scrollTop, left: zOffset.left, bottom: zOffset.top + zOffset.height + scrollTop, right: zOffset.left + zOffset.width }); } return results$; }; })(); trainers/dragSpell/zones/pulse/pulse.ls (function(){ return function(slide, currentZone, color){ var zone; zone = slide.zones[currentZone]; zone.css({ backgroundColor: color, transition: "300ms" }); setTimeout(function(){ return zone.css({ backgroundColor: "", transition: "100ms" }); }, 300); return setTimeout(function(){ return zone.css({ transition: "" }); }, 400); }; })(); trainers/dragSpell/zones/zone/arrow/arrow.ls (function(){ return function(div){ return Div({ position: "absolute", top: "-1.7em", left: 0, right: 0, display: "flex", visibility: "hidden" }).append(SvgIcon({ svg: path("/../app01/lib/svg/shape/arrow-top.svg"), width: "1.5em", color: Color.grey[400] }).css({ display: "inline-block", flex: "1 1 auto", transform: "rotate(180deg)" })); }; })(); trainers/dragSpell/zones/zone/tooltip/tooltip.ls (function(){ return function(label){ var letter; return Div({ display: "flex", position: "absolute", left: "-10%", padding: "0.4em", outline: '1px dashed #bbb', backgroundColor: "rgba(255, 255, 255, 0.9)", backgroundClip: "border-box", visibility: "hidden" }).append(letter = Div({ position: "absolute", left: 0, right: 0, top: "-0.1em", color: Color.grey[400] }).html(label)); }; })(); trainers/dragSpell/zones/zone/zone.ls (function(){ return function(slide, label, i){ var playSound, div, letter, arrow; playSound = function(){ var text, ref$, voice, ref1$; text = ((ref$ = slide.atom.sounds) != null ? ref$[i] : void 8) || label; text = text.trim(); if (text) { voice = slide.getParam("voice", slide.atom); return (ref1$ = slide.sounds[text + voice]) != null ? ref1$.play() : void 8; } }; div = Div({ textAlign: "center", verticalAlign: "middle", display: "inline-block", border: '1px dashed #bbb', padding: "0.2em", margin: "0.2em", backgroundClip: "border-box" }).append(letter = Div({ display: "inline-block", color: Color.grey[400] }).html(label), arrow = inc("arrow/arrow")()).tap(slide.getParam("soundMode", slide.atom) === "a" && slide.getParam("showSolution", slide.atom) ? { up: playSound } : void 8); if (!slide.getParam("showSolution", slide.atom)) { letter.css({ opacity: 0 }); } else { div.append(div.tooltip = inc("tooltip/tooltip")(label)); } div.arrow = arrow; div.label = label; div.letter = letter; return div; }; })(); trainers/dragSpell/zones/zones.ls (function(){ return function(slide){ var div, i$, ref$, len$, i, letter, zone; div = Div({ textAlign: "center", display: "inline-block", margin: "1.5em auto", whiteSpace: "nowrap" }); for (i$ = 0, len$ = (ref$ = slide.word).length; i$ < len$; ++i$) { i = i$; letter = ref$[i$]; div.append(zone = inc("zone/zone")(slide, letter, i)); slide.zones.push(zone); } slide.div.append(div); return div; }; })(); trainers/drawLines/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/drawLines/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); texts = []; if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else if (soundMode === "b") { debug("no soundMode b"); } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/drawLines/_preview/preview.ls (function(){ return function(slide){ return slide.interactive.onReady(); }; })(); trainers/drawLines/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, interactive, c, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.interactive.remove(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; interactive = inc("../../interactive/interactive")(slide); interactive.onReady(); if (a.resolved) { interactive.solve(); } else { if (a.selectedLines[0].line != null) { interactive.set(a.selectedLines); } } Div({ margin: "3em 0" }).html(interactive, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).html(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))).appendTo(slide.div); } for (i$ = 0, len$ = (ref$ = slide.div.findAll(".colorPicker")).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.remove()); } return results$; } }; })(); trainers/drawLines/_start/start.ls (function(){ return function(slide){ var ref$; slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.buttons, { padding: 10 }); }); return typeof (ref$ = slide.interactive).onReady == 'function' ? ref$.onReady() : void 8; }; })(); trainers/drawLines/_t.ls (function(){ return { lineNum: { de: "Linie $1", en: "Line $1", fr: "Ligne $1", es: "línea $1", pt: "Linha $1" } }; })(); trainers/drawLines/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).appendTo(slide.div); }; })(); trainers/drawLines/buttons/buttons.ls (function(){ return function(slide){ return Div({ margin: "1em 0" }).html(slide.solveButton = inc("solveButton/button")(slide), slide.clearButton = inc("clearButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide)).appendTo(slide.div); }; })(); trainers/drawLines/buttons/checkButton/button.ls (function(){ return function(slide){ var click, div; click = function(button){ var result; slide.interactive.removeUnfinishedLines(); result = slide.interactive.validate(); if (result.selected.length === 0) { return; } slide.buttons.css({ pointerEvents: "none" }); slide.interactive.removeFeedback(); slide.interactive.showFeedback(result); if (result.isCorrect) { slide.interactive.css({ pointerEvents: "none" }); slide.score.addActionCorrect(slide.atom, { selectedLines: result.selected }); slide.score.log(slide.atom); button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); return setTimeout(slide.finish, 1000); } else { slide.score.addActionMistake(slide.atom, { selectedLines: result.selected }); button.setState("wrong"); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ button.setState("normal"); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } return slide.buttons.css({ pointerEvents: "" }); }, 500); } }; return div = Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/drawLines/buttons/clearButton/button.ls (function(){ return function(slide){ var tap, div; tap = function(){ slide.interactive.clear(); return slide.interactive.removeFeedback(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/bin.svg"), action: tap }).css({ margin: "0.5em" }); }; })(); trainers/drawLines/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, tap, div; showButton = function(){ div.hide(); return div.fadeIn(); }; tap = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: tap, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/drawLines/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, parseSolution, tap, div; showButton = function(){ div.hide(); return div.fadeIn(); }; parseSolution = function(ss){ var i$, len$, s, results$ = []; for (i$ = 0, len$ = ss.length; i$ < len$; ++i$) { s = ss[i$]; results$.push({ x: s.split(",")[0].trim(), y: s.split(",")[1].trim() }); } return results$; }; tap = function(){ slide.buttons.css({ pointerEvents: "none" }); slide.interactive.css({ pointerEvents: "none" }); slide.interactive.solve(); slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom); slide.score.log(slide.atom); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); slide.clearButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); return slide.buttons.css({ pointerEvents: "" }); }, 500); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(tap).hide(); div.showButton = showButton; return div; }; })(); trainers/drawLines/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/drawLines/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); slide.interactive = inc("interactive/interactive")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/drawLines/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/drawLines/interactive/bind/bind.ls (function(){ return function(slide, o){ o.lsg.bind("touchstart", function(e){ e.preventDefault(); slide.levelPlayer.page.pageScrollWrapper.setEnableScrollY(false); o.lastTouch = e; o.lastStartTouch = e; o.isTouchDown = true; return o.click(e, true); }); o.lsg.bind("touchmove", function(e){ o.lastTouch = e; if (o.isTouchDown) { return o.move(e, true); } }); o.lsg.bind("touchend", function(e){ var lastClickAge, ref$; slide.levelPlayer.page.pageScrollWrapper.setEnableScrollY(true); e.preventDefault(); o.isTouchDown = false; lastClickAge = e.timeStamp - ((ref$ = o.lastStartTouch) != null ? ref$.timeStamp : void 8); if (o.lastStartTouch !== o.lastTouch && lastClickAge > 200) { return o.click(o.lastTouch, true); } }); o.lsg.bind("mousemove", function(e){ e.preventDefault(); return o.move(e, false); }); o.lsg.bind("mouseup", function(e){ e.preventDefault(); if (o.isTouchDown) { o.isTouchDown = false; return o.click(e, false); } }); return o.lsg.bind("mousedown", function(e){ return o.isTouchDown = true; }); }; })(); trainers/drawLines/interactive/calcNearestPoint/calc.ls (function(){ return function(e, o){ var pageX, ref$, pageY, x, y, minDist, minIndex, i$, len$, i, p, px, py, dist; pageX = (ref$ = e.pageX) != null ? ref$ : e.touches[0].pageX; pageY = (ref$ = e.pageY) != null ? ref$ : e.touches[0].pageY; x = pageX - o.lsg.offset().left; y = pageY - o.lsg.offset().top; minDist = null; minIndex = -1; for (i$ = 0, len$ = (ref$ = o.points).length; i$ < len$; ++i$) { i = i$; p = ref$[i$]; if (p.disabled) { continue; } px = p.left + p.width / 2; py = p.top + p.height / 2; dist = Math.sqrt(Math.pow(x - px, 2) + Math.pow(y - py, 2)); if (minDist != null) { if (dist < minDist) { minDist = dist; minIndex = i; } } else { minDist = dist; minIndex = i; } } return minIndex; }; })(); trainers/drawLines/interactive/calcSolutions/calc.ls (function(){ return function(o){ var solutions, points, solutionPoints, i, solutionPointsPerIndex, i$, len$, point, classes, j$, len1$, c, classParsed, solutionId, directionId, variantId, that, index, directionIdIndex, ref$, key$; solutions = {}; points = o.lsg.findAll(".point"); solutionPoints = _.filter(points, function(p){ return _.some(p.classes(), function(c){ return _.startsWith(c, "solution"); }); }); i = 0; for (;;) { i++; solutionPointsPerIndex = _.filter(solutionPoints, fn$); if (solutionPointsPerIndex.length === 0) { break; } for (i$ = 0, len$ = solutionPointsPerIndex.length; i$ < len$; ++i$) { point = solutionPointsPerIndex[i$]; classes = _.filter(point.classes(), fn1$); for (j$ = 0, len1$ = classes.length; j$ < len1$; ++j$) { c = classes[j$]; classParsed = c.match(/^solution(\d+)(?:_([ab]))?(?:_variant(\d+))?$/); solutionId = classParsed[1]; directionId = classParsed[2]; variantId = (that = classParsed[3]) ? +that : void 8; if (directionId) { o.validateByDirection = true; } index = _.indexOf(points, point); solutions[solutionId] == null && (solutions[solutionId] = []); if (directionId) { directionIdIndex = directionId.charCodeAt(0) - 97; if (variantId) { (ref$ = solutions[solutionId])[key$ = variantId - 1] == null && (ref$[key$] = []); solutions[solutionId][variantId - 1][directionIdIndex] = index; } else { (ref$ = solutions[solutionId])[0] == null && (ref$[0] = []); solutions[solutionId][0][directionIdIndex] = index; } } else { if (variantId) { (ref$ = solutions[solutionId])[key$ = variantId - 1] == null && (ref$[key$] = []); solutions[solutionId][variantId - 1].push(index); } else { (ref$ = solutions[solutionId])[0] == null && (ref$[0] = []); solutions[solutionId][0].push(index); } } } } } if (o.numberOfLines !== _.values(solutions).length) { debug("The number of specified solutions doesn't match the number of possible lines to draw."); } return solutions; function fn$(p){ return _.some(p.classes(), function(c){ return _.startsWith(c, "solution" + i); }); } function fn1$(c){ return _.startsWith(c, "solution" + i); } }; })(); trainers/drawLines/interactive/clear/clear.ls (function(){ return function(o){ return function(){ var i$, len$, i, ref$, l; if (o.points != null) { for (i$ = 0, len$ = o.points.length; i$ < len$; ++i$) { i = i$; o.highlightPointer(o, false, i); } } o.lines = []; for (i$ = 0, len$ = (ref$ = o.lineContainer.findAll(".line")).length; i$ < len$; ++i$) { l = ref$[i$]; l.remove(); } o.disableNonLinePoints(false); o.lastPoint = -1; o.lastClickPoint = -1; o.currentLineIndex = o.numberOfLines === 1 ? 0 : -1; o.colorPicker.replaceWith(o.colorPicker = inc("../colorPicker/colorPicker")(o)); return o.pointer.hide(); }; }; })(); trainers/drawLines/interactive/click/click.ls (function(){ return function(o){ return function(e, isMobile){ var currentLine, ref$; o.div.removeFeedback(); currentLine = o.lines[o.currentLineIndex]; o.lastClickPoint = (ref$ = o.minIndex) != null ? ref$ : -1; if (isMobile) { o.minIndex = inc("../calcNearestPoint/calc")(e, o); } inc("../setPointer/set")(o); if (_.filter(o.lines, { ready: false }).length === 1) { inc("../drawLine/drawLine")(o, true); } else { if (o.lines.length === 0) { currentLine = inc("../startLine/start")(o); } else { if ((ref$ = o.minIndex) === (currentLine != null ? currentLine.from : void 8) || ref$ === (currentLine != null ? currentLine.to : void 8)) { inc("../undoLine/undo")(o, isMobile); inc("../drawLine/drawLine")(o, false); } else if (o.lines[o.currentLineIndex] != null) { inc("../drawLine/drawLine")(o, true); } else { currentLine = inc("../startLine/start")(o); } } } if (currentLine != null) { if (o.lastClickPoint > -1 && ((ref$ = o.lastClickPoint) !== (currentLine != null ? currentLine.from : void 8) && ref$ !== (currentLine != null ? currentLine.to : void 8))) { o.highlightPointer(o, false, o.lastClickPoint); } if (o.lastPoint > -1 && ((ref$ = o.lastPoint) !== (currentLine != null ? currentLine.from : void 8) && ref$ !== (currentLine != null ? currentLine.to : void 8))) { return o.highlightPointer(o, false, o.lastPoint); } } }; }; })(); trainers/drawLines/interactive/colorPicker/buttonColor/button.ls (function(){ return function(color, i, click){ var div; div = Div({ padding: "0.6em", color: "white", margin: "0.3em 0.5em", display: "inline-block", backgroundColor: color, cursor: "pointer", borderRadius: "4px" }).html(T("lineNum", i + 1)).tap(function(){ return click(i); }); div.setSelected = function(select){ return div.css(select ? { opacity: 1, background: color } : { opacity: 0.2 }); }; return div; }; })(); trainers/drawLines/interactive/colorPicker/colorPicker.ls (function(){ return function(o){ var setActiveButton, div, buttonsColor, i, c; if (o.numberOfLines === 1) { return Div(); } setActiveButton = function(i){ var i$, ref$, len$, j, b, line, newLine; for (i$ = 0, len$ = (ref$ = buttonsColor).length; i$ < len$; ++i$) { j = i$; b = ref$[i$]; if (j === i) { b.setSelected(true); } else { b.setSelected(false); } } if (o.currentLineIndex !== i) { o.removeUnfinishedLines(); line = o.lines[o.currentLineIndex]; newLine = o.lines[i]; o.currentLineIndex = i; if (newLine != null && newLine.ready) { return o.disableNonLinePoints(true); } else { return o.disableNonLinePoints(false); } } }; div = Div({ display: "inline-block", maxWidth: "90%" }).addClass("colorPicker").html(buttonsColor = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = o.colors).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; results$.push(inc("buttonColor/button")(c, i, setActiveButton)); } return results$; }())); setActiveButton(0); div.reset = function(){ return setActiveButton(-1); }; return div; }; })(); trainers/drawLines/interactive/disableNonLinePoints/disable.ls (function(){ return function(o){ return function(disable){ var currentLine, i$, ref$, len$, i, p, results$ = [], results1$ = []; if (engine.isMobileApp) { return; } if (disable) { currentLine = o.lines[o.currentLineIndex]; for (i$ = 0, len$ = (ref$ = o.points).length; i$ < len$; ++i$) { i = i$; p = ref$[i$]; if (i !== currentLine.from && i !== currentLine.to) { results$.push(p.disabled = true); } else { results$.push(p.disabled = false); } } return results$; } else { for (i$ = 0, len$ = (ref$ = o.points || []).length; i$ < len$; ++i$) { p = ref$[i$]; results1$.push(p.disabled = false); } return results1$; } }; }; })(); trainers/drawLines/interactive/drawLine/draw/draw.ls (function(){ return function(o, p1, p2, isClick){ var svg, id, x1, y1, x2, y2, vec, line, markerEndUrl; if (!p1 || !p2) { return; } if (p1.left === p2.left && p1.top === p2.top) { return; } svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; id = o.currentLineIndex; x1 = p1.left; y1 = p1.top; x2 = p2.left; y2 = p2.top; vec = o.pointToPoint ? { as: [x1, y1], bs: [x2, y2] } : inc("lengthen/lengthen")([x1, y1], [x2, y2], 1000); line = svg("line"); if (o.arrowMode) { markerEndUrl = id === -1 ? "url(#arrowEnd-" + o.colors.length + ")" : "url(#arrowEnd-" + id + ")"; line.setAttribute("marker-end", markerEndUrl); } line.attr("x1", vec.as[0] + p1.width / 2); line.attr("y1", vec.as[1] + p1.height / 2); line.attr("x2", vec.bs[0] + p2.width / 2); line.attr("y2", vec.bs[1] + p2.height / 2); line.attr("stroke-width", o.lineSize); line.attr("stroke", o.colors[id] || Color.grey[450]); line.attr("stroke-dasharray", !isClick ? "5, 5" : ""); line.addClass("line"); line.addClass("line" + id); return line; }; })(); trainers/drawLines/interactive/drawLine/draw/lengthen/lengthen.ls (function(){ return function(a, b, l){ var d, ld; d = [b[0] - a[0], b[1] - a[1]]; ld = Math.sqrt(d[0] * d[0] + d[1] * d[1]); d[0] = d[0] / ld; d[1] = d[1] / ld; return { as: [a[0] - d[0] * l, a[1] - d[1] * l], bs: [b[0] + d[0] * l, b[1] + d[1] * l] }; }; })(); trainers/drawLines/interactive/drawLine/drawLine.ls (function(){ return function(o, isClick){ var currentLine, point1, point2, ref$, line; currentLine = o.lines[o.currentLineIndex]; point1 = o.points[currentLine.from]; point2 = o.points[o.minIndex]; if ((ref$ = o.lineContainer.findFirst(".line" + o.currentLineIndex)) != null) { ref$.remove(); } if (!point1 || !point2) { return; } if (!isClick) { line = inc("draw/draw")(o, point1, point2, false); o.lines[o.currentLineIndex].ready = false; delete o.lines[o.currentLineIndex].to; return o.lineContainer.svg.append(line); } else { if (o.minIndex === currentLine.from) { o.highlightPointer(o, false, o.minIndex); delete o.lines[o.currentLineIndex]; return o.disableNonLinePoints(false); } else { line = inc("draw/draw")(o, point1, point2, true); o.lineContainer.svg.append(line); o.highlightPointer(o, true, o.minIndex, o.colors[o.currentLineIndex]); o.lines[o.currentLineIndex].to = o.minIndex; o.lines[o.currentLineIndex].ready = true; o.lines[o.currentLineIndex].line = line; return o.disableNonLinePoints(true); } } }; })(); trainers/drawLines/interactive/get/get.ls (function(){ return function(o){ return function(){ return { lines: o.lines, solutions: o.solutions }; }; }; })(); trainers/drawLines/interactive/highlightPointer/highlight.ls (function(){ return function(o, doHighlight, i, color){ var point, colorStroke, colorFill, strokeWidth; point = o.lsg.find(".point")[i]; if (!point) { return; } color == null && (color = Color.grey[450]); colorStroke = o.points[i].colorStroke || "transparent"; colorFill = o.points[i].colorFill || Color.grey[450]; strokeWidth = o.points[i].strokeWidth || "1"; if (doHighlight) { point.attr("stroke", color); point.attr("stroke-width", "4"); return point.attr("fill", color); } else { point.attr("stroke", colorStroke); point.attr("stroke-width", strokeWidth); return point.attr("fill", colorFill); } }; })(); trainers/drawLines/interactive/init/init.ls (function(){ return function(slide){ var o, ref$, that, defaultColors, customColorsLength, ref1$, res$, i$, i; o = {}; o.pointToPoint = (ref$ = slide.getParam("pointToPoint")) != null ? ref$ : false; o.arrowMode = (ref$ = slide.getParam("arrowMode")) != null ? ref$ : false; o.customColors = (that = slide.getParam("colors")) ? _.ensureArray(that) : void 8; o.lineSize = slide.getParam("lineSize") || 3; o.lines = []; o.points = null; o.minIndex = null; o.lastPoint = -1; o.highlight = null; o.solutions = null; o.isTouchDown = false; o.lastTouch = null; o.lastStartTouch = null; o.history = {}; o.numberOfLines = (ref$ = slide.getParam("lines", slide.atom)) != null ? ref$ : 1; if (!_.isInteger(o.numberOfLines) || !(1 <= (ref$ = o.numberOfLines) && ref$ <= 6)) { debug('The property "lines" must be a whole number between 1 and 6'); o.numberOfLines = Math.max(Math.min(o.numberOfLines, 6), 1); } defaultColors = [Color.blue[500], Color.orange[500], Color.lime[500], Color.cyan.A200, Color.purple[500], Color.purple.A100]; customColorsLength = (ref$ = (ref1$ = o.customColors) != null ? ref1$.length : void 8) != null ? ref$ : 0; res$ = []; for (i$ = 0; i$ <= 5; ++i$) { i = i$; res$.push(((ref$ = o.customColors) != null ? ref$[i] : void 8) || defaultColors[i - customColorsLength]); } o.colors = res$; o.colors = _.slice(o.colors, 0, o.numberOfLines); o.currentLineIndex = o.numberOfLines === 1 ? 0 : -1; o.disableNonLinePoints = inc("../disableNonLinePoints/disable")(o); o.removeUnfinishedLines = inc("../removeUnfinishedLines/remove")(o); o.highlightPointer = inc("../highlightPointer/highlight"); return o; }; })(); trainers/drawLines/interactive/interactive.ls (function(){ return function(slide){ var o; o = inc("init/init")(slide); o.click = inc("click/click")(o); o.move = _.throttle(inc("move/move")(o), 100); o.clear = inc("clear/clear")(o); o.get = inc("get/get")(o); o.set = inc("set/set")(o); o.div = Div({ display: "inline-block" }).html(o.lsg = inc("lsg/lsg")(slide), o.colorPicker = inc("colorPicker/colorPicker")(o)).appendTo(slide.div); o.lineContainer = inc("lineContainer/container")(o).append(o.pointer = inc("pointer/pointer")()); o.div.get = o.get; o.div.set = o.set; o.div.clear = o.clear; o.div.solve = function(){ return inc("solve/solve")(o); }; o.div.onReady = function(){ return inc("onReady/onReady")(slide, o); }; o.div.validate = function(){ return inc("validate/validate")(slide, o); }; o.div.showFeedback = function(result){ return inc("showFeedback/show")(o, result); }; o.div.removeFeedback = function(){ return inc("removeFeedback/remove")(o); }; o.div.removeUnfinishedLines = o.removeUnfinishedLines; return o.div; }; })(); trainers/drawLines/interactive/lineContainer/container.ls (function(){ return function(o){ var div, svg, i, c; div = Div({ position: "absolute", top: 0, left: 0, bottom: 0, right: 0, pointerEvents: "none" }).html(svg = document.createElementNS("http://www.w3.org/2000/svg", "svg").css({ position: "absolute", top: 0, left: 0, width: "100%", height: "100%" }).append(o.arrowMode ? (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = o.colors).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; results$.push(inc("marker/marker")(c, i)); } return results$; }()) : void 8).append(inc("marker/marker")(Color.grey[450], i + 1))); div.svg = svg; return div; }; })(); trainers/drawLines/interactive/lineContainer/marker/marker.ls (function(){ return function(c, i){ var defs; defs = document.createElementNS('http://www.w3.org/2000/svg', "defs"); defs.setAttribute("id", "arrowHeads"); defs.innerHTML = "\n\n"; return defs; }; })(); trainers/drawLines/interactive/lsg/lsg.ls (function(){ return function(slide){ return inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", slide.atom), slide: slide, wrapWithDiv: true }); }; })(); trainers/drawLines/interactive/move/move.ls (function(){ return function(o){ return function(e, isMobile){ var ref$, currentLine; if (!o.div.isVisible()) { return; } o.lastPoint = (ref$ = o.minIndex) != null ? ref$ : -1; o.minIndex = inc("../calcNearestPoint/calc")(e, o); if (o.lastPoint === o.minIndex) { return; } if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } currentLine = o.lines[o.currentLineIndex]; if (!isMobile && (currentLine != null && currentLine.ready) && ((ref$ = o.minIndex) !== currentLine.from && ref$ !== currentLine.to)) { o.minIndex = o.lastPoint; } inc("../setPointer/set")(o); if (currentLine && (isMobile || _.filter(o.lines, { ready: false }).length === 1)) { inc("../drawLine/drawLine")(o, false); } if (isMobile && currentLine != null) { if (o.lastPoint > -1 && ((ref$ = o.lastPoint) !== (currentLine != null ? currentLine.from : void 8) && ref$ !== (currentLine != null ? currentLine.to : void 8))) { o.highlightPointer(o, false, o.lastPoint); } if (o.lastClickPoint > -1 && ((ref$ = o.lastClickPoint) !== (currentLine != null ? currentLine.from : void 8) && ref$ !== (currentLine != null ? currentLine.to : void 8))) { return o.highlightPointer(o, false, o.lastClickPoint); } } }; }; })(); trainers/drawLines/interactive/onReady/addColorsToPoints/add.ls (function(){ return function(o){ var pointSvgs, i$, ref$, len$, i, point, p, results$ = []; pointSvgs = o.lsg.findAll(".point"); for (i$ = 0, len$ = (ref$ = o.points).length; i$ < len$; ++i$) { i = i$; point = ref$[i$]; p = pointSvgs[i]; point.colorFill = p.attr("fill"); point.colorStroke = p.attr("stroke"); results$.push(point.strokeWidth = p.attr("stroke-width")); } return results$; }; })(); trainers/drawLines/interactive/onReady/onReady.ls (function(){ return function(slide, o){ o.points = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(o.lsg, ".point", "absolute"); o.solutions = inc("../calcSolutions/calc")(o); inc("addColorsToPoints/add")(o); o.lsg.append(o.lineContainer); return inc("../bind/bind")(slide, o); }; })(); trainers/drawLines/interactive/pointer/pointer.ls (function(){ return function(){ return Div({ position: "absolute" }).html(Svg({ svg: "\n \n" }).css({ position: "absolute", top: "18.5px", left: "0px", width: "20px" })).hide(); }; })(); trainers/drawLines/interactive/removeFeedback/remove.ls (function(){ return function(o){ var i$, ref$, len$, l, i, c, lineMarker, results$ = []; for (i$ = 0, len$ = (ref$ = o.lineContainer.svg.findAll(".feedbackLine")).length; i$ < len$; ++i$) { l = ref$[i$]; l.remove(); } o.lsg.css({ outline: "" }); if (o.arrowMode) { for (i$ = 0, len$ = (ref$ = o.colors).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; lineMarker = o.lsg.findFirst('#arrowEnd-' + i); results$.push(lineMarker.attr("fill", c)); } return results$; } }; })(); trainers/drawLines/interactive/removeUnfinishedLines/remove.ls (function(){ return function(o){ return function(){ var i$, ref$, len$, j, l, ref1$, ref2$, ref3$, results$ = []; for (i$ = 0, len$ = (ref$ = o.lines).length; i$ < len$; ++i$) { j = i$; l = ref$[i$]; if (l == null || l.ready) { continue; } if ((ref1$ = o.lineContainer.findFirst(".line" + j)) != null) { ref1$.remove(); } o.highlightPointer(o, false, l.from); results$.push((ref3$ = (ref2$ = o.lines)[j], delete ref2$[j], ref3$)); } return results$; }; }; })(); trainers/drawLines/interactive/set/set.ls (function(){ return function(o){ return function(lines){ var i$, len$, i, line, start, end, p1, p2, results$ = []; o.div.clear(); if (!lines) { return; } for (i$ = 0, len$ = lines.length; i$ < len$; ++i$) { i = i$; line = lines[i$]; start = line.line[0]; end = line.line[1]; if (start == null || end == null) { continue; } p1 = o.points[start]; p2 = o.points[end]; o.currentLineIndex = null; line = inc("../drawLine/draw/draw")(o, p1, p2, true); if (line != null) { line.setAttribute("stroke", o.colors[i] || Color.grey[450]); } o.highlightPointer(o, true, start, o.colors[i] || Color.grey[450]); o.highlightPointer(o, true, end, o.colors[i] || Color.grey[450]); results$.push(o.lineContainer.svg.append(line)); } return results$; }; }; })(); trainers/drawLines/interactive/setPointer/set.ls (function(){ return function(o){ var point; point = o.points[o.minIndex]; if (!point) { return; } if (!o.pointer.isVisible()) { o.pointer.show(); } return o.pointer.css({ left: point.left - 10 + point.width / 2 + "px", top: point.top - 28 + point.height / 2 + "px" }); }; })(); trainers/drawLines/interactive/showFeedback/show.ls (function(){ return function(o, result){ var showFeedback, i$, ref$, len$, s; showFeedback = function(lineResult){ var line, color, line2, id, lineMarker; line = _.find(o.lines, function(l){ return ((l != null ? l.from : void 8) === lineResult.line[0] && (l != null ? l.to : void 8) === lineResult.line[1]) || ((l != null ? l.from : void 8) === lineResult.line[1] && (l != null ? l.to : void 8) === lineResult.line[0]); }); if (line == null) { return; } if (!line.ready) { return; } if (line.line != null) { color = lineResult.correct ? Color.green[500] : Color.red[500]; line2 = line.line.clone().addClass("feedbackLine").attr("stroke", color).attr("stroke-width", "7").attr("opacity", "0.5").appendTo(o.lineContainer.svg); if (o.arrowMode) { id = _.find(line.line.classes(), function(c){ return c !== "line"; }).replace("line", ""); lineMarker = o.lsg.findFirst('#arrowEnd-' + id); return lineMarker.attr("fill", color); } } }; for (i$ = 0, len$ = (ref$ = result.selected).length; i$ < len$; ++i$) { s = ref$[i$]; showFeedback(s); } if (!result.isCorrect && _.every(result.selected, function(s){ return s.correct; })) { return o.lsg.css({ outline: "6px solid rgba(244,67,54,0.5)" }); } }; })(); trainers/drawLines/interactive/solve/solve.ls (function(){ return function(o){ var i$, ref$, line, start, end, p1, p2, ref1$, results$ = []; o.div.removeFeedback(); o.clear(); for (i$ in ref$ = o.solutions) { line = ref$[i$]; start = line[0][0]; end = line[0][1]; p1 = o.points[start]; p2 = o.points[end]; o.currentLineIndex = -1; o.highlightPointer(o, true, start, Color.grey[450]); if (!o.arrowMode) { o.highlightPointer(o, true, end, Color.grey[450]); } line = inc("../drawLine/draw/draw")(o, p1, p2, true); o.lineContainer.svg.append(line); results$.push(typeof (ref1$ = o.colorPicker).reset == 'function' ? ref1$.reset() : void 8); } return results$; }; })(); trainers/drawLines/interactive/startLine/start.ls (function(){ return function(o){ o.highlightPointer(o, true, o.minIndex, o.colors[o.currentLineIndex]); return o.lines[o.currentLineIndex] = { ready: false, from: o.minIndex }; }; })(); trainers/drawLines/interactive/undoLine/undo.ls (function(){ return function(o, isMobile){ var currentLine, ref$; o.disableNonLinePoints(false); o.highlightPointer(o, false, o.minIndex); currentLine = o.lines[o.currentLineIndex]; currentLine.ready = false; if (o.minIndex === currentLine.from) { currentLine.from = currentLine.to; } return ref$ = currentLine.to, delete currentLine.to, ref$; }; })(); trainers/drawLines/interactive/validate/validate.ls (function(){ return function(slide, o){ var isCorrect, solutionLines, selectedLines, i$, ref$, len$, l, result, res$, sel, lineCorrect; isCorrect = false; solutionLines = o.solutions; selectedLines = []; for (i$ = 0, len$ = (ref$ = o.lines).length; i$ < len$; ++i$) { l = ref$[i$]; if (l == null) { continue; } selectedLines.push([l.from, l.to]); } if (!o.validateByDirection) { selectedLines = _.map(selectedLines, function(l){ return _.sortBy(l); }); solutionLines = _.map(solutionLines, function(l){ return _.sortBy(l); }); } res$ = []; for (i$ = 0, len$ = selectedLines.length; i$ < len$; ++i$) { sel = selectedLines[i$]; lineCorrect = _.some(solutionLines, fn$); res$.push({ line: sel, correct: lineCorrect }); } result = res$; isCorrect = _.every(solutionLines, function(solutionVariants){ return _.some(solutionVariants, function(sol){ return _.some(selectedLines, function(sel){ return _.isEqual(sol, sel); }); }); }); return { isCorrect: isCorrect, selected: result }; function fn$(solutionVariants){ return _.some(solutionVariants, function(sol){ return _.isEqual(sol, sel); }); } }; })(); trainers/drawLines/textA/text.ls (function(){ return function(slide){ var tap, div, text; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } tap = function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); } }; div = Div(); if (slide.atom.a) { slide.div.append(div.append(text = Div({ margin: "1em auto 0", maxWidth: "90%", width: "30em", display: "inline-block", textAlign: slide.getParam("textAlign", slide.atom) || "center" }).html(slide.atom.a))); } if (slide.getParam("soundMode", slide.atom) === "a") { text.tap(tap); } return div; }; })(); trainers/findAll/_calcTotalProgressElements/calc.ls (function(){ return function(slide, onDone, onError){ var loadMediaFiles, onLoaded; loadMediaFiles = function(){ return slide.loadMediaFiles({ onDone: onLoaded, onError: onError }); }; onLoaded = function(errors){ if ((errors != null ? errors.length : void 8) > 0) { return onDone(errors); } else { slide.totalProgressElements = inc("../calcTotalProgressElements/calc")(slide); return onDone(); } }; return loadMediaFiles(); }; })(); trainers/findAll/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/findAll/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, voiceLang, voice, texts, i$, len$, t; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); texts = []; if (soundMode === "b") { texts = texts.concat(_.map(slide.objects, "sound")); } else if (soundMode === "a" || soundMode === "askSound") { texts.push(slide.atom.sound || slide.atom.a); } if (texts.length > 0) { for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { t = texts[i$]; if (t != null) { sounds.push({ text: t, voice: voice, voiceLang: voiceLang }); } } } return sounds; }; })(); trainers/findAll/_preview/preview.ls (function(){ return function(slide){ var ref$; if ((ref$ = slide.buttonDebug) != null) { ref$.hide(); } slide.zoomDiv.set(); return slide.zoomDiv.frameDiv.html(""); }; })(); trainers/findAll/_review/scoreActions/actionRow/row.ls (function(){ return function(slide, action, elements){ var row; return row = inc("/shared/scoreActionRow/row")(action).css({ textAlign: "left" }).append(inc("../tagIndex/tagIndex")({ tagIndex: action.newIndex || action.index, correct: action.correct, resolved: action.resolved })); }; })(); trainers/findAll/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, elements, indexMap, i$, ref$, len$, action, that, results$ = []; inc("hideZoomIcon/hide")(slide); scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } elements = slide.elements.childrenAll(); indexMap = inc("calcIndexMap/calc")(scoreEvent); for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { action = ref$[i$]; if (that = indexMap[action.index]) { action.newIndex = that; } inc("drawTags/draw")(slide, action, elements); results$.push(slide.div.append(inc("actionRow/row")(slide, action, elements))); } return results$; }; })(); trainers/findAll/_review/scoreActions/calcIndexMap/calc.ls (function(){ return function(scoreEvent){ var indexMap, lastIndex, i, i$, ref$, len$, a; indexMap = {}; lastIndex = -1; i = 0; for (i$ = 0, len$ = (ref$ = _.sortBy(scoreEvent.actions, 'index')).length; i$ < len$; ++i$) { a = ref$[i$]; if (lastIndex === a.index) { continue; } if (a.index !== i) { indexMap[a.index] = i; } i++; lastIndex = a.index; } return indexMap; }; })(); trainers/findAll/_review/scoreActions/drawTags/draw.ls (function(){ return function(slide, action, elements){ var element; element = _.find(elements, function(el){ return action.index === el.elementIndex; }); element.css({ opacity: 1, background: "" }); return element.append(inc("../tagIndex/tagIndex")({ tagIndex: action.newIndex || action.index, correct: action.correct, resolved: action.resolved }).css({ position: "absolute", top: "calc(50% - 0.8em)", left: "calc(50% - 0.5em)" })); }; })(); trainers/findAll/_review/scoreActions/hideZoomIcon/hide.ls (function(){ return function(slide){ var ref$; return (ref$ = slide.div.findFirst(".zoomIcon")) != null ? ref$.css({ visibility: "hidden" }) : void 8; }; })(); trainers/findAll/_review/scoreActions/tagIndex/tagIndex.ls (function(){ return function(o){ if (o.tagIndex != null) { return Div({ display: "inline-block", verticalAlign: "0.2em", fontSize: "0.7em", padding: "0.2em", boxShadow: '0px 0px 2px #bbb', backgroundColor: o.correct ? Color.green[200] : o.resolved ? Color.grey[200] : Color.red[200] }).html(o.tagIndex + 1); } }; })(); trainers/findAll/_start/enableZoomDiv/enable.ls (function(){ return function(slide){ if (slide.enableZoom) { slide.zoomDiv.setEnabled(true); } app.currentPage.updateLayout(); return slide.zoomDiv.set(); }; })(); trainers/findAll/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, element, results$ = []; slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); inc("enableZoomDiv/enable")(slide); for (i$ = 0, len$ = (ref$ = slide.elements.childrenAll()).length; i$ < len$; ++i$) { element = ref$[i$]; results$.push(element.enableTap()); } return results$; }; })(); trainers/findAll/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).css({ margin: "0.5em 0 0.5em 0" }).appendTo(slide.div); }; })(); trainers/findAll/buttonDebug/button.ls (function(){ return function(slide){ var elements, clickModes, tap; elements = slide.elements.findAll(".overlayElement"); clickModes = _.map(elements, "clickMode"); if (!_.includes(clickModes, "rectangle")) { return; } if (!engine.isDebug) { return; } tap = function(){ return inc("tap/tap")(elements); }; return Div({ display: "flex" }).addClass("levelDebugIcon").html(Div({ display: "flex", color: Color.grey[300], padding: "0.2em 0.2em", fontSize: "0.8em", marginTop: "0.2em" }).html(inc("icon/icon")(), "Show rectangles").tap(tap)).appendTo(slide.div); }; })(); trainers/findAll/buttonDebug/icon/icon.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/shape/debug.svg"), color: Color.grey[300] }).css({ marginRight: "0.2em" }); }; })(); trainers/findAll/buttonDebug/tap/tap.ls (function(){ return function(elements){ var i$, len$, el, results$ = []; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { el = elements[i$]; if (el.clickMode === "rectangle") { results$.push(el.css({ opacity: el.style.opacity === "0" ? 0.7 : 0 })); } } return results$; }; })(); trainers/findAll/buttonSolve/button.ls (function(){ return function(slide){ var button; button = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ marginTop: "1em", visibility: "hidden" }).appendTo(slide.div).addClass("solveButton").tap(slide.solve); button.showButton = function(){ return button.css({ visibility: "visible" }).fadeIn(); }; return button; }; })(); trainers/findAll/calcTotalProgressElements/calc.ls (function(){ return function(slide){ var lsgData, total, i$, ref$, len$, c; if (!slide.mediaParams) { return 0; } lsgData = inc("../lsg/getLsgData/get")(slide); total = 0; total += _.filter(lsgData.objects, function(o){ return o['class'] != null && _.includes(o['class'].split(" "), "correct"); }).length; for (i$ = 0, len$ = (ref$ = _.filter(slide.objects, fn$)).length; i$ < len$; ++i$) { c = ref$[i$]; total += _.filter(lsgData.objects, fn1$).length; } return total; function fn$(o){ return o.correct === true && o['class'] !== "correct"; } function fn1$(o){ return o['class'] != null && _.includes(o['class'].split(" "), c['class']); } }; })(); trainers/findAll/elements/calcLsgElements/calc.ls (function(){ return function(slide, classNames){ var selector, lsgElements; if (_.some(classNames, function(name){ return !name; })) { debug("Warning: invalid classNames array, please check the objects array for e.g. indentation mistakes"); } selector = "." + classNames.join(", ."); return lsgElements = slide.lsg.findAll(selector); }; })(); trainers/findAll/elements/element/calcCss/calc.ls (function(){ return function(slide, lsgEl, isCorrect){ var o1, o2; o1 = lsgEl.offset(); o2 = slide.lsg.offset(); return { position: "absolute", top: 100 * (o1.top - o2.top) / o2.height + "%", left: 100 * (o1.left - o2.left) / o2.width + "%", height: 100 * o1.height / o2.height + "%", width: 100 * o1.width / o2.width + "%", opacity: 0, background: isCorrect ? Color.green[300] : Color.red[300] }; }; })(); trainers/findAll/elements/element/element.ls (function(){ return function(slide, lsgEl, i){ var atomObject, isCorrect, clickMode, ref$, tap, div; atomObject = inc("getAtomObject/get")(slide, lsgEl); isCorrect = atomObject != null ? atomObject.correct : void 8; clickMode = (ref$ = slide.getParam("clickMode", atomObject)) != null ? ref$ : "rectangle"; tap = function(e){ return inc("tap/tap")(slide, div, e); }; div = Div(inc("calcCss/calc")(slide, lsgEl, isCorrect)).addClass("overlayElement"); div.elementIndex = i; div.lsgEl = lsgEl; div.atomObject = atomObject; div.isCorrect = isCorrect; div.isDone = false; div.clickMode = clickMode; div.enableTap = function(){ return inc("enableTap/enable")(slide, div, tap); }; return div; }; })(); trainers/findAll/elements/element/enableTap/enable.ls (function(){ return function(slide, div, tap){ var el; el = div.clickMode === "rectangle" ? div : div.lsgEl; return el.tap({ up: tap, animation: "none" }).css({ pointerEvents: "auto", cursor: "default" }); }; })(); trainers/findAll/elements/element/getAtomObject/get.ls (function(){ return function(slide, lsgEl){ var classNames, i$, ref$, len$, o, atomObject; classNames = lsgEl.classes(); for (i$ = 0, len$ = (ref$ = slide.objects).length; i$ < len$; ++i$) { o = ref$[i$]; if (in$(o['class'], classNames)) { atomObject = _.cloneDeep(o); if (atomObject['class'] === "correct") { atomObject.correct = true; } else if (atomObject['class'] === "wrong") { atomObject.correct = false; } return atomObject; } } if (lsgEl.hasClass("correct")) { return { 'class': "correct", correct: true }; } else if (lsgEl.hasClass("wrong")) { return { 'class': "wrong", correct: false }; } else {} }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/findAll/elements/element/tap/_iconFeedback/icon.ls (function(){ return function(slide, div, e, type, autoRemove){ var o, t, l, svg; o = slide.lsg.offset(); t = 100 * (e.clientY - o.top) / o.height + "%"; l = 100 * (e.clientX - o.left) / o.width + "%"; svg = SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-" + type + ".svg"), size: "1em" }).css({ position: "absolute", top: t, left: l, pointerEvents: "none", transform: "translate(-50%, -50%)" }).appendTo(div.parent()); if (autoRemove) { inc("removeTimeout/remove")(svg); } return svg; }; })(); trainers/findAll/elements/element/tap/_iconFeedback/removeTimeout/remove.ls (function(){ return function(svg){ setTimeout(function(){ return svg.fadeOut(200); }, 500); return setTimeout(function(){ return svg.remove(); }, 700); }; })(); trainers/findAll/elements/element/tap/_playSound/calcSoundId/calc.ls (function(){ return function(slide, div){ var text, voiceLang, voice, voiceId; text = div.atomObject.sound; voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); return voiceId = text + voice + voiceLang; }; })(); trainers/findAll/elements/element/tap/_playSound/play.ls (function(){ return function(slide, div, onDone){ var voiceId, ref$; if (!div.atomObject.sound) { return typeof onDone == 'function' ? onDone() : void 8; } if (slide.getParam("soundMode", slide.atom) !== "b") { return typeof onDone == 'function' ? onDone() : void 8; } if (!slide.objects.length > 0) { debug("You must define an objects array with sounds!"); return typeof onDone == 'function' ? onDone() : void 8; } voiceId = inc("calcSoundId/calc")(slide, div); if ((ref$ = slide.currentSound) != null) { ref$.stop(); } slide.currentSound = slide.sounds[voiceId]; return setTimeout(function(){ var ref$; return (ref$ = slide.currentSound) != null ? ref$.play(function(){ delete slide.currentSound; return typeof onDone == 'function' ? onDone() : void 8; }) : void 8; }, 300); }; })(); trainers/findAll/elements/element/tap/onCorrect/colorize/colorize.ls (function(){ return function(obj, element){ var i$, ref$, len$, el, results$ = []; if (obj.color) { if (element.tagName === "g") { for (i$ = 0, len$ = (ref$ = element.find("*")).length; i$ < len$; ++i$) { el = ref$[i$]; el.attr({ style: "" }); results$.push(el.attr({ fill: obj.color })); } return results$; } else { return element.attr({ fill: obj.color }); } } else { return element.attr({ stroke: obj.lineColor }); } }; })(); trainers/findAll/elements/element/tap/onCorrect/on.ls (function(){ return function(slide, div, e, action){ var allDone; slide.levelPlayer.progressBar.showGreen(); slide.totalDone++; div.isDone = true; div.css({ cursor: "default" }); div.lsgEl.css({ cursor: "default" }); if (div.atomObject.color != null || div.atomObject.lineColor != null) { inc("colorize/colorize")(div.atomObject, div.lsgEl); inc("../_iconFeedback/icon")(slide, div, e, "correct", true); } else { inc("../_iconFeedback/icon")(slide, div, e, "correct"); } allDone = slide.totalDone === slide.totalProgressElements; if (allDone) { slide.buttonSolve.css({ visibility: "hidden" }); slide.zoomDiv.disable(); } else { slide.buttonSolve.css({ pointerEvents: "none" }); } return inc("../_playSound/play")(slide, div, function(){ slide.score.addActionCorrect(slide.atom, action); if (allDone) { return slide.onAllDone(); } else { return slide.buttonSolve.css({ pointerEvents: "" }); } }); }; })(); trainers/findAll/elements/element/tap/onWrong/on.ls (function(){ return function(slide, div, e, action){ var i; slide.levelPlayer.progressBar.addElement().showRed(); i = inc("../_iconFeedback/icon")(slide, div, e, "wrong", true); inc("../_playSound/play")(slide, div); slide.score.addActionMistake(slide.atom, action); return setTimeout(function(){ if (!slide.trainerFinished && slide.buttonSolve.css("visibility") === "hidden" && !slide.isSolved) { return slide.buttonSolve.showButton(); } }, 400); }; })(); trainers/findAll/elements/element/tap/tap.ls (function(){ return function(slide, div, e){ var action; if (div.isDone) { return; } action = { index: div.elementIndex, 'class': div.atomObject['class'] }; return inc(div.isCorrect ? "onCorrect/on" : "onWrong/on")(slide, div, e, action); }; })(); trainers/findAll/elements/elements.ls (function(){ return function(slide){ var classNames, lsgElements, i, lsgEl; classNames = inc("getClassNames/get")(slide); lsgElements = inc("calcLsgElements/calc")(slide, classNames); return Div({ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, overflow: "hidden" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = lsgElements).length; i$ < len$; ++i$) { i = i$; lsgEl = ref$[i$]; results$.push(inc("element/element")(slide, lsgEl, i)); } return results$; }())).appendTo(slide.zoomDiv.overlayScaledDiv); }; })(); trainers/findAll/elements/getClassNames/get.ls (function(){ return function(slide){ return _.union(["correct", "wrong"], _.map(slide.objects, "class")); }; })(); trainers/findAll/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.objects = atom.objects ? _.ensureArray(atom.objects) : []; slide.totalProgressElements = inc("calcTotalProgressElements/calc")(slide); slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; slide.enableZoom = (ref1$ = slide.getParam("enableZoom")) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/findAll/init.ls (function(){ return function(slide){ slide.totalDone = 0; slide.solve = function(){ return inc("solve/solve")(slide); }; slide.onAllDone = function(){ return inc("onAllDone/on")(slide); }; slide.lsg = inc("lsg/lsg")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); slide.zoomDiv = inc("zoomDiv/div")(slide); slide.elements = inc("elements/elements")(slide); slide.buttonDebug = inc("buttonDebug/button")(slide); return slide.buttonSolve = inc("buttonSolve/button")(slide); }; })(); trainers/findAll/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/findAll/lsg/getLsgData/get.ls (function(){ return function(slide){ var lsgParams, mediaParams, lsgData, ref$; lsgParams = slide.getParam("lsg", slide.atom); mediaParams = slide.mediaParams; lsgData = _.endsWith(lsgParams.lsg, ".lsg") ? (mediaParams != null ? (ref$ = mediaParams.lsgs) != null ? ref$[lsgParams.lsg] : void 8 : void 8) || inc(lsgParams.lsg) : _.endsWith(lsgParams.lsg, ".lsr") ? inc(lsgParams.lsg)(lsgParams) : (debug("invalid lsg", lsgParams.lsg), null); if (lsgData) { lsgData.renderLanguage = slide.levelParams.contentLanguagePrimary; } return lsgData; }; })(); trainers/findAll/lsg/lsg.ls (function(){ return function(slide){ var lsgData, mp, wCustom, ref$, scale, w, h, svg, i$, ref1$, len$, el; lsgData = inc("getLsgData/get")(slide); mp = slide.mediaParams; wCustom = (ref$ = slide.getParam("lsg", slide.atom)) != null ? ref$.width : void 8; scale = wCustom ? wCustom / lsgData.width : 1; w = scale * lsgData.width; h = scale * lsgData.height; svg = Svg({ svg: LSG2.toSVG(lsgData, mp.svgs, mp.lsgs, mp.images) }).css({ width: w + "px", height: h + "px" }); svg.lsgWidth = w; svg.lsgHeight = h; for (i$ = 0, len$ = (ref1$ = svg.findAll(".ignore")).length; i$ < len$; ++i$) { el = ref1$[i$]; el.css({ pointerEvents: "none" }); } return svg; }; })(); trainers/findAll/onAllDone/finishZoomDiv/finish.ls (function(){ return function(slide){ var zd; zd = slide.zoomDiv; zd.setEnabled(false); zd.setScale({ scale: zd.getMinScale(), animateDuration: 500 }); zd.frameDiv.fadeOut(); return zd.disable(); }; })(); trainers/findAll/onAllDone/on.ls (function(){ return function(slide){ slide.score.log(slide.atom); inc("finishZoomDiv/finish")(slide); return setTimeout(slide.finish, 500); }; })(); trainers/findAll/solve/solve.ls (function(){ return function(slide){ var i$, ref$, len$, el; for (i$ = 0, len$ = (ref$ = slide.div.findAll(".overlayElement")).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.isCorrect && !el.isDone) { inc("solveElement/solve")(slide, el); } } slide.finishButton = true; slide.isSolved = true; slide.zoomDiv.disable(); slide.buttonSolve.css({ visibility: "hidden" }); return slide.onAllDone(); }; })(); trainers/findAll/solve/solveElement/solve.ls (function(){ return function(slide, el){ var o, e, action; o = el.offset(); e = { clientX: o.left + o.width / 2, clientY: o.top + o.height / 2 }; inc("../../elements/element/tap/_iconFeedback/icon")(slide, el, e, "resolved"); action = { index: el.elementIndex, 'class': el.atomObject['class'] }; slide.score.addActionResolved(slide.atom, action); return slide.levelPlayer.progressBar.showGrey(); }; })(); trainers/findAll/textA/text.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } div = inc("/shared/textA/text")(slide).css({ margin: "0.5em 2.5em 1em 2.5em", textAlign: "center", maxWidth: "30em" }).appendTo(slide.div); return div; }; })(); trainers/findAll/zoomDiv/disable/disable.ls (function(){ return function(slide, zoomDiv){ return function(){ var ref$; if ((ref$ = slide.div.findFirst(".zoomIcon")) != null) { ref$.css({ pointerEvents: "none" }); } return zoomDiv.overlayScaledDiv.append(Div({ position: "absolute", left: 0, right: 0, top: 0, bottom: 0, pointerEvents: "auto" })); }; }; })(); trainers/findAll/zoomDiv/div.ls (function(){ return function(slide){ var zoomDiv; Div({ display: "flex" }).html(Div({ display: "flex", alignItems: "flex-start" }).html(slide.enableZoom ? Div({ width: "1.4em" }) : void 8, zoomDiv = ZoomDiv({ contentHtml: slide.lsg, enabled: false, resizeSelf: true }).css({ outline: slide.enableZoom ? "1px solid " + Color.grey[200] : "", maxWidth: "10em", maxHeight: "10em" }), slide.enableZoom ? inc("zoomIcon/icon")(slide) : void 8)).appendTo(slide.div); zoomDiv.disable = inc("disable/disable")(slide, zoomDiv); zoomDiv.set = inc("setZoomDivSettings/set")(slide, zoomDiv); zoomDiv.onWindowResize(inc("onWindowResize/on")(zoomDiv)); return zoomDiv; }; })(); trainers/findAll/zoomDiv/onWindowResize/on.ls (function(){ return function(zoomDiv){ return function(){ zoomDiv.set(); return inc("/../app01/lib/util/waitFrames/wait")(2, zoomDiv.set); }; }; })(); trainers/findAll/zoomDiv/setZoomDivSettings/calcMaxHeight/calc.ls (function(){ return function(slide){ var centerHeight; centerHeight = inc("calcCenterHeight/calc")(slide); if (slide.enableZoom) { return (centerHeight - slide.instruction.offsetHeight - 100) * 0.8; } else { return centerHeight - slide.instruction.offsetHeight; } }; })(); trainers/findAll/zoomDiv/setZoomDivSettings/calcMaxHeight/calcCenterHeight/calc.ls (function(){ return function(slide){ return +slide.levelPlayer.page.pageWrapper.cssVar("centerHeight").replace("px", ""); }; })(); trainers/findAll/zoomDiv/setZoomDivSettings/calcMaxWidth/calc.ls (function(){ return function(slide){ if (slide.enableZoom) { return slide.div.offsetWidth - 60; } else { return slide.div.offsetWidth - 20; } }; })(); trainers/findAll/zoomDiv/setZoomDivSettings/calcScale/calc.ls (function(){ return function(slide, maxHeight, maxWidth){ var w, h, scaleX, scaleY, scale; w = slide.lsg.lsgWidth; h = slide.lsg.lsgHeight; scaleX = w > maxWidth ? maxWidth / w : 1; scaleY = h > maxHeight ? maxHeight / h : 1; return scale = Math.min(scaleX, scaleY); }; })(); trainers/findAll/zoomDiv/setZoomDivSettings/set.ls (function(){ return function(slide, zoomDiv){ return function(){ var maxWidth, maxHeight, scale; maxWidth = inc("calcMaxWidth/calc")(slide); maxHeight = slide.levelPlayer ? inc("calcMaxHeight/calc")(slide) : slide.div.offsetHeight; scale = inc("calcScale/calc")(slide, maxHeight, maxWidth); zoomDiv.css({ maxWidth: maxWidth + "px", maxHeight: maxHeight + "px" }).setScale({ scale: scale, minScale: scale, maxScale: scale * 4 }); slide.lsg.remove(); return zoomDiv.contentDiv.append(slide.lsg); }; }; })(); trainers/findAll/zoomDiv/zoomIcon/icon.ls (function(){ return function(slide){ var tap; tap = function(){ var zd; zd = slide.zoomDiv; return zd.setScale({ scale: zd.getCurrentScale() > 1 ? 0.3 : 2 }); }; return Div({ display: "flex", width: "1.4em", height: "1.4em" }).html(SvgIcon({ svg: path("magnifier.svg"), color: Color.grey[400], size: "0.9em" })).tap({ up: tap, tapZone: "0.5em" }).addClass("zoomIcon"); }; })(); trainers/findAll/zoomDiv/zoomIcon/magnifier.svg trainers/findAny/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/findAny/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, voiceLang, voice, texts, i$, len$, t, voices, soundTexts, ref$, lang, langShort; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); texts = []; if (soundMode === "a" || soundMode === "askSound") { texts.push(slide.atom.sound || slide.atom.a); } if (texts.length > 0) { for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { t = texts[i$]; if (t != null) { sounds.push({ text: t, voice: voice, voiceLang: voiceLang }); } } } voices = { de: "f5", en_gb: "f3", en: "f8Us", fr: "f1", es: "f1EsUs", pt: "f6" }; soundTexts = { de: "Hier siehst du eine mögliche Lösung", en: "Here is a possible solution", fr: "Voici une solution", es: "Esta es una solución posible", pt: "Aqui você pode ver uma possível solução" }; for (i$ = 0, len$ = (ref$ = ["de", "en_gb", "en", "fr", "es", "pt"]).length; i$ < len$; ++i$) { lang = ref$[i$]; langShort = lang.slice(0, 2); sounds.push({ text: soundTexts[lang] || soundTexts[langShort], voiceLang: langShort, voice: voices[lang] }); } return sounds; }; })(); trainers/findAny/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/findAny/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, lsg, elements, fillColor, j$, ref1$, len1$, j, results$ = []; slide.buttons.remove(); e = slide.score.getScoreEvent(slide.atom); if (e) { slide.lsgWrapper.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; lsg = slide.lsgWrapper.clone().css({ marginBottom: "1em" }); elements = lsg.findAll(".clickable"); if (a.correct) { lsg.css({ outline: "5px solid " + Color.green[500] }); } else if (!a.resolved) { lsg.css({ outline: "5px solid " + Color.red[500] }); } fillColor = slide.getParam("fillColor", slide.atom) || Color.blue[700]; for (j$ = 0, len1$ = (ref1$ = a.selectedIndices).length; j$ < len1$; ++j$) { j = ref1$[j$]; elements[j].attr({ fill: fillColor }); } results$.push(slide.div.append(Div({ margin: "3em 0" }).append(lsg, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))))); } return results$; } }; })(); trainers/findAny/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.buttons, { padding: 50 }); }); }; })(); trainers/findAny/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/findAny/buttons/buttons.ls (function(){ return function(slide){ return Div({ margin: "1em 0" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide)).appendTo(slide.div); }; })(); trainers/findAny/buttons/checkButton/button.ls (function(){ return function(slide){ var click; click = function(){ var result; slide.buttons.css({ pointerEvents: "none" }); result = slide.validate(); if (!result.isCorrect) { slide.lsgWrapper.css({ outline: "5px solid " + Color.red[500] }); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ slide.score.addActionMistake(slide.atom, { selectedIndices: result.selectedIndices }); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } slide.buttons.css({ pointerEvents: "" }); return slide.lsgWrapper.css({ outline: "" }); }, 500); } else { slide.lsgWrapper.css({ outline: "5px solid " + Color.green[500] }); slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atom, { selectedIndices: result.selectedIndices }); slide.score.log(slide.atom); slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 1000); } }; return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/findAny/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/findAny/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ var voice, text, result; voice = twitch({ de: "f5", en_gb: "f3", en: "f8Us", fr: "f1", es: "f1EsUs", pt: "f6" }); text = T("possibleSolution"); slide.sounds[text + voice].play(); slide.buttons.css({ pointerEvents: "none" }); slide.lsgWrapper.css({ pointerEvents: "none" }); result = slide.solve(); slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom, { selectedIndices: result.selectedIndices }); slide.score.log(slide.atom); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); return slide.buttons.css({ pointerEvents: "" }); }, 500); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/findAny/elements/element/element.ls (function(){ return function(slide, i, element){ var defaultColor, fillColor, selected, toggle; defaultColor = element.getAttribute("fill"); fillColor = slide.getParam("fillColor", slide.atom) || Color.blue[700]; selected = false; toggle = function(){ var i$, ref$, len$, el, f, results$ = []; selected = !selected; if (defaultColor) { return element.attr({ fill: selected ? fillColor : defaultColor }); } else { for (i$ = 0, len$ = (ref$ = element.findAll("*")).length; i$ < len$; ++i$) { el = ref$[i$]; if (f = el.attr("fill")) { if (el.attr("defaultFill") == null) { el.attr("defaultFill", f); } results$.push(el.attr({ fill: selected ? fillColor : el.attr("defaultFill") })); } } return results$; } }; element.tap({ up: toggle, animation: "none" }).css({ cursor: "initial" }); element.isSelected = function(){ return selected; }; element.toggle = toggle; return element; }; })(); trainers/findAny/elements/elements.ls (function(){ return function(slide){ var i$, ref$, len$, i, selector, elements, element; for (i$ = 0, len$ = (ref$ = slide.lsgWrapper.findAll(".ignore")).length; i$ < len$; ++i$) { i = ref$[i$]; i.css({ pointerEvents: "none" }); } selector = ".clickable"; return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.lsgWrapper.findAll(selector)).length; i$ < len$; ++i$) { i = i$; element = ref$[i$]; results$.push(inc("element/element")(slide, i, element)); } return results$; }()); }; })(); trainers/findAny/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/findAny/init.ls (function(){ return function(slide){ slide.totalGreen = slide.totalProgressElements; slide.currentGreen = 0; slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); slide.lsgWrapper = inc("lsg/lsg")(slide); slide.buttons = inc("buttons/buttons")(slide); slide.elements = inc("elements/elements")(slide); slide.validate = inc("validate/validate")(slide); return slide.solve = inc("solve/solve")(slide); }; })(); trainers/findAny/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/findAny/lsg/lsg.ls (function(){ return function(slide){ var lsg, div; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); if (!div) { return; } div.appendTo(slide.div); if (typeof div.updateLayout == 'function') { div.updateLayout(); } return div; }; })(); trainers/findAny/solve/solve.ls (function(){ return function(slide){ return function(){ var selectedElements, selected, correct, diff, i$, i, to$, el; selectedElements = _.filter(slide.elements, function(el){ return el.isSelected(); }); selected = selectedElements.length; correct = slide.atom.correct; diff = selected - correct; if (selected >= correct) { for (i$ = 1; i$ <= diff; ++i$) { i = i$; selectedElements[selectedElements.length - i].toggle(); } } else { for (i$ = 0, to$ = slide.elements.length; i$ < to$; ++i$) { i = i$; if (diff === 0) { break; } el = slide.elements[i]; if (el.isSelected()) { continue; } else { el.toggle(); diff++; } } } return { selectedIndices: _.findAllIndices(slide.elements, function(el){ return el.isSelected(); }) }; }; }; })(); trainers/findAny/textA/text.ls (function(){ return function(slide){ var click, div, text; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } click = function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); } }; div = Div(); if (slide.atom.a) { div.append(text = Div({ margin: "0.5em 0.5em", padding: "0 0.5em", display: "inline-block" }).html(slide.atom.a)).appendTo(slide.div); } if (slide.getParam("soundMode", slide.atom) === "a") { text.tap(click); } return div; }; })(); trainers/findAny/validate/validate.ls (function(){ return function(slide){ return function(){ var selected; selected = _.filter(slide.elements, function(el){ return el.isSelected(); }).length; return { isCorrect: selected === slide.atom.correct, selectedIndices: _.findAllIndices(slide.elements, function(el){ return el.isSelected(); }) }; }; }; })(); trainers/findOnImage/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image"); }; })(); trainers/findOnImage/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg"); }; })(); trainers/findOnImage/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, text; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); text = atom.sound ? atom.sound : soundMode === "a" ? atom.a : soundMode === "askSound" ? atom.a : soundMode === "b" ? atom.a : void 8; if (text != null) { sounds.push({ text: text, voice: slide.getParam("voice", atom), voiceLang: slide.getParam("voiceLang", atom) }); } } return sounds; }; })(); trainers/findOnImage/_preview/preview.ls (function(){ return function(slide){ var atom, ref$; slide.header.css({ opacity: 1, fontSize: "1em", color: Color.grey[700] }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(atom.a); } return results$; }()).join(", ")); return (ref$ = slide.debugTrigger) != null ? ref$.remove() : void 8; }; })(); trainers/findOnImage/_review/scoreActions/actionIcon/icon.ls (function(){ return function(action, type){ return Div({ display: "inline-block", position: "absolute", left: action.left + "%", top: action.top + "%", width: "0.8em", height: "0.8em", margin: "-0.4em", borderRadius: "50%" }).html(SvgIcon({ svg: (function(){ switch (type) { case "resolved": return path("/../app01/lib/svg/illustration/feedback-resolved.svg"); case "correct": return path("/../app01/lib/svg/illustration/feedback-correct.svg"); case "wrong": return path("/../app01/lib/svg/illustration/feedback-wrong.svg"); } }()) }).css({ position: "absolute", width: "0.8em", height: "0.8em" })); }; })(); trainers/findOnImage/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, atom, e, actions, j$, len1$, a, solvedAndCorrectActions, matchingWrongs, div, i, action, wrongAction; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; e = slide.score.getScoreEvent(atom); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.originalAtom = e.atom; actions.push(a); } } solvedAndCorrectActions = _.orderBy(_.filter(actions, function(a){ return a.correct || a.resolved; }), "position"); for (i$ = 0, len$ = solvedAndCorrectActions.length; i$ < len$; ++i$) { a = solvedAndCorrectActions[i$]; matchingWrongs = _.filter(actions, fn$); a.matchingWrongs = matchingWrongs; } if (actions.length === 0) { return; } div = Div({ textAlign: "left", marginTop: "3em" }).appendTo(slide.div); for (i$ = 0, len$ = solvedAndCorrectActions.length; i$ < len$; ++i$) { i = i$; action = solvedAndCorrectActions[i$]; if (action.matchingWrongs.length > 0) { wrongAction = { correct: false }; inc("/shared/scoreActionRow/row")(wrongAction, i).append(inc("mistake/mistake")(action.matchingWrongs, slide)).appendTo(div); } inc("/shared/scoreActionRow/row")(action, i).append(action.resolved ? inc("resolved/resolved")(action, slide) : inc("correct/correct")(action, slide)).appendTo(div); } return div; function fn$(wa){ return !wa.correct && !wa.resolved && wa.originalAtom === a.originalAtom; } }; })(); trainers/findOnImage/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ var imageOrLsg, check; imageOrLsg = inc("../imageOrLsg/imageOrLsg")(slide).css({ marginTop: "0.5em", width: "5em", height: "5em" }).append(check = inc("../actionIcon/icon")(action, "correct")); return Div({ display: "inline-block" }).append(action.originalAtom.a + "
", imageOrLsg); }; })(); trainers/findOnImage/_review/scoreActions/imageOrLsg/imageOrLsg.ls (function(){ return function(slide){ var lsg, image; lsg = slide.getParam("lsg"); image = slide.getParam("image"); if (lsg) { return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }); } else if (image) { return inc("/shared/image/image")({ image: image, slide: slide }); } }; })(); trainers/findOnImage/_review/scoreActions/mistake/mistake.ls (function(){ return function(actions, slide){ var imageOrLsg, i$, len$, a; imageOrLsg = inc("../imageOrLsg/imageOrLsg")(slide).css({ marginTop: "0.5em", width: "5em", height: "5em" }); for (i$ = 0, len$ = actions.length; i$ < len$; ++i$) { a = actions[i$]; imageOrLsg.append(inc("../actionIcon/icon")(a, "wrong")); } return Div({ display: "inline-block" }).append(T("youMadeNumMistakesAt", actions[0].originalAtom.a, actions.length), imageOrLsg); }; })(); trainers/findOnImage/_review/scoreActions/resolved/resolved.ls (function(){ return function(action, slide){ var imageOrLsg, check; imageOrLsg = inc("../imageOrLsg/imageOrLsg")(slide).css({ marginTop: "0.5em", width: "5em", height: "5em" }).append(check = inc("../actionIcon/icon")(action, "resolved")); return Div({ display: "inline-block" }).append(action.originalAtom.a + "
", imageOrLsg); }; })(); trainers/findOnImage/_start/start.ls (function(){ return function(slide){ slide.startNextElement(); return slide.instruction.play(function(){ if (slide.instruction.sound != null) { return slide.header.playAtom(); } }); }; })(); trainers/findOnImage/_t.ls (function(){ return { youMadeNumMistakesAt: { de: "Bei '$1' hast du $2 Fehler gemacht
", en: "You made (($2 mistake | $2 mistakes)) in '$1'
", fr: "Tu as fait (($2 erreur | $2 erreurs)) pour “$1”
", es: "Cometiste (($2 errores | $2 errores)) en '$1'
", pt: "Você cometeu (($2 erro | $2 erros)) em '$1'
" } }; })(); trainers/findOnImage/buttons/buttons.ls (function(){ return function(slide){ return Div({ margin: "2em 0 1em", minHeight: "3.6em" }).html(slide.solveButton = inc("solveButton/button")(slide)).appendTo(slide.div); }; })(); trainers/findOnImage/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, tap, div; showButton = function(){ slide.levelPlayer.page.centerDuration = 300; div.hide(); return div.fadeIn(); }; tap = function(){ slide.levelPlayer.page.centerDuration = 0; slide.solve(); return div.hide(); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(tap).hide(); div.showButton = showButton; return div; }; })(); trainers/findOnImage/clickContainer/calcScorePosition/calc.ls (function(){ return function(slide, e, div){ var x, ref$, ref1$, y, ref2$; x = (((ref$ = (ref1$ = e.touches) != null ? ref1$[0].pageX : void 8) != null ? ref$ : e.pageX) - div.offset().left) / div.width() * 100; x += x > 95 ? -2 : x < 5 ? 2 : 0; y = (((ref$ = (ref2$ = e.touches) != null ? ref2$[0].pageY : void 8) != null ? ref$ : e.pageY) - div.offset().top) / div.width() * 100; y += y > 95 ? -2 : y < 5 ? 2 : 0; return { top: _.round(y), left: _.round(x) }; }; })(); trainers/findOnImage/clickContainer/container.ls (function(){ return function(slide){ var wrongClick, div; slide.currentMistakes = []; wrongClick = function(e){ var ref$, pageX, ref1$, ref2$, pageY, ref3$, wrong, pos; if (((ref$ = e.touches) != null ? ref$.length : void 8) > 1) { return; } pageX = (ref1$ = (ref2$ = e.touches) != null ? ref2$[0].pageX : void 8) != null ? ref1$ : e.pageX; pageY = (ref1$ = (ref3$ = e.touches) != null ? ref3$[0].pageY : void 8) != null ? ref1$ : e.pageY; div.append(wrong = inc("../icon/icon")("wrong")); wrong.showAt(pageX - div.offset().left, pageY - div.offset().top, function(){ return wrong.remove(); }); pos = inc("calcScorePosition/calc")(slide, e, div); slide.score.addActionMistake(slide.currentAtom, pos); slide.levelPlayer.progressBar.addElement().showRed(); return slide.solveButton.showButton(); }; return div = Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }).tap({ up: wrongClick, animation: "none" }).css({ cursor: "initial" }).appendTo(slide.wrapper); }; })(); trainers/findOnImage/clickContainer/iconWrongTemp/icon.ls (function(){ return function(){ var showAt, div; showAt = function(x, y, onDone){ var diff; diff = inc("/../app01/lib/util/emToPx/emToPx")(0.75); div.css({ left: _.round(x - diff) + "px", top: _.round(y - diff) + "px" }).show(); return setTimeout(function(){ return div.fadeOut(300, onDone); }, 400); }; div = Div({ display: "inline-block", position: "absolute" }).append(Svg({ svg: path("/../app01/lib/svg/illustration/feedback-wrong.svg"), size: "1.5em" })).hide(); div.showAt = showAt; return div; }; })(); trainers/findOnImage/clickContainer/markPosition/mark.ls (function(){ return function(slide, e, div){ var x, ref$, ref1$, y, ref2$, actionObject; x = (((ref$ = (ref1$ = e.touches) != null ? ref1$[0].pageX : void 8) != null ? ref$ : e.pageX) - div.offset().left) / div.width() * 100; x += x > 95 ? -2 : x < 5 ? 2 : 0; y = (((ref$ = (ref2$ = e.touches) != null ? ref2$[0].pageY : void 8) != null ? ref$ : e.pageY) - div.offset().top) / div.width() * 100; y += y > 95 ? -2 : y < 5 ? 2 : 0; actionObject = { top: _.round(y), left: _.round(x) }; return slide.score.addActionMistake(slide.currentAtom, actionObject); }; })(); trainers/findOnImage/debugTrigger/trigger.ls (function(){ return function(slide){ var showGrid, toggleShowElements, toggleShowGrid, div; if (!engine.isDebug) { return; } showGrid = false; toggleShowElements = function(){ var i$, ref$, len$, e, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { e = ref$[i$]; if (showGrid) { results$.push(e.showDebug()); } else { results$.push(e.hideDebug()); } } return results$; }; toggleShowGrid = function(){ if (showGrid) { return slide.grid.show(); } else { return slide.grid.hide(); } }; div = Div({ position: "absolute", right: "0", bottom: "-1.5em", color: Color.grey[300], display: "inline-block" }).addClass("levelDebugIcon").html("Debug: Show grid").tap(function(){ showGrid = !showGrid; toggleShowGrid(); return toggleShowElements(); }).appendTo(slide.wrapper); return div; }; })(); trainers/findOnImage/elements/element/calcScorePosition/calc.ls (function(){ return function(slide, e){ var div, pageX, ref$, ref1$, pageY, ref2$, offset, x, y; div = slide.clickContainer; pageX = (ref$ = (ref1$ = e.touches) != null ? ref1$[0].pageX : void 8) != null ? ref$ : e.pageX; pageY = (ref$ = (ref2$ = e.touches) != null ? ref2$[0].pageY : void 8) != null ? ref$ : e.pageY; offset = div.offset(); x = (pageX - offset.left) / offset.width * 100; x += x > 95 ? -2 : x < 5 ? 2 : 0; y = (pageY - offset.top) / offset.width * 100; y += y > 95 ? -2 : y < 5 ? 2 : 0; return { top: _.round(y), left: _.round(x) }; }; })(); trainers/findOnImage/elements/element/debugLabel/label.ls (function(){ return function(label){ return Div().addClass("debugLabel").css({ position: "absolute", top: "50%", left: 0, right: 0, marginTop: "-0.7em" }).html(label).hide(); }; })(); trainers/findOnImage/elements/element/element.ls (function(){ return function(atom, i, slide){ var start, tap, showDebug, hideDebug, div, debugLabel, check; start = function(){ return div.show(); }; tap = function(e){ var ref$, pageX, ref1$, ref2$, pageY, ref3$, pos; if (((ref$ = e.touches) != null ? ref$.length : void 8) > 1) { return; } pageX = (ref1$ = (ref2$ = e.touches) != null ? ref2$[0].pageX : void 8) != null ? ref1$ : e.pageX; pageY = (ref1$ = (ref3$ = e.touches) != null ? ref3$[0].pageY : void 8) != null ? ref1$ : e.pageY; check.showAt(pageX - slide.clickContainer.offset().left, pageY - slide.clickContainer.offset().top); pos = inc("calcScorePosition/calc")(slide, e); div.css({ pointerEvents: "none" }); slide.clickContainer.css({ pointerEvents: "none" }); slide.solveButton.hide(); slide.levelPlayer.progressBar.showGreen(); slide.lastSolvedAtom = atom; return inc("../../playSoundB/play")(slide, function(){ return slide.score.addActionCorrect(atom, pos, function(){ return slide.score.log(atom, function(){ slide.header.finishAtom(); return slide.startNextElement(); }); }); }); }; showDebug = function(){ div.css({ backgroundColor: "rgba(255,255,255,0.4)", border: "3px dashed purple", color: "purple", overflow: "hidden", fontSize: "0.7em" }); return debugLabel.show(); }; hideDebug = function(){ div.css({ backgroundColor: "", textAlign: "", border: "", color: "" }); return debugLabel.hide(); }; slide.clickContainer.append(div = Div({ position: "absolute", top: atom.y1 + "%", left: atom.x1 + "%", width: (atom.x2 - atom.x1) + "%", height: (atom.y2 - atom.y1) + "%" }).append(debugLabel = inc("debugLabel/label")(atom.a)).tap({ up: tap, animation: "none" }).css({ cursor: "initial" }).hide(), check = inc("../../icon/icon")("correct")); div.start = start; div.showDebug = showDebug; div.hideDebug = hideDebug; return div; }; })(); trainers/findOnImage/elements/elements.ls (function(){ return function(slide){ var i, atom; return slide.elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; results$.push(inc("element/element")(atom, i, slide)); } return results$; }()); }; })(); trainers/findOnImage/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = _.ensureArray(atoms).length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/findOnImage/grid/grid.ls (function(){ return function(slide){ var div, i$, i; div = Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }).hide(); for (i$ = 0; i$ <= 10; ++i$) { i = i$; div.append(inc("lines/vertical/number")(i), inc("lines/vertical/line")(i), inc("lines/horizontal/number")(i), inc("lines/horizontal/line")(i)); } slide.wrapper.append(div); return div; }; })(); trainers/findOnImage/grid/lines/horizontal/line.ls (function(){ return function(i){ var toPercent, div; toPercent = function(crd){ return crd * 10 + "%"; }; return div = Div({ position: "absolute", top: toPercent(i), backgroundColor: "black", height: "2px", width: "100%" }); }; })(); trainers/findOnImage/grid/lines/horizontal/number.ls (function(){ return function(i){ var toPercent; toPercent = function(crd){ return crd * 10 + "%"; }; return Div().html(i * 10 + "").css({ position: "absolute", top: toPercent(i), left: "-1.5em", marginTop: "-0.6em" }); }; })(); trainers/findOnImage/grid/lines/vertical/line.ls (function(){ return function(i){ var toPercent; toPercent = function(crd){ return crd * 10 + "%"; }; return Div({ position: "absolute", left: toPercent(i), backgroundColor: "black", height: "100%", width: "2px" }); }; })(); trainers/findOnImage/grid/lines/vertical/number.ls (function(){ return function(i){ var toPercent; toPercent = function(crd){ return crd * 10 + "%"; }; return Div().html(i * 10 + "").css({ position: "absolute", left: toPercent(i), top: "-1.5em", marginLeft: "-0.4em" }); }; })(); trainers/findOnImage/header/header.ls (function(){ return function(slide){ var div; slide.div.append(div = slide.getParam("soundMode") === "askSound" ? inc("headerSound/headerSound")(slide) : inc("headerText/headerText")(slide)); return div; }; })(); trainers/findOnImage/header/headerSound/headerSound.ls (function(){ return function(slide){ var playAtom, startAtom, finishAtom, speaker; playAtom = function(){ var atom, text, voice; atom = slide.currentAtom; if (atom === slide.lastSolvedAtom) { return; } text = atom.sound || atom.a; voice = slide.getParam("voice", atom); return speaker.play(text + voice); }; startAtom = function(){ var atom; atom = slide.currentAtom; if (!atom.sound && !atom.a) { return speaker.hide(); } else { return speaker.show().css({ opacity: 1, transition: "150ms opacity" }); } }; finishAtom = function(){ return speaker.css({ opacity: 0 }); }; speaker = inc("/shared/askSound/ask")(slide.sounds).css({ marginBottom: "1em" }); speaker.startAtom = startAtom; speaker.playAtom = playAtom; speaker.finishAtom = finishAtom; return speaker; }; })(); trainers/findOnImage/header/headerText/headerText.ls (function(){ return function(slide){ var playAtom, startAtom, finishAtom, div; playAtom = function(){ var atom; atom = slide.currentAtom; if (atom === slide.lastSolvedAtom) { return; } if (slide.getParam("soundMode", atom) === "a") { return setTimeout(function(){ var text, voice; text = atom.sound || atom.a; voice = slide.getParam("voice", atom); return slide.sounds[text + voice].play(); }, 500); } }; startAtom = function(){ var atom; atom = slide.currentAtom; if (!atom.a) { return div.hide(); } else { div.show().html(atom.a); return setTimeout(function(){ return div.css({ opacity: 1, transition: "opacity 500ms" }); }, 500); } }; finishAtom = function(){ return div.css({ opacity: 0, transition: "" }); }; div = Div({ padding: "0.5em 0.5em 1em", margin: "0 auto", width: "30em", maxWidth: "90%" }).html(" "); div.startAtom = startAtom; div.playAtom = playAtom; div.finishAtom = finishAtom; return div; }; })(); trainers/findOnImage/icon/icon.ls (function(){ return function(type){ var showAt, div; showAt = function(x, y, onDone){ var diff; diff = inc("/../app01/lib/util/emToPx/emToPx")(0.75); div.css({ left: _.round(x - diff) + "px", top: _.round(y - diff) + "px" }).show(); if (onDone) { return setTimeout(function(){ return div.fadeOut(300, onDone); }, 400); } }; div = Div({ display: "inline-block", position: "absolute" }).append(SvgIcon({ svg: (function(){ switch (type) { case "resolved": return path("/../app01/lib/svg/illustration/feedback-resolved.svg"); case "correct": return path("/../app01/lib/svg/illustration/feedback-correct.svg"); case "wrong": return path("/../app01/lib/svg/illustration/feedback-wrong.svg"); } }()), size: "1.5em" })).hide(); div.showAt = showAt; return div; }; })(); trainers/findOnImage/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image"); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide }).css(!image.width ? { width: 300 + "px", height: 300 + "px" } : void 8).appendTo(slide.wrapper); }; })(); trainers/findOnImage/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.div.css({ marginBottom: "1em" }); slide.solve = inc("solve/solve")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.header = inc("header/header")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.image = inc("image/image")(slide); slide.lsgWrapper = inc("lsg/lsg")(slide); slide.grid = inc("grid/grid")(slide); slide.clickContainer = inc("clickContainer/container")(slide); slide.debugTrigger = inc("debugTrigger/trigger")(slide); inc("buttons/buttons")(slide); inc("elements/elements")(slide); return slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; }; })(); trainers/findOnImage/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/findOnImage/lsg/lsg.ls (function(){ return function(slide){ var lsg, div, ref$; lsg = slide.getParam("lsg"); if (!lsg) { return; } return div = (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide })) != null ? ref$.css(!lsg.width ? { height: "100%", width: "15em" } : void 8).appendTo(slide.wrapper) : void 8; }; })(); trainers/findOnImage/playSoundB/play.ls (function(){ return function(slide, onDone){ var atom; atom = slide.atoms[slide.currentIndex]; if (slide.getParam("soundMode", atom) === "b") { return setTimeout(function(){ var voice, text; voice = slide.getParam("voice", atom); text = atom.sound || atom.a; return slide.sounds[text + voice].play(onDone); }, 300); } else { return setTimeout(onDone, 500); } }; })(); trainers/findOnImage/solve/solve.ls (function(){ return function(slide){ return function(){ var atom, icon, centerX, centerY, parentDiv, pos; atom = slide.atoms[slide.currentIndex]; slide.clickContainer.append(icon = inc("../icon/icon")("resolved")); centerX = slide.div.offset().width / 2; centerY = slide.div.offset().height / 2; parentDiv = slide.getParam("image") ? slide.image : slide.lsgWrapper; pos = { top: _.round((atom.y2 + atom.y1) / 2), left: _.round((atom.x2 + atom.x1) / 2) }; icon.showAt(pos.left * parentDiv.height() / 100, pos.top * parentDiv.height() / 100); slide.clickContainer.css({ pointerEvents: "none" }); slide.currentElement.css({ pointerEvents: "none" }); slide.levelPlayer.progressBar.showGrey(); return inc("../playSoundB/play")(slide, function(){ return slide.score.addActionResolved(atom, pos, function(){ return slide.score.log(atom, function(){ slide.header.finishAtom(); return slide.startNextElement(); }); }); }); }; }; })(); trainers/findOnImage/startNextElement/start.ls (function(){ return function(slide){ var atom, ref$, currentElement; slide.currentIndex++; atom = slide.atoms[slide.currentIndex]; if (atom) { slide.currentAtom = atom; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, slide.currentAtom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, slide.currentAtom); } slide.header.startAtom(); if (slide.instruction.hasPlayed()) { slide.header.playAtom(); } currentElement = slide.elements[slide.currentIndex]; slide.currentElement = currentElement; currentElement.start(); return slide.clickContainer.css({ pointerEvents: "" }); } else { slide.header.finishAtom(); slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); } }; })(); trainers/findOnImage/wrapper/wrapper.ls (function(){ return function(slide){ return Div({ display: "inline-block" }).appendTo(slide.div); }; })(); trainers/findSequence/_calcTotalProgressElements/calc.ls (function(){ return function(slide, onDone, onError){ var loadMediaFiles, onLoaded; loadMediaFiles = function(){ return slide.loadMediaFiles({ onDone: onLoaded, onError: onError }); }; onLoaded = function(errors){ if ((errors != null ? errors.length : void 8) > 0) { return onDone(errors); } else { slide.totalProgressElements = inc("../calcTotalProgressElements/calc")(slide); return onDone(); } }; return loadMediaFiles(); }; })(); trainers/findSequence/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/findSequence/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, ref$, i$, len$, atom, text, voiceLang, voice; sounds = []; if ((ref$ = slide.getParam("soundMode")) === "a" || ref$ === "b" || ref$ === "askSound") { for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; text = atom.sound || atom.a; voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); if (text) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } return sounds; }; })(); trainers/findSequence/_preview/preview.ls (function(){ return function(slide){ var ref$; return (ref$ = slide.debugButton) != null ? ref$.hide() : void 8; }; })(); trainers/findSequence/_review/scoreActions/actions.ls (function(){ return function(slide){ var i$, ref$, len$, i, atom, e, actionGroups, ref1$; inc("../../elements/elements")(slide); for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; e = slide.score.getScoreEvent(atom); if (!e) { continue; } actionGroups = inc("calcActionGroups/calc")(e.actions); if (!((ref1$ = e.actions[0]) != null && ref1$.pos)) { if (_.find(slide.targetElements, fn$)) { debug("Multi element atoms review in findSequence only supported with new action syntax"); return; } inc("oldActions/actions")(slide, atom, actionGroups); } else { inc("actions/actions")(slide, atom, actionGroups); } } function fn$(elementsPerAtom){ return elementsPerAtom > 1; } }; })(); trainers/findSequence/_review/scoreActions/actions/actionDiv/div.ls (function(){ return function(slide, atom, actionGroup){ var lsg, action; lsg = slide.getParam("lsg", atom); if (!lsg) { return; } return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ width: "15em", maxWidth: "100%", height: "auto" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actionGroup).length; i$ < len$; ++i$) { action = ref$[i$]; results$.push(inc("../icon/icon")(action)); } return results$; }())); }; })(); trainers/findSequence/_review/scoreActions/actions/actions.ls (function(){ return function(slide, atom, actionGroups){ var actionGroup, dummyAction; return slide.div.append(Div({ display: "flex", flexDirection: "column", alignItems: "stretch", padding: "0.5em", margin: "0px auto 0.4em", maxWidth: "90%", background: Color.grey[150] }).html(atom.a && slide.getParam("soundMode") !== "askSound" ? Div({ margin: "1em 0" }).html(atom.a) : void 8, (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actionGroups).length; i$ < len$; ++i$) { actionGroup = ref$[i$]; dummyAction = { correct: actionGroup.type, duration: actionGroup.duration }; results$.push(inc("/shared/scoreActionRowFlex/row")(dummyAction, inc("actionDiv/div")(slide, atom, actionGroup)).css({ margin: "0.2em 0", padding: "0.6em 0 0.2em", maxWidth: "", borderTop: "2px solid " + Color.grey[300] })); } return results$; }()))); }; })(); trainers/findSequence/_review/scoreActions/actions/icon/icon.ls (function(){ return function(action){ var type; type = action.correct ? "correct" : "wrong"; return Div({ position: "absolute", top: action.pos.top + "%", left: action.pos.left + "%" }).html(SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-" + type + ".svg") }).css({ position: "absolute", top: "-0.3em", left: "-0.3em", width: "0.6em", height: "0.6em" })); }; })(); trainers/findSequence/_review/scoreActions/calcActionGroups/calc.ls (function(){ return function(actions){ var actionGroups, lastActionGroup, getActionGroups; actionGroups = []; lastActionGroup = null; getActionGroups = function(result, action){ if (action.correct !== (lastActionGroup != null ? lastActionGroup.type : void 8)) { actionGroups.push([]); lastActionGroup = _.last(actionGroups); lastActionGroup.type = action.correct; lastActionGroup.duration = 0; } lastActionGroup.push(action); return lastActionGroup.duration += action.duration; }; _.reduce(actions, getActionGroups, actionGroups); return actionGroups; }; })(); trainers/findSequence/_review/scoreActions/oldActions/actionDiv/div.ls (function(){ return function(slide, atom, actionGroup){ var lsg, div; lsg = slide.getParam("lsg", atom); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ width: "15em", maxWidth: "100%", height: "auto" }); requestAnimationFrame(function(){ var elements, i$, ref$, len$, a, els, rects, j$, len1$, j, element, el, action, results$ = []; elements = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; els = div.find("." + a['class']); rects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(div, "." + a['class'], "percent"); for (j$ = 0, len1$ = els.length; j$ < len1$; ++j$) { j = j$; element = els[j$]; el = Div({ position: "absolute", left: rects[j].left, top: rects[j].top, width: rects[j].width, height: rects[j].height }).appendTo(div); elements.push(el); } } for (i$ = 0, len$ = (ref$ = actionGroup).length; i$ < len$; ++i$) { action = ref$[i$]; if (action.index > -1) { results$.push(elements[action.index].append(inc("../icon/icon")(action))); } } return results$; }); return div; }; })(); trainers/findSequence/_review/scoreActions/oldActions/actions.ls (function(){ return function(slide, atom, actionGroups){ var actionGroup, dummyAction; return slide.div.append(Div({ display: "flex", flexDirection: "column", alignItems: "stretch", padding: "0.5em", margin: "0px auto 0.4em", maxWidth: "90%", background: Color.grey[150] }).html(atom.a != null ? Div({ margin: "1em 0" }).html(atom.a) : void 8, (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actionGroups).length; i$ < len$; ++i$) { actionGroup = ref$[i$]; dummyAction = { correct: actionGroup.type, duration: actionGroup.duration }; results$.push(inc("/shared/scoreActionRowFlex/row")(dummyAction, inc("actionDiv/div")(slide, atom, actionGroup)).css({ margin: "0.2em 0", maxWidth: "", borderTop: "2px solid " + Color.grey[300] })); } return results$; }()))); }; })(); trainers/findSequence/_review/scoreActions/oldActions/icon/icon.ls (function(){ return function(action){ var type; type = action.correct ? "correct" : "wrong"; return Div({ position: "absolute", top: "50%", left: "50%" }).html(SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-" + type + ".svg") }).css({ position: "absolute", top: "-0.3em", left: "-0.3em", width: "0.6em", height: "0.6em" })); }; })(); trainers/findSequence/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); return slide.startNextElement(); }; })(); trainers/findSequence/_t.ls (function(){ return { correctWouldBe: { de: ", richtig wäre", en: ", correct would be", fr: ", la solution est", es: ", lo correcto sería", pt: ", o correto seria" } }; })(); trainers/findSequence/calcTotalProgressElements/calc.ls (function(){ return function(slide){ var lsgDescription, lsgPath, lsg, ref$, ref1$, total, i$, ref2$, len$, a, c; lsgDescription = slide.getParam("lsg", slide.atom); lsgPath = lsgDescription != null ? lsgDescription.lsg : void 8; lsg = _.endsWith(lsgPath, "lsg") ? (ref$ = slide.mediaParams) != null ? (ref1$ = ref$.lsgs) != null ? ref1$[lsgPath] : void 8 : void 8 : inc(lsgPath); if (!lsg) { return 0; } if (_.isFunction(lsg)) { lsg = lsg(lsgDescription); } total = 0; for (i$ = 0, len$ = (ref2$ = slide.atoms).length; i$ < len$; ++i$) { a = ref2$[i$]; c = a['class']; total += _.filter(lsg.objects, fn$).length; } return total; function fn$(o){ var ref$; return _.includes((ref$ = o['class']) != null ? ref$.split(" ") : void 8, c); } }; })(); trainers/findSequence/debugButton/button.ls (function(){ return function(slide){ var div; if (!engine.isDebug) { return; } return div = Div({ position: "absolute", right: 0, bottom: "-1.5em", color: Color.grey[300] }).addClass("levelDebugIcon").html("Debug: Show rectangles").tap(function(){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; results$.push(el.div.css({ backgroundColor: el.div.style.backgroundColor === "" ? "rgba(255, 0, 0, 0.2)" : "" })); } return results$; }).appendTo(slide.lsg.firstChild); }; })(); trainers/findSequence/elements/element/calcScorePosition/calc.ls (function(){ return function(slide, pageX, pageY){ var divOffset, x, y; divOffset = slide.lsg.firstChild.offset(); x = (pageX - divOffset.left) / divOffset.width * 100; x += x > 95 ? -2 : x < 5 ? 2 : 0; y = (pageY - divOffset.top) / divOffset.width * 100; y += y > 95 ? -2 : y < 5 ? 2 : 0; return { top: _.round(y), left: _.round(x) }; }; })(); trainers/findSequence/elements/element/colorize/colorize.ls (function(){ return function(atom, e){ if (atom.color) { return e.attr({ fill: atom.color }); } else { return e.attr({ stroke: atom.lineColor }); } }; })(); trainers/findSequence/elements/element/element.ls (function(){ return function(slide, rectangle, i, element, atom){ var isActive, isDone, pageX, pageY, start, onFinish, onCorrect, onWrong, click, playSoundB, div; isActive = false; isDone = false; pageX = null; pageY = null; start = function(){ return isActive = true; }; onFinish = function(){ slide.lsg.css({ pointerEvents: "" }); slide.currentTargetIndex = 0; return slide.score.log(slide.currentAtom, function(){ return slide.startNextElement(); }); }; onCorrect = function(){ var correctIcon, callback; slide.currentTargetIndex++; isDone = true; slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atoms[slide.currentIndex], { pos: inc("calcScorePosition/calc")(slide, pageX, pageY) }, function(){ if (slide.currentTargetIndex === slide.targetElements[slide.currentIndex]) { slide.lsg.css({ pointerEvents: "none" }); if (!slide.atoms[slide.currentIndex + 1]) { return playSoundB(onFinish); } else { playSoundB(); return onFinish(); } } }); slide.lsg.append(correctIcon = inc("icon/icon")(slide.getParam("correctIconType"), i, slide.getParam("customCorrectIcons"))); if (atom.color || atom.lineColor) { inc("colorize/colorize")(atom, element); callback = correctIcon.remove; } correctIcon.showAt(pageX - slide.lsg.offset().left, pageY - slide.lsg.offset().top, callback); if (slide.getParam("clickMode") === "rectangle") { return div.unbind("mousedown touchstart"); } else { return element.unbind("mousedown touchstart"); } }; onWrong = function(){ var wrongIcon; slide.levelPlayer.progressBar.addElement().showRed(); slide.score.addActionMistake(slide.atoms[slide.currentIndex], { pos: inc("calcScorePosition/calc")(slide, pageX, pageY) }); slide.lsg.append(wrongIcon = inc("icon/icon")("wrong", i)); return wrongIcon.showAt(pageX - slide.lsg.offset().left, pageY - slide.lsg.offset().top, function(){ return wrongIcon.remove(); }); }; click = function(e){ var ref$, ref1$, ref2$, ref3$; if (((ref$ = e.touches) != null ? ref$.length : void 8) > 1) { return; } if (isDone) { return; } pageX = (ref1$ = (ref2$ = e.touches) != null ? ref2$[0].pageX : void 8) != null ? ref1$ : e.pageX; pageY = (ref1$ = (ref3$ = e.touches) != null ? ref3$[0].pageY : void 8) != null ? ref1$ : e.pageY; if (isActive) { return onCorrect(); } else { return onWrong(); } }; playSoundB = function(onDone){ var text; text = atom != null ? atom.sound : void 8; if (text && slide.getParam("soundMode", atom) === "b") { return setTimeout(function(){ var voice; voice = slide.getParam("voice", atom); return slide.sounds[atom.sound + voice].play(onDone); }, 300); } else { return setTimeout(onDone, 500); } }; div = Div({ position: "absolute", left: rectangle.left, top: rectangle.top, width: rectangle.width, height: rectangle.height }).appendTo(slide.lsg); if (slide.clickMode === "rectangle") { div.tap({ up: click, animation: "none" }).css({ cursor: "initial" }); } else { div.css({ pointerEvents: "none" }); element.tap({ up: click, animation: "none" }).css({ cursor: "initial" }); } return { start: start, div: div }; }; })(); trainers/findSequence/elements/element/icon/icon.ls (function(){ return function(type, index, customCorrectIcons){ var showAt, div; showAt = function(x, y, onDone){ div.css({ left: x + "px", top: y + "px" }); div.show(); if (onDone != null || type === "wrong") { return setTimeout(function(){ return div.fadeOut(300, onDone); }, 400); } }; div = Div({ display: "inline-flex", position: "absolute", left: "50%", top: "50%" }).append((function(){ switch (type) { case "numbers": return inc("types/numbers/div")(index); case "letters": return inc("types/letters/div")(index); case "check": return inc("types/check/div")(); case "wrong": return inc("types/wrong/div")(); case "custom": return inc("types/custom/div")(customCorrectIcons, index); default: debug("please define correctIconType"); return inc("types/check/div")(); } }())).hide(); div.showAt = showAt; return div; }; })(); trainers/findSequence/elements/element/icon/types/check/div.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-correct.svg") }).css({ position: "absolute", width: "1.5em", height: "1.5em" }); }; })(); trainers/findSequence/elements/element/icon/types/custom/div.ls (function(){ return function(customCorrectIcons, index){ var content; if (customCorrectIcons == null || customCorrectIcons[index] == null) { debug("customCorrectIcons not defined correctly"); return; } content = customCorrectIcons[index]; return Div({ display: "flex", position: "absolute", fontWeight: "bold", color: "white", backgroundColor: Color.green[500] }).css(content.length <= 1 ? { height: "1.5em", width: "1.5em", borderRadius: "50%" } : { borderRadius: "15px", padding: "5px" }).html(content); }; })(); trainers/findSequence/elements/element/icon/types/letters/div.ls (function(){ return function(index){ return Div({ display: "flex", position: "absolute", width: "1.5em", height: "1.5em", borderRadius: "50%", fontWeight: "bold", color: "white", backgroundColor: Color.green[500] }).html(String.fromCharCode(65 + index)); }; })(); trainers/findSequence/elements/element/icon/types/numbers/div.ls (function(){ return function(index){ return Div({ display: "flex", position: "absolute", width: "1.5em", height: "1.5em", borderRadius: "50%", fontWeight: "bold", color: "white", backgroundColor: Color.green[500] }).html(index + 1); }; })(); trainers/findSequence/elements/element/icon/types/wrong/div.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-wrong.svg") }).css({ position: "absolute", width: "1.5em", height: "1.5em" }); }; })(); trainers/findSequence/elements/elements.ls (function(){ return function(slide){ var elements, i$, ref$, len$, i, wrongRects, wrongElements, element, atom, foundElements, rects, j$, len1$, j; elements = []; slide.wrongElements = []; slide.targetElements = _.times(slide.atoms.length, _.constant(0)); slide.currentTargetIndex = 0; for (i$ = 0, len$ = (ref$ = slide.lsg.find(".ignore")).length; i$ < len$; ++i$) { i = ref$[i$]; i.css({ pointerEvents: "none" }); } wrongRects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(slide.lsg, ".wrong", "percent"); wrongElements = slide.lsg.find(".wrong"); for (i$ = 0, len$ = wrongElements.length; i$ < len$; ++i$) { i = i$; element = wrongElements[i$]; slide.wrongElements.push(inc("element/element")(slide, wrongRects[i], -1, element, null)); } for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; foundElements = slide.lsg.find("." + atom['class']); rects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(slide.lsg, "." + atom['class'], "percent"); for (j$ = 0, len1$ = foundElements.length; j$ < len1$; ++j$) { j = j$; element = foundElements[j$]; elements.push(inc("element/element")(slide, rects[j], i, element, atom)); slide.targetElements[i] += 1; } } return elements; }; })(); trainers/findSequence/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = inc("calcTotalProgressElements/calc")(slide); slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/findSequence/header/header.ls (function(){ return function(slide){ var div; slide.div.append(div = slide.getParam("soundMode") === "askSound" ? inc("headerSound/headerSound")(slide) : inc("headerText/headerText")(slide)); return div; }; })(); trainers/findSequence/header/headerSound/finish/finish.ls (function(){ return function(speaker){ return function(){ return speaker.css({ opacity: 0 }); }; }; })(); trainers/findSequence/header/headerSound/headerSound.ls (function(){ return function(slide){ var speaker; speaker = inc("/shared/askSound/ask")(slide.sounds); speaker.start = inc("start/start")(speaker, slide); speaker.playSound = inc("playSound/play")(speaker, slide); speaker.finish = inc("finish/finish")(speaker); return speaker; }; })(); trainers/findSequence/header/headerSound/playSound/play.ls (function(){ return function(speaker, slide){ return function(onDone){ var atom, text, voice; atom = slide.currentAtom; text = atom.sound || atom.a; voice = slide.getParam("voice", atom); return speaker.play(text + voice, onDone); }; }; })(); trainers/findSequence/header/headerSound/start/start.ls (function(){ return function(speaker, slide){ return function(){ var atom; atom = slide.currentAtom; if (!atom.sound && !atom.a) { return speaker.hide(); } else { return speaker.show().css({ opacity: 1, transition: "150ms opacity" }); } }; }; })(); trainers/findSequence/header/headerText/finish/finish.ls (function(){ return function(slide, div){ return function(){ if (!slide.currentAtom.a) { return; } return div.css({ opacity: 0, height: 0, padding: "" }); }; }; })(); trainers/findSequence/header/headerText/headerText.ls (function(){ return function(slide){ var div; div = Div({ padding: "0.5em 0.5em 1em", cursor: "default", margin: "0 auto", width: "30em", maxWidth: "90%" }).html(" "); div.start = inc("start/start")(slide, div); div.playSound = inc("playSound/play")(slide); div.finish = inc("finish/finish")(slide, div); return div; }; })(); trainers/findSequence/header/headerText/playSound/play.ls (function(){ return function(slide){ return function(onDone){ var atom; atom = slide.currentAtom; if (slide.getParam("soundMode", atom) === "a") { return setTimeout(function(){ var text, voice, ref$; text = atom.sound || atom.a; voice = slide.getParam("voice", atom); if ((ref$ = slide.currentSound) != null) { ref$.stop(); } slide.currentSound = slide.sounds[text + voice]; return slide.currentSound.play(onDone); }, 500); } else { return onDone(); } }; }; })(); trainers/findSequence/header/headerText/start/animateHeaderDiv/animate.ls (function(){ return function(slide, atom, div){ var previousDivHeight, ref$; if (slide.currentIndex === 0) { return div.html(atom.a).offsetSave(); } else { previousDivHeight = (ref$ = div.savedOffset) != null ? ref$.height : void 8; inc("updateHeader/update")(div, atom); div.offsetSave(); if (!previousDivHeight) { previousDivHeight = div.height(); } div.css({ height: previousDivHeight + "px" }); return setTimeout(function(){ return div.css({ height: div.savedOffset.height + "px", opacity: 1, transition: "500ms" }); }); } }; })(); trainers/findSequence/header/headerText/start/animateHeaderDiv/updateHeader/update.ls (function(){ return function(div, atom){ return div.html(atom.a).css({ height: "100%", opacity: 0, transition: "" }); }; })(); trainers/findSequence/header/headerText/start/start.ls (function(){ return function(slide, div){ return function(){ var atom; atom = slide.currentAtom; if (!atom.a) { return; } return inc("animateHeaderDiv/animate")(slide, atom, div); }; }; })(); trainers/findSequence/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.clickMode = slide.getParam("clickMode") || "rectangle"; slide.instruction = inc("instruction/instruction")(slide); slide.header = inc("header/header")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.debugButton = inc("debugButton/button")(slide); slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; slide.elements = inc("elements/elements")(slide); return inc("optimizeLayout/optimize")(slide); }; })(); trainers/findSequence/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/findSequence/lsg/lsg.ls (function(){ return function(slide){ var lsg, div; lsg = slide.getParam("lsg"); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); if (!div) { return; } div.appendTo(slide.div); if (typeof div.updateLayout == 'function') { div.updateLayout(); } return div; }; })(); trainers/findSequence/optimizeLayout/optimize.ls (function(){ return function(slide){ var f; if (slide.clickMode !== "rectangle") { return; } f = function(){ var correctRects, i$, ref$, len$, i, element, wrongRects, results$ = []; correctRects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(slide.lsg, _.map(slide.atoms, function(atom){ return "." + atom['class']; }).join(", "), "percent"); for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { i = i$; element = ref$[i$]; element.div.css(correctRects[i]); } wrongRects = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(slide.lsg, ".wrong", "percent"); for (i$ = 0, len$ = (ref$ = slide.wrongElements).length; i$ < len$; ++i$) { i = i$; element = ref$[i$]; results$.push(element.div.css(wrongRects[i])); } return results$; }; return slide.div.onWindowResize(_.debounce(f, 100)); }; })(); trainers/findSequence/startNextElement/start.ls (function(){ return function(slide){ var atom, page, finished, i$, to$, i, results$ = []; slide.currentIndex++; atom = slide.atoms[slide.currentIndex]; page = slide.levelPlayer.page; if (atom) { slide.currentAtom = atom; if (typeof page.setTrainerHint == 'function') { page.setTrainerHint(slide, slide.currentAtom); } if (typeof page.setCalculator == 'function') { page.setCalculator(slide, slide.currentAtom); } slide.header.start(); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return slide.header.playSound(function(){ return page.scrollElementIntoView(slide.lsg, { padding: 10 }); }); } }); finished = _.sum(slide.targetElements.slice(0, slide.currentIndex)); for (i$ = finished, to$ = slide.targetElements[slide.currentIndex] + finished; i$ < to$; ++i$) { i = i$; results$.push(slide.elements[i].start()); } return results$; } else { slide.div.css({ pointerEvents: "none" }); slide.header.finish(); return setTimeout(slide.finish, 1000); } }; })(); trainers/findWordsInText/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image"); }; })(); trainers/findWordsInText/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg"); }; })(); trainers/findWordsInText/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, parts, i$, ref$, len$, atom, voice, voiceLang, j$, ref1$, len1$, p, text; sounds = []; soundMode = slide.getParam("soundMode"); parts = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; voice = slide.getParam("voice", atom); voiceLang = slide.getParam("voiceLang", atom); if (atom.sound) { sounds.push({ text: atom.sound, voice: voice, voiceLang: voiceLang }); } else { parts = inc("../../sentences/sentence/calcParts/calc")(atom.b); } if (soundMode === "b") { for (j$ = 0, len1$ = (ref1$ = _.filter(parts, fn$)).length; j$ < len1$; ++j$) { p = ref1$[j$]; text = p.gap.split("_").join(" "); if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } else if (soundMode === "finish") { text = inc("../../sentences/sentence/calcText/calc")(parts); } else if (soundMode === "a" || soundMode === "askSound") { if (atom.a) { text = atom.a; } } if (text) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; function fn$(p){ return p.gap != null; } }; })(); trainers/findWordsInText/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = slide.sentencesDiv.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.show()); } return results$; }; })(); trainers/findWordsInText/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, sentenceDivs, s, matchingActions, div, i, results$ = []; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; actions.push(a); } } if (actions.length > 0) { sentenceDivs = slide.div.find(".sentenceDiv"); for (i$ = 0, len$ = sentenceDivs.length; i$ < len$; ++i$) { s = sentenceDivs[i$]; matchingActions = _.filter(actions, fn$); div = Div({ margin: "1.5em 0", textAlign: "left" }).append((fn1$())); results$.push(s.after(div)); } return results$; } function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(s.atom); } function fn1$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = matchingActions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(a, i).append(inc("scoreAction/scoreAction")(a, slide))); } return results$; } }; })(); trainers/findWordsInText/_review/scoreActions/scoreAction/scoreAction.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/findWordsInText/_skip/skip.ls (function(){ return function(slide){ var i$, to$, i; slide.solveButton.remove(); if (slide.currentElement == null) { return slide.onFinishedSlide(); } for (i$ = 0, to$ = slide.currentElement.atom.b.split("((").length - 1; i$ < to$; ++i$) { i = i$; slide.levelPlayer.progressBar.showGreen(); } return slide.startNextElement(); }; })(); trainers/findWordsInText/_start/start.ls (function(){ return function(slide){ slide.startNextElement(); return slide.instruction.play(); }; })(); trainers/findWordsInText/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide, totalProgressElements, i$, len$, atom; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; totalProgressElements = 0; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; totalProgressElements += atom.b.split("((").length - 1; } slide.totalProgressElements = totalProgressElements; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/findWordsInText/header/header.ls (function(){ return function(slide){ var soundMode, div; soundMode = slide.getParam("soundMode"); slide.div.append(div = soundMode === "askSound" ? inc("headerSound/headerSound")(slide) : inc("headerText/headerText")(slide)); return div; }; })(); trainers/findWordsInText/header/headerSound/headerSound.ls (function(){ return function(slide){ var playAtom, startAtom, finishAtom, speaker; playAtom = function(){ var atom, text, voice; atom = slide.currentAtom; if (atom == null) { return; } text = atom.sound || atom.a; voice = slide.getParam("voice", atom); return speaker.play(text + voice); }; startAtom = function(){ var atom; atom = slide.currentAtom; if (!atom.sound && !atom.a) { return speaker.hide(); } else { return speaker.show().css({ opacity: 1, transition: "150ms opacity" }); } }; finishAtom = function(){ return speaker.css({ opacity: 0 }); }; speaker = inc("/shared/askSound/ask")(slide.sounds).css({ margin: "" }); speaker.startAtom = startAtom; speaker.playAtom = playAtom; speaker.finishAtom = finishAtom; return speaker; }; })(); trainers/findWordsInText/header/headerText/headerText.ls (function(){ return function(slide){ var playAtom, startAtom, finishAtom, div, textDiv, separator; playAtom = function(){ var atom, text; atom = slide.currentAtom; if (atom == null) { return; } text = atom.sound || atom.a; if (slide.getParam("soundMode", atom) === "a" && text) { return setTimeout(function(){ var voice; voice = slide.getParam("voice", atom); return slide.sounds[text + voice].play(); }, 500); } }; startAtom = function(){ var atom; atom = slide.currentAtom; if (!atom.a) { return div.hide(); } else { div.show(); textDiv.html(atom.a); return setTimeout(function(){ return textDiv.css({ opacity: 1, transition: "opacity 500ms" }); }, 500); } }; finishAtom = function(){ return textDiv.css({ opacity: 0, transition: "" }); }; div = Div().append(textDiv = Div({ padding: "0 1em 0.4em", opacity: 0, margin: "0 auto", width: "30em", maxWidth: "90%" }).html(" "), separator = inc("separator/separator")()); div.startAtom = startAtom; div.playAtom = playAtom; div.finishAtom = finishAtom; return div; }; })(); trainers/findWordsInText/header/headerText/separator/separator.ls (function(){ return function(){ return Div({ width: "5em", borderBottom: "1px solid " + Color.grey[300], margin: "0.6em auto" }); }; })(); trainers/findWordsInText/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image"); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/findWordsInText/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.header = inc("header/header")(slide); slide.sentencesDiv = inc("sentences/sentences")(slide); slide.solveButton = inc("solveButton/button")(slide); slide.staticContainer = inc("staticContainer/container")(slide); slide.solve = inc("solve/solve")(slide); return slide.startNextElement = inc("startNextElement/start")(slide); }; })(); trainers/findWordsInText/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/findWordsInText/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg"); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/findWordsInText/sentences/addStaticText/add.ls (function(){ return function(slide){ return slide.staticContainer.html(Div({ marginTop: "1em", display: "inline-block", fontStyle: "italic" }).html(slide.currentAtom.c)); }; })(); trainers/findWordsInText/sentences/sentence/break/break.ls (function(){ return function(s){ return "
"; }; })(); trainers/findWordsInText/sentences/sentence/calcParts/calc.ls (function(){ return function(s){ s = _.replaceAll(s, "
))", "))
"); return inc("/shared/convertGapString/convert")(s); }; })(); trainers/findWordsInText/sentences/sentence/calcText/calc.ls (function(){ return function(parts){ var text, i$, len$, p; text = ""; for (i$ = 0, len$ = parts.length; i$ < len$; ++i$) { p = parts[i$]; text += p.gap ? p.gap.split("_").join(" ") : p.word ? p.word : p.space ? " " : void 8; } return text; }; })(); trainers/findWordsInText/sentences/sentence/combiner/combiner.ls (function(){ return function(){ return Span().addClass("combiner"); }; })(); trainers/findWordsInText/sentences/sentence/continueButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(function(){ div.remove(); return slide.startNextElement(); }, 500); }; return div = Div({ textAlign: "center", pointerEvents: "auto" }).html(Button({ label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ marginTop: "1em" }).tap(click)).hide(); }; })(); trainers/findWordsInText/sentences/sentence/playSoundFinish/play.ls (function(){ return function(slide, atom, sentence, onDone){ var voice, text; voice = slide.getParam("voice", atom); text = atom.sound || sentence; return slide.sounds[text + voice].play(onDone); }; })(); trainers/findWordsInText/sentences/sentence/sentence.ls (function(){ return function(slide, atom, i){ var parts, words, solved, totalTodo, isFinished, start, onMistake, onCorrect, playFinishSound, finish, div, doCombine, spaceWidth, i$, len$, p, element, w, combiner, lastPart, lastElement, continueButton; parts = inc("calcParts/calc")(atom.b); words = []; solved = 0; totalTodo = _.filter(parts, function(p){ return p.gap != null; }).length; isFinished = false; start = function(){ var i$, ref$, len$, w; if (totalTodo === 0) { div.show(); for (i$ = 0, len$ = (ref$ = words).length; i$ < len$; ++i$) { w = ref$[i$]; w.css({ backgroundColor: "white", borderBottom: "2px solid white" }); } return slide.startNextElement(); } else { return div.css({ pointerEvents: "" }).show(); } }; onMistake = function(label){ var wordIndex, action; setTimeout(function(){ if (!slide.isSolved && !isFinished && !slide.solveButton.isVisible()) { return slide.solveButton.showButton(); } }, 700); wordIndex = _.findIndex(_.filter(parts, "word"), function(p){ return p.word === label; }); action = { gap: wordIndex, text: label }; return slide.score.addActionMistake(atom, action); }; onCorrect = function(label){ var gapIndex, action; gapIndex = _.findIndex(_.filter(parts, "gap"), function(p){ return p.gap === label; }); action = { gap: gapIndex, text: label }; return slide.score.addActionCorrect(atom, action, function(){ var i$, ref$, len$, w; solved++; isFinished = solved === totalTodo; if (isFinished) { if (slide.solveButton.isVisible()) { slide.solveButton.hide(); } div.css({ pointerEvents: "none" }); for (i$ = 0, len$ = (ref$ = words).length; i$ < len$; ++i$) { w = ref$[i$]; w.css({ borderBottom: !w.isGap() ? "2px solid white" : void 8 }); } return playFinishSound(); } }); }; playFinishSound = function(){ if (slide.getParam("soundMode", atom) === "finish") { return setTimeout(function(){ var value; value = inc("calcText/calc")(parts); return inc("playSoundFinish/play")(slide, atom, value, finish); }, 500); } else { return finish(); } }; finish = function(){ var isContinueButton, ref$; isContinueButton = (ref$ = slide.getParam("continueButton")) != null ? ref$ : true; return slide.score.log(atom, function(){ return setTimeout(function(){ if (i === slide.sentences.length - 1 || !isContinueButton) { return slide.startNextElement(); } else { slide.levelPlayer.page.centerDuration = 300; continueButton.fadeIn(); return slide.levelPlayer.page.scrollElementIntoView(continueButton, { padding: 50 }); } }, 1000); }); }; div = Span().addClass("sentenceDiv").css({ pointerEvents: "none" }).hide(); if (_.find(parts, { space: true })) { doCombine = true; } spaceWidth = slide.getParam("extraSpace") ? "0.5em" : "0.2em"; for (i$ = 0, len$ = parts.length; i$ < len$; ++i$) { p = parts[i$]; element = p.space ? inc("space/space")(p) : p['break'] ? inc("break/break")() : (w = inc("word/word")(slide, atom, p, onMistake, onCorrect), words.push(w), w); if (p.space && (((typeof lastPart != 'undefined' && lastPart !== null) && lastPart.word) || ((typeof lastPart != 'undefined' && lastPart !== null) && lastPart.gap))) { lastElement.css({ marginRight: spaceWidth }); } if (doCombine && ((p.gap && ((typeof lastPart != 'undefined' && lastPart !== null) && lastPart.word)) || (p.word && ((typeof lastPart != 'undefined' && lastPart !== null) && lastPart.gap)) || (p.word && ((typeof lastPart != 'undefined' && lastPart !== null) && lastPart.word)))) { combiner = inc("combiner/combiner")(); lastElement.wrap(combiner); lastElement.after(element); } else { div.append(element); } lastPart = p; lastElement = element; } div.append("
", continueButton = inc("continueButton/button")(slide)); div.words = words; div.start = start; div.atom = atom; div.playFinishSoundAndFinish = playFinishSound; div.parts = parts; return div; }; })(); trainers/findWordsInText/sentences/sentence/space/space.ls (function(){ return function(part){ return " "; }; })(); trainers/findWordsInText/sentences/sentence/word/word.ls (function(){ return function(slide, atom, part, onMistake, onCorrect){ var isDone, label, htmlLabel, click, div, span; isDone = false; label = part.word || part.gap; htmlLabel = label.split("_").join(" "); label = label.split("_").join(" "); click = function(){ if (part.gap) { isDone = true; div.css({ backgroundColor: Color.green[500], borderBottom: "2px solid " + Color.green[500], pointerEvents: "none" }); slide.levelPlayer.progressBar.showGreen(); div.unbind(); if (slide.getParam("soundMode") === "b") { setTimeout(function(){ var voice, text; voice = slide.getParam("voice", atom); text = atom.sound || label; return slide.sounds[text + voice].play(function(){ return onCorrect(label); }); }, 300); } else { onCorrect(label); } return setTimeout(function(){ return div.css({ backgroundColor: 'white' }); }, 300); } else { div.css({ backgroundColor: Color.red[500], borderBottom: "2px solid " + Color.red[500] }); onMistake(label); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ return div.css({ backgroundColor: 'white', borderBottom: '2px solid #EEE' }); }, 300); } }; div = Span(); div.css({ borderBottom: '2px solid #EEE', cursor: "pointer", lineHeight: "2em", backgroundClip: "border-box", fontWeight: part.bold ? "bold" : void 8, fontStyle: part.italic ? "italic" : void 8, color: part.textColor ? part.textColor : void 8, backgroundColor: part.markColor ? part.markColor : void 8 }).html(span = Span({ padding: "0.4em 0 0.2em" }).html(htmlLabel)).tap({ up: click, animation: { down: function(){ return div.css({ backgroundColor: Color.grey[100] }); }, up: function(){ return div.css({ backgroundColor: "transparent" }); }, cancel: function(){ return div.css({ backgroundColor: "transparent" }); } } }); div.isDone = function(){ return isDone; }; div.isGap = function(){ return part.gap != null; }; div.label = label; return div; }; })(); trainers/findWordsInText/sentences/sentences.ls (function(){ return function(slide){ var div, i, atom; return div = Div({ maxWidth: "30em", padding: "0 1em", margin: "0 auto 1em", textAlign: slide.getParam("textAlign") || "left" }).html(slide.sentences = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; results$.push(inc("sentence/sentence")(slide, atom, i)); } return results$; }())).appendTo(slide.div); }; })(); trainers/findWordsInText/solve/solve.ls (function(){ return function(slide){ return function(onDone){ var words, i$, len$; words = slide.currentElement.words; for (i$ = 0, len$ = words.length; i$ < len$; ++i$) { (fn$.call(this, i$, words[i$])); } return setTimeout(function(){ var i$, ref$, len$, word; for (i$ = 0, len$ = (ref$ = words).length; i$ < len$; ++i$) { word = ref$[i$]; word.css({ backgroundColor: "white" }); } return onDone(); }, 500); function fn$(i, word){ var parts, label, gapIndex, action; if (word.isGap() && !word.isDone()) { word.css({ backgroundColor: Color.grey[300], borderBottom: "2px solid " + Color.grey[500] }); slide.levelPlayer.progressBar.showGrey(); parts = slide.currentElement.parts; label = word.label; gapIndex = _.findIndex(_.filter(parts, "gap"), function(p){ return p.gap === label; }); action = { gap: gapIndex, text: label }; slide.score.addActionResolved(slide.currentAtom, action); } else if (!word.isGap()) { word.css({ borderBottom: "2px solid white" }); } } }; }; })(); trainers/findWordsInText/solveButton/button.ls (function(){ return function(slide){ var showButton, click, wrapper, div; showButton = function(){ slide.levelPlayer.page.centerDuration = 300; slide.levelPlayer.page.bottom.show().append(wrapper); slide.solveButton.css({ pointerEvents: "" }); return wrapper.hide().fadeIn(); }; click = function(){ var ref$; slide.solveButton.css({ pointerEvents: "none" }); if ((ref$ = slide.currentElement) != null) { ref$.css({ pointerEvents: "none" }); } slide.isSolved = true; return slide.solve(function(){ var ref$; wrapper.hide(); return (ref$ = slide.currentElement) != null ? ref$.playFinishSoundAndFinish() : void 8; }); }; wrapper = Div({ margin: "0.5em", textAlign: "center" }).html(div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).tap(click)).hide(); div.showButton = showButton; return div; }; })(); trainers/findWordsInText/startNextElement/start.ls (function(){ return function(slide){ return function(){ var ref$, s; slide.currentIndex++; slide.currentAtom = slide.atoms[slide.currentIndex]; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, slide.currentAtom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, slide.currentAtom); } if (slide.currentIndex === 1) { slide.levelPlayer.page.centerDuration = 300; } s = slide.sentences[slide.currentIndex]; slide.currentElement = s; if (s) { slide.header.startAtom(); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return slide.levelPlayer.page.scrollElementIntoView(s, { padding: 50 }); } }); slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: function(){ return slide.header.playAtom(); } }); if (slide.currentAtom.c) { inc("../sentences/addStaticText/add")(slide); } else { slide.staticContainer.empty(); } return s.start(); } else { slide.levelPlayer.page.centerDuration = 0; slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); } }; }; })(); trainers/findWordsInText/staticContainer/container.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ margin: "0 1em", textAlign: "center" })); return div; }; })(); trainers/findZone/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/findZone/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, ref$, i$, len$, atom, text, voiceLang, voice; sounds = []; if ((ref$ = slide.getParam("soundMode")) === "a" || ref$ === "b" || ref$ === "askSound") { for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; text = atom.sound || atom.a; voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); if (text) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } return sounds; }; })(); trainers/findZone/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/findZone/_review/scoreActions/actions.ls (function(){ return function(slide){ var i$, ref$, len$, i, a, lresult$, e, el, eo, lo, j$, ref1$, len1$, action, results$ = []; slide.wrapper.css({ marginBottom: "1em" }); for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; lresult$ = []; e = slide.score.getScoreEvent(a); if (!e) { continue; } el = slide.lsg.findFirst("." + a['class']).css({ opacity: 0.5 }); if (el.attr("fill") === "transparent") { el.attr({ fill: Color.grey[300] }); } eo = el.offset(); lo = slide.lsg.offset(); slide.lsg.append(inc("tagIndex/tagIndex")(i).css({ position: "absolute", top: eo.top + eo.height / 2 - lo.top - 10 + "px", left: eo.left + eo.width / 2 - lo.left - 8 + "px" })); for (j$ = 0, len1$ = (ref1$ = e.actions).length; j$ < len1$; ++j$) { action = ref1$[j$]; lresult$.push(slide.div.append(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, i, slide) : inc("mistake/mistake")(action, i, slide)).css({ textAlign: "left" }))); } results$.push(lresult$); } return results$; }; })(); trainers/findZone/_review/scoreActions/correct/correct.ls (function(){ return function(action, i, slide){ return Div({ display: "inline-block" }).append(inc("../tagIndex/tagIndex")(action.index).css({ backgroundClip: "border-box", verticalAlign: "top" })); }; })(); trainers/findZone/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, i, slide){ return inc("../correct/correct")(action, i, slide).append(T("correctWouldBe"), inc("../tagIndex/tagIndex")(i).css({ backgroundClip: "border-box", verticalAlign: "top", margin: "0 0.5em" })); }; })(); trainers/findZone/_review/scoreActions/tagIndex/tagIndex.ls (function(){ return function(i, color){ return Div({ display: "inline-block", backgroundClip: "border-box", verticalAlign: "0.2em", fontSize: "0.7em", backgroundColor: color || Color.yellow[200], padding: "0.2em", boxShadow: '0px 0px 2px #bbb' }).html(i + 1); }; })(); trainers/findZone/_start/start.ls (function(){ return function(slide){ slide.startNextElement(); slide.instruction.play(function(){ return slide.header.playAtom(); }); return slide.levelPlayer.page.bottom.append(slide.zoomControls).show(); }; })(); trainers/findZone/_t.ls (function(){ return { correctWouldBe: { de: ", richtig wäre", en: ", correct would be", fr: ", la solution est", es: ", lo correcto sería", pt: ", o correto seria" } }; })(); trainers/findZone/elements/element/element.ls (function(){ return function(slide, atom, i){ var onCorrect, onWrong; onCorrect = function(){ var a; a = { index: i, scale: slide.lsg.scale }; slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.currentAtom, a); slide.score.log(slide.currentAtom); return setTimeout(slide.startNextElement, 1000); }; onWrong = function(){ var a; a = { index: i, scale: slide.lsg.scale }; slide.levelPlayer.progressBar.addElement().showRed(); return slide.score.addActionMistake(slide.currentAtom, a); }; return inc("zone/zone")(slide, atom, onCorrect, onWrong, i); }; })(); trainers/findZone/elements/element/zone/icon/icon.ls (function(){ return function(type, index, customCorrectIcons){ var showAt, div; showAt = function(x, y, onDone){ div.css({ left: x + "px", top: y + "px" }); div.show(); if (type === "wrong") { return setTimeout(function(){ return div.fadeOut(300, onDone); }, 400); } }; div = Div({ display: "inline-flex", position: "absolute", left: "50%", top: "50%" }).append(div = (function(){ switch (type) { case "numbers": return inc("types/numbers/div")(index); case "letters": return inc("types/letters/div")(index); case "check": return inc("types/check/div")(); case "wrong": return inc("types/wrong/div")(); case "custom": return inc("types/custom/div")(customCorrectIcons, index); default: debug("please define correctIconType"); return inc("types/check/div")(); } }())).hide(); div.showAt = showAt; return div; }; })(); trainers/findZone/elements/element/zone/icon/types/check/div.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-correct.svg") }).css({ position: "absolute", width: "1.5em", height: "1.5em" }); }; })(); trainers/findZone/elements/element/zone/icon/types/custom/div.ls (function(){ return function(customCorrectIcons, index){ var content; if (customCorrectIcons == null || customCorrectIcons[index] == null) { debug("customCorrectIcons not defined correctly"); return; } content = customCorrectIcons[index]; return Div({ display: "flex", position: "absolute", fontWeight: "bold", color: "white", backgroundColor: Color.green[500] }).css(content.length <= 1 ? { height: "1.5em", width: "1.5em", borderRadius: "50%" } : { borderRadius: "15px", padding: "5px" }).html(content); }; })(); trainers/findZone/elements/element/zone/icon/types/letters/div.ls (function(){ return function(index){ return Div({ display: "flex", position: "absolute", width: "1.5em", height: "1.5em", borderRadius: "50%", fontWeight: "bold", color: "white", backgroundColor: Color.green[500] }).html(String.fromCharCode(65 + index)); }; })(); trainers/findZone/elements/element/zone/icon/types/numbers/div.ls (function(){ return function(index){ return Div({ display: "flex", position: "absolute", width: "1.5em", height: "1.5em", borderRadius: "50%", fontWeight: "bold", color: "white", backgroundColor: Color.green[500] }).html(index + 1); }; })(); trainers/findZone/elements/element/zone/icon/types/wrong/div.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-wrong.svg") }).css({ position: "absolute", width: "1.5em", height: "1.5em" }); }; })(); trainers/findZone/elements/element/zone/zone.ls (function(){ return function(slide, atom, onCorrect, onWrong, index){ var showZones, ref$, showSolvedZones, showCorrectIcon, that, isSolved, lastClickEvent, click, showIcon, hideZone, correct, wrong, target, fill, opacity, wrongFill, correctFill; showZones = (ref$ = slide.getParam("showZones", atom)) != null ? ref$ : false; showSolvedZones = (ref$ = slide.getParam("showSolvedZones", atom)) != null ? ref$ : false; showCorrectIcon = (that = slide.getParam("showCorrectIcon", atom)) != null ? that : (that = slide.getParam("showCheck", atom)) != null ? (debug("please change showCheck to showCorrectIcon"), that) : false; isSolved = false; lastClickEvent = null; click = function(e){ if (slide.lastTapStart < slide.lastGestureStart) { return; } lastClickEvent = e; slide.lsg.css({ pointerEvents: "none" }); if (atom === slide.currentAtom) { return correct(); } else { return wrong(); } }; showIcon = function(type){ var icon, e, pageX, ref$, ref1$, pageY, ref2$; if (!showCorrectIcon) { return; } slide.lsg.append(icon = inc("icon/icon")(type || slide.getParam("correctIconType"), index, slide.getParam("customCorrectIcons"))); e = lastClickEvent; pageX = (((ref$ = (ref1$ = e.touches) != null ? ref1$[0].pageX : void 8) != null ? ref$ : e.pageX) - slide.lsg.offset().left) / slide.lsg.scale; pageY = (((ref$ = (ref2$ = e.touches) != null ? ref2$[0].pageY : void 8) != null ? ref$ : e.pageY) - slide.lsg.offset().top) / slide.lsg.scale; return icon.showAt(pageX, pageY, function(){ return icon.remove(); }); }; hideZone = function(){ if (showSolvedZones) { return; } return setTimeout(function(){ return target.css({ opacity: 0, transition: "opacity 200ms" }); }, 1000); }; correct = function(){ target.attr({ fill: correctFill, opacity: 0.8 }).css({ pointerEvents: "none" }); showIcon(); hideZone(); isSolved = true; return onCorrect(); }; wrong = function(){ target.attr({ fill: wrongFill, opacity: 0.8 }); setTimeout(function(){ target.attr({ fill: fill, opacity: showZones ? opacity : 0 }); return slide.lsg.css({ pointerEvents: "" }); }, 1000); showIcon("wrong"); return onWrong(); }; target = slide.lsg.findFirst("." + atom['class']); fill = target.attr("fill") || Color.blue[500]; opacity = target.attr("opacity") || 0.3; wrongFill = Color.red[500]; correctFill = Color.green[500]; target.attr({ opacity: showZones ? opacity : 0, fill: fill, stroke: showZones ? Color.grey[500] : void 8, "stroke-width": showZones ? "2px" : void 8 }); target.tap({ down: function(){ return slide.lastTapStart = new Date(); }, up: click }).css({ cursor: "" }); return { atom: atom }; }; })(); trainers/findZone/elements/elements.ls (function(){ return function(slide){ var i$, ref$, len$, i, a, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; results$.push(inc("element/element")(slide, a, i)); } return results$; }; })(); trainers/findZone/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/findZone/header/header.ls (function(){ return function(slide){ var div; slide.div.append(div = slide.getParam("soundMode") === "askSound" ? inc("headerSound/headerSound")(slide) : inc("headerText/headerText")(slide)); return div; }; })(); trainers/findZone/header/headerSound/headerSound.ls (function(){ return function(slide){ var playAtom, startAtom, finishAtom, speaker; playAtom = function(){ var atom; atom = slide.currentAtom; return inc("/shared/playSoundA/play")(atom, slide); }; startAtom = function(){ var atom; atom = slide.currentAtom; if (!atom.sound && !atom.a) { return speaker.hide(); } else { return speaker.show().css({ opacity: 1, transition: "150ms opacity" }); } }; finishAtom = function(){ return speaker.css({ opacity: 0 }); }; speaker = inc("/shared/askSound/ask")(slide.sounds); speaker.startAtom = startAtom; speaker.playAtom = playAtom; speaker.finishAtom = finishAtom; return slide.askSound = speaker; }; })(); trainers/findZone/header/headerText/headerText.ls (function(){ return function(slide){ var currentSound, playAtom, startAtom, finishAtom, div; currentSound = null; playAtom = function(){ var atom; atom = slide.currentAtom; if (currentSound != null) { currentSound.stop(); } return currentSound = inc("/shared/playSoundA/play")(atom, slide); }; startAtom = function(){ var atom; atom = slide.currentAtom; if (!atom.a) { return div.hide(); } else { div.show().html(atom.a); return setTimeout(function(){ return div.css({ opacity: 1, transition: "opacity 500ms" }); }, 500); } }; finishAtom = function(){ return div.css({ opacity: 0 }); }; div = Div({ cursor: "default", textAlign: slide.getParam("divAlign") || "center", maxWidth: "90%", width: "30em", margin: "0.5em auto 1em", opacity: 0 }).html(" "); div.startAtom = startAtom; div.playAtom = playAtom; div.finishAtom = finishAtom; return div; }; })(); trainers/findZone/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.maxZoom = 3; slide.minZoom = 1; slide.instruction = inc("instruction/instruction")(slide); slide.header = inc("header/header")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.zoomControls = inc("zoomControls/controls")(slide); slide.elements = inc("elements/elements")(slide); return slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; }; })(); trainers/findZone/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/findZone/lsg/enableGestures/enable.ls (function(){ return function(slide, div){ var initialScale, initialTranslation, updateTransform; initialScale = null; initialTranslation = null; updateTransform = function(){ var offset, containerOff, needsUpdate; if (Math.abs(div.translation.x) > 0 || Math.abs(div.translation.y) > 0 || div.scale > 1) { slide.lastGestureStart = new Date(); } div.css({ transform: "translate(" + div.translation.x + "px, " + div.translation.y + "px) scale(" + div.scale + ", " + div.scale + ")" }); offset = div.offset(); containerOff = slide.wrapper.offset(); needsUpdate = false; if (offset.right < containerOff.right - 1) { div.translation.x -= offset.right - containerOff.right; needsUpdate = true; } else if (offset.left > containerOff.left + 1) { div.translation.x -= offset.left - containerOff.left; needsUpdate = true; } if (offset.bottom < containerOff.bottom - 1) { div.translation.y -= offset.bottom - containerOff.bottom; needsUpdate = true; } else if (offset.top > containerOff.top + 1) { div.translation.y -= offset.top - containerOff.top; needsUpdate = true; } if (needsUpdate) { return updateTransform(); } }; div.gesturePinch({ id: "pinch", onStart: function(gr){ return initialScale = gr.target.scale; }, onChanged: function(gr){ gr.target.scale = _.round(Math.max(gr.zoom * initialScale, slide.minZoom), 1); gr.target.scale = _.round(Math.min(gr.target.scale, slide.maxZoom), 1); return updateTransform(); }, onEnded: function(gr){}, shouldRecognizeSimultaneously: function(gr1, gr2){ return false; }, cancelsOthers: true }); div.gesturePan({ id: "pan", onStart: function(gr){ return initialTranslation = gr.target.translation; }, onChanged: function(gr){ gr.target.translation = { x: gr.translation.x + initialTranslation.x, y: gr.translation.y + initialTranslation.y }; return updateTransform(); }, onEnded: function(gr){} }); div.scale = 1; return div.translation = { x: 0, y: 0 }; }; })(); trainers/findZone/lsg/lsg.ls (function(){ return function(slide){ var div, ref$, i$, ref1$, len$, i; div = (ref$ = inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg"), slide: slide })) != null ? ref$.css({ position: "absolute", left: 0, top: 0, width: "100%", height: "100%" }).appendTo(slide.wrapper) : void 8; for (i$ = 0, len$ = (ref1$ = div.findAll(".ignore")).length; i$ < len$; ++i$) { i = ref1$[i$]; i.css({ pointerEvents: "none" }); } inc("enableGestures/enable")(slide, div); return div; }; })(); trainers/findZone/startNextElement/disableOtherTypes/disable.ls (function(){ return function(slide, atom){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { el = ref$[i$]; if (el.atom.type !== atom.type) { results$.push(el.disable()); } else { results$.push(el.enable()); } } return results$; }; })(); trainers/findZone/startNextElement/start.ls (function(){ return function(slide){ var atom, ref$; slide.currentIndex++; atom = slide.atoms[slide.currentIndex]; slide.lsg.css({ pointerEvents: "" }); if (atom) { if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, atom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, atom); } slide.currentAtom = atom; slide.header.startAtom(); if (slide.instruction.hasPlayed()) { return slide.header.playAtom(); } } else { slide.div.css({ pointerEvents: "none" }); slide.header.finishAtom(); slide.zoomControls.hide(); return setTimeout(slide.finish, 1000); } }; })(); trainers/findZone/wrapper/wrapper.ls (function(){ return function(slide){ return Div({ width: "20em", maxWidth: "90%", height: "20em", margin: "0 auto", overflow: "hidden" }).appendTo(slide.div); }; })(); trainers/findZone/zoomControls/button/button.ls (function(){ return function(iconPath, click){ var interval, startInterval, onInterval, up, div; interval = null; startInterval = function(){ interval = setInterval(onInterval, 150); return click(); }; onInterval = function(){ if (!div.isVisible()) { clearInterval(interval); interval = null; return; } return click(); }; up = function(){ clearInterval(interval); interval = null; return click(); }; return div = Button({ icon: iconPath }).css({ paddingLeft: "1em", paddingRight: "1em", backgroundColor: Color.grey[200], border: "1px solid " + Color.grey[350], margin: "0.5em" }).tap({ longDown: startInterval }).bind("mouseup touchend", up); }; })(); trainers/findZone/zoomControls/controls.ls (function(){ return function(slide){ var zoomIn, zoomOut; zoomIn = function(){ slide.lsg.scale += 0.2; slide.lsg.scale = _.round(Math.min(slide.lsg.scale, slide.maxZoom), 1); return slide.lsg.css({ transform: "scale(" + slide.lsg.scale + ", " + slide.lsg.scale + ")" }); }; zoomOut = function(){ slide.lsg.scale -= 0.2; slide.lsg.scale = _.round(Math.max(slide.lsg.scale, slide.minZoom), 1); return slide.lsg.css({ transform: "scale(" + slide.lsg.scale + ", " + slide.lsg.scale + ")" }); }; return Div({ textAlign: "center", width: "100%" }).append(inc("button/button")(path("/../app01/lib/svg/shape/minus.svg"), zoomOut), inc("button/button")(path("/../app01/lib/svg/shape/plus.svg"), zoomIn)); }; })(); trainers/flashRead/_media2/images/images.ls (function(){ return function(slide){ var choice; return _.concat(slide.getParam("image", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("image", choice)); } return results$; }())); }; })(); trainers/flashRead/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var choice; return _.concat(slide.getParam("lsg", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("lsg", choice)); } return results$; }())); }; })(); trainers/flashRead/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, solutions, i$, ref$, len$, choice, voiceLang, voice, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { solutions = _.filter(slide.choices, { correct: true }); texts = _.map(solutions, function(c){ return c.sound || c.text; }); } else { texts = []; } for (i$ = 0, len$ = (ref$ = _.filter(slide.choices, fn$)).length; i$ < len$; ++i$) { choice = ref$[i$]; texts.push(choice.sound); } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; function fn$(c){ return c.sound != null && c.image == null && c.lsg == null; } }; })(); trainers/flashRead/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/flashRead/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", marginBottom: "1em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/flashRead/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ var image, lsg, css, div; image = slide.getParam("image", action.choice); lsg = slide.getParam("lsg", action.choice); css = { width: "1.3em", height: "1.3em" }; return div = Div({ display: "inline-block" }).append(image ? inc("/shared/image/image")({ image: image, slide: slide }).css(css).css({ verticalAlign: "-0.3em" }) : lsg ? inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css(css).css({ verticalAlign: "top" }) : void 8); }; })(); trainers/flashRead/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return inc("../correct/correct")(action, slide); }; })(); trainers/flashRead/_start/start.ls (function(){ return function(slide){ var i$, ref$, len$, button, results$ = []; slide.instruction.play(function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.startButton, { padding: 10 }); }); for (i$ = 0, len$ = (ref$ = slide.buttons).length; i$ < len$; ++i$) { button = ref$[i$]; results$.push(button.disable()); } return results$; }; })(); trainers/flashRead/_t.ls (function(){ return { start: { de: "Start", en: "Start", fr: "Commencer", es: "Comenzar", pt: "Iniciar" } }; })(); trainers/flashRead/buttons/_shared/click/click.ls (function(){ return function(slide, div, choice, transitions){ var click, clear, playSoundAndFinish; click = function(){ div.css({ pointerEvents: "none" }); if (choice.correct) { slide.currentGreen++; slide.score.addActionCorrect(slide.atom, { choice: choice }); transitions.feedback(Color.green[500]); slide.levelPlayer.progressBar.showGreen(); if (slide.currentGreen === slide.totalGreen) { slide.score.log(slide.atom); slide.div.css({ pointerEvents: "none" }); return playSoundAndFinish(); } } else { slide.score.addActionMistake(slide.atom, { choice: choice }); slide.levelPlayer.progressBar.addElement().showRed(); transitions.feedback(Color.red[500]); return setTimeout(clear, 500); } }; clear = function(){ div.css({ pointerEvents: "" }); return transitions.feedbackReset(); }; playSoundAndFinish = function(){ var text, voice; text = slide.atom.sound || choice.sound || choice.text; voice = slide.getParam("voice", slide.atom); if (slide.getParam("soundMode", slide.atom) === "b" && text) { return setTimeout(function(){ return slide.sounds[text + voice].play(function(){ return setTimeout(slide.finish, 700); }); }, 500); } else { return setTimeout(slide.finish, 1000); } }; return click; }; })(); trainers/flashRead/buttons/button/adjustWidth/adjust.ls (function(){ return function(div, lsg, image){ return requestAnimationFrame(function(){ var pw, dw, scale, element, w; pw = div.parent().width(); dw = div.width({ withMargins: true }); if (dw * 2 > pw) { scale = _.round(pw / (dw * 2 + 20), 2); element = lsg || image; w = element.width() * scale + "px"; return element.css({ width: w, height: w }); } }); }; })(); trainers/flashRead/buttons/button/button.ls (function(){ return function(slide, choice, i){ var div, transitions, click, enable, disable, lsg, image; div = Div({ display: "inline-block", opacity: 0, border: "4px solid transparent", backgroundColor: Color.grey[50], backgroundClip: "border-box", verticalAlign: "top", margin: "0.3em", outline: "1px solid " + Color.grey[250] }); transitions = inc("transitions/transitions")(slide, div); click = inc("../_shared/click/click")(slide, div, choice, transitions); enable = function(){ if (typeof lsg != 'undefined' && lsg !== null) { lsg.css({ visibility: "visible" }); } if (typeof image != 'undefined' && image !== null) { image.css({ visibility: "visible" }); } return transitions.enable(); }; disable = function(){ if (typeof lsg != 'undefined' && lsg !== null) { lsg.css({ visibility: "hidden" }); } if (typeof image != 'undefined' && image !== null) { image.css({ visibility: "hidden" }); } return transitions.disable(); }; div.append(choice.lsg ? lsg = inc("lsg/lsg")(slide, choice) : choice.image ? image = inc("image/image")(slide, choice) : void 8).tap({ up: click, animation: transitions.getTapAnimations() }); inc("adjustWidth/adjust")(div, lsg, image); div.enable = enable; div.disable = disable; return div; }; })(); trainers/flashRead/buttons/button/image/image.ls (function(){ return function(slide, choice){ var image; image = slide.getParam("image", choice); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide }).css({ width: slide.buttonWidth, height: slide.buttonWidth }); }; })(); trainers/flashRead/buttons/button/lsg/lsg.ls (function(){ return function(slide, choice){ var lsg; lsg = slide.getParam("lsg", choice); if (!lsg) { return; } return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ width: slide.buttonWidth, height: slide.buttonWidth }); }; })(); trainers/flashRead/buttons/button/transitions/transitions.ls (function(){ return function(slide, div){ return { enable: function(){ return div.css({ pointerEvents: "", opacity: 1, transition: "opacity 200ms", outline: "", boxShadow: "2px 3px 7px 1px rgba(0, 0, 0, 0.2)" }); }, disable: function(){ return div.css({ boxShadow: "", pointerEvents: "none" }); }, feedback: function(c){ return div.css({ border: "4px solid " + c }); }, feedbackReset: function(){ div.css({ border: "4px solid transparent", transition: "border 500ms" }); return setTimeout(function(){ return div.css({ transition: "" }); }, 500); }, getTapAnimations: function(){ return { up: function(){ return div.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "box-shadow 500ms" }); }, cancel: function(){ return div.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "box-shadow 200ms" }); }, down: function(){ return div.css({ boxShadow: "2px 3px 9px 3px rgba(0,0,0,0.2)", transition: "box-shadow 0ms" }); } }; } }; }; })(); trainers/flashRead/buttons/buttons.ls (function(){ return function(slide){ var div, i, choice, combiner1, combiner2; slide.totalGreen = _.filter(slide.choices, { correct: true }).length; slide.currentGreen = 0; slide.div.append(div = Div({ padding: "1em 0" }).append(slide.buttons = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { i = i$; choice = ref$[i$]; if (choice.sound && !choice.lsg && !choice.image) { results$.push(inc("soundButton/button")(slide, choice, i)); } else { results$.push(inc("button/button")(slide, choice, i)); } } return results$; }()))); if (slide.buttons.length >= 2) { combiner1 = inc("combiner/combiner")(); slide.buttons[0].wrap(combiner1); slide.buttons[0].after(slide.buttons[1]); } if (slide.buttons.length >= 4) { combiner1.after(document.createElement("br")); combiner2 = inc("combiner/combiner")(); slide.buttons[2].wrap(combiner2); slide.buttons[2].after(slide.buttons[3]); } return div; }; })(); trainers/flashRead/buttons/combiner/combiner.ls (function(){ return function(){ return Div({ display: "inline-block" }); }; })(); trainers/flashRead/buttons/soundButton/button.ls (function(){ return function(slide, choice, i){ var isPlaying, sound, voice, text, div, transitions, click, enable, disable, toggle, speaker; isPlaying = false; sound = slide.getParam("sound", choice); voice = slide.getParam("voice", choice); text = choice.sound + voice; if (!sound) { return; } div = Div({ display: "inline-flex", flexDirection: "columns", backgroundColor: Color.grey[150], border: "2px solid " + Color.grey[250], opacity: 0, margin: "0.6em", backgroundClip: "border-box" }); transitions = inc("transitions/transitions")(slide, div); click = inc("../_shared/click/click")(slide, div, choice, transitions); enable = function(){ if (typeof lsg != 'undefined' && lsg !== null) { lsg.css({ visibility: "visible" }); } if (typeof image != 'undefined' && image !== null) { image.css({ visibility: "visible" }); } return transitions.enable(); }; disable = function(){ if (typeof lsg != 'undefined' && lsg !== null) { lsg.css({ visibility: "hidden" }); } if (typeof image != 'undefined' && image !== null) { image.css({ visibility: "hidden" }); } return transitions.disable(); }; toggle = function(){ if (isPlaying) { isPlaying = false; slide.currentSoundButton = null; speaker.reset(); return slide.sounds[text].stop(); } else { isPlaying = true; if (slide.currentSoundButton) { slide.currentSoundButton.toggle(); } slide.currentSoundButton = div; return slide.sounds[text].play(function(){ isPlaying = false; return slide.currentSoundButton = null; }, function(c, t, l){ return speaker.update(c, t, l); }); } }; div.append(Div({ height: "3em", width: "3em", display: "flex", marginRight: "0.2em" }).append(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "2.4em", progressbarType: "none", speakerType: "123" })).tap(toggle), Div().addClass("button").css({ width: "3em", height: "3em", display: "flex", backgroundColor: Color.grey[150] }).append(SvgIcon({ svg: path("/../app01/lib/svg/shape/check.svg"), color: Color.grey[450], width: "1.3em" })).tap(click)); div.toggle = toggle; div.enable = enable; div.disable = disable; return div; }; })(); trainers/flashRead/buttons/soundButton/transitions/transitions.ls (function(){ return function(slide, div){ return { enable: function(){ return div.css({ pointerEvents: "", opacity: 1, transition: "opacity 200ms", backgroundColor: "" }); }, disable: function(){ return div.css({ boxShadow: "", pointerEvents: "none" }); }, feedback: function(c){ return div.findFirst(".button").css({ backgroundColor: c }); }, feedbackReset: function(){ var button; button = div.findFirst(".button"); button.css({ backgroundColor: Color.grey[150], transition: "500ms" }); return setTimeout(function(){ return button.css({ transition: "" }); }, 500); } }; }; })(); trainers/flashRead/calcButtonWidth/calc.ls (function(){ return function(){ var w; w = body.width(); if (w < 450) { return Math.floor(w / 2.8) + "px"; } else { return "10em"; } }; })(); trainers/flashRead/calcChoices/automatic/calc.ls (function(){ return function(slide){ var choice, k, ref$, v, choices, s, otherAtoms, totalButtons, i$, len$, atom; choice = { correct: true }; for (k in ref$ = slide.atom.b) { v = ref$[k]; choice[k] = v; } choices = [choice]; s = JSON.stringify; otherAtoms = _.shuffleWithSeed(_.filter(slide.trainerParams.atoms, function(atom){ return s(atom.b) !== s(slide.atom.b); })); totalButtons = slide.trainerParams.totalButtons || 4; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choice = { correct: false }; for (k in ref$ = atom.b) { v = ref$[k]; choice[k] = v; } choices.push(choice); } return choices; }; })(); trainers/flashRead/calcChoices/calc.ls (function(){ return function(slide){ var choices, shuffleButtons, ref$; choices = _.ensureArray(slide.atom.b); if (_.filter(choices, "correct").length === 0) { choices = inc("automatic/calc")(slide); } shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; if (shuffleButtons) { choices = _.shuffleWithSeed(choices); } return choices; }; })(); trainers/flashRead/card/card.ls (function(){ return function(slide){ var duration, flip, faceCss, part, div, front, frontFace, back, backFace, centerWrapper; duration = slide.getParam("readDuration") || 2000; flip = function(){ var i$, ref$, len$, d; for (i$ = 0, len$ = (ref$ = [front, back]).length; i$ < len$; ++i$) { d = ref$[i$]; d.flipped -= 180; d.css({ transform: "rotateY(" + d.flipped + "deg)", transition: "500ms" }); } div.css({ pointerEvents: "none" }); return setTimeout(function(){ backFace.fadeOut(300); centerWrapper.css({ pointerEvents: "none" }); return setTimeout(function(){ var i$, ref$, len$, button, results$ = []; for (i$ = 0, len$ = (ref$ = slide.buttons).length; i$ < len$; ++i$) { button = ref$[i$]; results$.push(button.enable()); } return results$; }, 300); }, duration); }; faceCss = function(front){ return { position: "absolute", left: 0, top: 0, right: 0, bottom: 0, overflow: "hidden", transform: "rotateY(" + (front ? 0 : -180) + "deg)", backfaceVisibility: "hidden", webkitBackfaceVisibility: "hidden" }; }; part = slide.atom.a; div = Div({ margin: "0 auto", maxWidth: "90%", width: part.image || part.lsg ? slide.buttonWidth : "15em", height: part.image || part.lsg ? slide.buttonWidth : "4em" }).append(front = Div(faceCss(true)).append(frontFace = inc("text/text")(". . .").css({ color: Color.grey[500] })), back = Div(faceCss(false)).append(backFace = part.image || part.lsg ? inc("imageOrLsg/imageOrLsg")(slide, part) : inc("text/text")(part).css({ fontSize: "1.2em" }))); centerWrapper = Div({ display: "flex", position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }).appendTo(slide.buttonsDiv).append(div); div.flip = flip; front.flipped = 0; back.flipped = -180; return div; }; })(); trainers/flashRead/card/imageOrLsg/imageOrLsg.ls (function(){ return function(slide, part){ var lsg, image, div; lsg = slide.getParam("lsg", part); image = slide.getParam("image", part); if (!(lsg || image)) { return; } div = lsg ? inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }) : inc("/shared/image/image")({ image: image, slide: slide }); return Div({ display: "inline-block", border: "1px solid " + Color.grey[250], backgroundClip: "border-box", backgroundColor: Color.grey[50], verticalAlign: "top", width: "100%", height: "100%" }).append(div.css({ width: "100%", height: "100%" })); }; })(); trainers/flashRead/card/text/text.ls (function(){ return function(text){ var div; return div = Div({ display: "flex", height: "100%", padding: "0.5em", backgroundColor: Color.grey[50], border: "1px solid " + Color.grey[250], backgroundClip: "border-box", wordBreak: "break-word", hyphens: "auto" }).append(Div({ display: "inline-flex", maxWidth: "100%" }).html(Span().addClass("label").html(text))); }; })(); trainers/flashRead/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.choices = inc("calcChoices/calc")(slide); slide.totalProgressElements = _.filter(slide.choices, "correct").length; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/flashRead/init.ls (function(){ return function(slide){ slide.buttonWidth = inc("calcButtonWidth/calc")(); slide.instruction = inc("instruction/instruction")(slide); slide.buttonsDiv = inc("buttons/buttons")(slide); slide.card = inc("card/card")(slide); return slide.startButton = inc("startButton/button")(slide); }; })(); trainers/flashRead/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/flashRead/startButton/button.ls (function(){ return function(slide){ var duration, click, div; duration = slide.getParam("readDuration") || 2000; click = function(){ div.setState("disabled"); return slide.card.flip(); }; return div = Button({ label: T("start") }).css({ margin: "1em 0 0.5em", padding: "0.8em 1.2em", visibility: "visible" }).tap(click).appendTo(slide.div); }; })(); trainers/flipButtons/_media2/images/images.ls (function(){ return function(slide){ var choice; return _.concat(slide.getParam("image", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("image", choice)); } return results$; }()), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("image", choice.flip)); } return results$; }())); }; })(); trainers/flipButtons/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var choice; return _.concat(slide.getParam("lsg", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("lsg", choice)); } return results$; }()), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("lsg", choice.flip)); } return results$; }())); }; })(); trainers/flipButtons/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, choices, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { choices = _.ensureArray(slide.atom.b); texts = _.map(choices, function(c){ var ref$, ref1$; return ((ref$ = c.flip) != null ? ref$.sound : void 8) || c.sound || ((ref1$ = c.flip) != null ? ref1$.text : void 8); }); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/flipButtons/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/flipButtons/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, slide){ var image, lsg, css, div, ref$, text; image = slide.getParam("image", action.choice); lsg = slide.getParam("lsg", action.choice); css = { width: "1.3em", height: "1.3em" }; return div = Div({ display: "inline-block" }).append(image ? inc("/shared/image/image")({ image: image, slide: slide }).css(css).css({ verticalAlign: "-0.3em" }) : lsg ? (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide })) != null ? ref$.css(css).css({ verticalAlign: "top" }) : void 8 : void 8, action.choice.text ? (text = image || lsg ? " " + action.choice.text : action.choice.text, Div({ display: "inline-block" }).html(text)) : void 8); }; })(); trainers/flipButtons/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", marginBottom: "1em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(inc("actionDiv/div")(action, slide))); } return results$; }()))); } }; })(); trainers/flipButtons/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.buttonsDiv, { padding: 10 }); }); }; })(); trainers/flipButtons/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).appendTo(slide.div); }; })(); trainers/flipButtons/buttons/adjustWideButtonsHeight/adjust.ls (function(){ return function(cards){ var maxH, card, i$, len$, results$ = []; maxH = _.max((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = cards).length; i$ < len$; ++i$) { card = ref$[i$]; results$.push(Math.max(card.front.offset().height, card.back.offset().height)); } return results$; }())); for (i$ = 0, len$ = cards.length; i$ < len$; ++i$) { card = cards[i$]; results$.push(card.adjustHeight(maxH)); } return results$; }; })(); trainers/flipButtons/buttons/button/button.ls (function(){ return function(slide, choice){ var correctChoices, wrongChoices, onMistake, onCorrect, tap, playSoundB, cardInclude, ref$, w, width, div, ref1$, ref2$; correctChoices = _.filter(slide.choices, { correct: true }); wrongChoices = _.filter(slide.choices, function(c){ return c.correct == null; }); slide.totalGreen = correctChoices.length; slide.currentGreen = 0; onMistake = function(){ var index; div.onMistake(); slide.levelPlayer.progressBar.addElement().showRed(); index = _.indexOf(wrongChoices, choice); if (choice.flip != null && !slide.automaticChoices) { return playSoundB(function(){ return slide.score.addActionMistake(slide.atom, { choice: choice, index: index }); }); } else { return slide.score.addActionMistake(slide.atom, { choice: choice, index: index }); } }; onCorrect = function(){ var isFinished; slide.currentGreen++; slide.levelPlayer.progressBar.showGreen(); isFinished = slide.currentGreen === slide.totalGreen; if (isFinished) { slide.div.css({ pointerEvents: "none" }); } div.onCorrect(); return playSoundB(function(){ var index; index = _.indexOf(correctChoices, choice); return slide.score.addActionCorrect(slide.atom, { choice: choice, index: index }, function(){ if (isFinished) { return slide.score.log(slide.atom, function(){ return setTimeout(slide.finish, 500); }); } }); }); }; tap = function(){ div.css({ pointerEvents: "none" }); if (choice.correct) { return onCorrect(); } else { return onMistake(); } }; playSoundB = function(onDone){ if (slide.getParam("soundMode", slide.atom) === "b") { return setTimeout(function(){ var sound, ref$, voice, ref1$; sound = ((ref$ = choice.flip) != null ? ref$.sound : void 8) || choice.sound || choice.flip.text; voice = slide.getParam("voice", slide.atom); if ((ref1$ = slide.currentSound) != null) { ref1$.stop(); } slide.currentSound = slide.sounds[sound + voice]; return slide.currentSound.play(function(){ delete slide.currentSound; return typeof onDone == 'function' ? onDone() : void 8; }); }, 500); } else { return setTimeout(function(){ return typeof onDone == 'function' ? onDone() : void 8; }, 500); } }; cardInclude = ((ref$ = slide.getParam("wideButtons")) != null ? ref$ : false) ? "wideButton/button" : "rectButton/button"; w = body.width(); width = w < 450 ? Math.floor(w / 2.8) + "px" : "10em"; div = inc(cardInclude)(slide, { cardWidth: width, mediaParams: slide.mediaParams, frontImage: choice.image, frontLsg: choice.lsg, frontText: choice.text, backImage: (ref$ = choice.flip) != null ? ref$.image : void 8, backLsg: (ref1$ = choice.flip) != null ? ref1$.lsg : void 8, backText: (ref2$ = choice.flip) != null ? ref2$.text : void 8, onTap: tap }); return div; }; })(); trainers/flipButtons/buttons/button/rectButton/animations/tap.ls (function(){ return function(div){ return { up: function(){ return div.front.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "box-shadow 500ms" }); }, cancel: function(){ return div.front.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "box-shadow 200ms" }); }, down: function(){ return div.front.css({ boxShadow: "2px 3px 9px 3px rgba(0,0,0,0.2)", transition: "box-shadow 0ms" }); } }; }; })(); trainers/flipButtons/buttons/button/rectButton/buildSide/build.ls (function(){ return function(side, image, lsg, text, slide){ var faceCss, cardFace; faceCss = function(front){ return { position: "absolute", left: 0, top: 0, padding: "6px", width: "100%", height: "100%", backgroundColor: "white", zIndex: front ? 2 : 1, transform: "rotateY(" + (front ? 0 : -180) + "deg)", backfaceVisibility: "hidden", webkitBackfaceVisibility: "hidden", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)" }; }; cardFace = function(){ if (image || lsg) { if (text) { return inc("faces/imageText")({ image: image, lsg: lsg, text: text, slide: slide }); } else { return inc("faces/image")({ image: image, lsg: lsg, slide: slide }); } } else { return inc("faces/text")({ text: text }); } }; return Div(faceCss(side === "front")).append(cardFace()); }; })(); trainers/flipButtons/buttons/button/rectButton/buildSide/faces/image.ls (function(){ return function(o){ var div; return div = Div({ position: "relative", left: 0, top: 0, width: "100%", height: "100%", pointerEvents: "none" }).append(inc("imageOrLsg/imageOrLsg")(o).css({ position: "absolute", left: 0, top: 0, width: "100%", height: "100%", backgroundColor: "white" })); }; })(); trainers/flipButtons/buttons/button/rectButton/buildSide/faces/imageOrLsg/imageOrLsg.ls (function(){ return function(o){ if (o.image != null) { return inc("/shared/image/image")({ image: o.image, slide: o.slide }); } else if (o.lsg != null) { return inc("/shared/lsg/lsg")({ lsg: o.lsg, slide: o.slide }); } }; })(); trainers/flipButtons/buttons/button/rectButton/buildSide/faces/imageText.ls (function(){ return function(o){ var div; return div = Div({ position: "relative", left: 0, top: 0, width: "100%", height: "100%", overflow: "hidden", backgroundColor: "white", pointerEvents: "none" }).append(inc("imageOrLsg/imageOrLsg")(o).css({ position: "absolute", left: 0, top: 0, width: "100%", height: "100%", backgroundColor: "white" }), Div({ position: "absolute", left: 0, bottom: 0, width: "100%", padding: "0.2em 0.2em", backgroundColor: "rgba(255, 255, 255, 0.7)" }).addClass("currentAtomText").secureHtml(o.text)); }; })(); trainers/flipButtons/buttons/button/rectButton/buildSide/faces/text.ls (function(){ return function(o){ return Div({ display: "flex", width: "100%", height: "100%", backgroundColor: Color.grey[150], pointerEvents: "none" }).append(Div({ display: "inline-flex", maxWidth: "100%" }).html(Span().addClass("currentAtomText").secureHtml(o.text))); }; })(); trainers/flipButtons/buttons/button/rectButton/button.ls (function(){ return function(slide, o){ var div, flipSpeed; div = Div({ display: "inline-block", width: o.cardWidth, height: o.cardWidth, perspective: "500px", margin: "0.5em" }); div.append(div.front = inc("buildSide/build")("front", o.frontImage, o.frontLsg, o.frontText, slide)).append(div.back = inc("buildSide/build")("back", o.backImage, o.backLsg, o.backText, slide)).tap({ up: function(){ return o.onTap(div); }, animation: inc("animations/tap")(div) }); flipSpeed = 500; div.front.flipped = 0; div.back.flipped = -180; div.colorize = function(color, isCorrect){ div.back.css({ backgroundColor: color }); return setTimeout(function(){ return div.back.css({ boxShadow: "0px 0px 3px rgba(0,0,0,0.2)" }); }, flipSpeed); }; div.flip = function(){ var flipButton; flipButton = function(d){ d.flipped -= 180; return d.css({ transform: "rotateY(" + d.flipped + "deg)", transition: flipSpeed + "ms" }); }; flipButton(div.front); return flipButton(div.back); }; div.onMistake = function(callback){ if ((o.backImage || o.backLsg || o.backText) && !slide.automaticChoices) { div.flip(); return div.colorize(Color.red[500]); } else { div.front.css({ backgroundColor: Color.red[500], transition: "100ms" }); return setTimeout(function(){ div.front.css({ backgroundColor: "white", transition: "500ms" }); return div.css({ pointerEvents: "" }); }, flipSpeed); } }; div.onCorrect = function(){ div.flip(); return div.colorize(Color.green[500], true); }; return div; }; })(); trainers/flipButtons/buttons/button/wideButton/adjustHeight/adjust.ls (function(){ return function(h, div, frontFace, backFace){ div.css({ height: (h + 12) + "px" }); div.front.css({ height: h + "px", bottom: "6px" }); div.back.css({ height: h + "px", bottom: "6px" }); if (typeof frontFace.adjustHeight == 'function') { frontFace.adjustHeight(h); } return typeof backFace.adjustHeight == 'function' ? backFace.adjustHeight(h) : void 8; }; })(); trainers/flipButtons/buttons/button/wideButton/animations/tap.ls (function(){ return function(div){ return { up: function(){ return div.front.face.setBoxShadow("2px 3px 7px 1px rgba(0,0,0,0.2)", 500); }, cancel: function(){ return div.front.face.setBoxShadow("2px 3px 7px 1px rgba(0,0,0,0.2)", 200); }, down: function(){ return div.front.face.setBoxShadow("2px 3px 9px 3px rgba(0,0,0,0.2)", 0); } }; }; })(); trainers/flipButtons/buttons/button/wideButton/buildSide/build.ls (function(){ return function(side, image, lsg, text, slide){ var faceCss, cardFace, div, face; faceCss = function(front){ return { position: "absolute", left: "6px", top: "6px", right: "6px", minHeight: "5em", transform: "rotateY(" + (front ? 0 : -180) + "deg)", backfaceVisibility: "hidden", webkitBackfaceVisibility: "hidden" }; }; cardFace = function(){ if (image || lsg) { if (text) { return inc("faces/imageText")({ image: image, lsg: lsg, text: text, slide: slide }); } else { return inc("faces/image")({ image: image, lsg: lsg, slide: slide }); } } else { return inc("faces/text")({ text: text }); } }; div = Div(faceCss(side === "front")).append(face = cardFace()); div.face = face; return div; }; })(); trainers/flipButtons/buttons/button/wideButton/buildSide/faces/image.ls (function(){ return function(o){ var div, image; div = Div({ display: "flex", height: "100%", width: "100%", pointerEvents: "none" }).append(image = inc("imageOrLsg/imageOrLsg")(o).css({ flex: "0 0 auto", minHeight: "5em", height: "5em", width: "100%", backgroundColor: "white", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)" })); div.adjustHeight = function(height){ return image.css({ height: height + "px", width: height + "px", border: "6px solid white", boxSizing: "border-box", webkitBoxSizing: "border-box" }); }; div.setBorderColor = function(color, duration){ return image.css({ borderColor: color + "", transition: duration + "ms" }); }; div.setBoxShadow = function(bShadow, transition){ return image.css({ boxShadow: bShadow + "", transition: "box-shadow " + transition + "ms" }); }; return div; }; })(); trainers/flipButtons/buttons/button/wideButton/buildSide/faces/imageOrLsg/imageOrLsg.ls (function(){ return function(o){ if (o.image != null) { return inc("/shared/image/image")({ image: o.image, slide: o.slide }); } else if (o.lsg != null) { return inc("/shared/lsg/lsg")({ lsg: o.lsg, slide: o.slide }); } }; })(); trainers/flipButtons/buttons/button/wideButton/buildSide/faces/imageText.ls (function(){ return function(o){ var div, image, text; div = Div({ position: "relative", display: "flex", width: "100%", height: "100%", overflow: "hidden", backgroundColor: "white", border: "6px solid white", pointerEvents: "none", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)" }).append(image = inc("imageOrLsg/imageOrLsg")(o).css({ display: "inline-block", flex: "0 0 auto", width: "4.5em", height: "4.5em", marginRight: "6px", backgroundColor: "white" }), text = Div().addClass("currentAtomText").css({ display: "inline-block", flex: "0 1 auto", width: "100%", padding: "0.2em 0.2em", backgroundColor: "white", textAlign: "left" }).secureHtml(o.text)); div.setBorderColor = function(color, duration){ return div.css({ borderColor: color + "", transition: duration + "ms" }); }; div.setBoxShadow = function(bShadow, transition){ return div.css({ boxShadow: bShadow + "", transition: "box-shadow " + transition + "ms" }); }; return div; }; })(); trainers/flipButtons/buttons/button/wideButton/buildSide/faces/text.ls (function(){ return function(o){ var div; div = Div({ display: "flex", padding: "0.5em", height: "100%", backgroundColor: Color.grey[150], border: "6px solid white", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", pointerEvents: "none" }).append(Div({ display: "inline-flex", maxWidth: "100%" }).html(Span().addClass("currentAtomText").secureHtml(o.text))); div.setBorderColor = function(color, duration){ return div.css({ borderColor: color + "", transition: duration + "ms" }); }; div.setBoxShadow = function(bShadow, transition){ return div.css({ boxShadow: bShadow + "", transition: "box-shadow " + transition + "ms" }); }; return div; }; })(); trainers/flipButtons/buttons/button/wideButton/button.ls (function(){ return function(slide, o){ var flipSpeed, div, inner; flipSpeed = 500; div = Div({ display: "block", width: "20em", maxWidth: "90%", minHeight: "4em", margin: "0.2em auto", backgroundColor: "transparent", perspective: "1000px" }).html(inner = Div({ textAlign: "center", width: "100%", height: "100%", transition: "transform 0.8s", transformStyle: "preserve-3d" })); inner.append(div.front = inc("buildSide/build")("front", o.frontImage, o.frontLsg, o.frontText, slide), div.back = inc("buildSide/build")("back", o.backImage, o.backLsg, o.backText, slide)); div.tap({ up: function(){ return o.onTap(div); }, animation: inc("animations/tap")(div) }); div.colorize = function(color, isCorrect){ var ref$; if (typeof (ref$ = div.back.face).setBorderColor == 'function') { ref$.setBorderColor(color, 0); } return setTimeout(function(){ if (isCorrect) { div.front.face.setBoxShadow("0px 0px 3px rgba(0,0,0,0.2)", 500); return div.back.face.setBoxShadow("0px 0px 3px rgba(0,0,0,0.2)", 500); } }, flipSpeed); }; div.onCorrect = function(){ inner.css({ transform: "rotateY(-180deg)" }); return div.colorize(Color.green[500], true); }; div.onMistake = function(){ var ref$; if ((o.backImage || o.backLsg || o.backText) && !slide.automaticChoices) { inner.css({ transform: "rotateY(-180deg)" }); return div.colorize(Color.red[500]); } else { if (typeof (ref$ = div.front.face).setBorderColor == 'function') { ref$.setBorderColor(Color.red[500], 0); } return setTimeout(function(){ var ref$; if (typeof (ref$ = div.front.face).setBorderColor == 'function') { ref$.setBorderColor(Color.white, 500); } return div.css({ pointerEvents: "" }); }, flipSpeed); } }; div.adjustHeight = function(h){ return inc("adjustHeight/adjust")(h, div, div.front.face, div.back.face); }; return div; }; })(); trainers/flipButtons/buttons/buttons.ls (function(){ return function(slide){ var shuffleButtons, ref$, wideButtons, choices, createWrapper, buttons, choice, chunkSize, chunk; shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; wideButtons = (ref$ = slide.getParam("wideButtons", slide.atom)) != null ? ref$ : false; choices = shuffleButtons ? _.shuffleWithSeed(slide.choices) : slide.choices; createWrapper = function(children){ return Div({ display: "flex", flexWrap: "wrap", flex: "0 1 auto" }).html(children); }; slide.div.append(slide.buttonsDiv = Div({ display: "flex", flexWrap: "wrap", marginTop: "1em" }).append(buttons = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(inc("button/button")(slide, choice)); } return results$; }()))); if (!wideButtons) { chunkSize = body.width() > 650 && buttons.length !== 4 ? 3 : 2; slide.buttonsDiv.css({ flexWrap: "nowrap", flexDirection: "column" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.chunk(buttons, chunkSize)).length; i$ < len$; ++i$) { chunk = ref$[i$]; results$.push(createWrapper(chunk)); } return results$; }())); } if (wideButtons) { slide.buttonsDiv.css({ flexDirection: "column" }); inc("adjustWideButtonsHeight/adjust")(buttons); } return buttons; }; })(); trainers/flipButtons/calcChoices/automatic/calc.ls (function(){ return function(slide){ var choice, k, ref$, v, choices, otherAtoms, totalButtons, i$, len$, atom; choice = { correct: true }; for (k in ref$ = slide.atom.b) { v = ref$[k]; choice[k] = v; } choices = [choice]; otherAtoms = _.shuffleWithSeed(_.without(slide.trainerParams.atoms, slide.atom)); totalButtons = slide.trainerParams.totalButtons || 3; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choice = { correct: false }; for (k in ref$ = atom.b) { v = ref$[k]; choice[k] = v; } choices.push(choice); } return choices; }; })(); trainers/flipButtons/calcChoices/calc.ls (function(){ return function(slide){ var choices; choices = _.ensureArray(slide.atom.b); if (_.filter(choices, "correct").length === 0) { slide.automaticChoices = true; choices = inc("automatic/calc")(slide); } return choices; }; })(); trainers/flipButtons/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.choices = inc("calcChoices/calc")(slide); slide.totalProgressElements = _.filter(slide.choices, "correct").length; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/flipButtons/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/flipButtons/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.textA = inc("textA/text")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/flipButtons/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/flipButtons/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/flipButtons/textA/text.ls (function(){ return function(slide){ var p, image, lsg; p = slide.getParam; if (p("soundMode", slide.atom) === "askSound" || !slide.atom.a) { return; } image = p("image", slide.atom); lsg = p("lsg", slide.atom); return inc("/shared/textA/text")(slide).css({ maxWidth: "90%", width: "30em", padding: image || lsg ? "0.5em 1em" : "0 1em" }).appendTo(slide.div); }; })(); trainers/flowText/_media2/images/images.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }; })(); trainers/flowText/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }; })(); trainers/flowText/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, voiceLang, voice, texts2, solutions, j$, len1$, t; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); if (!(_.includes(atom.b, "((") || _.includes(atom.b, ""))) { continue; } if (atom.sound != null) { sounds.push({ text: atom.sound, voice: voice, voiceLang: voiceLang }); } else if (slide.getParam("soundMode", atom) === "b") { texts2 = []; solutions = inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); texts2 = texts2.concat(solutions); for (j$ = 0, len1$ = texts2.length; j$ < len1$; ++j$) { t = texts2[j$]; if (t != null) { sounds.push({ text: t, voice: voice, voiceLang: voiceLang }); } } } } return sounds; }; })(); trainers/flowText/_preview/preview.ls (function(){ return function(slide){ var flowIndex, staticIndex, flowElements, staticElements, i$, ref$, len$, atom, flowDiv, ref1$, results$ = []; flowIndex = 0; staticIndex = 0; flowElements = slide.flowContainer.childrenAll(); staticElements = slide.staticContainer.childrenAll(); for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; flowDiv = Div().addClass("flowDiv"); flowDiv.atom = atom; if (atom.b || atom.image || atom.lsg) { flowDiv.append(flowElements[flowIndex].show()); flowIndex++; } if (atom.a && atom.b) { flowDiv.append((ref1$ = staticElements[staticIndex]) != null ? ref1$.show() : void 8); staticIndex++; } flowDiv.append("
"); results$.push(flowDiv.appendTo(slide.div)); } return results$; }; })(); trainers/flowText/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, element, matchingActions, results$ = []; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; a.originalAtom = e.atom; actions.push(a); } } for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { element = ref$[i$]; if (element.atom == null) { continue; } matchingActions = _.filter(actions, fn$); results$.push(element.div.parent().append(inc("/shared/gapComponent/scoreActions/actions")({ slide: slide, gapComponent: element.div, actions: matchingActions, showYellowTag: element.div.gaps().length > 1 }).css({ marginBottom: "1em" }))); } return results$; function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(element.atom); } }; })(); trainers/flowText/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide, totalGaps){ return Div({ display: "inline-block" }).html(("'" + action.text + "'") + (totalGaps > 1 ? " (" + (action.gap + 1) + ". Lücke)" : "")); }; })(); trainers/flowText/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide, totalGaps){ var text, solution; text = action.text; solution = action.solution; return Div({ display: "inline-block" }).append("'", text, "'", T("instead"), "'", solution, "'", totalGaps > 1 ? T("gap", action.gap + 1) : ""); }; })(); trainers/flowText/_skip/skip.ls (function(){ return function(slide){ var ref$, i$, to$, ref1$, i; if (slide.currentElement == null) { return slide.onFinishedSlide(); } if ((ref$ = slide.currentElement.textA) != null) { ref$.remove(); } for (i$ = 0, to$ = ((ref1$ = slide.atoms[slide.currentIndex].b) != null ? ref1$.split("((").length : void 8) - 1; i$ < to$; ++i$) { i = i$; slide.levelPlayer.progressBar.showGreen(); } return slide.startNextElement(); }; })(); trainers/flowText/_start/start.ls (function(){ return function(slide){ slide.startNextElement(); return slide.instruction.play(); }; })(); trainers/flowText/_t.ls (function(){ return { instead: { de: " anstatt ", en: " instead ", fr: " au lieu de ", es: " en lugar de ", pt: "ao invés de" }, gap: { de: " ($1. Lücke)", en: " ($1. gap)", fr: " (espace vide n° $1)", es: " ($1º espacio vacío)", pt: " ($1º espaço vazio)" } }; })(); trainers/flowText/content/content.ls (function(){ return function(slide){ return Div({ width: "30em", margin: "0 auto", maxWidth: "90%", display: "inline-block", textAlign: "left" }).appendTo(slide.div); }; })(); trainers/flowText/elements/element/element.ls (function(){ return function(atom, i, slide){ if (atom.b) { return inc("text/text")(atom, i, slide); } else if (atom.image) { return inc("image/image")(atom, i, slide); } else if (atom.lsg) { return inc("lsg/lsg")(atom, i, slide); } }; })(); trainers/flowText/elements/element/image/image.ls (function(){ return function(atom, i, slide){ var start, div, image; start = function(){ if (image) { div.hide(); div.fadeIn(800); } return slide.startNextElement(); }; div = Div({ textAlign: "center" }); div.append(image = inc("/shared/image/image")({ image: slide.getParam("image", atom), slide: slide, parent: div, wrapWithDiv: true })).hide().appendTo(slide.flowContainer); return { start: start, div: div }; }; })(); trainers/flowText/elements/element/lsg/lsg.ls (function(){ return function(atom, i, slide){ var start, div, lsg; start = function(){ if (lsg) { div.hide(); div.fadeIn(800); } return slide.startNextElement(); }; div = Div({ textAlign: "center" }); div.append(lsg = inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", atom), slide: slide, parent: div, wrapWithDiv: true })).hide().appendTo(slide.flowContainer); return { start: start, div: div }; }; })(); trainers/flowText/elements/element/text/text.ls (function(){ return function(atom, i, slide){ var start, startNext, finish, gapText, atomA; start = function(){ gapText.hide(); gapText.fadeIn(800); if (atom.a) { atomA.hide(); atomA.fadeIn(800); } if (gapText.gaps().length === 0) { return startNext(); } else { return gapText.start(); } }; startNext = function(){ return setTimeout(function(){ slide.startNextElement(); if (atom.a) { return atomA.remove(); } }, 300); }; finish = function(result){ slide.score.log(atom); gapText.stop(); return inc("/shared/playSoundB/play")(atom, slide, result != null ? result.correctValue : void 8, startNext); }; slide.flowContainer.append(gapText = inc("/shared/gapComponent/component/component")({ slide: slide, atom: atom, text: atom.b, mode: "write", onActionCorrect: function(action, callback){ return slide.score.addActionCorrect(atom, action, callback); }, onActionMistake: function(action){ return slide.score.addActionMistake(atom, action); }, onActionResolved: function(action){ return slide.score.addActionResolved(atom, action); }, onFinish: finish }).css({ paddingRight: "0.3em" }).hide()); if (atom.a) { slide.staticContainer.append(atomA = Div({ color: "grey" }).html(atom.a).hide()); } return { start: start, div: gapText, textA: atomA, atom: atom }; }; })(); trainers/flowText/elements/elements.ls (function(){ return function(slide){ var elements, i, atom, e; return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; e = inc("element/element")(atom, i, slide); if (!e) { continue; } results$.push(e); } return results$; }()); }; })(); trainers/flowText/flowContainer/container.ls (function(){ return function(slide){ var div; slide.content.append(div = Div()); return div; }; })(); trainers/flowText/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, totalProgressElements, i$, len$, atom, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; totalProgressElements = 0; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; if (atom.b) { totalProgressElements += atom.b.split("((").length - 1; } } slide.totalProgressElements = totalProgressElements; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/flowText/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.content = inc("content/content")(slide); slide.flowContainer = inc("flowContainer/container")(slide); slide.staticContainer = inc("staticContainer/container")(slide); slide.elements = inc("elements/elements")(slide); return slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; }; })(); trainers/flowText/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/flowText/startNextElement/start.ls (function(){ return function(slide){ var currentAtom, ref$; slide.currentIndex++; slide.currentElement = slide.elements[slide.currentIndex]; currentAtom = slide.atoms[slide.currentIndex]; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, currentAtom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, currentAtom); } if (slide.currentElement) { slide.currentElement.start(); return slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ var ref$; return slide.levelPlayer.page.scrollElementIntoView(typeof (ref$ = slide.currentElement.div).gaps == 'function' ? ref$.gaps()[0] : void 8, { padding: 50 }); } }); } else { slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); } }; })(); trainers/flowText/staticContainer/container.ls (function(){ return function(slide){ var div; slide.content.append(div = Div({ margin: "0.8em 0", textAlign: "center" })); return div; }; })(); trainers/followPath/_media2/images/images.ls (function(){ return function(slide){ return slide.trainerParams.backgroundImage; }; })(); trainers/followPath/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return _.concat(slide.trainerParams.backgroundLsg, slide.trainerParams.arrowLsg); }; })(); trainers/followPath/_media2/svgs/svgs.ls (function(){ return function(slide){ return _.concat(slide.atom.path, slide.trainerParams.backgroundSvg, slide.trainerParams.arrowSvg); }; })(); trainers/followPath/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/followPath/_review/scoreActions/_t.ls (function(){ return { allCorrect: { de: "Alles richtig!", en: "All correct!", fr: "Tous corrects !", es: "¡Todo bien!", pt: "Tudo certo!" }, nMistakes: { de: "$1 Fehler.", en: "$1 mistakes.", fr: "$1 erreurs.", es: "$1 errores.", pt: "$1 erros." } }; })(); trainers/followPath/_review/scoreActions/actions.ls (function(){ return function(slide){ var paths, i$, len$, p, l, scoreEvent, allCorrect, actionLabel, lsg, ref$, a, results$ = []; paths = slide.path.find("path"); for (i$ = 0, len$ = paths.length; i$ < len$; ++i$) { p = paths[i$]; l = p.getTotalLength(); p.setAttribute("stroke-dasharray", l + ", " + l); p.setAttribute("opacity", "1"); p.setAttribute("stroke", Color.grey[850]); } scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } if (!in$("point", _.keys(scoreEvent.actions[0]))) { return; } slide.wrapper.remove(); allCorrect = scoreEvent.mistakes === 0; actionLabel = Div({ display: "inline-block", marginTop: "1em", color: allCorrect ? Color.green[500] : Color.red[500] }).html(allCorrect ? T("allCorrect") : T("nMistakes", scoreEvent.mistakes)); slide.div.append(actionLabel, "
", lsg = slide.wrapper.clone()); for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { a = ref$[i$]; if (a.correct) { continue; } results$.push(lsg.append(inc("icon/icon")().css({ top: a.point.y * slide.scale + "px", left: a.point.x * slide.scale + "px" }))); } return results$; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/followPath/_review/scoreActions/icon/icon.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-wrong.svg") }).css({ position: "absolute", width: "0.8em", height: "0.8em", margin: "-0.4em" }); }; })(); trainers/followPath/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.startNextPath(); return inc("../resize/resize")(slide); }; })(); trainers/followPath/background/background.ls (function(){ return function(slide){ var div, size; div = slide.trainerParams.backgroundImage ? inc("image/image")(slide) : slide.trainerParams.backgroundLsg ? inc("lsg/lsg")(slide) : inc("svg/svg")(slide); size = 400 * slide.scale + "px"; return div.css({ width: size, height: size }).appendTo(slide.wrapper); }; })(); trainers/followPath/background/image/image.ls (function(){ return function(slide){ return inc("/shared/image/image")({ image: slide.trainerParams.backgroundImage, slide: slide, parent: slide.wrapper }); }; })(); trainers/followPath/background/lsg/lsg.ls (function(){ return function(slide){ return inc("/shared/lsg/lsg")({ lsg: slide.trainerParams.backgroundLsg, slide: slide, parent: slide.wrapper }); }; })(); trainers/followPath/background/svg/defaultSvg/house.svg trainers/followPath/background/svg/svg.ls (function(){ return function(slide){ var svg; svg = _.find(slide.mediaParams.svgs, { path: slide.trainerParams.backgroundSvg }); svg = (svg != null ? svg.svgText : void 8) || inc("defaultSvg/house.svg"); return svg = Svg({ svg: svg }); }; })(); trainers/followPath/calcScale/calc.ls (function(){ return function(slide){ var w, h, ref$, scaleW, scaleH, scale; w = body.width(); h = body.height() - (((ref$ = slide.levelPlayer) != null ? ref$.page.top.height() : void 8) || 0); scaleW = w * 0.7 / 400; scaleH = h * 0.6 / 400; return scale = Math.min(scaleW, scaleH, 1); }; })(); trainers/followPath/cursor/arrow/arrow.ls (function(){ return function(slide){ var that; if ((that = slide.trainerParams.arrowLsg) != null) { return inc("lsg/lsg")(slide, that); } else { return inc("svg/svg")(slide); } }; })(); trainers/followPath/cursor/arrow/lsg/lsg.ls (function(){ return function(slide, lsg){ return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ width: 60 * slide.scale + "px", height: 60 * slide.scale + "px" }); }; })(); trainers/followPath/cursor/arrow/svg/svg.ls (function(){ return function(slide){ var customArrow, size; customArrow = _.find(slide.mediaParams.svgs, { path: slide.trainerParams.arrowSvg }); size = customArrow != null ? 60 * slide.scale : 40 * slide.scale; return Svg({ svg: (customArrow != null ? customArrow.svgText : void 8) || path("/../app01/lib/svg/icon/arrow-right.svg"), color: !customArrow ? Color.white : void 8 }).css({ width: size + "px", height: size + "px" }); }; })(); trainers/followPath/cursor/calcAngle/calc.ls (function(){ return function(slide){ var path, points, p, p0, p1, angle; path = slide.currentPath; points = slide.currentPathPoints; p = Math.min(slide.currentPathPosition, points.length - 2); p0 = points[p]; p1 = points[p + 1]; return angle = Math.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / Math.PI; }; })(); trainers/followPath/cursor/cursor.ls (function(){ return function(slide){ var start, div, circle; start = function(){ var point, angle, ref$, ref1$; point = slide.currentPath.getPointAtLength(slide.currentPathPosition); angle = inc("calcAngle/calc")(slide); div.css({ transform: "translate3d(" + point.x * slide.scale + "px," + point.y * slide.scale + "px, 0)rotate(" + angle + "deg)" + (90 < (ref$ = ((angle) % (ref1$ = 360) + ref1$) % ref1$) && ref$ < 270 ? "scale(1,-1)" : "") + "" }); return inc("drag/drag")(slide); }; div = Div({ position: "absolute", left: 0, top: 0 }).append(circle = Div({ position: "absolute", display: "flex", width: 80 * slide.scale + "px", height: 80 * slide.scale + "px", marginLeft: -40 * slide.scale + "px", marginTop: -40 * slide.scale + "px", top: "50%", left: "50%", borderRadius: "40px", backgroundColor: 'rgba(0,0,0, 0.2)' }).append(inc("arrow/arrow")(slide))); slide.cursor = div; div.start = start; div.circle = circle; return div; }; })(); trainers/followPath/cursor/drag/drag.ls (function(){ return function(slide){ var maxNumberOfPointsToSkip, cursor, allowedDragDistance, ref$, points, totalPathLength, inCursorOffset, down, up, move, isAtPathEnd, showSolved, unbindListeners, positionCursorCloseTo; maxNumberOfPointsToSkip = 30; cursor = slide.cursor; allowedDragDistance = (ref$ = slide.getParam("dragTolerance")) != null ? ref$ : 100; down = function(e){ var mousePos, ref$, path, pathOffset, cursorOffsetInPath; e.preventDefault(); mousePos = inc("point/point")({ x: (ref$ = e.pageX) != null ? ref$ : e.touches[0].pageX, y: (ref$ = e.pageY) != null ? ref$ : e.touches[0].pageY }); path = slide.currentPath; points = slide.currentPathPoints; totalPathLength = path.getTotalLength(); pathOffset = { x: slide.path.offset().left, y: slide.path.offset().top }; cursorOffsetInPath = { x: cursor.circle.offset().left + cursor.circle.width() / 2 - pathOffset.x, y: cursor.circle.offset().top + cursor.circle.height() / 2 - pathOffset.y }; inCursorOffset = mousePos.substract(cursorOffsetInPath); cursor.circle.css({ backgroundColor: 'rgba(0,0,0, 0.3)' }); body.bind("mousemove touchmove", move); return body.bind("mouseup touchend", up); }; up = function(){ unbindListeners(); if (!cursor.isVisible()) { return; } cursor.circle.css({ backgroundColor: 'rgba(0,0,0, 0.2)' }); if (isAtPathEnd()) { slide.pathDraw.drawUntil(totalPathLength); return showSolved(); } }; move = function(e){ var pos, ref$, ref1$, ref2$; if (!cursor.isVisible()) { unbindListeners(); return; } pos = inc("point/point")({ x: (ref$ = (ref1$ = e.touches) != null ? ref1$[0].pageX : void 8) != null ? ref$ : e.pageX || 0, y: (ref$ = (ref2$ = e.touches) != null ? ref2$[0].pageY : void 8) != null ? ref$ : e.pageY || 0 }).substract(inCursorOffset).divideBy(slide.scale); return positionCursorCloseTo(pos); }; isAtPathEnd = function(){ return slide.currentPathPosition + 5 > totalPathLength; }; showSolved = function(){ cursor.parent().unbind("mousedown touchstart", down); return slide.startNextPath(); }; unbindListeners = function(){ body.unbind("mouseup touchend", up); return body.unbind("mousemove touchmove", move); }; positionCursorCloseTo = function(mousePos){ var currentPathPosition, previousPoint, distanceToPreviousPoint, distanceToFirstNextPoint, i$, to$, i, nextPoint, distanceToNextPoint, existsCloserNextPoint, c, pathAngle, ref$, ref1$; if (isAtPathEnd()) { slide.pathDraw.drawUntil(totalPathLength); cursor.css({ opacity: 0 }); return; } currentPathPosition = slide.currentPathPosition; previousPoint = points[currentPathPosition]; distanceToPreviousPoint = mousePos.distanceTo(previousPoint); distanceToFirstNextPoint = undefined; for (i$ = 0, to$ = maxNumberOfPointsToSkip; i$ < to$; ++i$) { i = i$; nextPoint = points[currentPathPosition + i] || points[points.length - 1]; distanceToNextPoint = mousePos.distanceTo(nextPoint); distanceToFirstNextPoint == null && (distanceToFirstNextPoint = distanceToNextPoint); if (distanceToNextPoint < distanceToPreviousPoint) { existsCloserNextPoint = true; break; } } if (!existsCloserNextPoint && distanceToFirstNextPoint > allowedDragDistance) { if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.notificationSuccess); } slide.levelPlayer.progressBar.addElement().showRed(); slide.score.addActionMistake(slide.atom, { point: { x: previousPoint.x, y: previousPoint.y } }); c = slide.cursor.firstChild.css("backgroundColor"); slide.cursor.firstChild.css({ backgroundColor: Color.red[500], pointerEvents: "none" }); setTimeout(function(){ return slide.cursor.firstChild.css({ backgroundColor: c, pointerEvents: "" }); }, 1000); unbindListeners(); return; } if (existsCloserNextPoint) { slide.currentPathPosition = slide.currentPathPosition + 1; try { return positionCursorCloseTo(mousePos); } catch (e$) {} } else { pathAngle = inc("../calcAngle/calc")(slide); slide.pathDraw.drawUntil(slide.currentPathPosition); return cursor.css({ transform: "translate3d(" + previousPoint.x * slide.scale + "px," + previousPoint.y * slide.scale + "px,0)rotate(" + pathAngle + "deg)" + (90 < (ref$ = ((pathAngle) % (ref1$ = 360) + ref1$) % ref1$) && ref$ < 270 ? "scale(1,-1)" : "") + "" }); } }; return cursor.bind("mousedown touchstart", down); }; })(); trainers/followPath/cursor/drag/point/point.ls (function(){ return function(o){ var point; point = { x: o.x, y: o.y }; point.substract = function(p){ point.x -= p.x; point.y -= p.y; return point; }; point.add = function(p){ point.x += p.x; point.y += p.y; return point; }; point.multiplyBy = function(a){ point.x *= a; point.y *= a; return point; }; point.divideBy = function(a){ point.x /= a; point.y /= a; return point; }; point.distanceTo = function(p){ return Math.sqrt(Math.pow(p.x - point.x, 2) + Math.pow(p.y - point.y, 2)); }; return point; }; })(); trainers/followPath/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/followPath/init.ls (function(){ return function(slide){ slide.currentPathIndex = -1; slide.scale = inc("calcScale/calc")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.background = inc("background/background")(slide); slide.path = inc("path/path")(slide); slide.pathDraw = inc("pathDraw/path")(slide); return slide.startNextPath = function(){ return inc("startNextPath/start")(slide); }; }; })(); trainers/followPath/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/followPath/path/path.ls (function(){ return function(slide){ var svg, ref$, pathPreviewColor, i$, ref1$, len$, p; svg = (ref$ = _.find(slide.mediaParams.svgs, { path: slide.atom.path })) != null ? ref$.svgText : void 8; pathPreviewColor = slide.getParam("pathPreviewColor", slide.atom) || Color.grey[200]; slide.wrapper.append(svg = Svg({ svg: svg }).css({ position: "absolute", top: 0, left: 0, width: 400 * slide.scale + "px", height: 400 * slide.scale + "px", pointerEvents: "none" })); for (i$ = 0, len$ = (ref1$ = svg.find("path")).length; i$ < len$; ++i$) { p = ref1$[i$]; p.setAttribute("stroke", pathPreviewColor); } return svg; }; })(); trainers/followPath/pathDraw/path.ls (function(){ return function(slide){ var strokeColor, drawUntil, svg, ref$, i$, ref1$, len$, p; strokeColor = slide.getParam("pathColor", slide.atom) || Color.grey[850]; drawUntil = function(length){ var p; if (!(p = svg.find("path")[slide.currentPathIndex])) { return; } p.setAttribute("stroke-dasharray", length + ", " + p.getTotalLength()); p.setAttribute("opacity", "1"); return p.setAttribute("stroke", strokeColor); }; slide.wrapper.append(svg = Svg({ svg: (ref$ = _.find(slide.mediaParams.svgs, { path: slide.atom.path })) != null ? ref$.svgText : void 8 }).css({ position: "absolute", top: 0, left: 0, width: 400 * slide.scale + "px", height: 400 * slide.scale + "px", pointerEvents: "none" })); for (i$ = 0, len$ = (ref1$ = svg.find("path")).length; i$ < len$; ++i$) { p = ref1$[i$]; p.setAttribute("opacity", "0"); } svg.drawUntil = drawUntil; return svg; }; })(); trainers/followPath/resize/resize.ls (function(){ return function(slide){ var s, onResize; s = slide; return onResize = function(){ var i$, ref$, len$, el; if (!s.div.isVisible()) { window.removeEventListener("resize", onResize); return; } s.scale = inc("../calcScale/calc")(slide); for (i$ = 0, len$ = (ref$ = [s.background, s.path, s.pathDraw]).length; i$ < len$; ++i$) { el = ref$[i$]; el.css({ width: 400 * s.scale + "px", height: 400 * s.scale + "px" }); } s.cursor.replaceWith(inc("../cursor/cursor")(s)); return s.cursor.start(); }; }; })(); trainers/followPath/startNextPath/start.ls (function(){ return function(slide){ var p, res$, i$, to$, i, ref$; slide.currentPathIndex++; p = slide.path.find("path")[slide.currentPathIndex]; if (p) { slide.currentPath = p; slide.currentPathPosition = 0; slide.currentPathLength = p.getTotalLength(); res$ = []; for (i$ = 0, to$ = parseInt(p.getTotalLength()) + 10; i$ <= to$; ++i$) { i = i$; res$.push(p.getPointAtLength(i)); } slide.currentPathPoints = res$; if ((ref$ = slide.cursor) != null) { ref$.remove(); } slide.wrapper.append(inc("../cursor/cursor")(slide)); return slide.cursor.start(); } else { slide.div.css({ pointerEvents: "none" }); slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atom, { point: null }); slide.score.log(slide.atom); return slide.finish(); } }; })(); trainers/followPath/wrapper/wrapper.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ display: "inline-block" })); return div; }; })(); trainers/followPathFreeDraw/_media2/svgs/svgs.ls (function(){ return function(slide){ return _.concat(slide.atom.path, slide.trainerParams.backgroundSvg); }; })(); trainers/followPathFreeDraw/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/followPathFreeDraw/_review/scoreActions/_t.ls (function(){ return { allCorrect: { de: "Alles richtig!", en: "All correct!", fr: "Tous corrects !", es: "¡Todo bien!", pt: "Tudo certo!" }, nMistakes: { de: "$1 Fehler.", en: "$1 mistakes.", fr: "$1 erreurs.", es: "$1 errores.", pt: "$1 erros." } }; })(); trainers/followPathFreeDraw/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, allCorrect, actionLabel, lsg, i$, ref$, len$, a, results$ = []; scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } if (in$(!"point", _.keys(scoreEvent.actions[0]))) { return; } slide.wrapper.remove(); allCorrect = scoreEvent.mistakes === 0; actionLabel = Div({ display: "inline-block", color: allCorrect ? Color.green[500] : Color.red[500], marginTop: "1em" }).html(allCorrect ? T("allCorrect") : T("nMistakes", scoreEvent.mistakes)); slide.div.append(actionLabel, "
", lsg = slide.wrapper.clone()); for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { a = ref$[i$]; if (a.correct) { continue; } results$.push(lsg.append(inc("icon/icon")().css({ top: a.point.y * slide.scale + "px", left: a.point.x * slide.scale + "px" }))); } return results$; }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/followPathFreeDraw/_review/scoreActions/icon/icon.ls (function(){ return function(){ return SvgIcon({ svg: path("/../app01/lib/svg/illustration/feedback-wrong.svg") }).css({ position: "absolute", width: "0.8em", height: "0.8em", margin: "-0.4em" }); }; })(); trainers/followPathFreeDraw/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.startNextPath(); return inc("../resize/resize")(slide); }; })(); trainers/followPathFreeDraw/background/background.ls (function(){ return function(slide){ var svg; svg = _.find(slide.mediaParams.svgs, { path: slide.trainerParams.backgroundSvg }); svg = (svg != null ? svg.svgText : void 8) || inc("defaultSvg/house.svg"); slide.wrapper.append(svg = Svg({ svg: svg }).css({ width: 400 * slide.scale + "px", height: 400 * slide.scale + "px" })); return svg; }; })(); trainers/followPathFreeDraw/background/defaultSvg/house.svg trainers/followPathFreeDraw/calcScale/calc.ls (function(){ return function(slide){ var w, h, ref$, scaleW, scaleH, scale; w = body.width(); h = body.height() - (((ref$ = slide.levelPlayer) != null ? ref$.page.top.height() : void 8) || 0); scaleW = w * 0.7 / 400; scaleH = h * 0.6 / 400; return scale = Math.min(scaleW, scaleH, 1); }; })(); trainers/followPathFreeDraw/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/followPathFreeDraw/hintPoint/hintPoint.ls (function(){ return function(slide){ var circleRadius, circleTimePerPoint, circle; circleRadius = 8; circleTimePerPoint = 12; slide.wrapper.append(circle = Div({ position: "absolute", width: 2 * circleRadius * slide.scale + "px", height: 2 * circleRadius * slide.scale + "px", marginLeft: -circleRadius * slide.scale + "px", marginTop: -circleRadius * slide.scale + "px", top: 0, left: 0, borderRadius: "100%", backgroundColor: Color.blue[500], opacity: 0, pointerEvents: "none" })); circle.startAnimation = function(){ var path, keyFrames, i$, len$, i, p, percentage; path = _.map(slide.currentPathPoints, function(p){ return { x: p.x * slide.scale, y: p.y * slide.scale }; }); keyFrames = { "0%": { transform: "translate(" + path[0].x + "px, " + path[0].y + "px) scale(3, 3)", opacity: 0 }, "20%": { transform: "translate(" + path[0].x + "px, " + path[0].y + "px)", opacity: 1 }, "100%": { transform: "translate(" + path[path.length - 1].x + "px, " + path[path.length - 1].y + "px) scale(2, 2)", opacity: 0 } }; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { i = i$; p = path[i$]; percentage = 0.2 + i * 0.5 / path.length; keyFrames[Math.round(percentage * 100) + "%"] = { transform: "translate(" + p.x + "px, " + p.y + "px)", opacity: 1 }; } return circle.show().css({ opacity: 0, transform: "translate(" + path[0].x + "px, " + path[0].y + "px)" }).keyframeAnimate({ keyframes: keyFrames, duration: circleTimePerPoint * slide.currentPathLength, delay: 1000, iterationCount: "infinite", timing: "linear" }); }; return circle; }; })(); trainers/followPathFreeDraw/init.ls (function(){ return function(slide){ slide.currentPathIndex = -1; slide.scale = inc("calcScale/calc")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.background = inc("background/background")(slide); slide.path = inc("path/path")(slide); slide.pathDraw = inc("pathDraw/path")(slide); slide.hintPoint = inc("hintPoint/hintPoint")(slide); return slide.startNextPath = function(){ return inc("startNextPath/start")(slide); }; }; })(); trainers/followPathFreeDraw/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/followPathFreeDraw/path/path.ls (function(){ return function(slide){ var svg, ref$, i$, ref1$, len$, p; svg = (ref$ = _.find(slide.mediaParams.svgs, { path: slide.atom.path })) != null ? ref$.svgText : void 8; slide.wrapper.append(svg = Svg({ svg: svg }).css({ position: "absolute", top: 0, left: 0, width: 400 * slide.scale + "px", height: 400 * slide.scale + "px", pointerEvents: "none" })); for (i$ = 0, len$ = (ref1$ = svg.find("path")).length; i$ < len$; ++i$) { p = ref1$[i$]; p.setAttribute("stroke", Color.grey[200]); } return svg; }; })(); trainers/followPathFreeDraw/pathDraw/drawLogic/checkCorrect/check.ls (function(){ return function(slide, path){ var maxAllowedDistance, maxAllowedDistanceEndPoints, dist, pathLength, l, i, p, getPos, i$, percentage, currentPos, slidePos, d, allowedDistance; maxAllowedDistance = 40 * slide.scale; maxAllowedDistanceEndPoints = 25 * slide.scale; dist = function(p1, p2){ return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)); }; pathLength = (l = 0, (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = path).length; i$ < len$; ++i$) { i = i$; p = ref$[i$]; if (i > 0) { results$.push(l += dist(path[i - 1], p)); } } return results$; }()), l); getPos = function(points, length, percentage){ var l, i$, len$, i, p, d, v; l = length * percentage; for (i$ = 0, len$ = points.length; i$ < len$; ++i$) { i = i$; p = points[i$]; if (i > 0) { d = dist(points[i - 1], p); if (l < d) { v = { x: d > 0 ? (p.x - points[i - 1].x) / d : p.x, y: d > 0 ? (p.y - points[i - 1].y) / d : p.y }; return { x: points[i - 1].x + v.x * l, y: points[i - 1].y + v.y * l }; } else { l -= d; } } } return { x: _.last(points).x, y: _.last(points).y }; }; for (i$ = 0; i$ <= 100; ++i$) { percentage = i$; p = percentage / 100; currentPos = getPos(path, pathLength, p); slidePos = getPos(slide.currentPathPoints, slide.currentPathLength, p); slidePos.x *= slide.scale; slidePos.y *= slide.scale; d = dist(currentPos, slidePos); allowedDistance = p === 0 || p === 1 ? maxAllowedDistanceEndPoints : maxAllowedDistance; if (d > allowedDistance) { return false; } } return true; }; })(); trainers/followPathFreeDraw/pathDraw/drawLogic/drawLogic.ls (function(){ return function(slide, canvas, repaint){ var animationFrame, gravity, wrongPathFlySpeed, wrongPathFadeSpeed, colorFadeSpeed, minMoveDistanceSquared, colorWrong, colorCorrect, colorCurrent, colorDone, drawLogic, toX, toY, toRgbValues, fromRgbValues, addWrongPathSegments, update, paintIfNeeeded, paint; animationFrame = undefined; gravity = 2000; wrongPathFlySpeed = 100; wrongPathFadeSpeed = 1.5; colorFadeSpeed = 1; minMoveDistanceSquared = 20; colorWrong = Color.red[500]; colorCorrect = Color.green[500]; colorCurrent = Color.black; colorDone = Color.grey[500]; drawLogic = { finishedPaths: [], currentPath: { color: colorCurrent, points: [] }, wrongPaths: [] }; toX = function(x){ return x - canvas.offset().left; }; toY = function(y){ return y - canvas.offset().top; }; drawLogic.onDown = function(e){ var i$; slide.hintPoint.hide(); for (i$ = 0; i$ < 2; ++i$) { drawLogic.currentPath.points.push({ x: toX(e.clientX), y: toY(e.clientY) }); } return paintIfNeeeded(); }; drawLogic.onMove = function(e){ var lastPoint, ref$, x, y; lastPoint = (ref$ = drawLogic.currentPath.points)[ref$.length - 1]; x = toX(e.clientX); y = toY(e.clientY); if (Math.pow(x - lastPoint.x, 2) + Math.pow(y - lastPoint.y, 2) < minMoveDistanceSquared) { return; } drawLogic.currentPath.points.push({ x: x, y: y }); return paintIfNeeeded(); }; toRgbValues = function(colorString){ return _.map(colorString.replace("rgba(", "").replace(",1)", "").split(","), function(v){ return +v; }); }; fromRgbValues = function(rgb){ return "rgba(" + rgb.join(",") + ",1)"; }; drawLogic.onUp = function(e){ var correct; correct = inc("checkCorrect/check")(slide, drawLogic.currentPath.points); if (correct) { drawLogic.currentPath.fadeFromColor = toRgbValues(drawLogic.currentPath.color); drawLogic.currentPath.fadeToColors = [toRgbValues(colorCorrect), toRgbValues(colorDone)]; drawLogic.currentPath.fadeSpeeds = [colorFadeSpeed * 8, colorFadeSpeed]; drawLogic.currentPath.fade = 0; drawLogic.finishedPaths.push(drawLogic.currentPath); update(); canvas.css({ pointerEvents: "none" }); slide.startNextPath(); } else { slide.hintPoint.show(); addWrongPathSegments(drawLogic.currentPath.points); if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.notificationSuccess); } slide.levelPlayer.progressBar.addElement().showRed(); slide.score.addActionMistake(slide.atom); } return drawLogic.currentPath = { color: colorCurrent, points: [] }; }; addWrongPathSegments = function(path){ var segLength, i$, len$, i, p, dx, dy, points, res$, j$, to$, j; segLength = 5; for (i$ = 0, len$ = path.length; i$ < len$; i$ += segLength) { i = i$; p = path[i$]; dx = _.random(-wrongPathFlySpeed, wrongPathFlySpeed); dy = _.random(-0.5 * wrongPathFlySpeed, 0); res$ = []; for (j$ = 0, to$ = Math.min(segLength, path.length - i); j$ < to$; ++j$) { j = j$; res$.push({ x: path[i + j].x, y: path[i + j].y }); } points = res$; drawLogic.wrongPaths.push({ points: points, dx: dx, dy: dy, alpha: 1, color: colorWrong }); } return update(); }; update = function(timeStamp){ var dt, i$, to$, i, path, j$, ref$, len$, p, hasFadingPath, rgb, res$; dt = 0.0166; for (i$ = 0, to$ = drawLogic.wrongPaths.length; i$ < to$; ++i$) { i = i$; if (i < drawLogic.wrongPaths.length) { path = drawLogic.wrongPaths[i]; for (j$ = 0, len$ = (ref$ = path.points).length; j$ < len$; ++j$) { p = ref$[j$]; p.x += dt * path.dx; p.y += dt * path.dy; } path.dy += gravity * dt; path.alpha -= dt * wrongPathFadeSpeed; if (path.alpha <= 0) { drawLogic.wrongPaths.splice(i, 1); } } } for (i$ = 0, len$ = (ref$ = drawLogic.finishedPaths).length; i$ < len$; ++i$) { p = ref$[i$]; if (p.fadeToColors.length) { hasFadingPath = true; p.fade = Math.min(1, p.fade + dt * p.fadeSpeeds[0]); res$ = []; for (j$ = 0; j$ < 3; ++j$) { i = j$; res$.push(p.fadeFromColor[i] * (1 - p.fade) + p.fadeToColors[0][i] * p.fade); } rgb = res$; p.color = fromRgbValues(rgb); if (p.fade === 1) { p.fadeFromColor = p.fadeToColors[0]; p.fade = 0; p.fadeToColors.splice(0, 1); p.fadeSpeeds.splice(0, 1); } } } paint(); if (drawLogic.wrongPaths.length > 0 || hasFadingPath) { return animationFrame = requestAnimationFrame(update); } }; paintIfNeeeded = function(){ var animationFrame; return animationFrame != null ? animationFrame : animationFrame = requestAnimationFrame(paint); }; paint = function(){ repaint(drawLogic); return animationFrame = undefined; }; return drawLogic; }; })(); trainers/followPathFreeDraw/pathDraw/path.ls (function(){ return function(slide){ var trackingTouchIdentifier, touchDown, touchMove, touchUp, mouseDown, mouseMove, mouseUp, canvas, repaint, drawLogic; touchDown = function(e){ var touch; if (trackingTouchIdentifier) { return; } e.preventDefault(); touch = e.touches[0]; trackingTouchIdentifier = touch.identifier; return drawLogic.onDown(touch); }; touchMove = function(e){ var i$, ref$, len$, t; for (i$ = 0, len$ = (ref$ = e.changedTouches).length; i$ < len$; ++i$) { t = ref$[i$]; if (t.identifier === trackingTouchIdentifier) { e.preventDefault(); drawLogic.onMove(t); return; } } }; touchUp = function(e){ var i$, ref$, len$, t; for (i$ = 0, len$ = (ref$ = e.changedTouches).length; i$ < len$; ++i$) { t = ref$[i$]; if (t.identifier === trackingTouchIdentifier) { trackingTouchIdentifier = undefined; e.preventDefault(); drawLogic.onUp(t); return; } } }; mouseDown = function(e){ return drawLogic.onDown(e); }; mouseMove = function(e){ if (e.buttons > 0) { drawLogic.onMove(e); } }; mouseUp = function(e){ return drawLogic.onUp(e); }; slide.wrapper.append(canvas = document.createElement("canvas").attr({ width: 400 * slide.scale * window.devicePixelRatio, height: 400 * slide.scale * window.devicePixelRatio }).bind("touchstart", touchDown).bind("touchmove", touchMove).bind("touchend", touchUp).bind("mousedown", mouseDown).bind("mousemove", mouseMove).bind("mouseup", mouseUp).css({ position: "absolute", top: 0, left: 0, width: 400 * slide.scale + "px", height: 400 * slide.scale + "px", pointerEvents: "none", touchAction: "none" })); repaint = inc("repaint/repaint")(slide, canvas); drawLogic = inc("drawLogic/drawLogic")(slide, canvas, repaint); canvas.start = function(){ return canvas.css({ pointerEvents: "auto" }); }; return canvas; }; })(); trainers/followPathFreeDraw/pathDraw/repaint/repaint.ls (function(){ return function(slide, canvas){ var ctx, toX, toY, drawPath, repaint; ctx = canvas.getContext("2d"); ctx.lineWidth = 20 * slide.scale * window.devicePixelRatio; ctx.lineCap = "round"; ctx.lineJoin = "round"; toX = function(x){ return x * window.devicePixelRatio; }; toY = function(y){ return y * window.devicePixelRatio; }; drawPath = function(path){ var ref$, p, i$, to$, i; if (path.points.length < 1) { return; } ctx.beginPath(); ctx.globalAlpha = (ref$ = path.alpha) != null ? ref$ : 1; ctx.strokeStyle = path.color; p = path.points[0]; ctx.moveTo(toX(p.x), toY(p.y)); for (i$ = 1, to$ = path.points.length; i$ < to$; ++i$) { i = i$; p = path.points[i]; ctx.lineTo(toX(p.x), toY(p.y)); } ctx.stroke(); }; return repaint = function(drawLogic){ var i$, ref$, len$, path; ctx.clearRect(0, 0, canvas.width, canvas.height); for (i$ = 0, len$ = (ref$ = drawLogic.finishedPaths).length; i$ < len$; ++i$) { path = ref$[i$]; drawPath(path); } for (i$ = 0, len$ = (ref$ = drawLogic.wrongPaths).length; i$ < len$; ++i$) { path = ref$[i$]; drawPath(path); } drawPath(drawLogic.currentPath); }; }; })(); trainers/followPathFreeDraw/resize/resize.ls (function(){ return function(slide){ var s, onResize; s = slide; return onResize = function(){ var i$, ref$, len$, el; if (!s.div.isVisible()) { window.removeEventListener("resize", onResize); return; } s.scale = inc("../calcScale/calc")(slide); for (i$ = 0, len$ = (ref$ = [s.background, s.path, s.pathDraw]).length; i$ < len$; ++i$) { el = ref$[i$]; el.css({ width: 400 * s.scale + "px", height: 400 * s.scale + "px" }); } s.cursor.replaceWith(inc("../cursor/cursor")(s)); return s.cursor.start(); }; }; })(); trainers/followPathFreeDraw/startNextPath/start.ls (function(){ return function(slide){ var p, res$, i$, to$, i; slide.currentPathIndex++; p = slide.path.find("path")[slide.currentPathIndex]; if (p) { slide.currentPath = p; slide.currentPathLength = p.getTotalLength(); res$ = []; for (i$ = 0, to$ = parseInt(p.getTotalLength()) + 10; i$ <= to$; ++i$) { i = i$; res$.push(p.getPointAtLength(i)); } slide.currentPathPoints = res$; slide.pathDraw.start(); return slide.hintPoint.startAnimation(); } else { slide.div.css({ pointerEvents: "none" }); slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atom, { point: null }); slide.score.log(slide.atom); return setTimeout(slide.finish, 1000); } }; })(); trainers/followPathFreeDraw/wrapper/wrapper.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ display: "inline-block" })); return div; }; })(); trainers/gap/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/gap/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/gap/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, that, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); texts = (that = slide.atom.sound) ? [that] : soundMode === "a" || soundMode === "askSound" ? [slide.atom.a] : soundMode === "b" ? inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: slide.atom.b }) : []; voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/gap/_preview/preview.ls (function(){ return function(slide){ var lsg, ref$, width; lsg = (ref$ = slide.lsg) != null ? ref$.findFirst("svg") : void 8; if (!lsg) { return; } width = lsg.css("width"); return lsg.css({ width: width.replace("em", "") * 0.4 + "em" }); }; })(); trainers/gap/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return inc("/shared/gapComponent/scoreActions/actions")({ slide: slide, gapComponent: slide.textB, actions: scoreEvent.actions, showYellowTag: slide.textB.gaps().length > 1 }).appendTo(slide.div).css({ paddingTop: "1em" }); } }; })(); trainers/gap/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.levelPlayer.page.enableFreezeMinHeight(); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.textB, { padding: 50 }); }); } }); if (slide.gapMode === "buttons") { slide.levelPlayer.page.bottom.append(slide.buttonsDiv).show(); } inc("/shared/playSoundA/play")(slide.atom, slide); if (slide.textB.gaps().length === 0) { slide.finishButton = true; slide.levelPlayer.page.setBottomFreeze("5em"); } return slide.textB.start(); }; })(); trainers/gap/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).appendTo(slide.div).css({ margin: "-0.4em 0 0" }); }; })(); trainers/gap/buttonsDiv/buttonsDiv.ls (function(){ return function(slide){ if (slide.gapMode !== "buttons") { return; } return ScrollDiv({ scrollbarMode: "show" }).addClass("gapTextButtonsDiv").css({ width: "100%", textAlign: "center", maxHeight: body.height() / 2 + "px" }); }; })(); trainers/gap/calcShowContinueSpeakerButton/calc.ls (function(){ return function(levelParams, trainerParams, atoms){ var getParam, i$, len$, atom, texts, that, j$, len1$, text; getParam = function(v, atom){ return (atom != null ? atom[v] : void 8) || trainerParams[v] || levelParams[v]; }; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; if (!atom.b || getParam("soundMode", atom) !== "b") { continue; } texts = (that = atom.sound) ? [that] : inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); for (j$ = 0, len1$ = texts.length; j$ < len1$; ++j$) { text = texts[j$]; if (text.split(/\s+/).length > 6) { return true; } } } return false; }; })(); trainers/gap/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ slide.levelPlayer.page.centerDuration = 600; slide.div.append(div); div.fadeIn(600); return requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(div, { padding: 50 }); }); }; click = function(){ var ref$; if ((ref$ = slide.currentBSound) != null) { ref$.stop(); } div.hide(); return setTimeout(function(){ return inc("../onFinish/onFinish")(slide); }, 200); }; div = Div({ textAlign: "center" }).append(Button({ label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "1em", textAlign: "center" }).tap(click).addClass("keyManager-enter").bind("keyManager", click)); div.showButton = showButton; return div; }; })(); trainers/gap/continueSpeakerButton/button.ls (function(){ return function(slide){ var showButton, click, div, speaker; showButton = function(){ slide.levelPlayer.page.centerDuration = 600; slide.div.append(div); div.fadeIn(600); return requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(div, { padding: 50 }); }); }; click = function(){ var ref$; if ((ref$ = slide.currentBSound) != null) { ref$.stop(); } div.hide(); return setTimeout(function(){ return inc("../onFinish/onFinish")(slide); }, 500); }; div = Div({ textAlign: "center" }).append(Button(T("continueButton")).css({ margin: "1em", textAlign: "center", color: Color.grey[800] }).prepend(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ progressbarType: "below", progressBarFillDirection: "left", speakerType: "123", size: "1.6em" }).css({ marginRight: "0.5em" })).tap(click).addClass("keyManager-enter").bind("keyManager", click)); speaker.findFirst(".progressBarVolume").css({ backgroundColor: Color.grey[600] }); speaker.findFirst(".speaker").setColor(Color.grey[600]); div.showButton = showButton; div.speaker = speaker; return div; }; })(); trainers/gap/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, showContinueSpeakerButton, slides, atom, slide, totalProgressElements; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } showContinueSpeakerButton = inc("calcShowContinueSpeakerButton/calc")(levelParams, trainerParams, atoms); return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.showContinueSpeakerButton = showContinueSpeakerButton; slide.atom = atom; totalProgressElements = inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b); slide.totalProgressElements = Math.max(1, totalProgressElements); slide.gapMode = slide.getParam("gapMode", slide.atom); slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/gap/imageOrLsg/imageOrLsg.ls (function(){ return function(slide){ var p, lsg, image, div; p = slide.getParam; lsg = p("lsg", slide.atom); image = p("image", slide.atom); if (lsg) { div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); } else if (image) { div = inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }); } else { return; } return div != null ? div.appendTo(slide.div) : void 8; }; })(); trainers/gap/init.ls (function(){ return function(slide){ var separator; slide.div.css({ paddingBottom: "1em", width: "35em", maxWidth: "90%", margin: "0 auto" }); slide.instruction = inc("instruction/instruction")(slide); slide.imageOrLsg = inc("imageOrLsg/imageOrLsg")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.continueButton = inc("continueButton/button")(slide); slide.continueSpeakerButton = inc("continueSpeakerButton/button")(slide); slide.buttonsDiv = inc("buttonsDiv/buttonsDiv")(slide); return slide.div.append(Div({ display: "inline-flex", flexDirection: "column", maxWidth: "90%", alignItems: slide.getParam("textAlign", slide.atom) === "left" ? "flex-start" : void 8 }).append(slide.textA = inc("textA/textA")(slide), separator = inc("separator/separator")(slide), slide.textB = inc("textB/textB")(slide))); }; })(); trainers/gap/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/gap/onFinish/onFinish.ls (function(){ return function(slide){ return slide.score.log(slide.atom, function(){ slide.div.css({ pointerEvents: "none" }); if (slide.textB.gaps().length === 0) { slide.levelPlayer.progressBar.showGreen(); } return slide.finish(); }); }; })(); trainers/gap/separator/separator.ls (function(){ return function(slide){ if (!slide.textA) { return; } return Div({ width: "100%", borderBottom: "1px solid " + Color.grey[300], margin: "0.6em auto" }); }; })(); trainers/gap/textA/textA.ls (function(){ return function(slide){ var p; if (!slide.atom.a) { return; } p = slide.getParam; if (p("soundMode", slide.atom) === "askSound") { return; } return Div({ width: "100%", padding: "0.4em 0 0.2em", textAlign: p("textAlign", slide.atom), alignSelf: p("textAlign", slide.atom) === "left" ? "flex-start" : "center" }).html(slide.atom.a); }; })(); trainers/gap/textB/playSoundB/play.ls (function(){ return function(slide, result, callback){ var onFinish; onFinish = function(){ slide.continueButton.hide(); slide.continueSpeakerButton.hide(); return callback(); }; if (slide.getParam("soundMode", slide.atom) === "b") { slide.currentBSound = inc("/shared/playSoundB/play")(slide.atom, slide, result != null ? result.correctValue : void 8, onFinish); return inc("showContinueSpeakerButton/show")(slide); } else { return setTimeout(onFinish, 1000); } }; })(); trainers/gap/textB/playSoundB/showContinueSpeakerButton/show.ls (function(){ return function(slide){ var timepassed, duration, playTimer, speakerButton, onInterval, showButton; timepassed = 0; duration = null; playTimer = null; speakerButton = slide.continueSpeakerButton; onInterval = function(){ if (timepassed > duration || !speakerButton.isVisible()) { clearInterval(playTimer); speakerButton.speaker.reset(); return; } timepassed += 10; return speakerButton.speaker.update(timepassed, duration); }; showButton = function(){ var ref$; duration = (ref$ = slide.currentBSound) != null ? typeof ref$.getDuration == 'function' ? ref$.getDuration() : void 8 : void 8; if (!duration) { return slide.continueButton.showButton(); } else if (slide.div.isVisible() && slide.showContinueSpeakerButton && duration > 1000) { playTimer = setInterval(onInterval, 10); return speakerButton.showButton(); } }; return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: showButton }); }; })(); trainers/gap/textB/textB.ls (function(){ return function(slide){ var p, atom, gapComponent; p = slide.getParam; atom = slide.atom; gapComponent = inc("/shared/gapComponent/component/component")({ slide: slide, atom: atom, text: atom.b, textAlign: p("textAlign", atom), mode: slide.gapMode, buttonsDiv: slide.buttonsDiv, onActionCorrect: function(action, callback){ return slide.score.addActionCorrect(atom, action, callback); }, onActionMistake: function(action){ return slide.score.addActionMistake(atom, action); }, onActionResolved: function(action){ return slide.score.addActionResolved(atom, action); }, onFinish: function(result){ return inc("playSoundB/play")(slide, result, function(){ return inc("../onFinish/onFinish")(slide); }); } }); return gapComponent.css({ width: "100%", textAlign: p("textAlign", atom), fontSize: (p("fontScale", atom) || 1) + "em", marginTop: "0.3em", fontFamily: gapComponent.style["fontFamily"] === "" ? p("fontFamily", atom) : void 8 }); }; })(); trainers/gapMulti/_media2/images/images.ls (function(){ return function(slide){ var images, atom, i$, ref$, len$, p; images = _.concat(slide.getParam("image"), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }())); for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; p = slide.getParam("person", atom); if (p != null && p.image) { images.push(p.image); } } return images; }; })(); trainers/gapMulti/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var lsgs, atom, i$, ref$, len$, p; lsgs = _.concat(slide.getParam("lsg"), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }())); for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; p = slide.getParam("person", atom); if (p != null && p.lsg) { lsgs.push(p.lsg); } } return lsgs; }; })(); trainers/gapMulti/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, p, i$, ref$, len$, atom, soundMode, texts, that, j$, len1$, text, voice, voiceLang; sounds = []; p = slide.getParam; for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "a" && "b")).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = p("soundMode", atom); if (soundMode === "b" || soundMode === "ab") { texts = (that = atom.sound) ? [that] : inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); for (j$ = 0, len1$ = texts.length; j$ < len1$; ++j$) { text = texts[j$]; if (text) { voice = p("voiceB", atom) || p("voice", atom); voiceLang = p("voiceLangB", atom) || p("voiceLang", atom); sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } if (soundMode === "a" || soundMode === "ab" || soundMode === "askSound") { text = atom.sound || atom.a; if (text) { voice = p("voiceA", atom) || p("voice", atom); voiceLang = p("voiceLangA", atom) || p("voiceLang", atom); sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } return sounds; }; })(); trainers/gapMulti/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, e, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { e = ref$[i$]; e.show(); results$.push((ref1$ = e.lsgOrImage) != null ? ref1$.scaleToParent() : void 8); } return results$; }; })(); trainers/gapMulti/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, element, matchingActions, results$ = []; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; a.originalAtom = e.atom; actions.push(a); } } for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { element = ref$[i$]; if (element.gapComponent == null) { continue; } matchingActions = _.filter(actions, fn$); results$.push(element.after(inc("/shared/gapComponent/scoreActions/actions")({ slide: slide, gapComponent: element.gapComponent, actions: matchingActions, showYellowTag: element.gapComponent.gaps().length > 1 }))); } return results$; function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(element.atom); } }; })(); trainers/gapMulti/_skip/skip.ls (function(){ return function(slide){ var gc, unfinishedGaps, i$, len$, g, ref$, ref1$, ref2$; gc = slide.currentElement.gapComponent; unfinishedGaps = _.filter(gc.gaps(), function(g){ return !g.gapIsCompleted; }); if (slide.currentElement === _.last(slide.elements)) { slide.levelPlayer.currentGap = undefined; for (i$ = 0, len$ = unfinishedGaps.length; i$ < len$; ++i$) { g = unfinishedGaps[i$]; slide.levelPlayer.progressBar.showGreen(); } slide.onFinishedSlide(); return; } if (gc.isVisible()) { gc.css({ pointerEvents: "none" }); } if (typeof gc.stop == 'function') { gc.stop(); } if ((ref$ = slide.levelPlayer.currentGap) != null) { ref$.stopGap(); } for (i$ = 0, len$ = unfinishedGaps.length; i$ < len$; ++i$) { g = unfinishedGaps[i$]; slide.levelPlayer.progressBar.showGreen(); } if ((ref1$ = slide.buttonsDiv) != null) { ref1$.hide(); } if ((ref2$ = slide.currentBSound) != null) { ref2$.stop(); } slide.continueButton.hide(); slide.continueSpeakerButton.hide(); return requestAnimationFrame(function(){ return slide.finishCurrentElement(); }); }; })(); trainers/gapMulti/_start/start.ls (function(){ return function(slide){ if (slide.design !== "dialogue") { slide.elementsDiv.css({ width: "35em" }); } slide.levelPlayer.page.bottom.append(slide.buttonsDiv); slide.startNextElement(); return slide.instruction.play(); }; })(); trainers/gapMulti/buttonsDiv/buttonsDiv.ls (function(){ return function(slide){ return ScrollDiv({ scrollbarMode: "show" }).addClass("gapTextButtonsDiv").css({ width: "100%", textAlign: "center", maxHeight: body.height() / 2 + "px" }).hide(); }; })(); trainers/gapMulti/calcShowContinueSpeakerButton/calc.ls (function(){ return function(slide){ var i$, ref$, len$, atom, texts, that, j$, len1$, text; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; if (!atom.b || slide.getParam("soundMode", atom) !== "b") { continue; } texts = (that = atom.sound) ? [that] : inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); for (j$ = 0, len1$ = texts.length; j$ < len1$; ++j$) { text = texts[j$]; if (text.split(/\s+/).length > 6) { return true; } } } return false; }; })(); trainers/gapMulti/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ slide.currentElement.after(div); div.fadeIn(600); return requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(div, { padding: 50 }); }); }; click = function(){ var ref$; if ((ref$ = slide.currentBSound) != null) { ref$.stop(); } div.hide(); return setTimeout(slide.finishCurrentElement, 200); }; div = Div({ textAlign: "center" }).append(Button({ label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ minWidth: "5em", margin: "1em", textAlign: "center" }).tap(click).addClass("keyManager-enter").bind("keyManager", click)); div.showButton = showButton; return div; }; })(); trainers/gapMulti/continueSpeakerButton/button.ls (function(){ return function(slide){ var showButton, click, div, speaker; showButton = function(){ slide.currentElement.after(div); div.fadeIn(600); return requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(div, { padding: 50 }); }); }; click = function(){ var ref$; if ((ref$ = slide.currentBSound) != null) { ref$.stop(); } div.hide(); return setTimeout(slide.finishCurrentElement, 500); }; div = Div({ textAlign: "center" }).append(Button(T("continueButton")).css({ margin: "1em", textAlign: "center", color: Color.grey[800] }).prepend(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ progressbarType: "below", progressBarFillDirection: "left", speakerType: "123", size: "1.6em" }).css({ marginRight: "0.5em" })).tap(click).addClass("keyManager-enter").bind("keyManager", click)); speaker.findFirst(".progressBarVolume").css({ backgroundColor: Color.grey[600] }); speaker.findFirst(".speaker").setColor(Color.grey[600]); div.showButton = showButton; div.speaker = speaker; return div; }; })(); trainers/gapMulti/elements/_shared/lsgOrImage/lsgOrImage.ls (function(){ return function(atom, slide, parent){ var div; if (atom.image) { return div = inc("/shared/image/image")({ image: slide.getParam("image", atom), slide: slide, parent: parent, wrapWithDiv: true }); } else if (atom.lsg) { return inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", atom), slide: slide, parent: parent, wrapWithDiv: true }); } }; })(); trainers/gapMulti/elements/elements.ls (function(){ return function(slide){ var i, atom; slide.elements = []; return Div({ display: "inline-block", textAlign: "left", maxWidth: "95%" }).html(slide.elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; if (atom.text) { results$.push(inc("textElement/element")(atom, slide)); } else { results$.push(inc("gapElement/element")(atom, i, slide)); } } return results$; }())).appendTo(slide.div); }; })(); trainers/gapMulti/elements/gapElement/askSound/askSound.ls (function(){ return function(slide, atom){ var init, div, speaker; init = function(){ var voice, text; voice = slide.getParam("voice", atom); text = atom.sound || atom.a; speaker.setSound(slide.sounds[text + voice]); return slide.askSound = speaker; }; div = Div({ textAlign: "center" }).append(speaker = inc("/../app01/lib/gui/speakerIconPlayer/speakerIconPlayer")({ size: "2em" })); div.init = init; return div; }; })(); trainers/gapMulti/elements/gapElement/calcShowAskSound/calc.ls (function(){ return function(atom, slide){ return slide.getParam("soundMode", atom) === "askSound" && (atom.sound || atom.a); }; })(); trainers/gapMulti/elements/gapElement/div/default/div.ls (function(){ return function(atom, i, slide){ var startAnimation, div; startAnimation = function(){ var ref$; div.fadeIn(); return (ref$ = div.lsgOrImage) != null ? ref$.scaleToParent() : void 8; }; div = Div({ padding: "1em", borderTop: i !== 0 ? "1px solid " + Color.grey[250] : void 8, textAlign: slide.getParam("textAlign", atom) || "center" }); div.startAnimation = startAnimation; return div; }; })(); trainers/gapMulti/elements/gapElement/div/dialogue/avatar/avatar.ls (function(){ return function(position, type){ return inc("/../lsg-avatar/avatarTalk/avatarTalk")({ type: type, size: "4em" }).css({ position: "absolute", top: 0, marginTop: "-0.3em" }).css(position === "left" ? { left: 0, marginLeft: "-0.5em" } : { right: 0, marginRight: "-0.5em" }); }; })(); trainers/gapMulti/elements/gapElement/div/dialogue/avatarLsgOrImage/lsgOrImage.ls (function(){ return function(slide, person, position){ var lsg, image, div, wrapper; lsg = slide.getParam("lsg", person); image = slide.getParam("image", person); div = person.lsg ? inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ overflow: "hidden" }) : person.image ? inc("/shared/image/image")({ image: image, slide: slide }) : void 8; return wrapper = Div({ position: "absolute", width: "4em", height: "4em", marginTop: "-0.7em", top: 0 }).css(position === "left" ? { left: 0 } : { right: 0 }).html(div.css({ position: "absolute", borderRadius: "50%", top: 0, left: 0, width: "4em", height: "4em" })); }; })(); trainers/gapMulti/elements/gapElement/div/dialogue/bubble/bubble.ls (function(){ return function(person, position){ return Div({ position: "absolute", top: 0, bottom: 0, boxShadow: "1px 1px 10px rgba(0,0,0,0.2)", borderRadius: "0.5em" }).css(position === "left" ? { left: person === "default" ? "3.5em" : "4.8em", right: "0.5em" } : { left: "0.5em", right: person === "default" ? "3.5em" : "4.8em" }).append(Div({ position: "absolute", top: "0.75em", left: position === "left" ? "-0.3em" : void 8, right: position === "right" ? "-0.3em" : void 8, width: "1em", height: "1em", transform: "rotate(45deg)", boxShadow: "1px 1px 10px rgba(0,0,0,0.2)" }), Div({ position: "absolute", top: "0.75em", left: position === "left" ? "-0.3em" : void 8, right: position === "right" ? "-0.3em" : void 8, width: "1em", height: "1em", backgroundColor: "white", transform: "rotate(45deg)" }), Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0, borderRadius: "0.5em", backgroundColor: Color.white })); }; })(); trainers/gapMulti/elements/gapElement/div/dialogue/calcAvatarType/calc.ls (function(){ return function(atom, slide){ var type, i; slide.voiceAvatarMap == null && (slide.voiceAvatarMap = {}); slide.types == null && (slide.types = ["m2", "m1", "m3", "f1", "f2", "f3"]); type = slide.voiceAvatarMap[atom.voice]; if (!type) { i = _.findIndex(slide.types, function(t){ return t === atom.voice; }); if (i === -1) { i = _.findIndex(slide.types, function(t){ return t[0] === atom.voice[0]; }); } type = slide.types[i]; slide.types.splice(i, 1); slide.voiceAvatarMap[atom.voice] = type; } return type; }; })(); trainers/gapMulti/elements/gapElement/div/dialogue/calcRole/calc.ls (function(){ return function(atom, slide){ var role; slide.roles == null && (slide.roles = {}); slide.totalRoles == null && (slide.totalRoles = 0); role = slide.roles[atom.voice]; if (!role) { slide.totalRoles++; role = slide.totalRoles; slide.roles[atom.voice] = role; } return role; }; })(); trainers/gapMulti/elements/gapElement/div/dialogue/div.ls (function(){ return function(atom, slide){ var role, type, position, person, startAnimation, div, avatar; role = inc("calcRole/calc")(atom, slide); type = inc("calcAvatarType/calc")(atom, slide); position = atom.position || (role % 2 === 1 ? "left" : "right"); person = slide.getParam("person", atom) || "default"; startAnimation = function(){ var ref$; div.show(); if ((ref$ = div.lsgOrImage) != null) { ref$.scaleToParent(); } return div.keyframeAnimate({ keyframes: { "0%": { opacity: 0, transform: "scale(0.9, 0.9)" }, "100%": { opacity: 1, transform: "" } }, duration: 400 }); }; div = Div({ margin: "1.5em 0", minHeight: "2.4em", minWidth: "15em", maxWidth: "35em", transformOrigin: position === "left" ? "0% 0%" : "100% 0%" }).css(position === "left" ? { padding: "0.8em 1.4em 0.6em 4.3em", textAlign: "left" } : { padding: "0.8em 4.3em 0.6em 1.4em", textAlign: "right" }).css(person !== "default" ? position === "left" ? { paddingLeft: "5.6em" } : { paddingRight: "5.6em" } : void 8).append(person === "default" ? avatar = inc("avatar/avatar")(position, type) : inc("avatarLsgOrImage/lsgOrImage")(slide, person, position), inc("bubble/bubble")(person, position)); div.startAnimation = startAnimation; return div; }; })(); trainers/gapMulti/elements/gapElement/div/div.ls (function(){ return function(atom, i, slide){ if (slide.design === "dialogue") { return inc("dialogue/div")(atom, slide); } else { return inc("default/div")(atom, i, slide); } }; })(); trainers/gapMulti/elements/gapElement/element.ls (function(){ return function(atom, i, slide){ var start, div, lsgOrImage, askSound, gapComponent; start = function(){ div.startAnimation(); gapComponent.start(); return typeof askSound != 'undefined' && askSound !== null ? askSound.init() : void 8; }; div = inc("div/div")(atom, i, slide); div.append(lsgOrImage = inc("../_shared/lsgOrImage/lsgOrImage")(atom, slide, div), inc("calcShowAskSound/calc")(atom, slide) ? askSound = inc("askSound/askSound")(slide, atom) : inc("textA/textA")(atom, slide), inc("separator/separator")(atom, slide), gapComponent = inc("gapComponent/gapComponent")(atom, slide)).hide(); div.atom = atom; div.gapComponent = gapComponent; div.start = start; div.lsgOrImage = lsgOrImage; return div; }; })(); trainers/gapMulti/elements/gapElement/gapComponent/gapComponent.ls (function(){ return function(atom, slide){ var p, gapMode, gapComponent; p = slide.getParam; gapMode = p("gapMode", atom); gapComponent = inc("/shared/gapComponent/component/component")({ slide: slide, atom: atom, text: atom.b, textAlign: p("textAlign", atom), mode: gapMode, buttonsDiv: slide.buttonsDiv, onStart: function(){ var ref$; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, atom); } return typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function' ? ref$.setCalculator(slide, atom) : void 8; }, onActionCorrect: function(action, callback){ return slide.score.addActionCorrect(atom, action, callback); }, onActionMistake: function(action){ return slide.score.addActionMistake(atom, action); }, onActionResolved: function(action){ return slide.score.addActionResolved(atom, action); }, onFinish: function(result){ return slide.playSoundBCurrentElement(result, function(){ return slide.finishCurrentElement(); }); } }); return gapComponent.css({ width: "100%", textAlign: p("textAlign", atom), fontSize: (p("fontScale", atom) || 1) + "em", fontFamily: gapComponent.style["fontFamily"] === "" ? p("fontFamily", atom) : void 8 }); }; })(); trainers/gapMulti/elements/gapElement/separator/calcShowSeparator/calc.ls (function(){ return function(atom, slide){ return atom.a && atom.b && !inc("../../calcShowAskSound/calc")(atom, slide); }; })(); trainers/gapMulti/elements/gapElement/separator/separator.ls (function(){ return function(atom, slide){ if (!inc("calcShowSeparator/calc")(atom, slide)) { return; } return Div({ height: "0.5em" }); }; })(); trainers/gapMulti/elements/gapElement/textA/textA.ls (function(){ return function(atom, slide){ if (!atom.a) { return; } return Div({ width: "100%", paddingBottom: "0.3em", color: slide.design === "dialogue" ? Color.grey[700] : void 8, fontStyle: slide.design === "dialogue" ? "italic" : void 8 }).secureHtml(atom.a); }; })(); trainers/gapMulti/elements/textElement/element.ls (function(){ return function(atom, slide){ var start, div; start = function(){ div.fadeIn(); return slide.finishCurrentElement(); }; div = Div({ margin: "0.2em 0", padding: "0 1em" }); div.html(inc("../_shared/lsgOrImage/lsgOrImage")(atom, slide, div), inc("text/text")(atom, slide)).hide(); div.atom = atom; div.start = start; return div; }; })(); trainers/gapMulti/elements/textElement/text/text.ls (function(){ return function(atom, slide){ return Div({ lineHeight: "1.5em", padding: "1em 0", textAlign: slide.getParam("textAlign", atom) || "center" }).secureHtml(atom.text); }; })(); trainers/gapMulti/finishCurrentElement/finish.ls (function(){ return function(slide){ return function(){ return slide.score.log(slide.currentAtom, function(){ var ref$; if (((ref$ = slide.currentElement.gapComponent) != null ? ref$.gaps().length : void 8) === 0) { slide.levelPlayer.progressBar.showGreen(); } if (slide.currentElement === _.last(slide.elements)) { slide.div.css({ pointerEvents: "none" }); return slide.finish(); } else { return slide.startNextElement(); } }); }; }; })(); trainers/gapMulti/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide, totalProgressElements, i$, len$, atom, totalGaps; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.showContinueSpeakerButton = inc("calcShowContinueSpeakerButton/calc")(slide); totalProgressElements = 0; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; totalGaps = inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b); totalProgressElements += totalGaps; if (atom.b && totalGaps === 0) { totalProgressElements++; } } slide.totalProgressElements = totalProgressElements; slide.design = slide.getParam("design") || "default"; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/gapMulti/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image"); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/gapMulti/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.buttonsDiv = inc("buttonsDiv/buttonsDiv")(slide); slide.elementsDiv = inc("elements/elements")(slide); slide.continueButton = inc("continueButton/button")(slide); slide.continueSpeakerButton = inc("continueSpeakerButton/button")(slide); slide.startNextElement = inc("startNextElement/start")(slide); slide.finishCurrentElement = inc("finishCurrentElement/finish")(slide); return slide.playSoundBCurrentElement = inc("playSoundBCurrentElement/play")(slide); }; })(); trainers/gapMulti/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/gapMulti/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg"); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/gapMulti/playSoundBCurrentElement/play.ls (function(){ return function(slide){ return function(result, onFinished){ var playSoundB, showContinueSpeakerButton, ref$, currentAtom, elementDone, ref1$; playSoundB = inc("play/play")(slide, result); showContinueSpeakerButton = inc("showContinueSpeakerButton/show")(slide); if ((ref$ = slide.buttonsDiv) != null) { ref$.hide(); } currentAtom = slide.currentAtom; elementDone = function(){ slide.continueButton.hide(); slide.continueSpeakerButton.hide(); return onFinished(); }; if (slide.getParam("continueButton", slide.currentAtom)) { slide.continueButton.showButton(); return playSoundB(); } else if ((ref1$ = slide.getParam("soundMode", slide.currentAtom)) === "b" || ref1$ === "ab") { playSoundB(elementDone); return showContinueSpeakerButton(currentAtom); } else { return setTimeout(elementDone, 1000); } }; }; })(); trainers/gapMulti/playSoundBCurrentElement/play/play.ls (function(){ return function(slide, result){ return function(onEnded){ var avatarTalk, currentAtom; avatarTalk = slide.currentElement.findFirst(".avatarTalk"); currentAtom = slide.currentAtom; return slide.currentBSound = inc("/shared/playSoundB/play")(slide.currentAtom, slide, result != null ? result.correctValue : void 8, onEnded, avatarTalk != null ? avatarTalk.update : void 8); }; }; })(); trainers/gapMulti/playSoundBCurrentElement/showContinueSpeakerButton/show.ls (function(){ return function(slide){ return function(currentAtom){ var timepassed, duration, playTimer, speakerButton, onInterval, showButton; timepassed = 0; duration = null; playTimer = null; speakerButton = slide.continueSpeakerButton; onInterval = function(){ if (timepassed > duration || !speakerButton.isVisible()) { clearInterval(playTimer); return speakerButton.speaker.reset(); } else { timepassed += 10; return speakerButton.speaker.update(timepassed, duration); } }; showButton = function(){ var ref$; duration = (ref$ = slide.currentBSound) != null ? typeof ref$.getDuration == 'function' ? ref$.getDuration() : void 8 : void 8; if (!duration) { return slide.continueButton.showButton(); } else if (slide.showContinueSpeakerButton && currentAtom === slide.currentAtom && duration > 1000) { playTimer = setInterval(onInterval, 10); return speakerButton.showButton(); } }; return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: function(){ return setTimeout(showButton, 300); } }); }; }; })(); trainers/gapMulti/startNextElement/start.ls (function(){ return function(slide){ return function(){ var page, element, atom, ref$, avatarTalk; slide.currentIndex++; page = slide.levelPlayer.page; if (slide.currentIndex === 0) { page.enableFreezeMinHeight(); } if (slide.currentIndex === 1) { page.centerDuration = 500; } element = slide.elements[slide.currentIndex]; atom = slide.atoms[slide.currentIndex]; slide.currentElement = element; slide.currentAtom = atom; if (element) { if (element.gapComponent != null && !element.gapComponent.isDone() && slide.getParam("gapMode", atom) === "buttons") { page.bottom.show(); if ((ref$ = slide.buttonsDiv) != null) { ref$.show(); } } element.start(); avatarTalk = element.findFirst(".avatarTalk"); inc("/shared/playSoundA/play")(atom, slide, void 8, avatarTalk != null ? avatarTalk.update : void 8); return slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ var scrollToElement, ref$; scrollToElement = ((ref$ = element.gapComponent) != null ? ref$.gaps()[0] : void 8) || element.gapComponent; return page.scrollElementIntoView(scrollToElement, { padding: 50 }); } }); } else { return setTimeout(slide.finish, 500); } }; }; })(); trainers/gapMultiLearnList/_media2/images/images.ls (function(){ return function(slide){ var images, atom, i$, ref$, len$, p; images = _.concat(slide.getParam("image"), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }())); for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; p = slide.getParam("person", atom); if (p != null && p.image) { images.push(p.image); } } return images; }; })(); trainers/gapMultiLearnList/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var lsgs, atom, i$, ref$, len$, p; lsgs = _.concat(slide.getParam("lsg"), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }())); for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; p = slide.getParam("person", atom); if (p != null && p.lsg) { lsgs.push(p.lsg); } } return lsgs; }; })(); trainers/gapMultiLearnList/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, p, i$, ref$, len$, atom, soundMode, customSound, texts, that, j$, len1$, text, voice, voiceLang; sounds = []; p = slide.getParam; for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "a" && "b")).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = p("soundMode", atom); if (soundMode === "b" || soundMode === "ab") { customSound = atom.soundB || atom.sound; texts = (that = customSound) ? [that] : inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); for (j$ = 0, len1$ = texts.length; j$ < len1$; ++j$) { text = texts[j$]; if (text) { voice = p("voiceB", atom) || p("voice", atom); voiceLang = p("voiceLangB", atom) || p("voiceLang", atom); sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } if (soundMode === "a" || soundMode === "ab" || soundMode === "askSound") { text = atom.soundA || atom.sound || atom.a; if (text) { voice = p("voiceA", atom) || p("voice", atom); voiceLang = p("voiceLangA", atom) || p("voiceLang", atom); sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } return sounds; }; })(); trainers/gapMultiLearnList/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, e, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { e = ref$[i$]; results$.push(e.show()); } return results$; }; })(); trainers/gapMultiLearnList/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, element, matchingActions, results$ = []; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; a.originalAtom = e.atom; actions.push(a); } } for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { element = ref$[i$]; if (element.gapComponent == null) { continue; } matchingActions = _.filter(actions, fn$); results$.push(element.after(inc("/shared/gapComponent/scoreActions/actions")({ slide: slide, gapComponent: element.gapComponent, actions: matchingActions, showYellowTag: element.gapComponent.gaps().length > 1 }))); } return results$; function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(element.atom); } }; })(); trainers/gapMultiLearnList/_skip/skip.ls (function(){ return function(slide){ var gc, unfinishedGaps, i$, len$, g, ref$, ref1$; gc = slide.currentElement.gapComponent; unfinishedGaps = _.filter(gc.gaps(), function(g){ return !g.gapIsCompleted; }); if (slide.currentElement === _.last(slide.elements)) { slide.levelPlayer.currentGap = undefined; for (i$ = 0, len$ = unfinishedGaps.length; i$ < len$; ++i$) { g = unfinishedGaps[i$]; slide.levelPlayer.progressBar.showGreen(); } slide.onFinishedSlide(); return; } gc = slide.currentElement.gapComponent; if (gc.isVisible()) { gc.css({ pointerEvents: "none" }); } if (typeof gc.stop == 'function') { gc.stop(); } if ((ref$ = slide.levelPlayer.currentGap) != null) { ref$.stopGap(); } for (i$ = 0, len$ = (ref1$ = gc.gaps()).length; i$ < len$; ++i$) { g = ref1$[i$]; if (!g.gapIsCompleted) { slide.levelPlayer.progressBar.showGreen(); } } return slide.startNextElement(); }; })(); trainers/gapMultiLearnList/_start/start.ls (function(){ return function(slide){ if (!_.startsWith(slide.levelPlayer.level.path, "/learnList")) { debug("warning: trainer may only be used in learnlists"); } inc("../optimizeWidth/optimize")(slide); slide.startNextElement(); return slide.instruction.play(); }; })(); trainers/gapMultiLearnList/_t.ls (function(){ return { again: { de: "Nochmal", en: "Again", fr: "Revoir", es: "Repetir", pt: "Repetir" }, knowActually: { de: "Kann ich eigentlich", en: "I actually know it!", fr: "Je connais !", es: "¡Ya me lo sé!", pt: "Já consigo!" }, nThAttempt: { de: "$1. Versuch", en: "$1. attempt", fr: "Essai n° $1", es: "$1° intento", pt: "$1ª tentativa" }, didntWrite: { de: "Du hast nichts geschrieben.", en: "You haven't written anything.", fr: "Tu n'as rien écrit.", es: "Aún no has escrito nada.", pt: "Você ainda não escreveu nada." }, notCorrect: { de: "Das ist nicht ganz richtig.", en: "That is not quite right.", fr: "Ce n'est pas tout à fait ça.", es: "No es del todo correcto.", pt: "Não está totalmente correto." } }; })(); trainers/gapMultiLearnList/elements/_shared/lsgOrImage/lsgOrImage.ls (function(){ return function(atom, slide, parent){ if (atom.image) { return inc("/shared/image/image")({ image: slide.getParam("image", atom), slide: slide, parent: parent, wrapWithDiv: true }); } else if (atom.lsg) { return inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", atom), slide: slide, parent: parent, wrapWithDiv: true }); } }; })(); trainers/gapMultiLearnList/elements/element/askSound/askSound.ls (function(){ return function(elementDiv, slide, atom){ var init, div, speaker; init = function(){ var voice, text; voice = slide.getParam("voice", atom); text = atom.sound || atom.a; speaker.setSound(slide.sounds[text + voice]); return slide.askSound = speaker; }; div = Div().html(speaker = inc("/../app01/lib/gui/speakerIconPlayer/speakerIconPlayer")({ size: "2em" })); div.init = init; return elementDiv.askSound = div; }; })(); trainers/gapMultiLearnList/elements/element/calcShowAskSound/calc.ls (function(){ return function(atom, slide){ return slide.getParam("soundMode", atom) === "askSound" && (atom.sound || atom.a); }; })(); trainers/gapMultiLearnList/elements/element/corner/corner.ls (function(){ return function(elementDiv, atom, slide){ var div; div = Div({ display: "flex", position: "absolute", top: 0, right: 0 }).html(inc("injectCounter/counter")(atom, slide)); div.showInjectIcon = function(){ return inc("showInjectIcon/show")(div); }; return elementDiv.corner = div; }; })(); trainers/gapMultiLearnList/elements/element/corner/injectCounter/counter.ls (function(){ return function(atom, slide){ var count, ref$; count = ((ref$ = slide.injectCounter) != null ? ref$[JSON.stringify(atom)] : void 8) || 0; if (count === 0) { return; } return Div({ fontSize: "0.75em", color: Color.grey[500] }).html(T("nThAttempt", count + 1)); }; })(); trainers/gapMultiLearnList/elements/element/corner/showInjectIcon/show.ls (function(){ return function(div){ return SvgIcon({ svg: path("/../app01/lib/svg/shape/arrow-inject.svg"), size: "0.6em" }).css({ margin: "0.2em", opacity: "0.6" }).appendTo(div); }; })(); trainers/gapMultiLearnList/elements/element/element.ls (function(){ return function(atom, slide){ var showAskSound, start, div, b; showAskSound = inc("calcShowAskSound/calc")(atom, slide); start = function(){ var ref$, type; div.fadeIn(); if ((ref$ = div.askSound) != null) { ref$.init(); } type = inc("/../app01/lib/util/cache/get/get")("learnlistKeyboardBottomType"); if (!type) { type = "small"; inc("/../app01/lib/util/cache/set/set")("learnlistKeyboardBottomType", type); } div.findFirst(".divEditable").setSoftKeyboardEnabled(type === "small"); return div.gapComponent.start(); }; div = Div({ padding: "1.1em 1em", marginTop: "-2px", borderTop: b = "1px solid " + Color.grey[150], borderBottom: b, background: "white", textAlign: "left" }); div.html(showAskSound ? inc("askSound/askSound")(div, slide, atom) : inc("textA/textA")(atom, slide), inc("gapComponent/gapComponent")(div, atom, slide), inc("corner/corner")(div, atom, slide)).hide(); div.start = start; div.atom = atom; return div; }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/gapComponent.ls (function(){ return function(element, atom, slide){ var page; page = app.currentPage; return element.gapComponent = inc("/shared/gapComponent/component/component")({ slide: slide, atom: atom, text: atom.b, mode: slide.getParam("gapMode", atom), inputEditable: true, onSubmitCustom: inc("onSubmit/on")(slide, atom), onStart: function(){ inc("showKeyboardBottom/show")(element, atom, slide); return inc("/../app01/lib/util/waitFrames/wait")(4, function(){ page.lockLayout = false; return page.scrollElementIntoView(slide.currentElement, { padding: 30 }); }); }, onFinish: function(result){ return slide.playSoundBCurrentElement(result, function(){ return slide.finishCurrentElement(); }); } }); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/_divSolved/div.ls (function(){ return function(){ return Div({ display: "inline-block", minWidth: "2em", background: Color.grey[100], lineHeight: "1.4em", padding: "0.2em", textAlign: "left", margin: "0.14em 0", maxWidth: "100%", overflowWrap: "break-word", wordWrap: "break-word", whiteSpace: "wrap" }); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/on.ls (function(){ return function(slide, atom){ return function(o, compareResult, callback){ var page, ref$, f; page = app.currentPage; o.gap.gapIsCompleted = true; o.result.isDone = true; page.lockLayout = true; if ((ref$ = slide.currentElement.keyboardBottom) != null) { ref$.remove(); } page.bottom.css({ background: Color.grey[50] }); slide.visibleLearnListItemsInfos[slide.currentIndex] = slide.getParam("soundMode", atom) === "askSound" ? "a" : "ab"; f = compareResult.isCorrect ? inc("onCorrect/on") : compareResult.isHalfCorrect ? inc("onHalfCorrect/on") : inc("onWrong/on"); return f(o, compareResult, callback, slide, atom); }; }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onCorrect/on.ls (function(){ return function(o, compareResult, callback, slide, atom){ inc("solveInput/solve")(o); slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(atom, { gap: o.gapIndex, text: o.gap.correctValue }); return callback(); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onCorrect/solveInput/solve.ls (function(){ return function(o){ var input; input = o.gap; return input.replaceWith(inc("../../_divSolved/div")().css({ color: Color.green[500] }).secureHtml(input.correctValue)); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onHalfCorrect/_t.ls (function(){ return { accentsInfo: { de: "Achte auf die Akzente.", en: "Pay attention to the accent.", fr: "Fais attention aux accents.", es: "Pon atención al acento.", pt: "Preste atenção à acentuação." }, lowerInfo: { de: "Achte auf die Groß- und Kleinschreibung.", en: "Pay attention to the case.", fr: "Fais attention aux majuscules et minuscules.", es: "Pon atención a las mayúsculas y minúsculas.", pt: "Preste atenção nas letras maiúsculas e minúsculas." }, punctInfo: { de: "Achte auf die Satzzeichen.", en: "Pay attention to the punctuation.", fr: "Fais attention à la ponctuation.", es: "Pon atención a la puntuación.", pt: "Preste atenção à pontuação." }, defaultInfo: { de: "Achte auf die markierten Stellen.", en_gb: "Pay attention to the highlighted parts.", en: "Pay attention to the highlighted sections.", fr: "Fais attention à ce qui est souligné.", es: "Pon atención a las partes resaltadas.", pt: "Preste atenção nas partes destacadas." } }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onHalfCorrect/bottom/train/_button/button.ls (function(){ return function(p){ var pos; pos = p.iconPosition; return Div({ flex: "0 1 auto", display: "flex", background: Color.grey[200], margin: "0.3em", padding: "0.6em 0.6em" }).html(pos !== "right" ? Svg(p.svg) : void 8, Div({ flex: "0 1 auto", overflow: "hidden", textAlign: "center", textOverflow: "ellipsis", paddingLeft: "0.2em", lineHeight: "1.4em", whiteSpace: "nowrap" }).html(p.label), pos === "right" ? Svg(p.svg) : void 8); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onHalfCorrect/bottom/train/bottom.ls (function(){ return function(o, compareResult, callback, slide, atom){ var r; r = compareResult.reason; return Div({ padding: "1em 0", display: "flex", flexDirection: "column", alignItems: "stretch" }).addClass("bottomTrain").html(Div({ textAlign: "center", marginBottom: "0.5em" }).html(r === "ascii" ? T("accentsInfo") : r === "lower" ? T("lowerInfo") : r === "punct" ? T("punctInfo") : T("defaultInfo")), Div({ display: "flex", alignItems: "stretch" }).html(inc("buttonSkip/button")(o, callback, slide, atom))); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onHalfCorrect/bottom/train/buttonSkip/button.ls (function(){ return function(o, callback, slide, atom){ var tap; tap = function(){ body.findFirst(".bottomTrain").remove(); return callback(); }; return inc("../_button/button")({ label: T("continueButton"), svg: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).tap(tap).bind("keyManager", tap).addClass("keyManager-right").addClass("keyManager-enter"); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onHalfCorrect/on.ls (function(){ return function(o, compareResult, callback, slide, atom){ var page; page = app.currentPage; slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(atom, { gap: o.gapIndex, text: o.gap.correctValue }); inc("solveInput/solve")(o, slide); page.bottom.show().keyframeAnimate({ duration: 300, keyframes: { "0%": { transform: "translateY(100%)" }, "100%": { transform: "translateY(0)" } } }).append(inc("bottom/train/bottom")(o, compareResult, callback, slide, atom)); return page.scrollElementIntoView(slide.currentElement, { padding: 150 }); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onHalfCorrect/solveInput/solve.ls (function(){ return function(o, slide){ var input, comparison; input = o.gap; comparison = inc("/shared/calcStringComparison/calc")({ input: input.getValue(), solution: input.correctValue, highlightColor: Color.orange[400] }); return input.replaceWith(inc("../../_divSolved/div")().html(Div().secureHtml(comparison.htmlInput()), Div({ marginTop: "0.2em", color: Color.grey[450] }).secureHtml(comparison.htmlSolution()))); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/bottom/_title/title.ls (function(){ return function(o){ return Div({ padding: "0.3em 0.3em 1.0em", maxWidth: "95%", width: "35em", textAlign: "center" }).html(o.gap.getValue() === "" ? T("didntWrite") : T("notCorrect")); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/bottom/test/bottom.ls (function(){ return function(o, callback, slide, atom){ o.slide.levelPlayer.progressBar.showRed(); slide.score.addActionMistake(atom, { gap: o.gapIndex, text: o.gap.getValue(), solution: o.gap.correctValue }); return Div({ padding: "1em", display: "flex", flexDirection: "column" }).addClass("bottomTest").html(inc("../_title/title")(o), Div().html(inc("buttonContinue/button")(o, callback))); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/bottom/test/buttonContinue/button.ls (function(){ return function(o, callback){ var tap; tap = function(){ body.findFirst(".bottomTest").remove(); return callback(); }; return Button({ label: "Weiter", icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).tap(tap).bind("keyManager", tap).addClass("keyManager-enter"); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/bottom/train/_button/button.ls (function(){ return function(p){ var pos; pos = p.iconPosition; return Div({ flex: "0 1 auto", display: "flex", background: Color.grey[200], margin: "0.3em", padding: "0.6em 0.6em" }).html(pos !== "right" ? Svg(p.svg) : void 8, Div({ flex: "0 1 auto", overflow: "hidden", textAlign: "center", textOverflow: "ellipsis", paddingLeft: "0.2em", lineHeight: "1.4em", whiteSpace: "nowrap" }).html(p.label), pos === "right" ? Svg(p.svg) : void 8); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/bottom/train/bottom.ls (function(){ return function(o, callback, slide, atom){ return Div({ padding: "1em 0", display: "flex", flexDirection: "column", alignItems: "stretch" }).addClass("bottomTrain").html(Div({ display: "flex", alignItems: "stretch" }).html(inc("buttonInject/button")(o, callback, slide, atom), inc("buttonSkip/button")(o, callback, slide, atom))); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/bottom/train/buttonInject/button.ls (function(){ return function(o, callback, slide, atom){ var tap; tap = function(){ body.findFirst(".bottomTrain").remove(); slide.injectElement(atom); slide.score.addActionRetry(atom, { gap: o.gapIndex, text: o.gap.getValue(), solution: o.gap.correctValue }); return callback(); }; return inc("../_button/button")({ label: T("again"), svg: path("/../app01/lib/svg/shape/arrow-inject.svg") }).tap(tap).bind("keyManager", tap).addClass("keyManager-left"); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/bottom/train/buttonSkip/button.ls (function(){ return function(o, callback, slide, atom){ var tap; tap = function(){ body.findFirst(".bottomTrain").remove(); o.slide.levelPlayer.progressBar.showGreen(); slide.score.addActionRetry(atom, { gap: o.gapIndex, text: o.gap.getValue(), solution: o.gap.correctValue }); return callback(); }; return inc("../_button/button")({ label: T("knowActually"), svg: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).tap(tap).bind("keyManager", tap).addClass("keyManager-right").addClass("keyManager-enter"); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/on.ls (function(){ return function(o, compareResult, callback, slide, atom){ var page; page = app.currentPage; inc("solveInput/solve")(o, slide); page.bottom.show().keyframeAnimate({ duration: 300, keyframes: { "0%": { transform: "translateY(100%)" }, "100%": { transform: "translateY(0)" } } }).append(slide.trainerParams.trainMode ? inc("bottom/train/bottom")(o, callback, slide, atom) : inc("bottom/test/bottom")(o, callback, slide, atom)); return page.scrollElementIntoView(slide.currentElement, { padding: 150 }); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/onSubmit/onWrong/solveInput/solve.ls (function(){ return function(o, slide){ var input, c; input = o.gap; c = inc("/shared/calcStringComparison/calc")({ input: input.getValue(), solution: input.correctValue }); return input.replaceWith(inc("../../_divSolved/div")().html(input.getValue().length === 0 && slide.trainerParams.trainMode ? Div({ color: Color.orange[400] }).secureHtml(input.correctValue) : [ Div().secureHtml(c.htmlInput()), Div({ marginTop: "0.2em", color: Color.grey[450] }).secureHtml(c.htmlSolution()) ])); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/_header/_key/key.ls (function(){ return function(){ return Div({ display: "flex", background: Color.grey[300], borderRadius: "5px", margin: "0.2em", height: "2.2em", width: "2.2em" }); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/_header/cssNoSpecialKeys/css.ls (function(){ return function(atom, slide){ var d, w; d = body.findFirst(".debugIcons"); w = d.width() - d.firstChild.width(); return { position: "absolute", right: w + 5 + "px", top: "-2.6em", height: "2em" }; }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/_header/header.ls (function(){ return function(element, atom, slide){ return Div(slide.getParam("keyboardSpecialKeys").length === 0 ? inc("cssNoSpecialKeys/css")(atom, slide) : { display: "flex", padding: "0.4em" }).html(inc("keyboardToggle/toggle")(element, atom, slide), inc("specialKeys/keys")(atom, slide)); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/_header/keyboardToggle/toggle.ls (function(){ return function(element, atom, slide){ var tap; tap = function(){ var input, t; input = element.findFirst(".input"); t = inc("/../app01/lib/util/cache/get/get")("learnlistKeyboardBottomType") || "small"; t = t === "small" ? "big" : "small"; inc("/../app01/lib/util/cache/set/set")("learnlistKeyboardBottomType", t); app.currentPage.lockLayout = true; input.stop(); slide.currentElement.keyboardBottom.remove(); return inc("/../app01/lib/util/waitFrames/wait")(5, function(){ inc("../../show")(element, atom, slide); input.divEditable.setSoftKeyboardEnabled(t === "small"); input.start(); inc("/../app01/lib/util/waitFrames/wait")(5, function(){ app.currentPage.lockLayout = false; return app.currentPage.scrollElementIntoView(slide.currentElement, { padding: 30 }); }); return app.currentPage.setBottomFreeze(0); }); }; return Div({ alignSelf: "stretch", display: "flex", alignItems: "flex-start" }).html(inc("../_key/key")().html(SvgIcon({ svg: path("/../app01/lib/svg/shape/keyboard.svg"), color: Color.blue[700] }).css({ marginTop: "0.08em" })).tap(tap)); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/_header/specialKeys/calcKeys/calc.ls (function(){ return function(atom, slide){ var keys, keys2, i$, to$, i, c; keys = slide.getParam("keyboardSpecialKeys") || ""; keys = keys.split(" "); if (keys.length < 5) { return keys; } keys2 = _.cloneDeep(keys); for (i$ = 0, to$ = keys.length - 1; i$ <= to$; ++i$) { i = i$; c = keys[i]; if (!in$(c, atom.b)) { _.remove(keys2, fn$); } if (keys2.length <= 4) { break; } } return keys2; function fn$(c2){ return c2 === c; } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/_header/specialKeys/keys.ls (function(){ return function(atom, slide){ var keys, k; keys = inc("calcKeys/calc")(atom, slide); return Div({ flex: "1 1 auto", display: "flex", justifyContent: "flex-start", flexWrap: "wrap" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = keys).length; i$ < len$; ++i$) { k = ref$[i$]; if (k !== "") { results$.push(inc("specialKey/key")(k, slide)); } } return results$; }())); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/_header/specialKeys/specialKey/key.ls (function(){ return function(k, slide){ var input, tap; input = slide.currentElement.gapComponent.findFirst(".input"); tap = function(){ var ref$; if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } if ((ref$ = input.divEditable) != null && ref$.d.isStarted) { return input.divEditable.insertAtCursor(k); } }; return inc("../../_key/key")().html(k).tap(tap); }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/big/bottom.ls (function(){ return function(element, atom, slide){ var div; div = Div().html(inc("../_header/header")(element, atom, slide), inc("screenKeyboard/keyboard")(atom, slide).css({ background: Color.grey[150] })); app.currentPage.bottom.css({ background: Color.grey[150] }); return slide.currentElement.bottomKeys = div; }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/big/screenKeyboard/keyboard.ls (function(){ return function(atom, slide){ var input, onKey, k; input = slide.currentElement.gapComponent.findFirst(".input"); onKey = function(k){ var ref$; if (!((ref$ = input.divEditable) != null && ref$.d.isStarted)) { return; } if (k === "back") { input.divEditable.keyBack(); return; } if (k === "submit" || k === "newline") { k = "\n"; } return input.divEditable.insertAtCursor(k); }; k = inc("/../app01/lib/gui/screenKeyboard/keyboard")({ onKey: onKey, layout: slide.getParam("keyboardLayout"), shiftStatus: false, showNewLine: false, showSubmit: true, newDesign: true }).css({ maxWidth: "40em", margin: "0 auto" }); k.start(); return k; }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/show.ls (function(){ return function(element, atom, slide){ var type, divEd, f, bottom; type = inc("/../app01/lib/util/cache/get/get")("learnlistKeyboardBottomType"); divEd = element.findFirst(".divEditable"); f = type === "big" ? inc("big/bottom") : inc("small/bottom"); bottom = f(element, atom, slide); bottom.onAnimationFrame(function(){ if (divEd.d.isStarted) { return bottom.show(); } else { return bottom.hide(); } }); inc("stopEvents/stop")(bottom, slide); app.currentPage.bottom.fadeIn(150).html(bottom); return slide.currentElement.keyboardBottom = bottom; }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/small/bottom.ls (function(){ return function(element, atom, slide){ var div; div = inc("../_header/header")(element, atom, slide); app.currentPage.bottom.css({ background: Color.grey[50] }); return slide.currentElement.bottomKeys = div; }; })(); trainers/gapMultiLearnList/elements/element/gapComponent/showKeyboardBottom/stopEvents/stop.ls (function(){ return function(div, slide){ var input; input = slide.currentElement.findFirst(".input"); return div.bind("touchstart", function(e){ e.preventDefault(); e.stopImmediatePropagation(); return input.css({ pointerEvents: "none" }); }).bind("touchend", function(e){ e.preventDefault(); e.stopImmediatePropagation(); return input.css({ pointerEvents: "auto" }); }).bind("mousedown", function(e){ e.preventDefault(); return e.stopImmediatePropagation(); }); }; })(); trainers/gapMultiLearnList/elements/element/textA/textA.ls (function(){ return function(atom, slide){ if (!atom.a) { return; } return Div({ padding: "0 0.1em 0.3em" }).secureHtml(slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(atom.a) : atom.a); }; })(); trainers/gapMultiLearnList/elements/elements.ls (function(){ return function(slide){ var atom; return Div({ display: "inline-block", textAlign: "left", maxWidth: "95%" }).html(slide.elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(inc("element/element")(atom, slide)); } return results$; }())).appendTo(slide.div); }; })(); trainers/gapMultiLearnList/finishCurrentElement/finish.ls (function(){ return function(slide){ return function(){ return slide.score.log(slide.currentElement.atom, function(){ if (slide.currentElement.gapComponent.gaps().length === 0) { slide.levelPlayer.progressBar.showGreen(); } if (slide.currentElement === _.last(slide.elements)) { slide.div.css({ pointerEvents: "none" }); return slide.finish(); } else { return slide.startNextElement(); } }); }; }; })(); trainers/gapMultiLearnList/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide, totalProgressElements, i$, len$, atom, totalGaps; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; totalProgressElements = 0; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; totalGaps = inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b); totalProgressElements += totalGaps; if (atom.b && totalGaps === 0) { totalProgressElements++; } } slide.totalProgressElements = totalProgressElements; slide.visibleLearnListItemsInfos = {}; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/gapMultiLearnList/init.ls (function(){ return function(slide){ slide.div.css({ padding: "2em 0" }); slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.elementsDiv = inc("elements/elements")(slide); slide.startNextElement = inc("startNextElement/start")(slide); slide.finishCurrentElement = inc("finishCurrentElement/finish")(slide); slide.playSoundBCurrentElement = inc("playSoundBCurrentElement/play")(slide); return slide.injectElement = inc("injectElement/inject")(slide); }; })(); trainers/gapMultiLearnList/injectElement/inject.ls (function(){ return function(slide){ return function(atom){ var id, ref$, i, el; id = JSON.stringify(atom); slide.injectCounter == null && (slide.injectCounter = {}); (ref$ = slide.injectCounter)[id] == null && (ref$[id] = 0); slide.injectCounter[id] += 1; i = Math.min(slide.elements.length, slide.currentIndex + 4); el = inc("../elements/element/element")(_.cloneDeep(atom), slide); slide.elements.splice(i, 0, el); slide.elementsDiv.insertBefore(el, slide.elementsDiv.childrenAll()[i]); return slide.currentElement.corner.showInjectIcon(); }; }; })(); trainers/gapMultiLearnList/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/gapMultiLearnList/optimizeWidth/calcLongestString/calc.ls (function(){ return function(atoms){ var longestString, i$, len$, atom, ref$, solutions, j$, len1$, s; longestString = ""; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; if (((ref$ = atom.a) != null ? ref$.length : void 8) > longestString.length) { longestString = atom.a; } solutions = inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); for (j$ = 0, len1$ = solutions.length; j$ < len1$; ++j$) { s = solutions[j$]; if (s.length > longestString.length) { longestString = s; } } } return longestString; }; })(); trainers/gapMultiLearnList/optimizeWidth/optimize.ls (function(){ return function(slide){ var longestString, div, w, emToPx; longestString = inc("calcLongestString/calc")(slide.atoms); slide.div.append(div = Div({ position: "fixed", opacity: "0", whiteSpace: "nowrap" }).secureHtml(longestString)); w = div.width() + 50; div.remove(); emToPx = inc("/../app01/lib/util/emToPx/emToPx"); w = Math.max(emToPx(15), w); w = Math.min(emToPx(35), w); return slide.elementsDiv.css({ width: w + "px" }); }; })(); trainers/gapMultiLearnList/playSoundBCurrentElement/play.ls (function(){ return function(slide){ return function(result, onFinished){ var playSoundB, currentAtom, elementDone, ref$; playSoundB = inc("play/play")(slide, result); currentAtom = slide.currentElement.atom; elementDone = function(){ return onFinished(); }; if ((ref$ = slide.getParam("soundMode", currentAtom)) === "b" || ref$ === "ab") { return playSoundB(elementDone); } else { return setTimeout(elementDone, 1000); } }; }; })(); trainers/gapMultiLearnList/playSoundBCurrentElement/play/play.ls (function(){ return function(slide, result){ return function(onEnded){ return slide.currentBSound = inc("/shared/playSoundB/play")(slide.currentElement.atom, slide, result != null ? result.correctValue : void 8, onEnded); }; }; })(); trainers/gapMultiLearnList/startNextElement/start.ls (function(){ return function(slide){ return function(){ var page, element, atom; slide.currentIndex++; page = slide.levelPlayer.page; if (slide.currentIndex === 0) { page.enableFreezeMinHeight(); } if (slide.currentIndex === 1) { page.centerDuration = 500; } element = slide.elements[slide.currentIndex]; atom = element.atom; slide.currentElement = element; if (element) { element.start(); inc("/shared/playSoundA/play")(atom, slide); if (slide.getParam("soundMode", atom) !== "askSound") { return slide.visibleLearnListItemsInfos[slide.currentIndex] = "a"; } } else { return setTimeout(slide.finish, 500); } }; }; })(); trainers/gravity/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/gravity/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/gravity/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, choices, voice, voiceLang, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { choices = _.filter(slide.choices, { correct: true }); texts = _.map(choices, function(c){ return c.text; }); } else if (soundMode === "a") { texts = [slide.atom.a]; } else { texts = []; } voice = slide.getParam("voice", slide.atom); voiceLang = slide.getParam("voiceLang", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/gravity/_preview/preview.ls (function(){ return function(slide){ var arrow; arrow = function(){ return SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-down.svg"), color: Color.grey[400] }).css({ height: "2em", width: "2em", marginTop: "-0.7em" }); }; return slide.fall.css({ flex: "" }).append(Div({ left: "50%", top: "2em", marginLeft: "-1em", width: "2em", height: "6em" }).append(arrow(), arrow(), arrow())); }; })(); trainers/gravity/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", marginBottom: "2em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/gravity/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/gravity/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/gravity/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ inc("/shared/playSoundA/play")(slide.atom, slide); return slide.fall.start(); }); }; })(); trainers/gravity/buttons/button/button.ls (function(){ return function(slide, choice){ var correctChoices, wrongChoices, playSoundAndFinish, click, div; correctChoices = _.filter(slide.choices, { correct: true }); wrongChoices = _.filter(slide.choices, { correct: false }); playSoundAndFinish = function(){ if (slide.getParam("soundMode", slide.atom) === "b") { if (slide.trueFalseMode && !slide.atom.sound) { return setTimeout(slide.finish, 500); } else { return setTimeout(function(){ var voice, text; voice = slide.getParam("voice", slide.atom); text = slide.atom.sound || choice.text; return slide.sounds[text + voice].play(slide.finish); }, 300); } } else { return setTimeout(slide.finish, 500); } }; click = function(){ var index; if (choice.correct) { index = _.indexOf(correctChoices, choice); slide.score.addActionCorrect(slide.atom, { text: choice.text, index: index }); div.setState("correct"); slide.div.css({ pointerEvents: "none" }); slide.levelPlayer.progressBar.showGreen(); slide.score.log(slide.atom); return slide.fall.solve(div, playSoundAndFinish); } else { index = _.indexOf(wrongChoices, choice); slide.score.addActionMistake(slide.atom, { text: choice.text, index: index }); slide.levelPlayer.progressBar.addElement().showRed(); div.setState("wrong"); return setTimeout(function(){ return div.setState("normal"); }, 500); } }; div = Button({ label: choice.text, action: click, icon: choice.icon === "correct" ? path("/../app01/lib/svg/icon/checkmark.svg") : choice.icon === "wrong" ? path("/../app01/lib/svg/icon/close.svg") : void 8 }).css({ margin: "0.5em" }); if (choice.correct) { div.correct = true; } return div; }; })(); trainers/gravity/buttons/buttons.ls (function(){ return function(slide){ var shuffleButtons, ref$, choices, buttons, choice; shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; choices = shuffleButtons && !slide.trueFalseMode ? _.shuffleWithSeed(slide.choices) : slide.choices; slide.div.append(Div({ padding: "0.5em" }).addClass("safeAreaMarginBottom").html(buttons = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(inc("button/button")(slide, choice)); } return results$; }()))); return buttons; }; })(); trainers/gravity/calcChoices/automatic/calc.ls (function(){ return function(slide){ var choices, otherAtoms, totalButtons, i$, len$, atom; choices = [{ correct: true, text: slide.atom.b }]; otherAtoms = _.shuffleWithSeed(_.filter(slide.trainerParams.atoms, function(atom){ return atom.b !== slide.atom.b; })); otherAtoms = _.uniqBy(otherAtoms, "b"); totalButtons = slide.trainerParams.totalButtons || 3; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choices.push({ correct: false, text: atom.b }); } return choices; }; })(); trainers/gravity/calcChoices/calc.ls (function(){ return function(slide){ var choices; return choices = slide.trueFalseMode ? inc("trueFalseChoices/choices")(slide) : _.includes(slide.atom.b, "++") || _.includes(slide.atom.b, "--") ? inc("plusplus/calc")(slide) : inc("automatic/calc")(slide); }; })(); trainers/gravity/calcChoices/plusplus/calc.ls (function(){ return function(slide){ var choices; return choices = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); }; })(); trainers/gravity/calcChoices/trueFalseChoices/choices.ls (function(){ return function(slide){ var trueLabel, falseLabel, ref$, choices; trueLabel = slide.getParam("trueButtonLabel") || T("true"); falseLabel = slide.getParam("falseButtonLabel") || T("false"); if (engine.isDebug && ((ref$ = slide.atom.b) === "correct" || ref$ === "wrong")) { debug("Please use new trueFalseMode syntax b: true / b: false (see post in content channel)"); return []; } return choices = [ { icon: "correct", correct: (ref$ = slide.atom.b) === true || ref$ === "correct", text: trueLabel }, { icon: "wrong", correct: (ref$ = slide.atom.b) === false || ref$ === "wrong", text: falseLabel } ]; }; })(); trainers/gravity/fall/fall.ls (function(){ return function(slide){ var startX, startY, solved, start, solve, div, fallDiv; startX = 0; startY = 0; solved = false; start = function(){ var y; if (solved) { return; } y = div.height() - fallDiv.height(); return requestAnimationFrame(function(){ return fallDiv.keyframeAnimate({ keyframes: { "100%": { transform: "translate(0, " + y + "px)" } }, duration: 8000, timing: "ease-in" }); }); }; solve = function(button, onCompleted){ var endX, y; solved = true; endX = button.offset().left - startX; endX += button.width() * 0.5 - fallDiv.width() * 0.5; y = div.height() - fallDiv.height() + inc("/../app01/lib/util/emToPx/emToPx")(0.5); return fallDiv.keyframeAnimate({ keyframes: { "100%": { transform: "translate(" + endX + "px," + y + "px)" } }, duration: 1200, onCompleted: function(){ var o, o2, left, bottom; o = fallDiv.offset(); o2 = div.offset(); left = o.left - o2.left; bottom = o2.height - o.top + o2.top - o.height; fallDiv.css({ position: "absolute", left: left + "px", bottom: bottom + "px", transform: "", margin: 0 }); return onCompleted(); } }); }; slide.div.css({ height: "var(--centerHeight)", display: "flex", flexDirection: "column", alignItems: "stretch" }).append(div = Div({ width: "25em", maxWidth: "90%", margin: "0 auto", flex: "0 1 600px", alignSelf: "center" })); div.append(fallDiv = slide.atom.lsg ? inc("lsg/lsg")(slide, div) : slide.atom.image ? inc("image/image")(slide, div) : inc("word/word")(slide)); requestAnimationFrame(function(){ startX = fallDiv.offset().left; return startY = fallDiv.offset().top; }); div.start = start; div.solve = solve; div.fallDiv = fallDiv; return div; }; })(); trainers/gravity/fall/image/image.ls (function(){ return function(slide, parent){ var image; image = slide.getParam("image", slide.atom); return Div({ display: "inline-block", backgroundColor: Color.grey[150], padding: "0.2em" }).append(inc("/shared/image/image")({ image: image, slide: slide, parent: parent })); }; })(); trainers/gravity/fall/lsg/lsg.ls (function(){ return function(slide, parent){ var lsg; lsg = slide.getParam("lsg", slide.atom); return Div({ display: "inline-block", backgroundColor: Color.grey[150], padding: "0.2em" }).append(inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: parent })); }; })(); trainers/gravity/fall/word/word.ls (function(){ return function(slide){ return Div({ display: "inline-block", backgroundColor: Color.grey[150], padding: "0.5em", maxWidth: "20em", margin: "0 0.5em" }).html(slide.atom.a); }; })(); trainers/gravity/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.trueFalseMode = (ref1$ = slide.getParam("trueFalseMode")) != null ? ref1$ : false; slide.totalProgressElements = 1; slide.choices = inc("calcChoices/calc")(slide); slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/gravity/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.fall = inc("fall/fall")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/gravity/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/imageButtons/_media2/images/images.ls (function(){ return function(slide){ var choice; return _.concat(slide.getParam("image", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("image", choice)); } return results$; }())); }; })(); trainers/imageButtons/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var choice; return _.concat(slide.getParam("lsg", slide.atom), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(slide.getParam("lsg", choice)); } return results$; }())); }; })(); trainers/imageButtons/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, choices, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { choices = _.filter(_.ensureArray(slide.atom.b), { correct: true }); texts = _.map(choices, function(c){ return c.sound || c.text; }); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/imageButtons/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/imageButtons/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", marginBottom: "1em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/imageButtons/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ var image, lsg, css, div; image = slide.getParam("image", action.choice); lsg = slide.getParam("lsg", action.choice); css = { width: "1.3em", height: "1.3em" }; return div = Div({ display: "inline-block" }).append(image ? inc("/shared/image/image")({ image: image, slide: slide }).css(css).css({ verticalAlign: "-0.3em" }) : lsg ? inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css(css).css({ verticalAlign: "top" }) : void 8); }; })(); trainers/imageButtons/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return inc("../correct/correct")(action, slide); }; })(); trainers/imageButtons/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.buttonsDiv, { padding: 10 }); }); }; })(); trainers/imageButtons/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/imageButtons/buttons/button/animations/tap.ls (function(){ return function(div){ return { up: function(){ return div.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "box-shadow 500ms" }); }, cancel: function(){ return div.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "box-shadow 200ms" }); }, down: function(){ return div.css({ boxShadow: "2px 3px 9px 3px rgba(0,0,0,0.2)", transition: "box-shadow 0ms" }); } }; }; })(); trainers/imageButtons/buttons/button/button.ls (function(){ return function(slide, choice){ var correctChoices, wrongChoices, onMistake, onCorrect, click, playSoundB, div, lsg, image, ref$; correctChoices = _.filter(slide.choices, { correct: true }); wrongChoices = _.filter(slide.choices, function(c){ return c.correct == null; }); slide.totalGreen = correctChoices.length; slide.currentGreen = 0; onMistake = function(){ var index; div.css({ border: "4px solid " + Color.red[500] }); slide.levelPlayer.progressBar.addElement().showRed(); index = _.indexOf(wrongChoices, choice); slide.score.addActionMistake(slide.atom, { choice: choice, index: index }); return setTimeout(function(){ return div.css({ border: "4px solid transparent", transition: "border 500ms", pointerEvents: "" }); }, 500); }; onCorrect = function(){ var isFinished; slide.currentGreen++; isFinished = slide.currentGreen === slide.totalGreen; if (isFinished) { slide.div.css({ pointerEvents: "none" }); } div.css({ border: "4px solid " + Color.green[500], boxShadow: "0px 0px 3px rgba(0,0,0,0.2)" }); slide.levelPlayer.progressBar.showGreen(); return playSoundB(function(){ var index; index = _.indexOf(correctChoices, choice); slide.score.addActionCorrect(slide.atom, { choice: choice, index: index }); if (isFinished) { slide.score.log(slide.atom); return setTimeout(slide.finish, 1000); } }); }; click = function(){ div.css({ pointerEvents: "none" }); if (choice.correct) { return onCorrect(); } else { return onMistake(); } }; playSoundB = function(onDone){ if (slide.getParam("soundMode", slide.atom) === "b") { return setTimeout(function(){ var sound, voice; slide.instruction.stop(); sound = slide.atom.sound || choice.sound || choice.text; voice = slide.getParam("voice", slide.atom); return slide.sounds[sound + voice].play(function(){ return typeof onDone == 'function' ? onDone() : void 8; }); }, 500); } else { return setTimeout(function(){ return typeof onDone == 'function' ? onDone() : void 8; }, 500); } }; div = Div({ display: "inline-block", border: "4px solid transparent", backgroundClip: "border-box", verticalAlign: "top", cursor: "pointer", margin: "0.3em", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)" }).append(choice.lsg ? lsg = inc("lsg/lsg")(slide, choice) : choice.image ? image = inc("image/image")(slide, choice) : void 8); div.tap({ up: click, animation: inc("animations/tap")(div) }); if ((lsg != null ? (ref$ = lsg.findFirst("rect")) != null ? ref$.getAttribute("fill") : void 8 : void 8) === "transparent") { if (lsg != null) { lsg.findFirst("rect").setAttribute("fill", "white"); } } return div; }; })(); trainers/imageButtons/buttons/button/image/image.ls (function(){ return function(slide, choice){ var image; image = slide.getParam("image", choice); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide }).css(!image.width ? { width: "6em", height: "6em" } : void 8); }; })(); trainers/imageButtons/buttons/button/lsg/lsg.ls (function(){ return function(slide, choice){ var lsg, div; lsg = slide.getParam("lsg", choice); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }); if (!lsg.width) { div.css({ width: "6em", height: "6em" }); } return div; }; })(); trainers/imageButtons/buttons/buttons.ls (function(){ return function(slide){ var shuffleButtons, ref$, choices, buttons, choice, combiner1, combiner2; shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; choices = shuffleButtons ? _.shuffleWithSeed(slide.choices) : slide.choices; slide.div.append(slide.buttonsDiv = Div({ marginTop: "1em" }).append(buttons = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(inc("button/button")(slide, choice)); } return results$; }()))); if (buttons.length >= 2) { combiner1 = inc("combiner/combiner")(); buttons[0].wrap(combiner1); buttons[0].after(buttons[1]); } if (buttons.length >= 4) { combiner1.after(document.createElement("br")); combiner2 = inc("combiner/combiner")(); buttons[2].wrap(combiner2); buttons[2].after(buttons[3]); } return buttons; }; })(); trainers/imageButtons/buttons/combiner/combiner.ls (function(){ return function(){ return Div({ display: "inline-block" }); }; })(); trainers/imageButtons/calcChoices/automatic/calc.ls (function(){ return function(slide){ var choice, k, ref$, v, choices, otherAtoms, totalButtons, i$, len$, atom; choice = { correct: true }; for (k in ref$ = slide.atom.b) { v = ref$[k]; choice[k] = v; } choices = [choice]; otherAtoms = _.shuffleWithSeed(_.filter(slide.trainerParams.atoms, function(atom){ return atom.b.text !== slide.atom.b.text; })); totalButtons = slide.trainerParams.totalButtons || 3; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choice = { correct: false }; for (k in ref$ = atom.b) { v = ref$[k]; choice[k] = v; } choices.push(choice); } return choices; }; })(); trainers/imageButtons/calcChoices/calc.ls (function(){ return function(slide){ var choices; choices = _.ensureArray(slide.atom.b); if (_.filter(choices, "correct").length === 0) { choices = inc("automatic/calc")(slide); } return choices; }; })(); trainers/imageButtons/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.choices = inc("calcChoices/calc")(slide); slide.totalProgressElements = _.filter(slide.choices, "correct").length; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/imageButtons/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/imageButtons/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.textA = inc("textA/text")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/imageButtons/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/imageButtons/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/imageButtons/textA/text.ls (function(){ return function(slide){ var image, lsg, div; if (slide.getParam("soundMode", slide.atom) === "askSound" || !slide.atom.a) { return; } image = slide.getParam("image", slide.atom); lsg = slide.getParam("lsg", slide.atom); div = inc("/shared/textA/text")(slide); div.css({ maxWidth: "90%", width: "30em", padding: image || lsg ? "0.5em 1em" : "0 1em" }); if (slide.atom.a) { slide.div.append(div); } return div; }; })(); trainers/kickItem/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/kickItem/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/kickItem/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, choices, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = _.ensureArray(slide.atom.sound); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else if (soundMode === "b") { choices = _.filter(slide.choices, { correct: false }); texts = _.map(choices, function(c){ return c.text; }); } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/kickItem/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/kickItem/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", margin: "2em 0" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/kickItem/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/kickItem/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/kickItem/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.buttons, { padding: 10 }); }); }; })(); trainers/kickItem/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).appendTo(slide.div); }; })(); trainers/kickItem/buttons/button/animateButton/animate.ls (function(){ return function(choice, div){ div.css({ transition: "" }); if (choice.correct !== true) { div.setState("correct"); div.append(inc("lineDiagonal/lineDiagonal")(div)); } else { div.setState("wrong"); } return setTimeout(function(){ var wasCorrect; wasCorrect = div.state === "correct"; div.setState("normal"); if (wasCorrect) { return div.css({ pointerEvents: "none" }); } }, 500); }; })(); trainers/kickItem/buttons/button/animateButton/lineDiagonal/lineDiagonal.ls (function(){ return function(div){ var svg, container; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; return container = svg("svg").css({ position: "absolute", left: 0, top: 0, width: div.width() + "px", height: div.height() + "px" }).append(svg("line").attr({ x1: 0, y1: div.height(), x2: div.width(), y2: 0, strokeWidth: "1.5px", stroke: Color.black })); }; })(); trainers/kickItem/buttons/button/button.ls (function(){ return function(slide, choice, i){ var click, playSound, div; click = function(){ var callback; inc("animateButton/animate")(choice, div); if (choice.correct !== true) { slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atom, { text: choice.text }); slide.currentGreen++; if (slide.currentGreen === slide.totalGreen) { slide.score.log(slide.atom); slide.div.css({ pointerEvents: "none" }); callback = slide.finish; } return playSound(choice, callback); } else { slide.score.addActionMistake(slide.atom, { text: choice.text }); return slide.levelPlayer.progressBar.addElement().showRed(); } }; playSound = function(choice, onDone){ if (slide.getParam("soundMode", slide.atom) === "b") { return setTimeout(function(){ var text, voice; text = choice.sound || slide.atom.sound || choice.text; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(function(){ return typeof onDone == 'function' ? onDone() : void 8; }); }, 300); } else { return setTimeout(function(){ return typeof onDone == 'function' ? onDone() : void 8; }, 500); } }; return div = Button({ label: choice.text, labelAllowWrap: true, action: click }).css({ margin: "0.5em" }); }; })(); trainers/kickItem/buttons/buttons.ls (function(){ return function(slide){ var shuffleButtons, ref$, div, buttons, i, choice; shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; if (shuffleButtons) { slide.choices = _.shuffleWithSeed(slide.choices); } slide.totalGreen = _.filter(slide.choices, { correct: false }).length; slide.currentGreen = 0; return div = Div({ padding: "1em 0.5em" }).append(buttons = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { i = i$; choice = ref$[i$]; results$.push(inc("button/button")(slide, choice, i)); } return results$; }())).appendTo(slide.div); }; })(); trainers/kickItem/calcTotalProgressElements/calc.ls (function(){ return function(atom){ var choices; choices = inc("/shared/convertPlusPlusString/convert")(atom.b); return _.filter(choices, { correct: false }).length; }; })(); trainers/kickItem/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide, i, s; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, j$, ref1$, len1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = inc("calcTotalProgressElements/calc")(atom); slide.choices = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); if (_.isArray(atom.sound)) { for (j$ = 0, len1$ = (ref1$ = atom.sound).length; j$ < len1$; ++j$) { i = j$; s = ref1$[j$]; _.filter(slide.choices, { correct: false })[i].sound = s; } } slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; results$.push(slide); } return results$; }()); }; })(); trainers/kickItem/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/kickItem/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.textA = inc("textA/text")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/kickItem/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/kickItem/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/kickItem/textA/text.ls (function(){ return function(slide){ var p, click, div; p = slide.getParam; if (p("soundMode", slide.atom) === "askSound") { return; } click = function(){ var text, voice; text = slide.atom.sound || slide.atom.a; voice = p("voice", slide.atom); return slide.sounds[text + voice].play(); }; div = Div(); if (!slide.atom.a) { return div; } return div.html(Div({ margin: "0 auto", width: "30em", maxWidth: "90%", textAlign: p("textAlign", slide.atom), padding: p("image", slide.atom) || p("lsg", slide.atom) ? "0.5em" : "0 0.5em" }).html(slide.atom.a).tap(p("soundMode", slide.atom) === "a" ? click : void 8)).appendTo(slide.div); }; })(); trainers/lineCombineLeft/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/lineCombineLeft/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/lineCombineLeft/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, allChoices, correctChoices, correctTexts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = _.ensureArray(slide.atom.sound); } else if (soundMode === "b") { allChoices = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); correctChoices = _.filter(allChoices, { correct: true }); correctTexts = _.map(correctChoices, function(c){ return c.text; }); texts = _.map(correctTexts, function(t){ return t + slide.atom.a; }); } else if (soundMode === "a") { texts = [slide.atom.b]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/lineCombineLeft/_preview/preview.ls (function(){ return function(slide){ return requestAnimationFrame(function(){ return inc("../optimizeWidth/optimize")(slide); }); }; })(); trainers/lineCombineLeft/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", margin: "2em 0" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/lineCombineLeft/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/lineCombineLeft/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/lineCombineLeft/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.left, { padding: 50 }); } }); return inc("../optimizeWidth/optimize")(slide); }; })(); trainers/lineCombineLeft/calcChoices/calc.ls (function(){ return function(slide){ var choices, correctChoices, i$, ref$, len$, i, s, shuffleButtons; choices = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); if (_.isArray(slide.atom.sound)) { correctChoices = _.filter(choices, { correct: true }); for (i$ = 0, len$ = (ref$ = slide.atom.sound).length; i$ < len$; ++i$) { i = i$; s = ref$[i$]; correctChoices[i].sound = s; } } shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; if (shuffleButtons) { choices = _.shuffleWithSeed(choices); } return choices; }; })(); trainers/lineCombineLeft/calcTotalProgressElements/calc.ls (function(){ return function(atom){ var choices; choices = inc("/shared/convertPlusPlusString/convert")(atom.b); return _.filter(choices, { correct: true }).length; }; })(); trainers/lineCombineLeft/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = inc("calcTotalProgressElements/calc")(atom); slide.choices = inc("calcChoices/calc")(slide); slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; results$.push(slide); } return results$; }()); }; })(); trainers/lineCombineLeft/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/lineCombineLeft/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.lineContainer = inc("lineContainer/container")(slide); slide.left = inc("left/left")(slide); return slide.right = inc("right/right")(slide); }; })(); trainers/lineCombineLeft/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/lineCombineLeft/left/element/animateElement/animate.ls (function(){ return function(o, div, circle){ var css1; css1 = { backgroundColor: o.correct ? Color.green[500] : Color.red[500], transition: "" }; div.css(css1); circle.css(css1); return setTimeout(function(){ div.css({ backgroundColor: Color.grey[300], transition: "background 50ms" }); return circle.css({ backgroundColor: Color.grey[400], transition: "background 50ms" }); }, 300); }; })(); trainers/lineCombineLeft/left/element/circle/circle.ls (function(){ return function(){ return Div({ position: "absolute", borderRadius: "50%", width: "12px", height: "12px", backgroundColor: Color.grey[400], marginTop: "-6px", top: "50%", right: "-6px" }); }; })(); trainers/lineCombineLeft/left/element/element.ls (function(){ return function(choice, i, slide){ var tap, div, circle; tap = function(){ var callback; inc("animateElement/animate")(choice, div, circle); if (choice.correct) { slide.lineContainer.drawLine(div); slide.levelPlayer.progressBar.showGreen(); slide.currentGreen++; slide.score.addActionCorrect(slide.atom, { text: choice.text + " + " + slide.atom.a }); div.css({ pointerEvents: "none" }); if (slide.currentGreen === slide.totalGreen) { slide.score.log(slide.atom); slide.div.css({ pointerEvents: "none" }); callback = slide.finish; } if (slide.getParam("soundMode", slide.atom) === "b") { return setTimeout(function(){ var text, voice; text = choice.sound || slide.atom.sound || choice.text + slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(callback); }, 300); } else { return setTimeout(function(){ return typeof callback == 'function' ? callback() : void 8; }, 1000); } } else { slide.score.addActionMistake(slide.atom, { text: choice.text + " + " + slide.atom.a }); return slide.levelPlayer.progressBar.addElement().showRed(); } }; return div = Div({ display: "inline-block", backgroundColor: Color.grey[300], margin: "0.3em 0.5em 0.3em 0", borderRight: "18px solid transparent", padding: "0.6em 0.7em", cursor: "pointer", whiteSpace: "normal" }).html(choice.text, circle = inc("circle/circle")()).tap(tap); }; })(); trainers/lineCombineLeft/left/left.ls (function(){ return function(slide){ var div, i$, ref$, len$, i, choice, e; slide.leftElements = []; slide.totalGreen = _.filter(slide.choices, { correct: true }).length; slide.currentGreen = 0; slide.wrapper.append(div = Div({ display: "inline-block", verticalAlign: "middle" })); for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { i = i$; choice = ref$[i$]; e = inc("element/element")(choice, i, slide); slide.leftElements.push(e); div.append(e, "
"); } return div; }; })(); trainers/lineCombineLeft/lineContainer/container.ls (function(){ return function(slide){ var solvedDivs, drawLine, redrawLines, div; solvedDivs = []; drawLine = function(leftDiv){ solvedDivs.push(leftDiv); return inc("drawLine/line")(slide, leftDiv); }; redrawLines = function(){ var i$, ref$, len$, leftDiv, results$ = []; div.empty(); for (i$ = 0, len$ = (ref$ = solvedDivs).length; i$ < len$; ++i$) { leftDiv = ref$[i$]; results$.push(inc("drawLine/line")(slide, leftDiv)); } return results$; }; slide.wrapper.append(div = Div({ position: "absolute", left: 0, top: 0, right: 0, bottom: 0, pointerEvents: "none" })); div.drawLine = drawLine; div.redrawLines = redrawLines; return div; }; })(); trainers/lineCombineLeft/lineContainer/drawLine/line.ls (function(){ return function(slide, leftDiv){ var l, r, c, leftDivX, leftDivY, rightDivX, rightDivY, width, height, x1, y1, x2, y2, createElement; l = leftDiv; r = slide.rightElement; c = slide.lineContainer; leftDivX = l.offset().left - c.offset().left + l.width() - 18; leftDivY = l.offset().top - c.offset().top + l.height() / 2; rightDivX = r.offset().left - c.offset().left; rightDivY = r.offset().top - c.offset().top + r.height() / 2; width = rightDivX - leftDivX; height = Math.abs(rightDivY - leftDivY); x1 = 0; y1 = Math.max(0, leftDivY - rightDivY); x2 = rightDivX - leftDivX; y2 = Math.max(0, rightDivY - leftDivY); if (height < 1) { y1 = 1.5; y2 = 1.5; leftDivY -= 1.5; rightDivY -= 1.5; } createElement = function(t){ return document.createElementNS("http://www.w3.org/2000/svg", t); }; return createElement("svg").css({ position: "absolute", left: leftDivX + "px", top: Math.min(leftDivY, rightDivY) + "px", width: width + "px", height: height + "px", minHeight: "3px" }).append(createElement("line").attr({ x1: x1, y1: y1, x2: x2, y2: y2, "stroke-width": "3", stroke: Color.grey[400] })).appendTo(slide.lineContainer); }; })(); trainers/lineCombineLeft/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/lineCombineLeft/optimizeWidth/optimize.ls (function(){ return function(slide){ var lastWindowWidth, f; lastWindowWidth = 0; f = function(){ var windowWidth, leftWidth, i$, ref$, len$, e, noWrapWidth, rightWidth, mL, mR; windowWidth = body.width(); if (lastWindowWidth !== windowWidth) { lastWindowWidth = windowWidth; leftWidth = 0; for (i$ = 0, len$ = (ref$ = slide.leftElements).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ width: "", whiteSpace: "nowrap" }); noWrapWidth = e.width({ withMargins: true }); e.css({ whiteSpace: "normal" }); leftWidth = Math.max(leftWidth, noWrapWidth); } slide.rightElement.css({ width: "" }); rightWidth = slide.rightElement.width({ withMargins: true }); if (leftWidth > windowWidth * 0.5) { leftWidth = windowWidth * 0.45; } if (rightWidth > windowWidth * 0.5) { rightWidth = windowWidth * 0.45; } for (i$ = 0, len$ = (ref$ = slide.leftElements).length; i$ < len$; ++i$) { e = ref$[i$]; mL = _.parseInt(e.css("marginLeft")); mR = _.parseInt(e.css("marginRight")); e.css({ width: (leftWidth - mL - mR) + "px" }); } mL = _.parseInt(slide.rightElement.css("marginLeft")); mR = _.parseInt(slide.rightElement.css("marginRight")); slide.rightElement.css({ width: (rightWidth - mL - mR + 10) + "px" }); slide.lineContainer.redrawLines(); } if (slide.div.isVisible()) { return requestAnimationFrame(f); } }; return f(); }; })(); trainers/lineCombineLeft/right/element/element.ls (function(){ return function(slide){ return Div({ display: "inline-block", backgroundColor: Color.grey[300], margin: "0.3em", marginLeft: "1.5em", padding: "0.6em", cursor: "default", whiteSpace: "normal" }).html(slide.atom.a).append(Div({ position: "absolute", borderRadius: "50%", width: "12px", height: "12px", backgroundColor: Color.grey[400], marginTop: "-6px", top: "50%", left: "-6px" })); }; })(); trainers/lineCombineLeft/right/right.ls (function(){ return function(slide){ var div; slide.wrapper.append(div = Div({ display: "inline-block", verticalAlign: "middle" }).append(slide.rightElement = inc("element/element")(slide))); return div; }; })(); trainers/lineCombineLeft/wrapper/wrapper.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ whiteSpace: "nowrap", display: "inline-block", minHeight: "10em" })); return div; }; })(); trainers/lineCombineRight/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/lineCombineRight/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/lineCombineRight/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, allChoices, correctChoices, correctTexts, res$, i$, len$, t, voiceLang, voice, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = _.ensureArray(slide.atom.sound); } else if (soundMode === "b") { allChoices = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); correctChoices = _.filter(allChoices, { correct: true }); correctTexts = _.map(correctChoices, function(c){ return c.text; }); res$ = []; for (i$ = 0, len$ = correctTexts.length; i$ < len$; ++i$) { t = correctTexts[i$]; res$.push(slide.atom.a + t); } texts = res$; } else if (soundMode === "a") { texts = [slide.atom.b]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/lineCombineRight/_preview/preview.ls (function(){ return function(slide){ return requestAnimationFrame(function(){ return inc("../optimizeWidth/optimize")(slide); }); }; })(); trainers/lineCombineRight/_review/scoreActions/actions.ls (function(){ return function(slide){ return inc("/trainers/lineCombineLeft/_review/scoreActions/actions")(slide); }; })(); trainers/lineCombineRight/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.right, { padding: 50 }); } }); return inc("../optimizeWidth/optimize")(slide); }; })(); trainers/lineCombineRight/calcTotalProgressElements/calc.ls (function(){ return function(atom){ var choices; choices = inc("/shared/convertPlusPlusString/convert")(atom.b); return _.filter(choices, { correct: true }).length; }; })(); trainers/lineCombineRight/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = inc("/trainers/lineCombineLeft/calcTotalProgressElements/calc")(atom); slide.choices = inc("/trainers/lineCombineLeft/calcChoices/calc")(slide); slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; results$.push(slide); } return results$; }()); }; })(); trainers/lineCombineRight/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/lineCombineRight/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.lineContainer = inc("lineContainer/container")(slide); slide.left = inc("left/left")(slide); return slide.right = inc("right/right")(slide); }; })(); trainers/lineCombineRight/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/lineCombineRight/left/element/element.ls (function(){ return function(slide){ return Div({ display: "inline-block", backgroundColor: Color.grey[300], margin: "0.3em", marginRight: "1.5em", padding: "0.6em", cursor: "default", whiteSpace: "normal" }).html(slide.atom.a).prepend(Div({ position: "absolute", borderRadius: "50%", width: "12px", height: "12px", backgroundColor: Color.grey[400], marginTop: "-6px", top: "50%", right: "-6px" })); }; })(); trainers/lineCombineRight/left/left.ls (function(){ return function(slide){ var div; slide.wrapper.append(div = Div({ display: "inline-block", verticalAlign: "middle" }).append(slide.leftElement = inc("element/element")(slide))); return div; }; })(); trainers/lineCombineRight/lineContainer/container.ls (function(){ return function(slide){ var solvedDivs, drawLine, redrawLines, div; solvedDivs = []; drawLine = function(rightDiv){ solvedDivs.push(rightDiv); return inc("drawLine/line")(slide, rightDiv); }; redrawLines = function(){ var i$, ref$, len$, rightDiv, results$ = []; div.empty(); for (i$ = 0, len$ = (ref$ = solvedDivs).length; i$ < len$; ++i$) { rightDiv = ref$[i$]; results$.push(inc("drawLine/line")(slide, rightDiv)); } return results$; }; slide.wrapper.append(div = Div({ position: "absolute", left: 0, top: 0, right: 0, bottom: 0, pointerEvents: "none" })); div.drawLine = drawLine; div.redrawLines = redrawLines; return div; }; })(); trainers/lineCombineRight/lineContainer/drawLine/line.ls (function(){ return function(slide, rightDiv){ var l, r, c, leftDivX, leftDivY, rightDivX, rightDivY, width, height, x1, y1, x2, y2, createElement; l = slide.leftElement; r = rightDiv; c = slide.lineContainer; leftDivX = l.offset().left - c.offset().left + l.width(); leftDivY = l.offset().top - c.offset().top + l.height() / 2; rightDivX = r.offset().left - c.offset().left - 0.5 + 18; rightDivY = r.offset().top - c.offset().top + r.height() / 2; width = rightDivX - leftDivX; height = Math.abs(leftDivY - rightDivY); x1 = rightDivX - leftDivX; y1 = Math.max(0, rightDivY - leftDivY); x2 = 0; y2 = Math.max(0, leftDivY - rightDivY); if (height < 1) { y1 = 1.5; y2 = 1.5; rightDivY -= 1.5; leftDivY -= 1.5; } createElement = function(t){ return document.createElementNS("http://www.w3.org/2000/svg", t); }; return createElement("svg").css({ position: "absolute", left: leftDivX + "px", top: Math.min(leftDivY, rightDivY) + "px", width: width + "px", height: height + "px", minHeight: "3px" }).append(createElement("line").attr({ x1: x1, y1: y1, x2: x2, y2: y2, "stroke-width": "3", stroke: Color.grey[400] })).appendTo(slide.lineContainer); }; })(); trainers/lineCombineRight/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/lineCombineRight/optimizeWidth/optimize.ls (function(){ return function(slide){ var lastWindowWidth, f; lastWindowWidth = 0; f = function(){ var windowWidth, rightWidth, i$, ref$, len$, e, noWrapWidth, leftWidth, mL, mR; windowWidth = body.width(); if (lastWindowWidth !== windowWidth) { lastWindowWidth = windowWidth; rightWidth = 0; for (i$ = 0, len$ = (ref$ = slide.rightElements).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ whiteSpace: "nowrap", width: "" }); noWrapWidth = e.width({ withMargins: true }); e.css({ whiteSpace: "normal" }); rightWidth = Math.max(rightWidth, noWrapWidth); } slide.leftElement.css({ width: "" }); leftWidth = slide.leftElement.width({ withMargins: true }); if (leftWidth > windowWidth * 0.5) { leftWidth = windowWidth * 0.45; } if (rightWidth > windowWidth * 0.5) { rightWidth = windowWidth * 0.45; } for (i$ = 0, len$ = (ref$ = slide.rightElements).length; i$ < len$; ++i$) { e = ref$[i$]; mL = _.parseInt(e.css("marginLeft")); mR = _.parseInt(e.css("marginRight")); e.css({ width: (rightWidth - mL - mR) + "px" }); } mL = _.parseInt(slide.leftElement.css("marginLeft")); mR = _.parseInt(slide.leftElement.css("marginRight")); slide.leftElement.css({ width: (leftWidth - mL - mR + 10) + "px" }); slide.lineContainer.redrawLines(); } if (slide.div.isVisible()) { return requestAnimationFrame(f); } }; return f(); }; })(); trainers/lineCombineRight/right/element/animateElement/animate.ls (function(){ return function(o, div, circle){ var css1; css1 = { backgroundColor: o.correct ? Color.green[500] : Color.red[500], transition: "" }; div.css(css1); circle.css(css1); return setTimeout(function(){ div.css({ backgroundColor: Color.grey[300], transition: "background 50ms" }); return circle.css({ backgroundColor: Color.grey[400], transition: "background 50ms" }); }, 300); }; })(); trainers/lineCombineRight/right/element/circle/circle.ls (function(){ return function(){ return Div({ position: "absolute", borderRadius: "50%", width: "12px", height: "12px", backgroundColor: Color.grey[400], marginTop: "-6px", top: "50%", left: "-6px" }); }; })(); trainers/lineCombineRight/right/element/element.ls (function(){ return function(choice, i, slide){ var tap, div, circle; tap = function(){ var callback; inc("animateElement/animate")(choice, div, circle); if (choice.correct) { slide.lineContainer.drawLine(div); slide.levelPlayer.progressBar.showGreen(); slide.currentGreen++; slide.score.addActionCorrect(slide.atom, { text: slide.atom.a + " + " + choice.text }); div.css({ pointerEvents: "none" }); if (slide.currentGreen === slide.totalGreen) { slide.score.log(slide.atom); slide.div.css({ pointerEvents: "none" }); callback = slide.finish; } if (slide.getParam("soundMode", slide.atom) === "b") { return setTimeout(function(){ var text, voice; text = choice.sound || slide.atom.sound || slide.atom.a + choice.text; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(callback); }, 300); } else { return setTimeout(function(){ return typeof callback == 'function' ? callback() : void 8; }, 1000); } } else { slide.score.addActionMistake(slide.atom, { text: slide.atom.a + " + " + choice.text }); return slide.levelPlayer.progressBar.addElement().showRed(); } }; return div = Div({ display: "inline-block", backgroundColor: Color.grey[300], margin: "0.3em 0 0.3em 0.5em", borderLeft: "18px solid transparent", padding: "0.6em 0.7em", cursor: "pointer", whiteSpace: "normal" }).html(circle = inc("circle/circle")(), choice.text).tap(tap); }; })(); trainers/lineCombineRight/right/right.ls (function(){ return function(slide){ var div, i$, ref$, len$, i, choice, e; slide.rightElements = []; slide.totalGreen = _.filter(slide.choices, { correct: true }).length; slide.currentGreen = 0; slide.wrapper.append(div = Div({ display: "inline-block", verticalAlign: "middle" })); for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { i = i$; choice = ref$[i$]; e = inc("element/element")(choice, i, slide); slide.rightElements.push(e); div.append(e, "
"); } return div; }; })(); trainers/lineCombineRight/wrapper/wrapper.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ whiteSpace: "nowrap", display: "inline-block", minHeight: "10em" })); return div; }; })(); trainers/list/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, res$, i$, ref$, len$, atom, voiceLang, voice, text; sounds = []; soundMode = slide.getParam("soundMode", atom); res$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.sound) { res$.push(atom.sound); } else if (soundMode === "a") { res$.push(atom.a); } else if (soundMode === "b") { res$.push(atom.b); } } texts = res$; voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/list/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, c, lresult$, j$, ref1$, len1$, span, results$ = []; inc("/trainers/listMatch/optimizeSizes/optimize")(slide); for (i$ = 0, len$ = (ref$ = slide.rows.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; lresult$ = []; for (j$ = 0, len1$ = (ref1$ = c.findAll("span")).length; j$ < len1$; ++j$) { span = ref1$[j$]; lresult$.push(span.css({ visibility: "visible" })); } results$.push(lresult$); } return results$; }; })(); trainers/list/_review/scoreActions/actions.ls (function(){ return function(slide){}; })(); trainers/list/_start/start.ls (function(){ return function(slide){ slide.levelPlayer.progressBar.disableSounds(); slide.instruction.play(); inc("/trainers/listMatch/optimizeSizes/optimize")(slide); slide.rows.showNext(); return setTimeout(function(){ return slide.continueButton.showButton(true, true); }, 500); }; })(); trainers/list/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ return setTimeout(function(){ slide.levelPlayer.page.bottom.html(div).show(); div.hide(); div.fadeIn(); return slide.levelPlayer.page.css({ transition: "500ms" }); }, 500); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(function(){ slide.rows.showNext(); return div.css({ pointerEvents: "" }); }, 500); }; div = Div({ textAlign: "center" }).append(Button({ label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "1em" }).tap(click)); div.showButton = showButton; return div; }; })(); trainers/list/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/list/init.ls (function(){ return function(slide){ slide.elementsLeft = []; slide.elementsRight = []; slide.instruction = inc("instruction/instruction")(slide); slide.rows = inc("rows/rows")(slide); return slide.continueButton = inc("continueButton/button")(slide); }; })(); trainers/list/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/list/rows/row/calcCss/calc.ls (function(){ return function(slide, atom){ var textAlign, css; textAlign = slide.getParam("textAlign", atom) || "center"; return css = { display: "inline-flex", margin: "0.5em 0.2em", padding: "0.5em 0.7em", overflow: "hidden", verticalAlign: "top", textAlign: textAlign, backgroundColor: Color.grey[150], justifyContent: textAlign === "left" ? "flex-start" : "center" }; }; })(); trainers/list/rows/row/row.ls (function(){ return function(atom, slide){ var sound, that, showRow, playSound, textAlign, css, div, left, leftSpan, right, rightSpan; sound = (that = atom.sound) ? that : slide.getParam("soundMode", atom) === "a" ? atom.a : slide.getParam("soundMode", atom) === "b" ? atom.b : void 8; showRow = function(){ var i$, ref$, len$, c; slide.levelPlayer.page.scrollElementIntoView(div, { padding: 50, duration: 500 }); leftSpan.css({ visibility: "visible" }); rightSpan.css({ visibility: "visible" }); for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ backgroundColor: Color.grey[300] }); } if (slide.getParam("soundMode", atom) != null) { div.tap({ up: playSound, animation: "none" }); return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: playSound }); } else { return requestAnimationFrame(function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.css({ backgroundColor: Color.grey[150], transition: "600ms" })); } return results$; }); } }; playSound = function(){ var i$, ref$, len$, c, voice; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ backgroundColor: Color.grey[300], transition: "" }); } voice = slide.getParam("voice", atom); return slide.sounds[sound + voice].play(function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = div.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.css({ backgroundColor: Color.grey[150], transition: "200ms" })); } return results$; }); }; textAlign = slide.getParam("textAlign", atom) || "center"; css = inc("calcCss/calc")(slide, atom); div = Div().html(left = Div(css).html(leftSpan = Span({ visibility: "hidden" }).html(atom.a)), right = Div(css).html(rightSpan = Span({ visibility: "hidden" }).html(atom.b))); slide.elementsLeft.push(left); slide.elementsRight.push(right); div.left = left; div.right = right; div.showRow = showRow; return div; }; })(); trainers/list/rows/rows.ls (function(){ return function(slide){ var currentIndex, showNext, div, rows, atom, row; currentIndex = -1; showNext = function(){ var atom; currentIndex++; if (currentIndex < rows.length) { rows[currentIndex].showRow(); atom = slide.atoms[currentIndex]; slide.score.addActionCorrect(atom); slide.score.log(atom); return slide.levelPlayer.progressBar.showGreen(); } else { slide.continueButton.remove(); slide.div.css({ pointerEvents: "none" }); return slide.finish(); } }; slide.div.append(div = Div({ marginTop: slide.getParam("hint") != null ? "1.5em" : void 8 }).append(rows = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(row = inc("row/row")(atom, slide)); } return results$; }()))); div.showNext = showNext; return div; }; })(); trainers/listMatch/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, text; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); text = atom.sound ? atom.sound : soundMode === "a" ? atom.a : soundMode === "b" ? atom.b : void 8; if (text != null) { sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } return sounds; }; })(); trainers/listMatch/_preview/preview.ls (function(){ return function(slide){ return requestAnimationFrame(function(){ var i$, ref$, len$, e, results$ = []; inc("../optimizeSizes/optimize")(slide); for (i$ = 0, len$ = (ref$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref$[i$]; results$.push(e.css({ color: 'black' })); } return results$; }); }; })(); trainers/listMatch/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, i, action; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.originalAtom = e.atom; actions.push(a); } } if (actions.length > 0) { return slide.div.append(Div({ textAlign: "left", margin: "2em 0" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/listMatch/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/listMatch/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/listMatch/_start/start.ls (function(){ return function(slide){ slide.showNext(); slide.levelPlayer.page.enableFreezeMinHeight(); slide.instruction.play(function(){ return slide.playOnElementStart(); }); inc("../optimizeSizes/optimize")(slide); if (_.some(slide.atoms, function(atom){ return _.includes(atom.a, ""); } return elements; }; })(); trainers/listMatch/elementsRight/element/element.ls (function(){ return function(slide, atom, i){ var currentAtom, down, up, cancel, onCorrect, onWrong, div; currentAtom = null; down = function(){ var i$, ref$, len$, el, results$ = []; currentAtom = slide.atoms[slide.currentIndex]; div.css({ backgroundColor: Color.grey[300] }); for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { el = ref$[i$]; if (el !== div && !el.isSolved) { results$.push(el.css({ pointerEvents: "none" })); } } return results$; }; up = function(){ if (currentAtom.b === div.atom.b) { atom = currentAtom; i = slide.currentIndex; onCorrect(); } else { onWrong(); } return setTimeout(function(){ var i$, ref$, len$, el, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { el = ref$[i$]; if (el !== div && !el.isSolved) { results$.push(el.css({ pointerEvents: "" })); } } return results$; }, 300); }; cancel = function(){ var i$, ref$, len$, el, results$ = []; div.css({ backgroundColor: Color.grey[150] }); for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { el = ref$[i$]; if (el !== div && !el.isSolved) { results$.push(el.css({ pointerEvents: "" })); } } return results$; }; onCorrect = function(){ var atom; div.css({ backgroundColor: Color.green[500], pointerEvents: "none" }); div.isSolved = true; slide.elementsLeft[i].css({ height: div.height() + "px" }); slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(currentAtom, { text: "'" + currentAtom.a + "' + '" + div.atom.b + "'" }); slide.score.log(currentAtom); atom = slide.atoms[slide.currentIndex]; if (slide.getParam("soundMode", atom) === "b") { setTimeout(function(){ var text, voice; text = atom.sound || atom.b; voice = slide.getParam("voice", atom); slide.soundPlaying = true; return slide.sounds[text + voice].play(function(){ return slide.soundPlaying = false; }); }, 300); } return setTimeout(function(){ div.css({ backgroundColor: Color.grey[150], opacity: 0 }); slide.asker.before(div); requestAnimationFrame(function(){ return div.css({ opacity: 1, transition: "opacity 400ms" }); }); slide.asker.before(document.createElement("br")); slide.showNext(); if (slide.instruction.hasPlayed()) { return slide.playOnElementStart(); } }, 300); }; onWrong = function(){ slide.score.addActionMistake(currentAtom, { text: "'" + currentAtom.a + "' + '" + div.atom.b + "'" }); slide.levelPlayer.progressBar.addElement().showRed(); div.css({ backgroundColor: Color.red[500] }); return setTimeout(function(){ return div.css({ backgroundColor: Color.grey[150] }); }, 300); }; div = Div({ display: "inline-flex", padding: body.width() < 400 ? "0.4em" : "0.7em", backgroundColor: Color.grey[150], border: "10px solid white", verticalAlign: "top", overflow: "hidden", whiteSpace: "pre-wrap", borderLeft: "2px solid white", cursor: "pointer" }).css(slide.getParam("textAlign", atom) === "left" ? { justifyContent: "flex-start", textAlign: "left" } : { justifyContent: "center", textAlign: "center" }).tap({ down: down, up: up, cancel: cancel }).html(Div({ display: "inline-block", maxWidth: "100%", pointerEvents: "none" }).html(atom.b)); div.atom = atom; return div; }; })(); trainers/listMatch/elementsRight/elements.ls (function(){ return function(slide){ var elements, res$, i$, ref$, len$, i, atom, e; res$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; res$.push(inc("element/element")(slide, atom, i)); } elements = res$; for (i$ = 0, len$ = (ref$ = _.shuffleWithSeed(elements)).length; i$ < len$; ++i$) { e = ref$[i$]; slide.todo.append(e); } return elements; }; })(); trainers/listMatch/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/listMatch/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.left = inc("left/left")(slide); slide.elementsLeft = inc("elementsLeft/elements")(slide); slide.right = inc("right/right")(slide); slide.elementsRight = inc("elementsRight/elements")(slide); slide.playOnElementStart = function(){ return inc("playOnElementStart/play")(slide); }; return slide.showNext = function(){ return inc("showNext/show")(slide); }; }; })(); trainers/listMatch/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/listMatch/left/left.ls (function(){ return function(slide){ return Div({ display: "inline-block", verticalAlign: "top" }).appendTo(slide.wrapper); }; })(); trainers/listMatch/optimizeSizes/calcWidth/calc.ls (function(){ return function(s, p){ var div, w; div = Div({ display: "inline-block", position: "absolute", borderLeft: p.css("borderLeft"), borderRight: p.css("borderRight"), paddingLeft: p.css("paddingLeft"), paddingRight: p.css("paddingRight"), pointerEvents: "none", opacity: 0 }).html(s).appendTo(p); w = div.width(); div.remove(); return w; }; })(); trainers/listMatch/optimizeSizes/optimize.ls (function(){ var calcWidth; calcWidth = inc("calcWidth/calc"); return function(slide){ var maxW, optimizeSizes; maxW = null; optimizeSizes = function(){ var maxWNew, i$, ref$, len$, e, lw, rw, lc, rc, ls, rs, j$, ref1$, len1$, w, minLW, minRW, h, ref2$; if (slide.div.isVisible()) { requestAnimationFrame(optimizeSizes); } maxWNew = body.width() * 0.85; if (maxWNew > 600) { maxWNew = 600; } if (maxW === maxWNew) { return; } maxW = maxWNew; for (i$ = 0, len$ = (ref$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ width: "", height: "", whiteSpace: "pre" }); } for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ width: "", height: "", whiteSpace: "pre" }); } lw = 0; rw = 0; lc = 0; rc = 0; ls = ""; rs = ""; for (i$ = 0, len$ = (ref$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref$[i$]; lw = Math.max(lw, e.width()); lc = Math.max(lc, e.text().length); for (j$ = 0, len1$ = (ref1$ = e.text().split(" ")).length; j$ < len1$; ++j$) { w = ref1$[j$]; if (w.length > ls.length) { ls = w; } } } for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref$[i$]; rw = Math.max(rw, e.width()); rc = Math.max(rc, e.text().length); for (j$ = 0, len1$ = (ref1$ = e.text().split(" ")).length; j$ < len1$; ++j$) { w = ref1$[j$]; if (w.length > rs.length) { rs = w; } } } if (lw + rw > maxW) { lw = lc / (lc + rc) * maxW; rw = rc / (lc + rc) * maxW; minLW = calcWidth(ls, slide.elementsLeft[0]); minRW = calcWidth(rs, slide.elementsRight[0]); if (minLW >= lw) { lw = minLW; rw = maxW - minLW; } else if (minRW > rw) { rw = minRW; lw = maxW - minRW; } } for (i$ = 0, len$ = (ref$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ width: lw + "px", whiteSpace: "pre-wrap" }); } for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ width: rw + "px", whiteSpace: "pre-wrap" }); } if ((ref$ = slide.asker) != null) { ref$.css({ width: rw + "px" }); } if ((ref1$ = slide.todo) != null) { ref1$.css({ width: rw + slide.todo.css("paddingLeft").replace("px", "") * 1 + "px" }); } h = 0; for (i$ = 0, len$ = (ref2$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref2$[i$]; h = Math.max(h, e.height()); } for (i$ = 0, len$ = (ref2$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref2$[i$]; h = Math.max(h, e.height()); } for (i$ = 0, len$ = (ref2$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref2$[i$]; e.css({ height: h + "px" }); } for (i$ = 0, len$ = (ref2$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref2$[i$]; e.css({ height: h + "px" }); } return (ref2$ = slide.asker) != null ? ref2$.css({ height: h + "px" }) : void 8; }; return optimizeSizes(); }; })(); trainers/listMatch/playOnElementStart/play.ls (function(){ return function(slide){ var atom, delay; atom = slide.atoms[slide.currentIndex]; if (!atom) { return; } if (slide.getParam("soundMode", atom) === "a") { delay = slide.currentIndex === 0 ? 500 : 100; return setTimeout(function(){ var text, voice; text = atom.sound || atom.a; voice = slide.getParam("voice", atom); return slide.sounds[text + voice].play(); }, delay); } }; })(); trainers/listMatch/right/asker/asker.ls (function(){ return function(slide){ return Div({ display: "inline-flex", padding: "0.5em 0.7em", border: "10px solid white", verticalAlign: "top", textAlign: "left", cursor: "default" }).html("???"); }; })(); trainers/listMatch/right/right.ls (function(){ return function(slide){ return Div({ display: "inline-block", verticalAlign: "top", textAlign: "left" }).html(slide.asker = inc("asker/asker")(slide), slide.todo = inc("todo/todo")(slide)).appendTo(slide.wrapper); }; })(); trainers/listMatch/right/todo/todo.ls (function(){ return function(slide){ return Div({ paddingTop: "1em", paddingLeft: "2em", whiteSpace: "normal", backgroundColor: "white" }); }; })(); trainers/listMatch/showNext/show.ls (function(){ return function(slide){ var page, finish, currentAtom, nextElement; page = slide.levelPlayer.page; slide.currentIndex++; finish = function(){ if (!slide.div.isVisible()) { return; } if (!slide.soundPlaying) { return slide.finish(); } else { return setTimeout(finish, 500); } }; if (slide.currentIndex >= slide.atoms.length) { slide.asker.hide(); slide.div.css({ pointerEvents: "none" }); finish(); return; } currentAtom = slide.atoms[slide.currentIndex]; if (typeof page.setTrainerHint == 'function') { page.setTrainerHint(slide, currentAtom); } if (typeof page.setCalculator == 'function') { page.setCalculator(slide, currentAtom); } nextElement = slide.elementsLeft[slide.currentIndex]; slide.levelPlayer.page.scrollElementIntoView(nextElement, { center: true }); nextElement.firstChild.css({ opacity: 1 }); slide.asker.css({ color: "white" }); return requestAnimationFrame(function(){ return slide.asker.css({ color: "black" }); }); }; })(); trainers/listMatch/wrapper/wrapper.ls (function(){ return function(slide){ return Div({ whiteSpace: "nowrap" }).appendTo(slide.div); }; })(); trainers/listMatchVertical/_media2/images/images.ls (function(){ return function(slide){ var images, i$, ref$, len$, atom, j$, ref1$, len1$, t, that; images = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = ["a", "b"]).length; j$ < len1$; ++j$) { t = ref1$[j$]; if (that = slide.getParam("image", atom[t])) { images.push(that); } } } return images; }; })(); trainers/listMatchVertical/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var lsgs, i$, ref$, len$, atom, j$, ref1$, len1$, t, that; lsgs = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; for (j$ = 0, len1$ = (ref1$ = ["a", "b"]).length; j$ < len1$; ++j$) { t = ref1$[j$]; if (that = slide.getParam("lsg", atom[t])) { lsgs.push(that); } } } return lsgs; }; })(); trainers/listMatchVertical/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, text; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); text = atom.sound ? atom.sound : soundMode === "a" ? atom.a : soundMode === "b" && atom.a != null ? atom.b : void 8; if (_.isString(text)) { sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } return sounds; }; })(); trainers/listMatchVertical/_preview/preview.ls (function(){ return function(slide){ _.forEach(slide.elementsTop, function(e){ e.css({ display: "inline-block" }); return e.show(); }); _.forEach(slide.elementsBottom, function(e){ return e.width(slide.elementsTop[0].width() + "px"); }); slide.div.append(slide.bottom.css({ backgroundColor: "" })); slide.top.css({ marginBottom: "2em" }); slide.bottom.css({ marginBottom: "2em" }); return slide.top.after(Div({ display: "inline-block", marginLeft: "-1em", width: "2em", height: "5em" }).append(SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-up.svg"), color: Color.grey[400] }).css({ height: "2em", width: "2em", marginTop: "-0.7em" }), SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-up.svg"), color: Color.grey[400] }).css({ height: "2em", width: "2em", marginTop: "-0.7em" }), SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-up.svg"), color: Color.grey[400] }).css({ height: "2em", width: "2em", marginTop: "-0.7em" }))); }; })(); trainers/listMatchVertical/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, event, elementTop, k, action; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } if (scoreEvents.length === 0) { return; } if (scoreEvents[0].actions[0].bottomIndex == null) { inc("correctOldAction/correct")(slide, scoreEvents); } return slide.div.html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvents).length; i$ < len$; ++i$) { event = ref$[i$]; elementTop = _.find(slide.elementsTop, fn$); results$.push(Div({ display: "flex", flexDirection: "column" }).append(elementTop.clone().css({ margin: "1em 0 -0.15em" })).append((fn1$()))); } return results$; function fn$(el){ return _.isEqual(el.atom, event.matchingAtom); } function fn1$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = event.actions).length; i$ < len$; ++i$) { k = i$; action = ref$[i$]; if (action.correct) { results$.push(inc("correct/correct")(action, slide)); } else { results$.push(inc("mistake/mistake")(action, slide)); } } return results$; } }())); }; })(); trainers/listMatchVertical/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ margin: "0.7em 0 0" }).append(slide.elementsBottom[action.bottomIndex].clone().css({ margin: "0 0 0.7em" }), inc("/shared/scoreActionRow/iconScore/icon")(action).css({ top: "-0.3em" })); }; })(); trainers/listMatchVertical/_review/scoreActions/correctOldAction/correct.ls (function(){ return function(slide, scoreEvents){ var i$, len$, event, lresult$, j$, ref$, len1$, action, texts, bText, bottomIndex, results$ = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { event = scoreEvents[i$]; lresult$ = []; for (j$ = 0, len1$ = (ref$ = event.actions).length; j$ < len1$; ++j$) { action = ref$[j$]; texts = action.text.split("' + '"); bText = texts[1]; bText = bText.substring(0, bText.length - 1); bottomIndex = _.indexOf(slide.atoms, _.find(slide.atoms, { b: bText })); lresult$.push(action.bottomIndex = bottomIndex); } results$.push(lresult$); } return results$; }; })(); trainers/listMatchVertical/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ margin: "0.7em 0 0" }).append(slide.elementsBottom[action.bottomIndex].clone().css({ margin: "" }), inc("/shared/scoreActionRow/iconScore/icon")(action).css({ top: "-0.3em" })); }; })(); trainers/listMatchVertical/_shared/image/image.ls (function(){ return function(slide, image){ if (!image) { return; } if (image.width) { debug("image width kann im listMatchVertical-trainer nicht angepasst werden"); } return inc("/shared/image/image")({ image: image, slide: slide }).css({ width: "100%" }); }; })(); trainers/listMatchVertical/_shared/lsg/lsg.ls (function(){ return function(slide, lsg){ var div; if (!lsg) { return; } if (lsg.width) { debug("lsg width kann im listMatchVertical-trainer nicht angepasst werden"); } return div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ width: "100%", height: "100%" }); }; })(); trainers/listMatchVertical/_start/start.ls (function(){ return function(slide){ slide.levelPlayer.page.bottom.html(slide.bottom).show(); slide.instruction.play(); slide.startNextElement(); return requestAnimationFrame(function(){ return inc("../optimizeHeights/optimize")(slide); }); }; })(); trainers/listMatchVertical/bottom/bottom.ls (function(){ return function(slide){ var isDown, toggle, div; isDown = true; toggle = function(){ var bottomEl, topEl, topElBottom; if (!isDown) { bottomEl = slide.elementsBottom[slide.currentIndex]; topEl = slide.elementsTop[slide.currentIndex]; topElBottom = slide.levelPlayer.page.topbar.height() + slide.instruction.height() + topEl.height(); if (topElBottom + bottomEl.height() > div.offset().top) { div.keyframeAnimate({ duration: "500ms", keyframes: { "100%": { maxHeight: "calc(var(--screenHeight) * 0.15)" } } }); } } else { div.keyframeAnimate({ duration: "500ms", keyframes: { "100%": { maxHeight: "calc(var(--screenHeight) * 0.5)" } } }); } return isDown = !isDown; }; div = ScrollDiv({ scrollbarMode: "show" }).css({ width: "100%", padding: "0.5em 0", textAlign: "center", animationTimingFunction: "easeInOut" }); div.toggle = toggle; return div; }; })(); trainers/listMatchVertical/elementsBottom/element/animate/animate.ls (function(){ return function(slide, div, target){ var dummy; slide.levelPlayer.page.scrollElementIntoView(slide.top, { padding: 150 }); dummy = Div().addClass("dummyBottom").css({ display: "inline-block", height: div.height() + "px", width: div.width() + "px", verticalAlign: "top", margin: "15px 10px 10px" }); inc("setBackgroundColor/set")(div); div.offsetSave(); div.replaceWith(dummy).css({ zIndex: 3, margin: "-2px auto 0" }); target.after(div); div.offsetAnimate(); return inc("removeEmptyRows/remove")(slide); }; })(); trainers/listMatchVertical/elementsBottom/element/animate/removeEmptyRows/remove.ls (function(){ return function(slide){ var rows, i$, ref$, len$, c, k, emptyRow; rows = {}; for (i$ = 0, len$ = (ref$ = slide.bottom.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; k = c.offset().top + ""; if (rows[k] == null) { rows[k] = []; } rows[k].push({ hidden: c.hasClass("dummyBottom"), div: c }); } emptyRow = _.find(rows, function(r){ return r.every(function(c){ return c.hidden === true; }); }); if (!emptyRow) { return; } return setTimeout(function(){ var i$, ref$, len$, c; for (i$ = 0, len$ = (ref$ = emptyRow).length; i$ < len$; ++i$) { c = ref$[i$]; c.div.keyframeAnimate({ keyframes: { "100%": { height: 0 } }, duration: 200, onCompleted: fn$ }); } if (_.values(rows).length === 1) { return slide.bottom.css({ padding: 0 }); } function fn$(div){ return div.remove(); } }, 500); }; })(); trainers/listMatchVertical/elementsBottom/element/animate/setBackgroundColor/set.ls (function(){ return function(div){ var c, i$, ref$, len$, p, results$ = []; c = { backgroundColor: Color.green[500] }; div.css(c); for (i$ = 0, len$ = (ref$ = div.puzzle).length; i$ < len$; ++i$) { p = ref$[i$]; results$.push(p.css(c)); } return results$; }; })(); trainers/listMatchVertical/elementsBottom/element/element.ls (function(){ return function(slide, atom, i, type){ var currentAtom, down, cancel, up, onDone, onCorrect, onWrong, stop, div, puzzle; currentAtom = null; down = function(){ var i$, ref$, len$, p, results$ = []; currentAtom = _.filter(slide.atoms, "a")[slide.currentIndex]; div.css({ backgroundColor: Color.grey[350] }); for (i$ = 0, len$ = (ref$ = puzzle).length; i$ < len$; ++i$) { p = ref$[i$]; results$.push(p.css({ backgroundColor: Color.grey[350] })); } return results$; }; cancel = function(){ var i$, ref$, len$, p, results$ = []; div.css({ backgroundColor: Color.grey[250] }); for (i$ = 0, len$ = (ref$ = puzzle).length; i$ < len$; ++i$) { p = ref$[i$]; results$.push(p.css({ backgroundColor: Color.grey[250] })); } return results$; }; up = function(){ if (_.isEqual(currentAtom.b, div.atom.b)) { atom = currentAtom; return onCorrect(); } else { return onWrong(); } }; onDone = function(){ return inc("onDone/onDone")(slide, div); }; onCorrect = function(){ return inc("onCorrect/onCorrect")(slide, currentAtom, i, div, onDone); }; onWrong = function(){ return inc("onWrong/onWrong")(slide, currentAtom, i, div, puzzle); }; stop = function(){ return div.fadeOut(); }; div = Div().addClass("elementBottom").css({ display: "inline-block", verticalAlign: "top", margin: "15px 10px 10px", padding: "0.7em", backgroundColor: Color.grey[250], cursor: "pointer", width: "15em", maxWidth: "90%", textAlign: slide.getParam("textAlign") || "center" }).html(type === "image" ? inc("../../_shared/image/image")(slide, atom.b.image) : type === "lsg" ? inc("../../_shared/lsg/lsg")(slide, atom.b.lsg) : atom.b, puzzle = inc("puzzle/puzzle")()).tap({ down: down, up: up, cancel: cancel, animation: "none" }); if (engine.isDebug) { div.addClass("keyManager-" + (49 + i)); div.bind("keyManager", function(){ down(); return up(); }, 1); } div.puzzle = puzzle; div.label = atom.b; div.atom = atom; return div; }; })(); trainers/listMatchVertical/elementsBottom/element/onCorrect/onCorrect.ls (function(){ return function(slide, atom, i, div, onDone){ var i$, ref$, len$, b, elementTop; slide.bottom.toggle(); slide.lastSolvedAtom = atom; slide.lastCorrectAt = new Date(); div.css({ pointerEvents: "none" }); for (i$ = 0, len$ = (ref$ = slide.bottom.childrenAll()).length; i$ < len$; ++i$) { b = ref$[i$]; b.css({ pointerEvents: "none" }); } slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(atom, { bottomIndex: i }); elementTop = slide.elementsTop[slide.currentIndex]; elementTop.css({ borderBottom: "" }); inc("../animate/animate")(slide, div, elementTop); return inc("../playSoundB/play")(slide, atom, function(){ var ref$; if ((ref$ = slide.currentSound) != null) { ref$.stop(); } return slide.score.log(atom, onDone); }); }; })(); trainers/listMatchVertical/elementsBottom/element/onDone/onDone.ls (function(){ return function(slide, div){ var delay; delay = new Date() - slide.lastCorrectAt < 1500 ? 1500 : 0; return setTimeout(function(){ slide.elementsTop[slide.currentIndex].fadeOut(); div.fadeOut(); return slide.startNextElement(); }, delay); }; })(); trainers/listMatchVertical/elementsBottom/element/onWrong/onWrong.ls (function(){ return function(slide, atom, i, div, puzzle){ var i$, len$, p; slide.score.addActionMistake(atom, { bottomIndex: i }); slide.levelPlayer.progressBar.addElement().showRed(); div.css({ backgroundColor: Color.red[500] }); for (i$ = 0, len$ = puzzle.length; i$ < len$; ++i$) { p = puzzle[i$]; p.css({ backgroundColor: Color.red[500] }); } return setTimeout(function(){ var i$, ref$, len$, p, results$ = []; div.css({ backgroundColor: Color.grey[250] }); for (i$ = 0, len$ = (ref$ = puzzle).length; i$ < len$; ++i$) { p = ref$[i$]; results$.push(p.css({ backgroundColor: Color.grey[250] })); } return results$; }, 400); }; })(); trainers/listMatchVertical/elementsBottom/element/playSoundB/play.ls (function(){ return function(slide, atom, onSoundDone){ var delay; delay = new Date() - slide.lastCorrectAt > 500 ? 0 : 1000; if (!_.isString(atom.b) && !atom.sound) { setTimeout(onSoundDone, delay); return; } return setTimeout(function(){ var text, voice; slide.instruction.stop(); if (slide.getParam("soundMode", atom) === "b") { text = atom.sound || atom.b; voice = slide.getParam("voice", atom); return slide.sounds[text + voice].play(function(){ return setTimeout(onSoundDone, 200); }); } else { return onSoundDone(); } }, delay); }; })(); trainers/listMatchVertical/elementsBottom/element/puzzle/puzzle.ls (function(){ return function(){ return [ Div().addClass("puzzleBottom").css({ position: "absolute", width: "38px", height: "8px", left: "61px", backgroundColor: Color.grey[250], top: "-7px" }), Div().addClass("puzzleBottom").css({ position: "absolute", width: "38px", height: "8px", right: "61px", backgroundColor: Color.grey[250], top: "-7px" }) ]; }; })(); trainers/listMatchVertical/elementsBottom/elements.ls (function(){ return function(slide){ var elements, i$, ref$, len$, i, atom, type, el; elements = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; type = atom.b.image ? "image" : atom.b.lsg ? "lsg" : "text"; elements.push(inc("element/element")(slide, atom, i, type)); } for (i$ = 0, len$ = (ref$ = _.shuffleWithSeed(elements)).length; i$ < len$; ++i$) { el = ref$[i$]; slide.bottom.append(el); } return elements; }; })(); trainers/listMatchVertical/elementsTop/element/element.ls (function(){ return function(slide, atom, i, type){ var stop, div, inner; stop = function(){ return div.fadeOut(); }; div = Div().addClass("elementTop").html(inner = Div({ margin: "10px 0", display: "inline-block", padding: "0.7em", backgroundColor: Color.grey[250], width: "15em", maxWidth: "90%", textAlign: slide.getParam("textAlign") || "center" }).html(type === "image" ? inc("../../_shared/image/image")(slide, atom.a.image) : type === "lsg" ? inc("../../_shared/lsg/lsg")(slide, atom.a.lsg) : atom.a, inc("puzzle/puzzle")())).hide(); div.atom = atom; div.start = inc("start/start")(slide, div); div.stop = stop; div.inner = inner; return div; }; })(); trainers/listMatchVertical/elementsTop/element/puzzle/puzzle.ls (function(){ return function(){ return [ Div().addClass("puzzleTop").css({ position: "absolute", width: "60px", height: "8px", left: 0, bottom: "-7px", backgroundColor: Color.grey[250] }), Div().addClass("puzzleTop").css({ position: "absolute", height: "8px", left: "100px", right: "100px", bottom: "-7px", backgroundColor: Color.grey[250] }), Div().addClass("puzzleTop").css({ position: "absolute", width: "60px", height: "8px", right: 0, bottom: "-7px", backgroundColor: Color.grey[250] }) ]; }; })(); trainers/listMatchVertical/elementsTop/element/start/start.ls (function(){ return function(slide, div){ return function(){ var i$, ref$, len$, b; if (slide.currentIndex !== -1) { div.fadeIn(); for (i$ = 0, len$ = (ref$ = slide.bottom.childrenAll()).length; i$ < len$; ++i$) { b = ref$[i$]; b.css({ pointerEvents: "" }); } } else { div.show(); } return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: function(){ return setTimeout(slide.playOnElementStart, 300); } }); }; }; })(); trainers/listMatchVertical/elementsTop/elements.ls (function(){ return function(slide){ var elements, i$, ref$, len$, i, atom, type; elements = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; if (atom.a == null) { continue; } type = atom.a.image ? "image" : atom.a.lsg ? "lsg" : "text"; elements.push(inc("element/element")(slide, atom, i, type)); } slide.top.append(elements); return elements; }; })(); trainers/listMatchVertical/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = _.filter(atoms, "a").length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/listMatchVertical/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.top = inc("top/top")(slide); slide.elementsTop = inc("elementsTop/elements")(slide); slide.bottom = inc("bottom/bottom")(slide); slide.elementsBottom = inc("elementsBottom/elements")(slide); slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; slide.playOnElementStart = function(){ return inc("playOnElementStart/play")(slide); }; return slide.showFinishScreen = function(){ return inc("showFinishScreen/show")(slide); }; }; })(); trainers/listMatchVertical/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/listMatchVertical/optimizeHeights/optimize.ls (function(){ return function(slide){ var topElementsHeights, bottomElementsHeights, topH; topElementsHeights = _.map(slide.elementsTop, function(e){ if (e.isVisible()) { return e.height(); } else { return 0; } }); bottomElementsHeights = _.map(slide.elementsBottom, function(e){ return e.height(); }); topH = _.max(topElementsHeights) + _.max(bottomElementsHeights); slide.top.css({ height: topH + 20 + "px" }); slide.bottom.css({ maxHeight: "calc(var(--screenHeight) * 0.5)" }); return slide.levelPlayer.page.setBottomFreeze(0); }; })(); trainers/listMatchVertical/playOnElementStart/play.ls (function(){ return function(slide){ var atom, delay; atom = _.filter(slide.atoms, "a")[slide.currentIndex]; if (!atom) { return; } if (!_.isString(atom.a) && !atom.sound) { return; } if (slide.getParam("soundMode", atom) !== "a") { return; } if (atom === slide.lastSolvedAtom) { return; } delay = slide.currentIndex === 0 ? 500 : 100; return setTimeout(function(){ var text, voice, ref$; text = atom.sound || atom.a; voice = slide.getParam("voice", atom); if ((ref$ = slide.currentSound) != null) { ref$.stop(); } slide.currentSound = slide.sounds[text + voice]; return slide.currentSound.play(); }, delay); }; })(); trainers/listMatchVertical/showFinishScreen/show.ls (function(){ return function(slide){ slide.div.css({ pointerEvents: "none" }); slide.bottom.hide(); slide.top.css({ visibility: "hidden" }); return setTimeout(function(){ var i$, ref$, len$, c, j$, ref1$, len1$, p; slide.levelPlayer.page.setBottomFreeze(0); for (i$ = 0, len$ = (ref$ = slide.top.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; if (c.hasClass("elementBottom")) { for (j$ = 0, len1$ = (ref1$ = c.puzzle).length; j$ < len1$; ++j$) { p = ref1$[j$]; p.css({ backgroundColor: Color.grey[250] }); } c.css({ backgroundColor: Color.grey[250], zIndex: "" }); } c.show(); } slide.top.css({ height: "", marginBottom: "1em", visibility: "visible" }); return setTimeout(slide.finish, 700); }, 500); }; })(); trainers/listMatchVertical/startNextElement/start.ls (function(){ return function(slide){ var startNew; startNew = function(){ var el, currentAtom, ref$; slide.currentIndex++; el = slide.elementsTop[slide.currentIndex]; currentAtom = _.filter(slide.atoms, "a")[slide.currentIndex]; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, currentAtom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, currentAtom); } if (el) { el.start(); slide.levelPlayer.page.scrollElementIntoView(el, { padding: 150 }); return slide.bottom.toggle(); } else { return slide.showFinishScreen(); } }; if (slide.currentIndex === -1) { return startNew(); } else { if (slide.levelPlayer.page.css("transition-duration") === "0s") { slide.levelPlayer.page.css({ transition: "200ms" }); } return setTimeout(startNew, 1000); } }; })(); trainers/listMatchVertical/top/top.ls (function(){ return function(slide){ return Div({ width: "100%" }).appendTo(slide.div); }; })(); trainers/listSort/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, text; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); text = atom.sound ? atom.sound : soundMode === "a" ? atom.a : soundMode === "b" ? atom.b : void 8; if (text != null) { sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } return sounds; }; })(); trainers/listSort/_preview/preview.ls (function(){ return function(slide){ return requestAnimationFrame(function(){ var i$, ref$, len$, e, results$ = []; inc("../optimizeSizes/optimize")(slide); for (i$ = 0, len$ = (ref$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref$[i$]; results$.push(e.css({ color: 'black' })); } return results$; }); }; })(); trainers/listSort/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, i, action; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.originalAtom = e.atom; actions.push(a); } } if (actions.length > 0) { return slide.div.append(Div({ textAlign: "left", marginBottom: "2em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/listSort/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(T("numIsX", action.i + 1, action.text)); }; })(); trainers/listSort/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(T("numIsNotX", action.i + 1, action.text)); }; })(); trainers/listSort/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.levelPlayer.page.enableFreezeMinHeight(); inc("../optimizeSizes/optimize")(slide); return slide.showNext(); }; })(); trainers/listSort/_t.ls (function(){ return { numIsNotX: { de: "$1. ist nicht '$2'", en: "$1. is not '$2'", fr: "Le n° $1 n'est pas '$2'", es: "El n.º $1 no es '$2'", pt: "O n.º $1 não é '$2'" }, numIsX: { de: "$1. ist '$2'", en: "$1. is '$2'", fr: "Le n° $1 est '$2'", es: "El n.° $1 es '$2'", pt: "O n.º $1 é '$2'" } }; })(); trainers/listSort/elementsLeft/element/element.ls (function(){ return function(slide, atom, i){ var div; return div = Div({ display: "inline-block", border: "10px solid white", padding: "0.5em", textAlign: "left", cursor: "default", color: Color.grey[300] }).html((i + 1) + "."); }; })(); trainers/listSort/elementsLeft/elements.ls (function(){ return function(slide){ var elements, i, atom, e; return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; e = inc("element/element")(slide, atom, i); slide.left.append(e, "
"); results$.push(e); } return results$; }()); }; })(); trainers/listSort/elementsRight/element/element.ls (function(){ var isDownFingers; isDownFingers = 0; return function(slide, atom, i){ var currentAtom, down, up, cancel, playSoundB, onCorrect, onWrong, div; currentAtom = null; down = function(){ if (isDownFingers > 0) { return; } isDownFingers++; currentAtom = slide.atoms[slide.currentIndex]; return div.css({ backgroundColor: Color.grey[300] }); }; up = function(){ if (isDownFingers > 1) { return; } isDownFingers--; if ((currentAtom != null ? currentAtom.b : void 8) === div.value) { atom = currentAtom; i = slide.currentIndex; return onCorrect(); } else { return onWrong(); } }; cancel = function(o){ if (isDownFingers > 1) { return; } isDownFingers--; return div.css({ backgroundColor: Color.grey[150] }); }; playSoundB = function(onDone){ var text; text = currentAtom.sound || currentAtom.b; if (text && slide.getParam("soundMode", currentAtom) === "b") { return setTimeout(function(){ var voice, voiceLang; voice = slide.getParam("voice", currentAtom); voiceLang = slide.getParam("voiceLang", currentAtom); return slide.sounds[text + voice].play(onDone); }, 300); } else { return setTimeout(onDone, 500); } }; onCorrect = function(){ var i$, ref$, len$, el; div.css({ backgroundColor: Color.green[500] }); for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { el = ref$[i$]; if (!el.isSolved) { el.css({ pointerEvents: "none" }); } } div.isSolved = true; slide.levelPlayer.progressBar.showGreen(); slide.elementsLeft[i].css({ height: div.height() + "px" }); slide.score.addActionCorrect(currentAtom, { i: slide.currentIndex, text: div.value }); return playSoundB(function(){ div.css({ backgroundColor: Color.grey[150] }); slide.asker.before(div); slide.asker.before(document.createElement("br")); if (slide.currentIndex + 1 >= slide.atoms.length) { slide.asker.hide(); } return slide.score.log(currentAtom, function(){ var i$, ref$, len$, el; for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { el = ref$[i$]; if (el !== div && !el.isSolved) { el.css({ pointerEvents: "" }); } } return slide.showNext(); }); }); }; onWrong = function(){ var atom; atom = slide.atoms[slide.currentIndex]; slide.score.addActionMistake(currentAtom, { i: slide.currentIndex, text: div.value }); slide.levelPlayer.progressBar.addElement().showRed(); div.css({ backgroundColor: Color.red[500] }); return setTimeout(function(){ return div.css({ backgroundColor: Color.grey[150] }); }, 300); }; div = Div({ display: "inline-flex", alignSelf: "flex-start", padding: "0.5em", backgroundColor: Color.grey[150], border: "10px solid white", verticalAlign: "top", overflow: "hidden", whiteSpace: "pre-wrap", borderLeft: "2px solid white", cursor: "pointer" }).css(slide.getParam("textAlign", atom) === "left" ? { justifyContent: "flex-start", textAlign: "left" } : { justifyContent: "center", textAlign: "center" }).append(Div({ display: "inline-block", maxWidth: "100%", pointerEvents: "none" }).html(atom.b)).tap({ down: down, up: up, cancel: cancel }); if (engine.isDebug) { div.addClass("keyManager-" + (49 + i)); div.bind("keyManager", function(){ down(); return up(); }); } div.value = atom.b; return div; }; })(); trainers/listSort/elementsRight/elements.ls (function(){ return function(slide){ var elements, res$, i$, ref$, len$, i, atom, e; res$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; res$.push(inc("element/element")(slide, atom, i)); } elements = res$; for (i$ = 0, len$ = (ref$ = _.shuffleWithSeed(elements)).length; i$ < len$; ++i$) { e = ref$[i$]; slide.todo.append(e); } return elements; }; })(); trainers/listSort/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = atoms.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/listSort/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.left = inc("left/left")(slide); slide.elementsLeft = inc("elementsLeft/elements")(slide); slide.right = inc("right/right")(slide); slide.elementsRight = inc("elementsRight/elements")(slide); return slide.showNext = function(){ return inc("showNext/show")(slide); }; }; })(); trainers/listSort/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/listSort/left/left.ls (function(){ return function(slide){ var div; slide.wrapper.append(div = Div({ display: "inline-block", verticalAlign: "top" })); return div; }; })(); trainers/listSort/optimizeSizes/calcWidth/calc.ls (function(){ return function(s, p){ var div, w; div = Div({ display: "inline-block", position: "absolute", borderLeft: p.css("borderLeft"), borderRight: p.css("borderRight"), paddingLeft: p.css("paddingLeft"), paddingRight: p.css("paddingRight"), pointerEvents: "none", opacity: 0 }).html(s).appendTo(p); w = div.width(); div.remove(); return w; }; })(); trainers/listSort/optimizeSizes/optimize.ls (function(){ var calcWidth; calcWidth = inc("calcWidth/calc"); return function(slide){ var maxW, optimizeSizes; maxW = null; optimizeSizes = function(){ var maxWNew, i$, ref$, len$, e, lw, rw, lc, rc, ls, rs, j$, ref1$, len1$, w, minLW, minRW; if (slide.div.isVisible()) { requestAnimationFrame(optimizeSizes); } maxWNew = body.width() * 0.85; if (maxWNew > 600) { maxWNew = 600; } if (maxW === maxWNew) { return; } maxW = maxWNew; for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ width: "", height: "", whiteSpace: "pre" }); } lw = 0; rw = 0; lc = 0; rc = 0; ls = ""; rs = ""; for (i$ = 0, len$ = (ref$ = slide.elementsLeft).length; i$ < len$; ++i$) { e = ref$[i$]; lw = Math.max(lw, e.width()); lc = Math.max(lc, e.innerHTML.length); for (j$ = 0, len1$ = (ref1$ = e.text().split(" ")).length; j$ < len1$; ++j$) { w = ref1$[j$]; if (w.length > ls.length) { ls = w; } } } for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref$[i$]; rw = Math.max(rw, e.width()); rc = Math.max(rc, e.innerHTML.length); for (j$ = 0, len1$ = (ref1$ = e.text().split(" ")).length; j$ < len1$; ++j$) { w = ref1$[j$]; if (w.length > rs.length) { rs = w; } } } if (lw + rw > maxW) { lw = lc / (lc + rc) * maxW; rw = rc / (lc + rc) * maxW; minLW = calcWidth(ls, slide.elementsLeft[0]); minRW = calcWidth(rs, slide.elementsRight[0]); if (minLW >= lw) { lw = minLW; rw = maxW - minLW; } else if (minRW > rw) { rw = minRW; lw = maxW - minRW; } } for (i$ = 0, len$ = (ref$ = slide.elementsRight).length; i$ < len$; ++i$) { e = ref$[i$]; e.css({ width: rw + "px", whiteSpace: "pre-wrap" }); } if ((ref$ = slide.asker) != null) { ref$.css({ width: rw + "px" }); } return (ref1$ = slide.todo) != null ? ref1$.css({ width: rw + slide.todo.css("paddingLeft").replace("px", "") * 1 + "px" }) : void 8; }; return optimizeSizes(); }; })(); trainers/listSort/right/asker/asker.ls (function(){ return function(slide){ return Div({ display: "inline-flex", padding: "0.5em", border: "10px solid white", verticalAlign: "top", textAlign: "left", cursor: "default" }).html("???"); }; })(); trainers/listSort/right/right.ls (function(){ return function(slide){ var div; slide.wrapper.append(div = Div({ display: "inline-block", verticalAlign: "top", textAlign: "left" }).append(slide.asker = inc("asker/asker")(slide), slide.todo = inc("todo/todo")(slide))); return div; }; })(); trainers/listSort/right/todo/todo.ls (function(){ return function(slide){ return Div({ paddingTop: "1em", paddingLeft: "2em", whiteSpace: "normal", backgroundColor: "white" }); }; })(); trainers/listSort/showNext/show.ls (function(){ return function(slide){ slide.currentIndex++; if (slide.currentIndex >= slide.atoms.length) { slide.div.css({ pointerEvents: "none" }); setTimeout(slide.finish, 700); return; } slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ var scrollToElement; scrollToElement = slide.elementsLeft[slide.currentIndex]; return slide.levelPlayer.page.scrollElementIntoView(scrollToElement, { padding: 50 }); } }); slide.elementsLeft[slide.currentIndex].css({ color: "black", transition: "color 300ms", transitionDelay: slide.currentIndex === 0 ? "500ms" : void 8 }); slide.asker.css({ color: "white", transition: "" }); return requestAnimationFrame(function(){ return slide.asker.css({ color: "black", transition: "color 300ms", transitionDelay: slide.currentIndex === 0 ? "500ms" : void 8 }); }); }; })(); trainers/listSort/wrapper/wrapper.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ whiteSpace: "nowrap" })); return div; }; })(); trainers/lsg/_finish/animate/animate.ls (function(){ return function(slide){ var svg, t, animation, hasShownObjects, showOnFinish, animate; animation = slide.getParam("animate"); hasShownObjects = false; showOnFinish = function(){ var targets, i$, len$, target; targets = slide.lsg.findAll(".onFinish"); for (i$ = 0, len$ = targets.length; i$ < len$; ++i$) { target = targets[i$]; target.setAttribute("opacity", 1); } return targets.length > 0; }; animate = function(){ var widthRatio, heightRatio; widthRatio = body.width() / slide.lsg.width(); heightRatio = body.height() / slide.lsg.height(); if (animation === "left") { return slide.lsg.css({ transform: "translate3d(-" + widthRatio * 100 + "%,0,0)", transition: "1000ms" }); } else if (animation === "right") { return slide.lsg.css({ transform: "translate3d(" + widthRatio * 100 + "%,0,0)", transition: "1000ms" }); } else if (animation === "top") { return slide.lsg.css({ transform: "translate3d(0,-" + heightRatio * 100 + "%,0)", transition: "1200ms" }); } else if (animation === "fade") { return slide.lsg.css({ opacity: 0, transition: "600ms" }); } else { return animation = null; } }; hasShownObjects = showOnFinish(); if (animation != null) { setTimeout(function(){ slide.instruction.css({ opacity: 0 }); return animate(); }, 500); } return hasShownObjects || animation != null; }; })(); trainers/lsg/_finish/finish.ls (function(){ return function(slide){ var ref$; slide.isAnimated = inc("animate/animate")(slide); if ((ref$ = slide.buttonsDiv) != null) { ref$.hide(); } return setTimeout(function(){ return slide.onFinishedSlide(); }, slide.isAnimated ? 1000 : 0); }; })(); trainers/lsg/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg"); }; })(); trainers/lsg/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, voiceLang, voice, solutions, j$, len1$, s; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); if (!(_.includes(atom.b, "((") || _.includes(atom.b, ""))) { continue; } if (atom.sound != null) { sounds.push({ text: atom.sound, voice: voice, voiceLang: voiceLang }); } else if (soundMode === "b") { solutions = inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); for (j$ = 0, len1$ = solutions.length; j$ < len1$; ++j$) { s = solutions[j$]; if (s != null) { sounds.push({ text: s, voice: voice, voiceLang: voiceLang }); } } } } return sounds; }; })(); trainers/lsg/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/lsg/_review/scoreActions/action/action.ls (function(){ return function(slide, action){ var element; element = _.find(slide.elements, function(el){ return el.atom.id === action.scoreEvent.atom.id; }); if (!element) { return; } return inc("/shared/gapComponent/scoreActions/actions")({ slide: slide, gapComponent: element.gapComponent, actions: [action], showYellowTag: true, yellowTagsCountPerSlide: true }); }; })(); trainers/lsg/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, div, action; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; actions.push(a); } } actions = _.orderBy(actions, "position"); if (actions.length > 0) { return div = Div({ margin: "1em auto", maxWidth: "95%" }).appendTo(slide.div).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { action = ref$[i$]; results$.push(inc("action/action")(slide, action)); } return results$; }())); } }; })(); trainers/lsg/_start/start.ls (function(){ return function(slide){ slide.levelPlayer.page.bottom.html(slide.buttonsDiv).show(); slide.startNextElement(); return slide.instruction.play(); }; })(); trainers/lsg/buttonsDiv/buttonsDiv.ls (function(){ return function(slide){ return ScrollDiv({ scrollbarMode: "show" }).addClass("gapTextButtonsDiv").css({ width: "100%", textAlign: "center", maxHeight: body.height() / 2 + "px" }).hide(); }; })(); trainers/lsg/elements/element/calcTargetCss/calc.ls (function(){ return function(atom, slide){ var svgClass, targets; svgClass = _.replaceAll(atom.id + "", ".", ""); targets = inc("/../app01/lib/util/calcRelativeSvgRects/calc")(slide.lsg, "." + svgClass); if (targets.length === 1) { return targets[0]; } else if (targets.length > 1) { return debug("no or too many target objects found for this atom:", atom); } else { return debug("no target object found"); } }; })(); trainers/lsg/elements/element/clickDiv/div.ls (function(){ return function(slide, gapComponent){ var click; click = function(){ var ref$; if (gapComponent.isDone()) { return; } return (ref$ = gapComponent.findFirst(".gap")) != null ? ref$.click() : void 8; }; return Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }).tap({ up: click, animation: "none" }); }; })(); trainers/lsg/elements/element/element.ls (function(){ return function(atom, slide){ var totalGaps, calcAndSetCss, targetCss, div, div2, gapComponent, text; totalGaps = inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b); calcAndSetCss = function(){ return div.css(inc("calcTargetCss/calc")(atom, slide)); }; targetCss = inc("calcTargetCss/calc")(atom, slide); if (!targetCss) { return; } div = Div({ display: "inline-flex", position: "absolute" }).appendTo(slide.lsg).append(div2 = totalGaps > 0 ? gapComponent = inc("gapComponent/gapComponent")(atom, slide) : text = inc("text/text")(atom, slide)); if (gapComponent) { div2.before(inc("clickDiv/div")(slide, gapComponent)); } div.isDone = div2.isDone; div.start = div2.start; div.stop = div2.stop; div.atom = atom; div.gapComponent = gapComponent; div.calcAndSetCss = calcAndSetCss; return div; }; })(); trainers/lsg/elements/element/gapComponent/gapComponent.ls (function(){ return function(atom, slide){ var p, gapMode; p = slide.getParam; gapMode = p("gapMode", atom); return inc("/shared/gapComponent/component/component")({ slide: slide, atom: atom, text: atom.b, mode: gapMode, buttonsDiv: slide.buttonsDiv, onStart: function(){ var ref$; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, atom); } return typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function' ? ref$.setCalculator(slide, atom) : void 8; }, onActionCorrect: function(action, callback){ return slide.score.addActionCorrect(atom, action, callback); }, onActionMistake: function(action){ return slide.score.addActionMistake(atom, action); }, onActionResolved: function(action){ return slide.score.addActionResolved(atom, action); }, onFinish: function(result){ return inc("/shared/playSoundB/play")(atom, slide, result != null ? result.correctValue : void 8, function(){ return slide.score.log(atom, slide.startNextElement); }); } }).css({ fontSize: (p("fontScale", atom) || 1) + "em", fontFamily: p("fontFamily", atom), maxWidth: "" }); }; })(); trainers/lsg/elements/element/text/text.ls (function(){ return function(atom, slide){ var div; div = Div({ whiteSpace: "nowrap" }).html(atom.b); div.start = slide.startNextElement; div.isDone = function(){ return true; }; return div; }; })(); trainers/lsg/elements/elements.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(inc("element/element")(atom, slide)); } return results$; }; })(); trainers/lsg/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, totalProgressElements, i$, len$, atom, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; totalProgressElements = 0; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; totalProgressElements += inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b); } slide.totalProgressElements = Math.max(1, totalProgressElements); slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/lsg/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.buttonsDiv = inc("buttonsDiv/buttonsDiv")(slide); slide.elements = inc("elements/elements")(slide); slide.startNextElement = inc("startNextElement/start")(slide); return requestAnimationFrame(function(){ return inc("optimizeLayout/optimize")(slide); }); }; })(); trainers/lsg/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/lsg/lsg/lsg.ls (function(){ return function(slide){ var lsg, div, i$, ref$, len$, el; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); if (!div) { return; } div.appendTo(slide.div); if (typeof div.updateLayout == 'function') { div.updateLayout(); } for (i$ = 0, len$ = (ref$ = div != null ? div.find(".onFinish") : void 8).length; i$ < len$; ++i$) { el = ref$[i$]; el.attr({ opacity: 0 }); } return div; }; })(); trainers/lsg/optimizeLayout/optimize.ls (function(){ return function(slide){ var i$, ref$, len$, element, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { element = ref$[i$]; element.calcAndSetCss(); results$.push(element.onWindowResize(_.debounce(element.calcAndSetCss, 100))); } return results$; }; })(); trainers/lsg/startNextElement/start.ls (function(){ return function(slide){ return function(){ var element, page, ref$, callback; element = _.find(slide.elements, function(el){ return !el.isDone(); }); page = slide.levelPlayer.page; if (element) { if (slide.getParam("gapMode", element.atom) === "buttons") { if ((ref$ = slide.buttonsDiv) != null) { ref$.show(); } } element.start(); inc("/shared/playSoundA/play")(element.atom, slide); return slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return page.scrollElementIntoView(element, { padding: 10 }); } }); } else { slide.div.css({ pointerEvents: "none" }); if (slide.score.totalScoredAtoms() === 0) { slide.levelPlayer.progressBar.showGreen(); } callback = function(){ return inc("../_finish/finish")(slide); }; return slide.finish(callback); } }; }; })(); trainers/mathFillStripe/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { debug("no soundMode b"); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/mathFillStripe/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/mathFillStripe/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, ref$, i$, ref1$, len$, i, a, dots, j$, ref2$, len1$, index, dot, j, v, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.buttons.remove(); if ((ref$ = slide.toolbar) != null) { ref$.remove(); } slide.dotsDiv.remove(); for (i$ = 0, len$ = (ref1$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref1$[i$]; dots = inc("../../dots/dots")(slide); if (a.resolved) { for (j$ = 0, len1$ = (ref2$ = slide.dots).length; j$ < len1$; ++j$) { index = j$; dot = ref2$[j$]; dot.setValue(slide.solutionSequence[index]); } } else { for (j$ = 0, len1$ = (ref2$ = a.values).length; j$ < len1$; ++j$) { j = j$; v = ref2$[j$]; dot = dots.findAll(".dot")[j]; dot.setValue(v === "b" ? "blue" : v === "o" ? "orange" : void 8); } } results$.push(slide.div.append(Div({ margin: "3em 0" }).append(dots, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))))); } return results$; } }; })(); trainers/mathFillStripe/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); }; })(); trainers/mathFillStripe/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) === "askSound") { div = inc("/shared/askSound/ask")(slide.sounds); div.appendTo(slide.div).css({ marginBottom: "1.5em" }); } return div; }; })(); trainers/mathFillStripe/buttons/buttons.ls (function(){ return function(slide){ return Div({ marginTop: '1.5em' }).append(slide.solveButton = inc("solveButton/button")(slide), slide.validateButton = inc("validateButton/button")(slide), slide.finishAfterSolveButton = inc("finishButton/button")(slide)).appendTo(slide.div); }; })(); trainers/mathFillStripe/buttons/finishButton/button.ls (function(){ return function(slide){ var up, div; up = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; return div = Button({ icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", label: T("continueButton"), action: up }).css({ margin: "0.5em" }).hide(); }; })(); trainers/mathFillStripe/buttons/solveButton/button.ls (function(){ return function(slide){ var click; click = function(){ slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom); slide.score.log(slide.atom); return slide.solve(); }; return Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).tap(click).css({ margin: "0.5em" }).hide(); }; })(); trainers/mathFillStripe/buttons/validateButton/button.ls (function(){ return function(slide){ var click; click = function(){ var result; result = slide.validate(); slide.div.css({ pointerEvents: "none" }); slide.validateButton.css({ backgroundColor: result.isCorrect ? Color.green[500] : Color.red[500] }); if (result.isCorrect) { slide.score.addActionCorrect(slide.atom, { values: result.values }); slide.score.log(slide.atom); slide.levelPlayer.progressBar.showGreen(); slide.dotsDiv.css({ outline: "3px solid " + Color.green[500] }); } else { slide.score.addActionMistake(slide.atom, { values: result.values }); slide.levelPlayer.progressBar.addElement().showRed(); slide.dotsDiv.css({ outline: "3px solid " + Color.red[500] }); } return setTimeout(function(){ if (result.isCorrect) { return setTimeout(slide.finish, 500); } else { slide.dotsDiv.css({ outline: "" }); slide.validateButton.css({ backgroundColor: Color.grey[300] }); slide.div.css({ pointerEvents: "" }); return slide.solveButton.show(); } }, 600); }; return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click }).css({ margin: "0.5em" }); }; })(); trainers/mathFillStripe/calcSolutionSequence/calc.ls (function(){ return function(slide){ var sequence, blue, ref$, i$, i, orange, total; sequence = []; blue = (ref$ = slide.atom.blue) != null ? ref$ : 0; for (i$ = 1; i$ <= blue; ++i$) { i = i$; sequence.push("blue"); } orange = (ref$ = slide.atom.orange) != null ? ref$ : 0; for (i$ = 1; i$ <= orange; ++i$) { i = i$; sequence.push("orange"); } total = _.ceil((blue + orange) / 10) * 10; while (sequence.length < total) { sequence.push("none"); } return sequence; }; })(); trainers/mathFillStripe/dots/dot/dot.ls (function(){ return function(row, col, slide){ var value, selected, triggered, down, up, click, start, changeValue, update, setValue, w, div; value = "none"; selected = false; triggered = false; down = function(){ slide.mouseDown = true; return slide.selectMode = click(); }; up = function(){ return slide.mouseDown = false; }; click = function(){ if (value === "none") { value = slide.selectedColor; update(); } else { value = "none"; div.css({ backgroundColor: 'white' }); } selected = !selected; return selected; }; start = function(){ return div.bind("mouseenter", function(e){ if (slide.mouseDown) { return changeValue(); } }).bind("touchmove", function(e){ var x, ref$, y, ref1$, div; e.preventDefault(); x = (ref$ = e.touches) != null ? ref$[0].pageX : void 8; y = (ref1$ = e.touches) != null ? ref1$[0].pageY : void 8; div = document.elementFromPoint(x, y); if (div != null && div.hasClass("dot")) { if (!div.isTriggered()) { div.changeValue(); } return div.setTriggered(true); } }).bind("touchend", function(e){ var i$, ref$, len$, d, results$ = []; up(); e.preventDefault(); for (i$ = 0, len$ = (ref$ = slide.div.find(".dot")).length; i$ < len$; ++i$) { d = ref$[i$]; results$.push(d.setTriggered(false)); } return results$; }).bind("mousedown touchstart", down).bind("mouseup", up); }; changeValue = function(){ var color; color = slide.selectedColor; value = slide.selectMode ? color : "none"; if (slide.selectMode) { if (!selected) { selected = !selected; } } else { if (selected) { selected = !selected; } } return update(); }; update = function(){ return div.css({ backgroundColor: value === "blue" ? Color.blue[500] : value === "orange" ? Color.orange[500] : "white" }); }; setValue = function(v){ value = v; return update(); }; w = body.width() < 370 ? 22 : 27; div = Div().addClass("dot").css({ display: "inline-block", width: w + "px", height: w + "px", margin: "0.15em", marginLeft: col === 5 ? '0.7em' : void 8, marginTop: row === 5 ? '0.7em' : 0, marginBottom: 0, cursor: "pointer", border: '1px solid #aaa', borderRadius: w / 2 + "px" }); update(); start(); div.isTriggered = function(){ return triggered; }; div.setTriggered = function(b){ return triggered = b; }; div.changeValue = changeValue; div.getValue = function(){ return value; }; div.setValue = setValue; return div; }; })(); trainers/mathFillStripe/dots/dots.ls (function(){ return function(slide){ var blue, ref$, orange, total, totalColumns, totalRows, div, dots, i, j; blue = (ref$ = slide.atom.blue) != null ? ref$ : 0; orange = (ref$ = slide.atom.orange) != null ? ref$ : 0; total = blue + orange; totalColumns = Math.min(10, slide.getParam("columns", slide.atom)) || 10; totalRows = Math.min(10, slide.getParam("rows", slide.atom)) || _.ceil(total / totalColumns); if (totalRows * totalColumns < total) { debug("MathFillStripe trainer not solvable because rows*columns totalDots && dot.getValue() === "none") { continue; } if (dot.getValue() !== slide.solutionSequence[index]) { isCorrect = false; break; } } } return result = inc("score/score")(isCorrect, slide); }; }; })(); trainers/mathFormula/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/mathFormula/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/mathFormula/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { debug("no soundMode b"); } else if (soundMode === "a") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/mathFormula/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/mathFormula/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, slide){ return Div({ display: "flex", justifyContent: "flex-start" }).html(Div({ padding: "0 0.3em" }).html(action.prefixMode === "equal" ? "=" : "≈"), MathDiv2({ value: action.value, enabled: false }).css({ margin: "0.3em 0.5em 0.5em 0" })); }; })(); trainers/mathFormula/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, actions, div, i$, len$, i, action, results$ = []; scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } slide.firstRow.css({ borderTop: "" }); actions = _.orderBy(scoreEvent.actions, "position"); if (actions.length > 0) { slide.div.append(div = Div({ textAlign: "left", margin: "1em 0 2em" })); for (i$ = 0, len$ = actions.length; i$ < len$; ++i$) { i = i$; action = actions[i$]; results$.push(div.append(inc("/shared/scoreActionRowFlex/row")(action, action.resolved ? inc("resolved/resolved")(slide) : inc("actionDiv/div")(action, slide)))); } return results$; } }; })(); trainers/mathFormula/_review/scoreActions/resolved/resolved.ls (function(){ return function(slide){ var b, value; b = slide.atom.b; value = _.isString(b) ? b : b[0]; return Div({ padding: "0.4em" }).append(Div().html(T("showSolution")), MathDiv2({ value: value, enabled: false }).css({ margin: "0.3em 0.5em 0.5em 0" })); }; })(); trainers/mathFormula/_start/start.ls (function(){ return function(slide){ var solutions, i$, to$, i, mathDiv, isEqual, variables, hasVariables, hasEqualSign, results$ = []; slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); slide.startNextRow(true); slide.currentRow.mathInput.start(); solutions = _.map(_.ensureArray(slide.atom.b), function(s){ return MathDiv2({ value: s }).m.getValue().replace(/\s+/g, ""); }); for (i$ = 0, to$ = solutions.length - 1; i$ <= to$; ++i$) { i = i$; mathDiv = MathDiv2({ gapValidateMode: "value", precision: slide.precision, value: solutions[i] }); if (i > 0) { isEqual = mathDiv.checkEquivalence({ solutions: _.filter(solutions, fn$), value: solutions[i] }); if (!isEqual) { debug("Warning: your solutions are not mathematically equivalent."); } } variables = _.filter(mathDiv.findAll(".mi"), fn1$); hasVariables = variables.length > 0; if (hasVariables) { debug("Warning: variables are not yet allowed in mathFormula solutions."); } hasEqualSign = _.some(mathDiv.findAll(".mo"), fn2$); if (hasEqualSign) { results$.push(debug("Warning: the equals sign is not yet allowed in mathFormula solutions.")); } } return results$; function fn$(s){ return s !== solutions[i]; } function fn1$(mi){ var ref$; return (ref$ = mi.text().trim()) !== "π" && ref$ !== "e"; } function fn2$(el){ return el.text().trim() === "="; } }; })(); trainers/mathFormula/_t.ls (function(){ return { showSolution: { de: "Lösung angezeigt: ", en: "Solution shown: ", fr: "Solution : ", es: "Solución mostrada: ", pt: "Solução exibida: " }, explainSolution: { de: "Lösung erklären", en: "Explain solution", fr: "Expliquer la solution", es: "Explicar solución", pt: "Explicar solução" }, rowEqualsLastRow: { de: "Die Zeile ist identisch mit der letzten Zeile.", en: "This row is identical to the last row.", fr: "Cette ligne est identique à la dernière.", es: "Esta fila es idéntica a la última fila.", pt: "Esta fileira é idêntica à última fileira." }, emptyRow: { de: "Eine leere Zeile kann nicht geprüft werden.", en: "An empty row cannot be checked.", fr: "Une ligne vide ne peut pas être vérifiée.", es: "No se puede verificar una fila vacía.", pt: "Não foi possível verificar uma fileira vazia." }, solution: { de: "Lösung:", en: "Solution:", fr: "Solution :", es: "Solución", pt: "Solução:" }, youWantToSeeSolution: { de: "Möchtest du die Aufgabe abbrechen und die Lösung sehen?", en: "Would you like to quit the exercise and see the solution?", fr: "Tu veux mettre fin à l'exercice et voir la solution ?", es: "¿Quieres interrumpir el ejercicio y ver la solución?", pt: "Você quer interromper o exercício e ver a solução?" }, wrongInfo: { de: "Ups, deine Lösung war falsch.", en: "Oops, your answer was incorrect.", fr: "Oups, ta réponse est incorrecte.", es: "¡Ups! Tu respuesta es incorrecta.", pt: "Ops! Sua resposta está incorreta." }, chooseSymbol: { de: "Bitte wähle ein Vergleichszeichen aus.", en_gb: "Please select a sign.", en: "Please select a sign.", fr: "Tu dois choisir un signe de comparaison.", es: "Por favor, elige un signo de comparación.", pt: "Por favor, escolha um símbolo de comparação." } }; })(); trainers/mathFormula/calcSyntax/calc.ls (function(){ return function(m){ var value; value = m.getValue(); value = value.replace(/[0-9]+/g, "$"); value = value.replace(/÷/g, ":"); return value = value.replace(/ +/g, ""); }; })(); trainers/mathFormula/divBeforeFinishButton/div.ls (function(){ return function(slide){ if (!slide.atom.sampleSolution) { return; } return Div({ display: "inline-block", padding: "0.58em 0.4em", margin: "0.4em" }).html(T("explainSolution")).tap(function(){ return slide.showTopSolution(); }); }; })(); trainers/mathFormula/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; return inc("../mathFormulaNext/generateSlides")(trainerParams, levelParams); atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; results$.push(slide); } return results$; }()); }; })(); trainers/mathFormula/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/mathFormula/init.ls (function(){ return function(slide){ var i$, ref$, len$, solution; slide.mode = slide.getParam("mode", slide.atom); slide.precision = slide.getParam("precision", slide.atom); slide.steps = slide.getParam("steps", slide.atom); if (!slide.mode) { debug("Please specify mode: \"term\" to use this trainer"); } if (engine.isDebug) { for (i$ = 0, len$ = (ref$ = _.ensureArray(slide.atom.b)).length; i$ < len$; ++i$) { solution = ref$[i$]; if (!_.startsWith(solution, ">> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/mathFormula/validate/validateWithoutPrecision/validate.ls (function(){ return function(slide){ var mathInput, value, prevMathInput, ref$, prevValue, solutions; mathInput = slide.currentRow.mathInput; value = mathInput.getValue().replace(/\s+/g, ""); prevMathInput = (ref$ = slide.rows)[ref$.length - 2].mathInput; prevValue = prevMathInput != null ? prevMathInput.getValue().replace(/\s+/g, "") : void 8; if (value.length === 0) { return; } if (value === prevValue) { return inc("../_shared/popup/popup")(T("rowEqualsLastRow")); } solutions = _.map(_.ensureArray(slide.atom.b), function(s){ return MathDiv2({ value: s }).m.getValue().replace(/\s+/g, ""); }); if (in$(value, solutions)) { return inc("../_shared/correct/correct")(slide, mathInput, value); } else if (mathInput.checkEquivalence({ solutions: solutions, value: value })) { return inc("../_shared/halfCorrect/halfCorrect")(slide, mathInput, value); } else { return inc("../_shared/wrong/wrong")(slide, mathInput, value); } }; })(); function in$(x, xs){ var i = -1, l = xs.length >>> 0; while (++i < l) if (x === xs[i]) return true; return false; } trainers/mathFormulaNext/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/mathFormulaNext/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/mathFormulaNext/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { debug("no soundMode b"); } else if (soundMode === "a") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/mathFormulaNext/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/mathFormulaNext/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, slide){ return Div({ display: "flex", justifyContent: "flex-start" }).html(Div({ padding: "0 0.3em" }).html(slide.mode === "term" ? "=" : void 8), MathDiv2({ value: action.value, enabled: false }).css({ margin: "0.3em 0.5em 0.5em 0" })); }; })(); trainers/mathFormulaNext/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, actions, div, i$, len$, i, action, results$ = []; scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } actions = _.orderBy(scoreEvent.actions, "position"); if (actions.length > 0) { slide.div.append(div = Div({ textAlign: "left", margin: "1em 0 2em" })); for (i$ = 0, len$ = actions.length; i$ < len$; ++i$) { i = i$; action = actions[i$]; results$.push(div.append(inc("/../app01-trainers/shared/scoreActionRowFlex/row")(action, action.resolved ? inc("resolved/resolved")(slide) : inc("actionDiv/div")(action, slide)))); } return results$; } }; })(); trainers/mathFormulaNext/_review/scoreActions/resolved/resolved.ls (function(){ return function(slide){ var calcSolution; calcSolution = inc("../../../startNewRow/row/_shared/bottomMessage/contentDiv/buttons/solve/tap/solutionDiv/solutionRow/calcSolution/calc"); return Div({ padding: "0.4em" }).append(Div().html(T("showSolution")), MathDiv2({ value: calcSolution(slide), enabled: false }).css({ margin: "0.3em 0.5em 0.5em 0" })); }; })(); trainers/mathFormulaNext/_start/checkContentSyntax/_getVars/get.ls (function(){ return function(am){ var vars, m, mj; vars = {}; m = MathDiv2({ value: am }).m; mj = inc("/../math-div2/mathDiv/_shared/getMathJsonFromAsciimath/get")(m, am); mj = mj.mathJson; inc("getVarsInMathJson/get")(mj, vars); delete vars.Pi; delete vars.ExponentialE; return _.keys(vars).sort(); }; })(); trainers/mathFormulaNext/_start/checkContentSyntax/_getVars/getVarsInMathJson/get.ls (function(){ return function(mj, vars){ var i$, len$, i, c; vars == null && (vars = {}); if (_.isString(mj)) { vars[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, vars); } } } return vars; }; })(); trainers/mathFormulaNext/_start/checkContentSyntax/check.ls (function(){ return function(slide){ if (!slide.mode) { debug("Warning: you need to specify a mode (term, equation or quadratic)."); return false; } if (slide.mode === "quadratic") { return inc("quadratic/quadratic")(slide); } else if (slide.mode === "equation") { return inc("equation/equation")(slide); } else { return inc("term/term")(slide); } }; })(); trainers/mathFormulaNext/_start/checkContentSyntax/equation/equation.ls (function(){ return function(slide){ var i$, ref$, len$, i, solution, rights, otherSolutions, isEqual, vars, hasVariables, roundedSolIsExact; if (!slide.atom.a) { debug("Warning: you need to to specify an a-element in the equation mode."); return false; } if (!_.startsWith(slide.atom.a, "")) { debug("Warning: you need to wrap the a-element in mat-tags."); return false; } if (slide.atom.a.split("=").length !== 2) { debug("Warning: you need to have one equals sign in the a-element."); return false; } if (!_.every(_.ensureArray(slide.atom.b), function(s){ return _.startsWith(s, " 0) { rights = _.map(slide.solutions, fn$); otherSolutions = _.filter(rights, fn1$); if (otherSolutions.length === 0) { continue; } isEqual = MathDiv2().checkEquivalence({ solutions: otherSolutions, value: solution.split("=")[1], gapValidateMode: "value" }); if (!isEqual) { debug("Warning: your solutions are not mathematically equivalent. Only single-solution equations are supported currently."); return false; } } if (slide.precision) { vars = inc("../_getVars/get")(solution.split("=")[1]); hasVariables = vars.length > 0; if (hasVariables && slide.precision) { debug("Warning: if the right side of the solution contains a variable, precision cannot be used."); return false; } roundedSolIsExact = MathDiv2().checkEquivalence({ value: solution.split("=")[1], solutions: [slide.roundedSolutions[i].split("=")[1]], gapValidateMode: "literalSorted" }); if (roundedSolIsExact) { debug("Warning: the rounded solution is the same as the solution. Don't use precision in this case."); return false; } } } return true; function fn$(s){ return s.split("=")[1]; } function fn1$(r){ return r !== rights[i]; } }; })(); trainers/mathFormulaNext/_start/checkContentSyntax/quadratic/calcDiscriminant/calc.ls (function(){ return function(value){ var s; if (!_.includes(value, "±") || !_.includes(value, "sqrt(")) { return; } s = value.split("±")[1].trim(); s = s.split("sqrt(")[1]; s = s.substring(0, s.length - 1); return MathDiv2({ value: s }).eval().result; }; })(); trainers/mathFormulaNext/_start/checkContentSyntax/quadratic/quadratic.ls (function(){ return function(slide){ var i$, ref$, len$, i, solution, otherSolutions, isEqual; for (i$ = 0, len$ = (ref$ = slide.solutions).length; i$ < len$; ++i$) { i = i$; solution = ref$[i$]; if (inc("calcDiscriminant/calc")(solution) < 0) { debug("Warning: solutions must be real numbers."); return false; } if (i > 0) { otherSolutions = _.filter(slide.solutions, fn$); if (otherSolutions.length === 0) { continue; } isEqual = fn1$; if (!_.every(["+", "-"], fn2$)) { debug("Warning: your solutions are not mathematically equivalent."); return false; } } } return true; function fn$(s){ return s !== slide.solutions[i]; } function fn1$(sign){ return MathDiv2().checkEquivalence({ solutions: otherSolutions, value: _.replaceAll(solution, "±", sign), gapValidateMode: "value" }); } function fn2$(sign){ return isEqual(sign); } }; })(); trainers/mathFormulaNext/_start/checkContentSyntax/term/term.ls (function(){ return function(slide){ var i$, ref$, len$, i, solution, otherSolutions, isEqual, variables, hasVariables, roundedSolIsExact; if (!_.every(_.ensureArray(slide.atom.b), function(s){ return _.startsWith(s, " 0) { otherSolutions = _.filter(slide.solutions, fn$); if (otherSolutions.length === 0) { continue; } isEqual = MathDiv2().checkEquivalence({ solutions: otherSolutions, value: solution, gapValidateMode: "value" }); if (!isEqual) { debug("Warning: your solutions are not mathematically equivalent."); } } if (slide.precision) { variables = inc("../_getVars/get")(solution); hasVariables = variables.length > 0; if (hasVariables && slide.precision) { debug("Warning: solutions with variables are not yet allowed when using precision mode in the mathFormula trainer."); } roundedSolIsExact = MathDiv2().checkEquivalence({ value: solution, solutions: [slide.roundedSolutions[i]], gapValidateMode: "value" }); if (roundedSolIsExact) { debug("Warning: the rounded solution is the same as the solution. Don't use precision in this case."); } } } return true; function fn$(s){ return s !== slide.solutions[i]; } }; })(); trainers/mathFormulaNext/_start/start.ls (function(){ return function(slide){ if (engine.isDebug) { if (!inc("checkContentSyntax/check")(slide)) { return; } } slide.instruction.play(function(){ return inc("/../app01-trainers/shared/playAskSoundOrSoundA/play")(slide); }); return slide.startNewRow(); }; })(); trainers/mathFormulaNext/_t.ls (function(){ return { showSolution: { de: "Lösung angezeigt: ", en: "Solution shown: ", fr: "Solution : ", es: "Solución mostrada: ", pt: "Solução exibida: " }, explainSolution: { de: "Lösung erklären", en: "Explain solution", fr: "Expliquer la solution", es: "Explicar solución", pt: "Explicar solução" }, solution: { de: "Lösung:", en: "Solution:", fr: "Solution :", es: "Solución", pt: "Solução:" }, 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" }, 'continue': { de: "Weiter", en: "Continue", fr: "Continuer", es: "Continuar", pt: "Continuar" }, empty: { de: "Eine leere Zeile kann nicht geprüft werden.", en: "An empty row cannot be checked.", fr: "Une ligne vide ne peut pas être vérifiée.", es: "No se puede verificar una fila vacía.", pt: "Não foi possível verificar uma fileira vazia." }, duplicate: { de: "Die Zeile ist identisch mit der letzten Zeile.", en: "This row is identical to the last row.", fr: "Cette ligne est identique à la dernière.", es: "Esta fila es idéntica a la última fila.", pt: "Esta fileira é idêntica à última fileira." }, noEquals: { de: "Die Zeile muss ein Gleichheitszeichen enthalten.", en_gb: "The equation is missing an equals sign.", en: "The equation is missing an equal sign.", fr: "Il manque le signe égal sur cette ligne.", es: "La fila debe tener un signo de igual.", ptDev: "A linha deve ter um sinal de igual." }, tooManyEquals: { de: "Die Zeile darf nur ein Gleichheitszeichen enthalten.", en_gb: "The equation can only have one equals sign.", en: "The equation can only have one equal sign.", fr: "Cette ligne ne peut contenir qu'un seul signe égal.", es: "La fila sólo puede tener un signo de igual.", ptDev: "A linha só pode ter um sinal de igual." }, noLeftSide: { de: "Die linke Seite der Gleichung ist leer.", en: "The left side of the equation is empty.", fr: "La partie gauche de l'équation est manquante.", es: "El lado izquierdo de la ecuación está vacío.", ptDev: "O lado esquerdo da equação está vazio." }, noRightSide: { de: "Die rechte Seite der Gleichung ist leer.", en: "The right side of the equation is empty.", fr: "La partie droite de l'équation est manquante.", es: "El lado derecho de la ecuación está vacío.", ptDev: "O lado direito da equação está vazio." } }; })(); trainers/mathFormulaNext/calcRoundedSolutions/calc.ls (function(){ return function(slide){ var round, i$, ref$, len$, solution, s, results$ = []; if (!slide.precision) { return; } round = function(value){ var v; v = MathDiv2({ value: value }).eval().result; return v.toFixed(slide.precision); }; for (i$ = 0, len$ = (ref$ = slide.solutions).length; i$ < len$; ++i$) { solution = ref$[i$]; if (slide.mode === "quadratic") { s = solution.split("±"); results$.push(round(s[0]) + "±" + round(s[1])); } else if (slide.mode === "equation") { s = solution.split("="); results$.push(s[0] + "=" + round(s[1])); } else { results$.push(round(solution)); } } return results$; }; })(); trainers/mathFormulaNext/calcSolutions/calc.ls (function(){ return function(slide){ var i$, ref$, ref1$, len$, solution, results$ = []; for (i$ = 0, len$ = (ref$ = _.ensureArray((ref1$ = slide.atom.b.solution) != null ? ref1$ : slide.atom.b)).length; i$ < len$; ++i$) { solution = ref$[i$]; results$.push(MathDiv2({ value: solution }).getValue().replace(/\s+/g, "")); } return results$; }; })(); trainers/mathFormulaNext/finishRow/finish.ls (function(){ return function(slide){ var row, ref$, ref1$; row = slide.currentRow; row.mathInput.css({ backgroundColor: Color.white, color: Color.black }); row.mathInput.scrollBarDiv.remove(); if ((ref$ = row.copyButton) != null) { ref$.remove(); } if ((ref1$ = row.hintButton) != null) { ref1$.remove(); } slide.solvedRowsDiv.append(row); if (slide.mode === "equation") { slide.solvedRowsDiv.updateAlignment(); } return slide.previousRow = row; }; })(); trainers/mathFormulaNext/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/../app01-trainers/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; results$.push(slide); } return results$; }()); }; })(); trainers/mathFormulaNext/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/../app01-trainers/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/mathFormulaNext/init.ls (function(){ return function(slide){ slide.mode = slide.getParam("mode", slide.atom); slide.precision = slide.getParam("precision", slide.atom); slide.steps = slide.getParam("steps", slide.atom); slide.solutions = inc("calcSolutions/calc")(slide); slide.roundedSolutions = inc("calcRoundedSolutions/calc")(slide); slide.finishRow = function(){ return inc("finishRow/finish")(slide); }; slide.startNewRow = function(){ return inc("startNewRow/start")(slide); }; slide.instruction = inc("instruction/instruction")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.image = inc("image/image")(slide); slide.rowsDiv = inc("rowsDiv/div")(slide); return slide.divBeforeFinishButton = inc("sampleSolutionButton/button")(slide); }; })(); trainers/mathFormulaNext/instruction/instruction.ls (function(){ return function(slide){ return inc("/../app01-trainers/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/mathFormulaNext/lsg/lsg.ls (function(){ return function(slide){ var lsg; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return inc("/../app01-trainers/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/mathFormulaNext/rowsDiv/div.ls (function(){ return function(slide){ return Div({ display: "inline-flex", minWidth: "10em", maxWidth: "64%", margin: "0.7em auto", flexDirection: "column", alignItems: "stretch" }).html(slide.solvedRowsDiv = inc("solvedRowsDiv/div")(slide)).appendTo(slide.div); }; })(); trainers/mathFormulaNext/rowsDiv/solvedRowsDiv/div.ls (function(){ return function(slide){ var div; div = slide.mode === "equation" ? ScrollDiv({ enableScrollX: true, enableScrollY: false, scrollbarMode: "hide" }) : Div(); div.html(inc("firstRow/row")(slide)); div.updateAlignment = function(){ return inc("updateAlignment/update")(slide); }; return div; }; })(); trainers/mathFormulaNext/rowsDiv/solvedRowsDiv/firstRow/row.ls (function(){ return function(slide){ var div; div = Div({ flex: "1 0 auto", width: "100%", marginTop: "-1px", textAlign: "left", padding: "0.5em 0.2em" }).html(slide.atom.a).addClass("row"); if (slide.getParam("soundMode", slide.atom) === "a") { div.tap({ down: function(){ var that, ref$; if ((that = slide.currentSound) != null) { that.stop(); return ref$ = slide.currentSound, delete slide.currentSound, ref$; } else { return inc("/../app01-trainers/shared/playAskSoundOrSoundA/play")(slide); } }, animation: "none" }); } return div; }; })(); trainers/mathFormulaNext/rowsDiv/solvedRowsDiv/updateAlignment/calcRowEqualsPosition/calc.ls (function(){ return function(row){ var equalsElement; equalsElement = _.filter(row.find(".mo"), function(el){ var ref$; return (ref$ = el.textContent) === "=" || ref$ === "≈"; })[0]; return equalsElement.offset({ withoutTransform: true }).left; }; })(); trainers/mathFormulaNext/rowsDiv/solvedRowsDiv/updateAlignment/getMaxEqualsPosition/get.ls (function(){ return function(solvedRows, calcRowEqualsPosition){ var allEqualsPositions; allEqualsPositions = _.map(solvedRows, function(row){ return calcRowEqualsPosition(row); }); return _.reduce(allEqualsPositions, function(a, b){ return Math.max(a, b); }); }; })(); trainers/mathFormulaNext/rowsDiv/solvedRowsDiv/updateAlignment/update.ls (function(){ return function(slide){ var solvedRows, calcRowEqualsPosition, maxEqualsPosition, i$, len$, row, results$ = []; if (slide.mode !== "equation") { return; } solvedRows = slide.solvedRowsDiv.find(".row"); calcRowEqualsPosition = inc("calcRowEqualsPosition/calc"); maxEqualsPosition = inc("getMaxEqualsPosition/get")(solvedRows, calcRowEqualsPosition); for (i$ = 0, len$ = solvedRows.length; i$ < len$; ++i$) { row = solvedRows[i$]; row.css({ paddingLeft: "0px", backgroundColor: Color.white }); results$.push(row.css({ paddingLeft: (maxEqualsPosition - calcRowEqualsPosition(row)) + "px" })); } return results$; }; })(); trainers/mathFormulaNext/sampleSolutionButton/button.ls (function(){ return function(slide){ if (!slide.atom.sampleSolution) { return; } return Button({ label: T("explainSolution") }).css({ margin: "0.8em" }).tap(function(){ return inc("showSolution/show")(slide); }); }; })(); trainers/mathFormulaNext/sampleSolutionButton/showSolution/show.ls (function(){ return function(slide){ var div; div = Div({ padding: "0.5em", textAlign: "left" }).append(slide.atom.sampleSolution); return inc("/../app01-trainers/shared/topMessage/topMessage")({ html: div, contentAlign: "left" }); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/buttons/continue/button.ls (function(){ return function(slide){ var tap; tap = inc("../../../../unfreeze/unfreeze"); return Button({ label: T("continue") }).tap(function(){ return tap(slide); }).addClass("keyManager-enter keyManager-esc").bind("keyManager", function(){ var ref$; if ((ref$ = body.findFirst(".calculatorBackground")) != null && ref$.isVisible()) { return; } return tap(slide); }); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/buttons/retry/button.ls (function(){ return function(slide){ var tap; tap = inc("../../../../unfreeze/unfreeze"); return Button({ label: T("tryAgain"), icon: path("/../app01/lib/svg/icon/refresh.svg") }).css({ marginRight: "0.8em" }).tap(function(){ return tap(slide); }).addClass("keyManager-enter keyManager-esc").bind("keyManager", function(){ var ref$; if ((ref$ = body.findFirst(".calculatorBackground")) != null && ref$.isVisible()) { return; } return tap(slide); }); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/buttons/solve/button.ls (function(){ return function(slide){ return Button({ label: T("solve"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).tap(function(){ return inc("tap/tap")(slide); }); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/buttons/solve/tap/solutionDiv/div.ls (function(){ return function(slide){ return Div().html(Div({ fontSize: "0.9em", padding: "0.5em 0", fontWeight: "bold" }).html(T("solution")), inc("solutionRow/row")(slide)); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/buttons/solve/tap/solutionDiv/solutionRow/calcSolution/calc.ls (function(){ return function(slide){ var solution, s, eq; solution = slide.precision ? slide.roundedSolutions[0] : slide.solutions[0]; if (slide.mode === "equation") { s = solution.split("="); eq = slide.precision ? "≈" : "="; return s[0] + eq + s[1]; } else { return solution; } }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/buttons/solve/tap/solutionDiv/solutionRow/row.ls (function(){ return function(slide){ var row, solution, mathInput, copyButton, hintButton; slide.currentRow = inc("../../../../../../../../row")(slide); row = slide.currentRow; solution = inc("calcSolution/calc")(slide); mathInput = row.mathInput; copyButton = row.copyButton; hintButton = row.hintButton; mathInput.stop(); mathInput.disable(); if (copyButton != null) { copyButton.hide(); } if (hintButton != null) { hintButton.hide(); } mathInput.css({ backgroundColor: Color.white }); mathInput.setValue(solution); if (slide.precision) { row.updateToApproxEquals(); } return row; }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/buttons/solve/tap/tap.ls (function(){ return function(slide){ var input, data, ref$; input = slide.currentRow.mathInput; data = { value: input.getValue() }; slide.bottomMessage.remove(); slide.levelPlayer.page.setBottomFreeze(0); input.css({ backgroundColor: Color.grey[100], color: Color.grey[400] }); slide.levelPlayer.progressBar.showGrey(); slide.isSolved = true; if ((ref$ = slide.currentRow.prefixDiv) != null) { ref$.css({ opacity: 0 }); } slide.rowsDiv.append(inc("solutionDiv/div")(slide)); return slide.score.addActionResolved(slide.atom, data, function(){ return slide.score.log(slide.atom, function(){ return slide.finish(); }); }); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/contentDiv/div.ls (function(){ return function(slide, hint, type){ var div; return Div({ width: "100%", textAlign: "center" }).html(ScrollDiv().css({ maxHeight: "50vh", wordWrap: "break-word", padding: "0 1em", marginBottom: "0.5em" }).html(Div({ paddingTop: "0.5em" }).html(hint || T("oopsWrong"))), div = Div({ marginBottom: "1em" }), type === "wrong" ? div.html(inc("buttons/retry/button")(slide), inc("buttons/solve/button")(slide)) : div.html(inc("buttons/continue/button")(slide))); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/bottomMessage/message.ls (function(){ return function(slide, hint, type){ var showBottomMessage; showBottomMessage = function(){ return slide.bottomMessage = Div({ display: "flex", minHeight: slide.currentRow.mathInput.m.screenKeyboard.lastHeight + "px" }).addClass("bottomMessage hint keyManagerScope gestureManagerScope").html(inc("contentDiv/div")(slide, hint, type)).appendTo(app.currentPage.bottom).fadeIn(); }; return inc("../freeze/freeze")(slide, showBottomMessage); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/findHint/calcSyntax/calc.ls (function(){ return function(m){ var value; value = m.getValue(); value = value.replace(/[0-9]+/g, "$"); value = value.replace(/÷/g, ":"); return value = value.replace(/ +/g, ""); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/findHint/find.ls (function(){ return function(slide, type){ var input, ref$, f, findHint, ref1$, ref2$; input = (ref$ = slide.currentRow) != null ? ref$.mathInput : void 8; f = function(s){ var syntax; if (!input) { return false; } else if (s.value != null) { return s.value === _.replaceAll(input.getValue(), " ", ""); } else if (s.syntax != null) { syntax == null && (syntax = inc("calcSyntax/calc")(input)); return s.syntax === syntax; } }; findHint = function(step){ return _.find(_.ensureArray(step), f); }; if (type === "correct") { return findHint((ref1$ = slide.steps) != null ? ref1$.correct : void 8); } else { return findHint((ref2$ = slide.steps) != null ? ref2$.wrong : void 8); } }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/freeze/freeze.ls (function(){ return function(slide, onDone){ var input, copyButton, hintButton; input = slide.currentRow.mathInput; copyButton = slide.currentRow.copyButton; hintButton = slide.currentRow.hintButton; input.stop(); input.disable(); if (copyButton != null) { copyButton.hide(); } if (hintButton != null) { hintButton.hide(); } return onDone(); }; })(); trainers/mathFormulaNext/startNewRow/row/_shared/unfreeze/unfreeze.ls (function(){ return function(slide){ var input, copyButton, hintButton, ref$; input = slide.currentRow.mathInput; copyButton = slide.currentRow.copyButton; hintButton = slide.currentRow.hintButton; if ((ref$ = slide.bottomMessage) != null) { ref$.remove(); } slide.levelPlayer.page.setBottomFreeze(0); input.css({ color: Color.black }); input.enable(); input.start(); if (input.getValue().length === 0) { if (copyButton != null) { copyButton.show(); } } return hintButton != null ? hintButton.show() : void 8; }; })(); trainers/mathFormulaNext/startNewRow/row/copyButton/button.ls (function(){ return function(slide){ return Div({ position: "absolute", right: "-1.5em" }).html(SvgIcon({ svg: path("/../app01/lib/svg/icon/paste.svg"), color: Color.grey[450] })).tap({ down: function(){ return inc("tap/tap")(slide); }, animation: "none" }); }; })(); trainers/mathFormulaNext/startNewRow/row/copyButton/tap/tap.ls (function(){ return function(slide){ var lastInput; lastInput = slide.previousRow.mathInput.getValue().replace("≈", "="); slide.currentRow.mathInput.setValue(lastInput); return inc("../../mathInput/onChange/on")(slide); }; })(); trainers/mathFormulaNext/startNewRow/row/hintButton/hintButton.ls (function(){ return function(slide){ var hint, ref$; hint = (ref$ = inc("../_shared/findHint/find")(slide, "correct")) != null ? ref$.info : void 8; return Div({ position: "absolute", right: "-3em" }).html(SvgIcon({ svg: path("/../app01/lib/svg/shape/help.svg"), color: Color.grey[450] })).tap({ down: function(){ return inc("tap/tap")(slide, hint); }, animation: "none" }); }; })(); trainers/mathFormulaNext/startNewRow/row/hintButton/tap/tap.ls (function(){ return function(slide, hint){ return inc("../../_shared/bottomMessage/message")(slide, hint, "correct"); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/mathInput.ls (function(){ return function(slide){ var matLayout, ref$, keyboardSpecialKeys, m; matLayout = (ref$ = slide.getParam("matLayout", slide.atom)) != null ? ref$ : {}; keyboardSpecialKeys = (ref$ = matLayout.specialKeys) != null ? ref$ : ""; if (slide.mode === "equation") { keyboardSpecialKeys = keyboardSpecialKeys + " ="; } else if (slide.mode === "quadratic") { keyboardSpecialKeys = keyboardSpecialKeys + " ±"; } return m = MathDiv2({ enabled: true, enableHorizontalScroll: true, mode: "input", submit: function(){ return inc("onSubmit/on")(slide); }, onChange: function(){ return inc("onChange/on")(slide); }, keyboardLayout: matLayout.keyboardLayout, keyboardSpecialKeys: keyboardSpecialKeys, showDigit3Space: false, paddingContent: "0.5em 0.2em" }).addClass("mathDivInput").css({ minWidth: "100%" }).tap(engine.isDebug ? { longDown: function(){ return debug("Syntax: " + inc("../_shared/findHint/calcSyntax/calc")(m)); }, animation: "none" } : void 8); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onChange/on.ls (function(){ return function(slide){ var copyButton, input; copyButton = slide.currentRow.copyButton; input = slide.currentRow.mathInput.getValue(); if (!copyButton) { return; } if (input.length > 0) { return copyButton.hide(); } else { return copyButton.show(); } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/check/check.ls (function(){ return function(slide, onDone){ var bm, currentValue, previousValue, ref$, ref1$; bm = inc("../../../_shared/bottomMessage/message"); currentValue = slide.currentRow.mathInput.getValue(); previousValue = (ref$ = slide.previousRow) != null ? (ref1$ = ref$.mathInput) != null ? ref1$.getValue() : void 8 : void 8; if (currentValue.length === 0) { return bm(slide, T("empty")); } if (currentValue === previousValue || currentValue === (previousValue != null ? previousValue.replace("≈", "=") : void 8)) { return bm(slide, T("duplicate")); } if (slide.mode === "equation") { if (!_.includes(currentValue, "=")) { return bm(slide, T("noEquals")); } if (_.filter(currentValue.split(""), function(c){ return c === "="; }).length > 1) { return bm(slide, T("tooManyEquals")); } if (!currentValue.split("=")[0]) { return bm(slide, T("noLeftSide")); } if (!currentValue.split("=")[1]) { return bm(slide, T("noRightSide")); } } return onDone(); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/decide.ls (function(){ return function(slide, onDone){ var mode, input, solutions, roundedSolutions, precision, updateToApproxEquals, result; mode = slide.mode; input = slide.currentRow.mathInput.getValue(); solutions = slide.solutions; roundedSolutions = slide.roundedSolutions; precision = slide.precision; updateToApproxEquals = slide.currentRow.updateToApproxEquals; result = slide.mode === "equation" ? inc("validateEquation/validate")(input, solutions, roundedSolutions, precision, updateToApproxEquals) : inc("validateTerm/validate")(input, solutions, roundedSolutions, precision, updateToApproxEquals, mode); return onDone(result); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateEquation/_hasInfiniteSolutions/has.ls (function(){ return function(input){ var splitInput; splitInput = input.split("="); return MathDiv2().checkEquivalence({ value: splitInput[0] + ("-" + splitInput[1]), solutions: ["0"], gapValidateMode: "value" }); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateEquation/_isBalanced/is.ls (function(){ return function(input, solution, precision){ var splitInput, splitSolution, left, right; splitInput = input.split("="); splitSolution = solution.split("="); left = _.replaceAll(splitInput[0], splitSolution[0], "(" + splitSolution[1] + ")"); right = _.replaceAll(splitInput[1], splitSolution[0], "(" + splitSolution[1] + ")"); return MathDiv2().checkEquivalence({ value: left, solutions: [right], gapValidateMode: "value", precision: precision }); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateEquation/_isEqual/is.ls (function(){ return function(input, solution){ var splitInput, splitSolution, isEqual; splitInput = input.split("="); splitSolution = solution.split("="); isEqual = function(v1, v2){ return MathDiv2().checkEquivalence({ value: v1, solutions: [v2], gapValidateMode: "literalSorted" }); }; return isEqual(splitInput[0], splitSolution[0]) && isEqual(splitInput[1], splitSolution[1]) || isEqual(splitInput[1], splitSolution[0]) && isEqual(splitInput[0], splitSolution[1]); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateEquation/validate.ls (function(){ return function(input, solutions, roundedSolutions, precision, updateToApproxEquals){ var isEqual, isBalanced, hasInfiniteSolutions; isEqual = inc("_isEqual/is"); isBalanced = inc("_isBalanced/is"); hasInfiniteSolutions = inc("_hasInfiniteSolutions/has"); if (precision) { return inc("withPrecision/decide")(input, solutions, roundedSolutions, precision, updateToApproxEquals, isEqual, isBalanced, hasInfiniteSolutions); } else { return inc("withoutPrecision/decide")(input, solutions, isEqual, isBalanced, hasInfiniteSolutions); } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateEquation/withPrecision/decide.ls (function(){ return function(input, solutions, roundedSolutions, precision, updateToApproxEquals, isEqual, isBalanced, hasInfiniteSolutions){ if (_.some(roundedSolutions, function(s){ return isEqual(input, s); })) { updateToApproxEquals(); return "correct"; } else if (!hasInfiniteSolutions(input) && isBalanced(input, solutions[0])) { return "halfCorrect"; } else if (isBalanced(input, solutions[0], precision)) { updateToApproxEquals(); return "halfCorrect"; } else { return "wrong"; } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateEquation/withoutPrecision/decide.ls (function(){ return function(input, solutions, isEqual, isBalanced, hasInfiniteSolutions){ if (_.some(solutions, function(s){ return isEqual(input, s); })) { return "correct"; } else if (!hasInfiniteSolutions(input) && isBalanced(input, solutions[0])) { return "halfCorrect"; } else { return "wrong"; } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateTerm/_checkEquivalence/check.ls (function(){ return function(mode){ if (mode === "quadratic") { return inc("quadratic/check"); } else { return inc("term/check"); } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateTerm/_checkEquivalence/quadratic/calcPlusMinus/calc.ls (function(){ return function(value){ var i$, ref$, len$, sign, results$ = []; for (i$ = 0, len$ = (ref$ = ["+", "-"]).length; i$ < len$; ++i$) { sign = ref$[i$]; results$.push(value.replace("±", sign)); } return results$; }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateTerm/_checkEquivalence/quadratic/check.ls (function(){ return function(input, solutions, gapValidateMode, precision){ var f, roundedSolutions, plusEquivalence, minusEquivalence; f = inc("calcPlusMinus/calc"); input = f(input); solutions = _.map(solutions, function(s){ return f(s); }); roundedSolutions = _.map(roundedSolutions, function(s){ return f(s); }); plusEquivalence = MathDiv2().checkEquivalence({ solutions: _.map(solutions, function(s){ return s[0]; }), value: input[0], gapValidateMode: gapValidateMode, precision: precision }); minusEquivalence = MathDiv2().checkEquivalence({ solutions: _.map(solutions, function(s){ return s[1]; }), value: input[1], gapValidateMode: gapValidateMode, precision: precision }); return plusEquivalence && minusEquivalence; }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateTerm/_checkEquivalence/term/check.ls (function(){ return function(input, solutions, gapValidateMode, precision){ return MathDiv2().checkEquivalence({ solutions: solutions, value: input, gapValidateMode: gapValidateMode, precision: precision }); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateTerm/validate.ls (function(){ return function(input, solutions, roundedSolutions, precision, updateToApproxEquals, mode){ var checkEquivalence; checkEquivalence = inc("_checkEquivalence/check")(mode); if (precision) { return inc("withPrecision/decide")(input, solutions, roundedSolutions, checkEquivalence, precision, updateToApproxEquals); } else { return inc("withoutPrecision/decide")(input, solutions, checkEquivalence); } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateTerm/withPrecision/decide.ls (function(){ return function(input, solutions, roundedSolutions, checkEquivalence, precision, updateToApproxEquals){ if (checkEquivalence(input, roundedSolutions, "literalSorted")) { updateToApproxEquals(); return "correct"; } else if (checkEquivalence(input, solutions, "value")) { return "halfCorrect"; } else if (checkEquivalence(input, solutions, "value", precision)) { updateToApproxEquals(); return "halfCorrect"; } else { return "wrong"; } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/decide/validateTerm/withoutPrecision/decide.ls (function(){ return function(input, solutions, checkEquivalence){ if (checkEquivalence(input, solutions, "literalSorted")) { return "correct"; } else if (checkEquivalence(input, solutions, "value")) { return "halfCorrect"; } else { return "wrong"; } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/finish/finish.ls (function(){ return function(slide, result){ if (result === "correct") { return inc("onCorrect/on")(slide); } else if (result === "halfCorrect") { return inc("onHalfCorrect/on")(slide); } else if (result === "wrong") { return inc("onMistake/on")(slide); } }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/finish/onCorrect/on.ls (function(){ return function(slide){ var input, data; input = slide.currentRow.mathInput; data = { value: input.getValue() }; input.css({ color: Color.green[400] }); slide.levelPlayer.progressBar.showGreen(); slide.isSolved = true; return slide.score.addActionCorrect(slide.atom, data, function(){ return slide.score.log(slide.atom, function(){ return setTimeout(function(){ slide.finishRow(); return slide.finish(); }, 800); }); }); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/finish/onHalfCorrect/on.ls (function(){ return function(slide){ var input, data; input = slide.currentRow.mathInput; data = { value: input.getValue() }; input.css({ color: Color.green[400] }); slide.levelPlayer.progressBar.addElement().showGreen(); return slide.score.addActionCorrect(slide.atom, data, function(){ return setTimeout(function(){ slide.finishRow(); return slide.startNewRow(); }, 500); }); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/finish/onMistake/on.ls (function(){ return function(slide){ var input, data; input = slide.currentRow.mathInput; data = { value: input.getValue() }; input.css({ color: Color.red[400] }); slide.levelPlayer.progressBar.addElement().showRed(); return slide.score.addActionMistake(slide.atom, data, function(){ var hint, ref$; hint = (ref$ = inc("../../../../_shared/findHint/find")(slide, "wrong")) != null ? ref$.info : void 8; return inc("../../../../_shared/bottomMessage/message")(slide, hint, "wrong"); }); }; })(); trainers/mathFormulaNext/startNewRow/row/mathInput/onSubmit/on.ls (function(){ return function(slide){ var finish, decide, check, freeze; finish = function(result){ return inc("finish/finish")(slide, result); }; decide = function(){ return inc("decide/decide")(slide, finish); }; check = function(){ return inc("check/check")(slide, decide); }; freeze = function(){ return inc("../../_shared/freeze/freeze")(slide, check); }; return freeze(); }; })(); trainers/mathFormulaNext/startNewRow/row/prefixDiv/calcMarginLeft/calc.ls (function(){ return function(page, div, mathDiv){ var marginLeft; div.appendTo(page); marginLeft = "-" + mathDiv.offsetWidth + "px"; div.remove(); return marginLeft; }; })(); trainers/mathFormulaNext/startNewRow/row/prefixDiv/div.ls (function(){ return function(slide){ var variable, ref$, showVariable, div, mathDiv; variable = (ref$ = slide.atom.b.variable) != null ? ref$ : "x_(1`,`2)"; showVariable = !slide.currentRow || slide.isSolved; div = Div({ display: "flex", paddingRight: "0.5em" }).html(mathDiv = MathDiv2({ value: slide.mode === "quadratic" && showVariable ? variable + "=" : "=" })).addClass("prefix"); div.css({ marginLeft: inc("calcMarginLeft/calc")(slide.levelPlayer.page, div, mathDiv) }); div.mathDiv = mathDiv; return div; }; })(); trainers/mathFormulaNext/startNewRow/row/row.ls (function(){ return function(slide){ var isFirst, showPrefix, showCopyButton, showHintButton, div, prefixDiv, mathInput, copyButton, hintButton; isFirst = !slide.currentRow; showPrefix = !(isFirst && slide.getParam("hideFirstPrefix", slide.atom)) && slide.mode !== "equation"; showCopyButton = !isFirst && !slide.getParam("hideCopyButton", slide.atom); showHintButton = !isFirst && inc("_shared/findHint/find")(slide, "correct"); div = Div({ display: "flex" }).html(showPrefix ? prefixDiv = inc("prefixDiv/div")(slide) : void 8, Div({ flex: "1 0 auto", width: "100%", marginTop: "-1px", borderTop: "1px solid " + Color.grey[250], borderBottom: "1px solid " + Color.grey[250], backgroundColor: Color.grey[100] }).html(mathInput = inc("mathInput/mathInput")(slide)).addClass("row"), showCopyButton ? copyButton = inc("copyButton/button")(slide) : void 8, showHintButton ? hintButton = inc("hintButton/hintButton")(slide) : void 8); div.prefixDiv = prefixDiv; div.mathInput = mathInput; div.copyButton = copyButton; div.hintButton = hintButton; div.updateToApproxEquals = function(){ return inc("updateToApproxEquals/update")(div, slide.mode); }; return div; }; })(); trainers/mathFormulaNext/startNewRow/row/updateToApproxEquals/update.ls (function(){ return function(div, mode){ var m, ref$; m = mode === "equation" ? div.mathInput : (ref$ = div.prefixDiv) != null ? ref$.mathDiv : void 8; return m != null ? m.setValue(m.getValue().replace("=", "≈")) : void 8; }; })(); trainers/mathFormulaNext/startNewRow/start.ls (function(){ return function(slide){ var ref$; slide.currentRow = inc("row/row")(slide); slide.rowsDiv.append(slide.currentRow); if ((ref$ = slide.levelPlayer.page.topbar.calculator) != null) { ref$.show(); } slide.currentRow.mathInput.start(); return slide.levelPlayer.page.scrollElementIntoView(slide.currentRow, { padding: 50 }); }; })(); trainers/mathGrid/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image"); }; })(); trainers/mathGrid/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg"); }; })(); trainers/mathGrid/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/mathGrid/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, i){ var i$, ref$, len$, j, c, tag, results$ = []; for (i$ = 0, len$ = (ref$ = action.cells).length; i$ < len$; ++i$) { j = i$; c = ref$[i$]; tag = i + (action.cells.length > 1 ? "." + j : ""); results$.push(Div({ display: "inline-block", padding: "0.3em" }).append(Div({ display: "flex", justifyContent: "flex-start", width: "2em", height: "2em", border: "1px solid " + Color.grey[400], background: c.resolved ? Color.grey[300] : c.correct ? Color.green[100] : Color.red[100] }).html(Div({ display: "inline-flex", flex: "1 1 auto" }).html(c.inputValue || c.value), inc("../tagIndex/tagIndex")(tag).css({ position: "absolute", top: "-0.7em", left: "-0.3em" })))); } return results$; }; })(); trainers/mathGrid/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i$, ref$, len$, cell, div, actions, a, k, j$, ref1$, len1$, i, c, lresult$, keys, j, k2, tag, r, a2, results$ = []; scoreEvent = slide.score.getScoreEvent(); for (i$ = 0, len$ = (ref$ = slide.cells).length; i$ < len$; ++i$) { cell = ref$[i$]; cell.unlock(); cell.solve(); } if (!scoreEvent) { return; } if (scoreEvent.actions[0].validatedCells != null) { return; } slide.div.append(div = Div({ textAlign: "left", marginBottom: "1em" })); actions = {}; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { a = ref$[i$]; k = ""; for (j$ = 0, len1$ = (ref1$ = a.cells).length; j$ < len1$; ++j$) { i = j$; c = ref1$[j$]; if (i !== 0) { k += ";"; } k += c.row + "," + c.column; } if (!actions[k]) { actions[k] = []; } actions[k].push(a); } i = 0; for (k in actions) { a = actions[k]; lresult$ = []; i++; keys = k.split(";"); for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) { j = i$; k2 = keys[i$]; tag = i + (keys.length > 1 ? "." + j : ""); r = k2.split(",")[0]; c = k2.split(",")[1]; cell = slide.cellWrapper.findFirst(".cell_" + r + "_" + c); if (cell != null) { cell.unlock(); } if (cell != null) { cell.append(inc("tagIndex/tagIndex")(tag).css({ position: "absolute", top: "-0.7em", left: "-0.3em" })); } } for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { a2 = a[i$]; lresult$.push(div.append(inc("/shared/scoreActionRowFlex/row")(a2, inc("actionDiv/div")(a2, i)))); } results$.push(lresult$); } return results$; }; })(); trainers/mathGrid/_review/scoreActions/tagIndex/tagIndex.ls (function(){ return function(i){ return Div().addClass("tagIndex").css({ display: "inline-block", verticalAlign: "0.2em", fontSize: "0.7em", backgroundColor: Color.yellow[200], padding: "0.2em", boxShadow: '0px 0px 2px #bbb' }).html(i); }; })(); trainers/mathGrid/_start/start.ls (function(){ return function(slide){ var callback, ref$; if (slide.totalProgressElements === 0) { slide.div.css({ pointerEvents: "none" }); callback = slide.finish; } else { slide.startNextGapPhase(); if ((ref$ = slide.screenKeyboard) != null) { ref$.start(); } callback = function(){ var that; if ((that = slide.crossOutInfo) != null) { return slide.levelPlayer.page.scrollElementIntoView(that, { padding: 50 }); } }; } return slide.instruction.play(callback); }; })(); trainers/mathGrid/_t.ls (function(){ return { solutionWrong: { de: "Ups, deine Lösung war falsch.", en: "Oops, your answer was incorrect.", fr: "Oups, ta réponse est incorrecte.", es: "¡Ups! Tu respuesta es incorrecta.", pt: "Ops! Sua resposta está incorreta." }, showSolution: { de: "Lösung angezeigt: ", en: "Solution shown: ", fr: "Solution :", es: "Solución mostrada:", pt: "Solução exibida:" }, showSolutionButton: { de: "Lösung anzeigen", en: "Show solution", fr: "Montrer la solution", es: "Mostrar solución", pt: "Mostrar solução" }, fillGreyFieldsFirst: { de: "Bitte trage erst in alle grauen Felder einen Wert ein, bevor du deine Eingabe prüfst.", en_gb: "Please enter a value in all grey fields before you check your entry.", en: "Please enter a value in all gray fields before you check your entry.", fr: "Tu dois remplir toutes les cases grises avant de vérifier ta réponse.", es: "Por favor, ingresa un valor en todas las casillas grises antes de verificar tu respuesta.", pt: "Por favor, insira um valor em todos os campos cinza antes de conferir sua resposta." }, fieldLocked: { de: "Dieses Feld ist noch gesperrt,
bitte löse zuerst die grauen Felder!", en_gb: "This field is still locked,
please solve the grey fields first!", en: "This field is still locked,
please solve the gray fields first!", fr: "Cette case est encore bloquée,
tu dois d'abord compléter les cases grises !", es: "¡Esta casilla aún está bloqueada!
Por favor, resuelve primero las casillas grises", pt: "Este campo ainda está bloqueado!
Por favor, resolva primeiro os campos cinza!" }, tap: { de: "Tippe", en: "tap", fr: "Appuie", es: "Presiona", pt: "Toque" }, click: { de: "Klicke", en: "click", fr: "Clique", es: "Pulsa", pt: "Clique" }, crossOutInfo: { de: "$1 doppelt auf ein Feld, um es durchzustreichen.", en: "Double $1 on a box to cross it out.", fr: "$1 deux fois sur une case pour la barrer.", es: "$1 dos veces una casilla para tacharla.", pt: "$1 duas vezes numa caixa para riscá-la." } }; })(); trainers/mathGrid/buttonCheck/button.ls (function(){ return function(slide){ var p, div; if (slide.totalProgressElements === 0 && slide.isDesktop) { return; } p = { label: T("checkButton") }; if (slide.isDesktop) { p.icon = path("/../app01/lib/svg/icon/arrow-right-small.svg"); p.iconPosition = "right"; } div = Button(p).css({ margin: "0.4em" }).tap({ up: slide.submit }); if (slide.isDesktop) { slide.div.append(div); } return div; }; })(); trainers/mathGrid/calcCellsData/calc.ls (function(){ return function(slide){ var cellsData, i$, ref$, len$, rowIndex, atom; cellsData = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { rowIndex = i$; atom = ref$[i$]; inc("calcAtom/calc")(atom, rowIndex, cellsData); } slide.maxGapPhaseIndex = _.max(_.map(cellsData, "gapPhaseIndex")); return cellsData; }; })(); trainers/mathGrid/calcCellsData/calcAtom/calc.ls (function(){ var styles, gapLetters; styles = { "_": "borderBottomThick", "[": "borderLeftThick", "=": ["borderBottomThick", "smallFontSize"], "s": "smallFontSize", "l": "alignLeft", "r": "alignRight", ",": "comma", ".": "dot", "/": "crossOut", " ": "default" }; gapLetters = "abcdefghijklmnopqrstuvwxyz"; return function(atom, rowIndex, cellsData){ var a, dontAdvanceCursor, doubleDigits, i$, len$, columnIndex, c, value, type, style, res$, j$, to$, i, gapPhaseIndex, gapPhase, isGapPhaseStart, results$ = []; a = atom.row.split("|"); if (_.last(a) === '!') { dontAdvanceCursor = true; } if (_.last(a) === 'd') { doubleDigits = true; dontAdvanceCursor = true; } a = _.filter(a, function(c){ return c.length === 3 || c.length === 4; }); for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { columnIndex = i$; c = a[i$]; value = doubleDigits ? c.slice(1, c.length - 1) : c.charAt(c.length - 2); type = c.charAt(c.length - 1); res$ = []; for (j$ = 0, to$ = c.length === 4 && !doubleDigits ? 1 : 0; j$ <= to$; ++j$) { i = j$; res$.push(styles[c.charAt(i)]); } style = res$; style = _.flatten(style); if (_.some(style, fn$)) { debug("this cell contains unavailable styles:", c); } gapPhaseIndex = _.indexOf(gapLetters, type.toLowerCase()); gapPhase = gapPhaseIndex > -1 ? c.charAt(2) : null; isGapPhaseStart = gapPhase ? type === type.toUpperCase() : void 8; type = value !== " " && type === " " ? "fix" : value === " " && type === " " ? "free" : "gap"; results$.push(cellsData.push({ atom: atom, row: rowIndex, column: columnIndex, value: value, style: style, type: type, gapPhase: gapPhase, gapPhaseIndex: gapPhaseIndex, isGapPhaseStart: isGapPhaseStart, dontAdvanceCursor: dontAdvanceCursor, doubleDigits: doubleDigits })); } return results$; function fn$(s){ return s === undefined; } }; })(); trainers/mathGrid/calcIsDesktop/calc.ls (function(){ return function(){ var isDesktop, showScreenKeyboard; isDesktop = inc("/../app01/lib/util/isDesktop/isDesktop")(); showScreenKeyboard = deviceLog['var']("showScreenKeyboard"); return isDesktop && !showScreenKeyboard; }; })(); trainers/mathGrid/calcTotalColumns/calc.ls (function(){ return function(slide){ return _.filter(slide.atoms[0].row.split("|"), function(c){ return c.length === 3 || c.length === 4; }).length; }; })(); trainers/mathGrid/calcTotalGapPhases/calc.ls (function(){ return function(atoms){ var gapLetters, cells, gapPhases, max; gapLetters = "abcdefghijklmnopqrstuvwxyz"; cells = _.flatMap(atoms, function(a){ var cells; cells = a.row.split("|"); return cells.splice(0, cells.length - 1); }); gapPhases = _.map(cells, function(c){ var ref$; return (ref$ = c[c.length - 1]) != null ? ref$.toLowerCase() : void 8; }); gapPhases = _.without(gapPhases, " "); gapPhases = _.uniq(gapPhases); max = _.max(_.map(gapPhases, function(p){ return gapLetters.indexOf(p); })); if (max == null) { return 0; } return max + 1; }; })(); trainers/mathGrid/cells/cellRow/cell/addDiagonalLine/add.ls (function(){ return function(cellData, div){ if (!_.includes(cellData.style, "crossOut")) { return; } return div.onDomAppend(function(){ return div.append(inc("../diagonalLine/line")(div)); }); }; })(); trainers/mathGrid/cells/cellRow/cell/cell.ls (function(){ return function(slide, cellData){ var inputValue, divSelected, down, select, unselect, onKeyChar, clear, check, solve, unlock, doubleTap, div, divValue, divLocked; inputValue = ""; divSelected = null; down = function(){ return slide.selectCell(cellData.row, cellData.column); }; select = function(){ if (!divSelected) { divSelected = inc("divSelected/div")(div); } return divSelected.show(); }; unselect = function(){ return divSelected != null ? divSelected.hide() : void 8; }; onKeyChar = function(c){ if (div.css("pointerEvents") === "none") { return; } if (cellData.type === "fix") { return; } if (cellData.type === "gap" && cellData.gapPhaseIndex !== slide.currentGapPhaseIndex) { return; } slide.resetFeedback(); if (cellData.doubleDigits && divValue.text().trim().length === 1) { divValue.append(c); return inputValue += c; } else { divValue.html(c); return inputValue = c; } }; clear = function(){ if (cellData.type === "fix") { return; } if (cellData.type === "gap" && cellData.gapPhaseIndex !== slide.currentGapPhaseIndex) { return; } slide.resetFeedback(); divValue.html(" "); return inputValue = ""; }; check = function(){ var returnValue; inputValue = inputValue + ""; return returnValue = cellData.type !== "gap" ? { correct: true, value: inputValue } : inputValue === "" && cellData.value.length > 0 && cellData.value !== " " ? "incomplete" : inputValue === cellData.value || inputValue === "0" && cellData.value === " " ? (div.removeClass("wrongCell"), div.addClass("correctCell"), { correct: true, value: inputValue }) : (div.addClass("wrongCell"), div.removeClass("correctCell"), { correct: false, value: inputValue }); }; solve = function(){ if (cellData.type === "gap") { divValue.html(cellData.value); div.css({ backgroundColor: Color.grey[250] }); } return div.removeClass("wrongCell").removeClass("correctCell").css({ pointerEvents: "" }); }; unlock = function(){ return typeof divLocked != 'undefined' && divLocked !== null ? divLocked.remove() : void 8; }; doubleTap = function(){ var that; if (cellData.type === "gap" && cellData.gapPhaseIndex > slide.currentGapPhaseIndex) { return; } if (that = div.findFirst(".diagonalLine")) { return that.remove(); } else { return div.append(inc("diagonalLine/line")(div)); } }; div = Div(); div.addClass("cell").addClass("cell_" + cellData.row + "_" + cellData.column).css({ display: "inline-flex", width: "2em", border: "1px solid " + Color.grey[250], marginLeft: "-1px", verticalAlign: "top", height: "100%", backgroundColor: cellData.type === "gap" ? Color.grey[100] : void 8, padding: "0 0.2em", justifyContent: _.includes(cellData.style, "alignLeft") ? "flex-start" : _.includes(cellData.style, "alignRight") ? "flex-end" : void 8 }).append(divValue = inc("divValue/div")(cellData), inc("divBorderThickBottom/div")(div, cellData), inc("divBorderThickLeft/div")(div, cellData), divLocked = inc("divLocked/div")(div, slide, cellData), inc("divComma/div")(cellData), inc("divDot/div")(cellData)).tap({ down: down, animation: "none" }); inc("addDiagonalLine/add")(cellData, div); if (slide.getParam("enableCrossOut")) { div.gestureTapSequence({ tapSequence: "..", maxDelay: 200, onEnded: doubleTap }); } div.cellData = cellData; div.select = select; div.unselect = unselect; div.clear = clear; div.check = check; div.unlock = unlock; div.solve = solve; div.onKeyChar = onKeyChar; div.inputValue = function(){ return inputValue; }; return div; }; })(); trainers/mathGrid/cells/cellRow/cell/diagonalLine/line.ls (function(){ return function(div){ var svg, w, h, container; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; w = div.offsetWidth - 2; h = div.offsetHeight - 2; return container = svg("svg").addClass("diagonalLine").css({ position: "absolute", left: 0, top: 0, width: w + "px", height: h + "px" }).append(svg("line").attr({ x1: 0, y1: h, x2: w, y2: 0, strokeWidth: "2px", stroke: Color.black })); }; })(); trainers/mathGrid/cells/cellRow/cell/divBorderThickBottom/div.ls (function(){ return function(cellDiv, cellData){ if (!_.includes(cellData.style, "borderBottomThick")) { return; } cellDiv.css({ borderBottomWidth: "2px" }); return Div({ position: "absolute", bottom: "-2px", left: "-1px", right: "-1px", height: "2px", backgroundColor: "black", zIndex: 1 }); }; })(); trainers/mathGrid/cells/cellRow/cell/divBorderThickLeft/div.ls (function(){ return function(cellDiv, cellData){ if (!_.includes(cellData.style, "borderLeftThick")) { return; } return Div({ position: "absolute", left: "-2px", top: "-2px", bottom: "-1px", width: "2px", backgroundColor: "black", zIndex: 1 }); }; })(); trainers/mathGrid/cells/cellRow/cell/divComma/div.ls (function(){ return function(cellData){ if (!_.includes(cellData.style, "comma")) { return; } return Div({ display: "inline-block", position: "absolute", left: "-0.15em", bottom: "0.25em", zIndex: 1 }).html(","); }; })(); trainers/mathGrid/cells/cellRow/cell/divDot/div.ls (function(){ return function(cellData){ if (!_.includes(cellData.style, "dot")) { return; } return Div({ display: "inline-block", position: "absolute", left: "-0.15em", bottom: "0.25em", zIndex: 1 }).html("."); }; })(); trainers/mathGrid/cells/cellRow/cell/divLocked/div.ls (function(){ return function(cellDiv, slide, cellData){ if (cellData.type !== "gap") { return; } if (cellData.gapPhaseIndex === slide.currentGapPhaseIndex) { return; } return Div({ position: "absolute", display: "inline-flex", top: 0, left: 0, right: 0, bottom: 0, backgroundColor: "white" }).append(SvgIcon({ svg: path("/../app01/lib/svg/shape/lock.svg"), color: Color.grey[400] }).css({ width: "1em", height: "1em" })); }; })(); trainers/mathGrid/cells/cellRow/cell/divSelected/div.ls (function(){ return function(cellDiv){ var div; cellDiv.append(div = Div({ border: "2px solid " + Color.lightBlue.A400, position: "absolute", top: "0px", bottom: "0px", left: "0px", right: "0px", pointerEvents: "none" })); return div; }; })(); trainers/mathGrid/cells/cellRow/cell/divValue/div.ls (function(){ return function(cellData){ var v; v = cellData.value; if (v === "*") { v = MathDiv2({ value: v, enabled: false }); } return Div({ display: "inline-block", verticalAlign: "center", fontSize: _.includes(cellData.style, "smallFontSize") ? "0.8em" : void 8 }).html(cellData.type === "fix" ? v : " "); }; })(); trainers/mathGrid/cells/cellRow/cellRow.ls (function(){ return function(slide, row, cells){ var cellsData, isSmall, cellData, cell; cellsData = _.filter(slide.cellsData, { row: row }); isSmall = _.includes(cellsData[0].style, "smallFontSize"); return Div({ whiteSpace: "nowrap", marginTop: "-1px", height: isSmall ? "1.5em" : "2.0em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = cellsData).length; i$ < len$; ++i$) { cellData = ref$[i$]; cell = inc("cell/cell")(slide, cellData); cells.push(cell); results$.push(cell); } return results$; }())); }; })(); trainers/mathGrid/cells/cells.ls (function(){ return function(slide){ var cells, div, row; cells = []; slide.cellWrapper = Div().append(div = Div({ display: "inline-block", padding: "1em 1px", overflow: "auto" }).append((function(){ var i$, to$, results$ = []; for (i$ = 0, to$ = slide.totalRows - 1; i$ <= to$; ++i$) { row = i$; results$.push(inc("cellRow/cellRow")(slide, row, cells)); } return results$; }())), slide.getParam("enableCrossOut") ? slide.crossOutInfo = inc("crossOutInfo/info")(slide) : void 8).appendTo(slide.div); inc("optimizeWidth/optimize")(slide, div); return cells; }; })(); trainers/mathGrid/cells/crossOutInfo/info.ls (function(){ return function(slide){ return Div({ marginBottom: "1em" }).html(SvgIcon({ svg: path("/../app01/lib/svg/shape/bulb.svg"), color: Color.grey[550] }).css({ verticalAlign: "-0.15em", marginRight: "0.2em" }), T("crossOutInfo", slide.isDesktop ? T("click") : T("tap"))); }; })(); trainers/mathGrid/cells/optimizeWidth/optimize.ls (function(){ return function(slide, div){ var fontSize, w, bodyW; fontSize = 1.2 * (slide.getParam("fontScale", slide.atom) || 1); div.css({ fontSize: fontSize + "em" }); w = div.width(); bodyW = body.width(); if (w > bodyW) { return div.css({ fontSize: fontSize * ((bodyW - 20) / w) + "em" }); } }; })(); trainers/mathGrid/checkCells/check.ls (function(){ return function(slide){ return function(){ var correct, validatedCells, i$, ref$, len$, cell, result; correct = true; validatedCells = []; for (i$ = 0, len$ = (ref$ = slide.cells).length; i$ < len$; ++i$) { cell = ref$[i$]; if (cell.cellData.gapPhaseIndex === slide.currentGapPhaseIndex) { result = cell.check(); if (result === "incomplete") { correct = "incomplete"; break; } else if (result.correct === false) { correct = false; } validatedCells.push({ row: cell.cellData.row, column: cell.cellData.column, value: cell.cellData.value, inputValue: result.value, correct: result.correct }); } } return { correct: correct, cells: validatedCells }; }; }; })(); trainers/mathGrid/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = inc("calcTotalGapPhases/calc")(atoms); slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/mathGrid/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image"); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/mathGrid/init.ls (function(){ return function(slide){ slide.isDesktop = inc("calcIsDesktop/calc")(); slide.cellsData = inc("calcCellsData/calc")(slide); slide.totalRows = slide.atoms.length; slide.totalColumns = inc("calcTotalColumns/calc")(slide); slide.currentGapPhaseIndex = -1; slide.instruction = inc("instruction/instruction")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.cells = inc("cells/cells")(slide); slide.screenKeyboard = inc("screenKeyboard/screenKeyboard")(slide); slide.onKey = inc("onKey/onKey")(slide); slide.selectCell = inc("selectCell/select")(slide); slide.checkCells = inc("checkCells/check")(slide); slide.submit = inc("submit/submit")(slide); slide.checkButton = inc("buttonCheck/button")(slide); slide.solveCurrentGapPhase = inc("solveCurrentGapPhase/solve")(slide); slide.setValueCurrentCell = inc("setValueCurrentCell/set")(slide); slide.startNextGapPhase = inc("startNextGapPhase/start")(slide); return slide.resetFeedback = inc("resetFeedback/reset")(slide); }; })(); trainers/mathGrid/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/mathGrid/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg"); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/mathGrid/onKey/onKey.ls (function(){ return function(slide){ var okChars, onKey; okChars = "0123456789"; onKey = function(e){ var k, r, ref$, c, ref1$; k = e.detail.functionKey; r = (ref$ = slide.selectedCell) != null ? ref$.cellData.row : void 8; c = (ref1$ = slide.selectedCell) != null ? ref1$.cellData.column : void 8; if (_.includes(okChars, e.detail.char)) { slide.setValueCurrentCell(e.detail.char); return; } else if (k === "down") { r++; if (r === slide.totalRows) { r--; } } else if (k === "up") { r--; if (r === -1) { r++; } } else if (k === "right") { c++; if (c === slide.totalColumns) { c--; } } else if (k === "left") { c--; if (c === -1) { c++; } } else if (k === "backspace") { slide.selectedCell.clear(); } else if (k === "enter") { slide.submit(); } else { return; } return slide.selectCell(r, c); }; return slide.div.bind("keyManager", onKey).addClass("keyManager-any"); }; })(); trainers/mathGrid/resetFeedback/reset.ls (function(){ return function(slide){ return function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = slide.div.findAll(".wrongCell, .correctCell")).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.css({ backgroundColor: Color.grey[100] })); } return results$; }; }; })(); trainers/mathGrid/screenKeyboard/screenKeyboard.ls (function(){ return function(slide){ var onKey, screenKeyboard; if (slide.isDesktop) { return; } onKey = function(e){ if (e === "submit") { return slide.submit(); } else if (e === "back") { return slide.selectedCell.clear(); } else { return slide.setValueCurrentCell(e); } }; screenKeyboard = inc("/../app01/lib/gui/screenKeyboard/keyboard")({ onKey: onKey, layout: "mathDivNumbers", submitLabel: T("checkButton"), showSubmit: true }); return { start: function(){ slide.levelPlayer.page.bottom.html(screenKeyboard).show(); return screenKeyboard.start(); }, stop: function(){ return screenKeyboard.stop(); } }; }; })(); trainers/mathGrid/selectCell/select.ls (function(){ return function(slide){ return function(rowIndex, columnIndex){ var ref$, i$, ref1$, len$, cell, results$ = []; if (_.isObject(rowIndex)) { columnIndex = rowIndex.cellData.column; rowIndex = rowIndex.cellData.row; } if ((ref$ = slide.selectedCell) != null) { ref$.unselect(); } for (i$ = 0, len$ = (ref1$ = slide.cells).length; i$ < len$; ++i$) { cell = ref1$[i$]; if (cell.cellData.row === rowIndex && cell.cellData.column === columnIndex) { cell.select(); results$.push(slide.selectedCell = cell); } } return results$; }; }; })(); trainers/mathGrid/setValueCurrentCell/getNextCells/get.ls (function(){ return function(slide){ var findCell; findCell = function(row, column){ return _.find(slide.cells, { cellData: { row: slide.selectedCell.cellData.row + row, column: slide.selectedCell.cellData.column + column, gapPhaseIndex: slide.selectedCell.cellData.gapPhaseIndex } }); }; return [findCell(-1, -1), findCell(0, 1), findCell(1, 0), findCell(0, -1)]; }; })(); trainers/mathGrid/setValueCurrentCell/set.ls (function(){ return function(slide){ return function(char){ var nextCells, that; if (slide.selectedCell.cellData.gapPhaseIndex > slide.currentGapPhaseIndex) { inc("topMessageLockedCell/topMessage")(); return; } if (slide.selectedCell.cellData.type === "fix") { return; } slide.selectedCell.onKeyChar(char); if (slide.selectedCell.cellData.dontAdvanceCursor) { return; } nextCells = _.filter(inc("getNextCells/get")(slide), function(c){ return (c != null ? c.inputValue() : void 8) === "" && c.cellData.type === "gap"; }); if ((that = nextCells[0]) != null) { return slide.selectCell(that); } }; }; })(); trainers/mathGrid/setValueCurrentCell/topMessageLockedCell/topMessage.ls (function(){ return function(){ var div; div = Div({ textAlign: "center" }).html(T("fieldLocked"), Div({ margin: "0.5em 0 0" }).html(Button({ label: T("closeButton"), icon: path("/../app01/lib/svg/icon/close-small.svg") }).tap(function(){ return div.close(); }))); return div = inc("/shared/topMessage/topMessage")({ html: div }); }; })(); trainers/mathGrid/solveCurrentGapPhase/solve.ls (function(){ return function(slide){ return function(){ var solvedCells, i$, ref$, len$, cell; solvedCells = []; for (i$ = 0, len$ = (ref$ = slide.cells).length; i$ < len$; ++i$) { cell = ref$[i$]; if (cell.cellData.gapPhaseIndex === slide.currentGapPhaseIndex) { cell.solve(); solvedCells.push({ row: cell.cellData.row, column: cell.cellData.column, value: cell.cellData.value, resolved: true }); } } return solvedCells; }; }; })(); trainers/mathGrid/startNextGapPhase/start.ls (function(){ return function(slide){ var gapLetters; gapLetters = "abcdefghijklmnopqrstuvwxyz"; return function(){ var phaseCells, i$, len$, cell, startCell, ref$; if (!slide.isDesktop) { slide.div.css({ paddingBottom: "" }); } slide.currentGapPhaseIndex++; phaseCells = _.filter(slide.cells, { cellData: { gapPhaseIndex: slide.currentGapPhaseIndex } }); for (i$ = 0, len$ = phaseCells.length; i$ < len$; ++i$) { cell = phaseCells[i$]; if (cell.cellData.gapPhaseIndex === slide.currentGapPhaseIndex) { cell.unlock(); } } startCell = _.find(phaseCells, { cellData: { isGapPhaseStart: true } }) || phaseCells[0]; if ((ref$ = slide.levelPlayer) != null) { ref$.page.scrollElementIntoView(startCell, { padding: 50 }); } return slide.selectCell(startCell); }; }; })(); trainers/mathGrid/submit/finish/finish.ls (function(){ return function(slide){ var ref$, ref1$, ref2$, ref3$; slide.div.css({ pointerEvents: "none" }); if ((ref$ = slide.bottomBarButtons) != null) { ref$.hide(); } if ((ref1$ = slide.checkButton) != null) { ref1$.hide(); } if ((ref2$ = slide.solveButton) != null) { ref2$.hide(); } if ((ref3$ = slide.screenKeyboard) != null) { ref3$.stop(); } slide.selectedCell.unselect(); slide.score.log(slide.atoms); return slide.finish(); }; })(); trainers/mathGrid/submit/hintMistake/hint.ls (function(){ return function(slide){ var isDone, solve, retry, html, div; isDone = false; solve = function(){ var solvedCells; slide.resetFeedback(); solvedCells = slide.solveCurrentGapPhase(); slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atoms, { cells: solvedCells }); isDone = true; if (slide.currentGapPhaseIndex === slide.maxGapPhaseIndex) { slide.finishButton = true; return inc("../finish/finish")(slide); } else { return slide.startNextGapPhase(); } }; retry = function(){ var i$, ref$, len$, c, results$ = []; isDone = true; for (i$ = 0, len$ = (ref$ = slide.div.findAll(".wrongCell, .correctCell")).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.css({ backgroundColor: Color.grey[100], pointerEvents: "" }).removeClass("wrongCell").removeClass("correctCell")); } return results$; }; html = Div({ padding: "0.3em", textAlign: "center" }).html(Div().html(T("solutionWrong")), Div({ margin: "0.7em 0 0.4em" }).html(Button({ label: T("tryAgain"), icon: path("/../app01/lib/svg/icon/refresh.svg") }).tap(function(){ return div.close("retry"); }).css({ marginRight: "0.8em" }), Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).tap(function(){ return div.close("solve"); }))); div = inc("/shared/topMessage/topMessage")({ html: html, onClose: function(type){ if (type === "solve") { return solve(); } else { return retry(); } } }).addClass("hint").addClass("gapWriteMistakeHint"); div.isDone = function(){ return isDone; }; div.solveAndContinue = solve; div.retryAndContinue = retry; return div; }; })(); trainers/mathGrid/submit/submit.ls (function(){ return function(slide){ var isDone, onCorrect, onMistake, onSubmit; isDone = false; onCorrect = function(cells){ slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atoms, { cells: cells }); return setTimeout(function(){ var i$, ref$, len$, c; for (i$ = 0, len$ = (ref$ = slide.div.findAll(".correctCell")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ backgroundColor: Color.grey[250], pointerEvents: "" }).removeClass("correctCell"); } if (slide.currentGapPhaseIndex === slide.maxGapPhaseIndex) { return inc("finish/finish")(slide); } else { slide.startNextGapPhase(); return isDone = false; } }, 700); }; onMistake = function(cells){ inc("hintMistake/hint")(slide); slide.score.addActionMistake(slide.atoms, { cells: cells }); slide.levelPlayer.progressBar.addElement().showRed(); return isDone = false; }; onSubmit = function(){ var validateResult, correct, cells, i$, ref$, len$, c; if (isDone) { return; } isDone = true; validateResult = slide.checkCells(); correct = validateResult.correct; cells = validateResult.cells; for (i$ = 0, len$ = (ref$ = slide.div.findAll(".wrongCell, .correctCell")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ pointerEvents: "none" }); } if (correct === "incomplete") { inc("topMessageIncomplete/topMessage")(slide); isDone = false; return; } for (i$ = 0, len$ = (ref$ = slide.div.findAll(".wrongCell")).length; i$ < len$; ++i$) { (fn$.call(this, ref$[i$])); } for (i$ = 0, len$ = (ref$ = slide.div.findAll(".correctCell")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ backgroundColor: Color.green[500] }); } if (correct) { return onCorrect(cells); } else { return onMistake(cells); } function fn$(c){ c.css({ backgroundColor: Color.red[500] }); } }; return onSubmit; }; })(); trainers/mathGrid/submit/topMessageIncomplete/topMessage.ls (function(){ return function(slide){ var i$, ref$, len$, c, div; for (i$ = 0, len$ = (ref$ = slide.div.findAll(".wrongCell, .correctCell")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ backgroundColor: Color.grey[100], pointerEvents: "" }).removeClass("wrongCell").removeClass("correctCell"); } div = Div({ textAlign: "center" }).html(T("fillGreyFieldsFirst"), Div({ margin: "0.5em 0 0" }).html(Button({ label: T("closeButton"), icon: path("/../app01/lib/svg/icon/close-small.svg") }).tap(function(){ return div.close(); }))); return div = inc("/shared/topMessage/topMessage")({ html: div }); }; })(); trainers/memory/_media2/images/images.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }; })(); trainers/memory/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }; })(); trainers/memory/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, p, i$, ref$, len$, atom, soundMode, text, voice, voiceLang; sounds = []; p = slide.getParam; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = p("soundMode", atom); if (soundMode === "a" || soundMode === "ab" || soundMode === "askSound") { text = atom.soundA || atom.sound || atom.a; if (text) { voice = p("voiceA", atom) || p("voice", atom); voiceLang = p("voiceLangA", atom) || p("voiceLang", atom); sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } if (soundMode === "b" || soundMode === "ab") { text = atom.soundB || atom.sound || atom.b; if (text) { voice = p("voiceB", atom) || p("voice", atom); voiceLang = p("voiceLangB", atom) || p("voiceLang", atom); sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } } return sounds; }; })(); trainers/memory/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, c, ref1$, ref2$, labels; if (slide.getParam("wideCards")) { for (i$ = 0, len$ = (ref$ = slide.cards.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; if ((ref1$ = c.front) != null) { ref1$.css({ transform: "rotateY(-180deg)" }); } if ((ref2$ = c.back) != null) { ref2$.css({ transform: "rotateY(-360deg)" }); } } } if (slide.getParam("soundMode") !== "askSound") { labels = _(slide.atoms).map("a").filter(function(l){ return (l != null ? l.trim().length : void 8) > 0; }).join(", "); if (labels) { return slide.header.replaceWith(Div({ opacity: 1, fontSize: "1em", color: Color.grey[700] }).secureHtml(labels)); } } }; })(); trainers/memory/_review/scoreActions/actionDiv/div.ls (function(){ return function(action, slide){ var atom, chooseMode, div, a, lsg; if (action.correct) { atom = action.originalAtom; } else { atom = action.atom; } chooseMode = slide.getParam("chooseMode"); div = Div({ display: "inline-block" }); if (chooseMode === "image") { if (atom.image) { div.html(inc("/shared/image/image")({ image: atom.image, slide: slide }).css({ width: "1.3em", height: "1.3em", verticalAlign: "-0.3em" })).secureAppend((a = action.originalAtom.a) ? " = " + a : void 8); } else if (atom.lsg) { lsg = slide.getParam("lsg", atom); div.html(inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }).css({ width: "1.3em", height: "1.3em", verticalAlign: "0" })).secureAppend((a = action.originalAtom.a) ? " = " + a : void 8); } } else if (chooseMode === "text") { div.secureAppend(action.originalAtom.a + " = " + atom.b); } return div; }; })(); trainers/memory/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, i, action; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.originalAtom = e.atom; actions.push(a); } } if (actions.length > 0) { return slide.div.append(Div({ textAlign: "left", margin: "2em 0" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(inc("actionDiv/div")(action, slide))); } return results$; }()))); } }; })(); trainers/memory/_start/start.ls (function(){ return function(slide){ slide.startNext(); return slide.instruction.play(); }; })(); trainers/memory/calcCardWidth/calc.ls (function(){ return function(){ var w; w = body.width(); if (w < 450) { return Math.floor(w / 2.8) + "px"; } else { return "10em"; } }; })(); trainers/memory/cards/adjustWideCardHeight/adjust.ls (function(){ return function(cards){ var maxH, card, i$, len$, results$ = []; maxH = _.max((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = cards).length; i$ < len$; ++i$) { card = ref$[i$]; results$.push(Math.max(card.front.offset().height, card.back.offset().height)); } return results$; }())); for (i$ = 0, len$ = cards.length; i$ < len$; ++i$) { card = cards[i$]; results$.push(card.adjustHeight(maxH)); } return results$; }; })(); trainers/memory/cards/card/card.ls (function(){ return function(slide, atom, i, click){ var p, useWideCards, ref$, cardInclude, card; p = slide.getParam; useWideCards = (ref$ = p("wideCards")) != null ? ref$ : false; cardInclude = useWideCards ? "wideCard/card" : "memoryCard/card"; card = inc(cardInclude)({ cardWidth: slide.cardWidth, slide: slide, frontImage: p("chooseMode") === "image" ? p("image", atom) : void 8, frontLsg: p("chooseMode") === "image" ? p("lsg", atom) : void 8, frontText: p("chooseMode") === "text" ? atom.b : void 8, backImage: atom.image ? p("image", atom) : void 8, backLsg: atom.lsg ? p("lsg", atom) : void 8, labelA: atom.a, labelB: atom.b, labelC: atom.c, onClick: click }); card.tag = i; return card; }; })(); trainers/memory/cards/card/memoryCard/animations/tap.ls (function(){ return function(div){ return { up: function(){ return div.front.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "500ms" }); }, cancel: function(){ return div.front.css({ boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", transition: "200ms" }); }, down: function(){ return div.front.css({ boxShadow: "2px 3px 9px 3px rgba(0,0,0,0.2)", transition: "0ms" }); } }; }; })(); trainers/memory/cards/card/memoryCard/card.ls (function(){ return function(o){ var flipSpeed, div, faceCss, cardFace; flipSpeed = 500; div = Div(); faceCss = function(front){ return { position: "absolute", left: 0, top: 0, padding: "6px", width: "100%", height: "100%", backgroundColor: "white", zIndex: front ? 2 : 1, transform: "rotateY(" + (front ? 0 : -180) + "deg)", backfaceVisibility: "hidden", webkitBackfaceVisibility: "hidden", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)" }; }; cardFace = function(image, lsg, textB, textA, textC){ if (image || lsg) { if (textC || textB) { return inc("cardFaces/imageText")({ image: image, lsg: lsg, text: textC || textB, slide: o.slide }); } else { return inc("cardFaces/image")({ image: image, lsg: lsg, slide: o.slide }); } } else { if (textC) { return inc("cardFaces/text")({ text: textC, slide: o.slide }); } else if (textA && textB) { return inc("cardFaces/doubleText")({ text1: textA, text2: textB, slide: o.slide }); } else { return inc("cardFaces/text")({ text: textB, slide: o.slide }); } } }; div.css({ display: "inline-block", width: o.cardWidth, height: o.cardWidth, perspective: "500px", margin: "0.5em" }).append(div.front = Div(faceCss(true)).append(cardFace(o.frontImage, o.frontLsg, o.frontText))).append(div.back = Div(faceCss(false)).append(cardFace(o.backImage, o.backLsg, o.labelB, o.labelA, o.labelC))).tap({ up: function(){ return o.onClick(div); }, animation: inc("animations/tap")(div) }); div.front.flipped = 0; div.back.flipped = -180; div.flip = function(){ var flip; flip = function(d){ d.flipped -= 180; return d.css({ transform: "rotateY(" + d.flipped + "deg)", transition: flipSpeed + "ms" }); }; flip(div.front); return flip(div.back); }; div.correct = function(callback){ div.css({ pointerEvents: "none" }); div.back.css({ backgroundColor: Color.green[500] }); div.flip(); return setTimeout(function(){ div.back.css({ backgroundColor: "white", transition: "500ms", boxShadow: "0px 0px 3px rgba(0,0,0,0.2)" }); return typeof callback == 'function' ? callback() : void 8; }, flipSpeed); }; div.wrong = function(callback){ div.css({ pointerEvents: "none" }); div.front.css({ backgroundColor: Color.red[500], transition: "100ms" }); return setTimeout(function(){ div.front.css({ backgroundColor: "white", transition: "500ms" }); div.css({ pointerEvents: "" }); return typeof callback == 'function' ? callback() : void 8; }, flipSpeed); }; return div; }; })(); trainers/memory/cards/card/memoryCard/cardFaces/_calcTextCss/calc.ls (function(){ return function(slide){ var ref$; return { padding: "0 0.5em", textAlign: (ref$ = slide.getParam("textAlign")) != null ? ref$ : "center" }; }; })(); trainers/memory/cards/card/memoryCard/cardFaces/calcDivCss/calc.ls (function(){ return function(textCss){ return _.merge({ width: "100%" }, textCss); }; })(); trainers/memory/cards/card/memoryCard/cardFaces/calcSeperatorCss/calc.ls (function(){ return function(slide){ var ref$; return { borderBottom: "1px solid " + Color.grey[300], margin: "0.8em 0", width: (ref$ = slide.getParam("textAlign")) === "left" || ref$ === "right" ? "calc(100% - 1em)" : "70%" }; }; })(); trainers/memory/cards/card/memoryCard/cardFaces/doubleText.ls (function(){ return function(o){ var textCss, divCss; textCss = inc("_calcTextCss/calc")(o.slide); divCss = inc("calcDivCss/calc")(textCss); return Div({ display: "flex", width: "100%", height: "100%", backgroundColor: Color.grey[150], flexDirection: "column", pointerEvents: "none" }).html(Div(divCss).addClass("currentAtomText1").secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(o.text1) : o.text1), o.text1 != null && o.text2 != null ? Div(inc("calcSeperatorCss/calc")(o.slide)) : void 8, Div(divCss).secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(o.text2) : o.text2)); }; })(); trainers/memory/cards/card/memoryCard/cardFaces/image.ls (function(){ return function(o){ var div; return div = Div({ position: "relative", left: 0, top: 0, width: "100%", height: "100%", pointerEvents: "none" }).append(inc("imageOrLsg/imageOrLsg")(o).css({ position: "absolute", left: 0, top: 0, width: "100%", height: "100%", backgroundColor: "white" })); }; })(); trainers/memory/cards/card/memoryCard/cardFaces/imageOrLsg/imageOrLsg.ls (function(){ return function(o){ if (o.image != null) { return inc("/shared/image/image")({ image: o.image, slide: o.slide }); } else if (o.lsg != null) { return inc("/shared/lsg/lsg")({ lsg: o.lsg, slide: o.slide }); } }; })(); trainers/memory/cards/card/memoryCard/cardFaces/imageText.ls (function(){ return function(o){ var div; return div = Div({ position: "relative", left: 0, top: 0, width: "100%", height: "100%", overflow: "hidden", backgroundColor: "white", pointerEvents: "none" }).html(inc("imageOrLsg/imageOrLsg")(o).css({ position: "absolute", left: 0, top: 0, width: "100%", height: "100%", backgroundColor: "white" }), Div({ display: "inline-flex", position: "absolute", left: 0, bottom: 0, width: "100%", backgroundColor: "rgba(255, 255, 255, 0.7)" }).css(inc("_calcTextCss/calc")(o.slide)).addClass("currentAtomText").html(Span().secureHtml(o.text))); }; })(); trainers/memory/cards/card/memoryCard/cardFaces/text.ls (function(){ return function(o){ return Div({ display: "flex", width: "100%", height: "100%", backgroundColor: Color.grey[150], pointerEvents: "none" }).html(Div({ display: "inline-flex", maxWidth: "100%" }).css(inc("_calcTextCss/calc")(o.slide)).html(Span().addClass("currentAtomText").secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(o.text) : o.text))); }; })(); trainers/memory/cards/card/wideCard/adjustHeight/adjust.ls (function(){ return function(h, div, frontFace, backFace){ div.css({ height: (h + 12) + "px" }); div.front.css({ height: h + "px", bottom: "6px" }); div.back.css({ height: h + "px", bottom: "6px" }); if (typeof frontFace.adjustHeight == 'function') { frontFace.adjustHeight(h); } return typeof backFace.adjustHeight == 'function' ? backFace.adjustHeight(h) : void 8; }; })(); trainers/memory/cards/card/wideCard/animations/tap.ls (function(){ return function(frontFace){ return { up: function(){ return frontFace.setBoxShadow("2px 3px 7px 1px rgba(0,0,0,0.2)", 500); }, cancel: function(){ return frontFace.setBoxShadow("2px 3px 7px 1px rgba(0,0,0,0.2)", 200); }, down: function(){ return frontFace.setBoxShadow("2px 3px 9px 3px rgba(0,0,0,0.2)", 0); } }; }; })(); trainers/memory/cards/card/wideCard/card.ls (function(){ return function(o){ var flipSpeed, div, faceCss, cardFace, inner, frontFace, backFace; flipSpeed = 500; div = Div(); faceCss = function(front){ return { position: "absolute", left: "6px", top: "6px", right: "6px", minHeight: "5em", transform: "rotateY(" + (front ? 0 : -180) + "deg)", backfaceVisibility: "hidden", webkitBackfaceVisibility: "hidden" }; }; cardFace = function(image, lsg, textB, textA, textC){ if (image || lsg) { if (textC || textB) { return inc("cardFaces/imageText")({ image: image, lsg: lsg, text: textC || textB, slide: o.slide }); } else { return inc("cardFaces/image")({ image: image, lsg: lsg, slide: o.slide }); } } else { if (textC) { return inc("cardFaces/text")({ text: textC, slide: o.slide }); } else if (textA && textB) { return inc("cardFaces/doubleText")({ text1: textA, text2: textB, slide: o.slide }); } else { return inc("cardFaces/text")({ text: textB, slide: o.slide }); } } }; div.css({ display: "block", width: "20em", maxWidth: "90%", minHeight: "4em", margin: "0.5em auto", backgroundColor: "transparent", perspective: "1000px" }).html(inner = Div({ width: "100%", height: "100%", transition: "transform 0.8s", transformStyle: "preserve-3d" }).append(div.front = Div(faceCss(true)).append(frontFace = cardFace(o.frontImage, o.frontLsg, o.frontText))).append(div.back = Div(faceCss(false)).append(backFace = cardFace(o.backImage, o.backLsg, o.labelB, o.labelA, o.labelC)))).tap({ up: function(){ return o.onClick(div); }, animation: inc("animations/tap")(frontFace) }); div.correct = function(callback){ div.css({ pointerEvents: "none" }); if (typeof backFace.setBorderColor == 'function') { backFace.setBorderColor(Color.green[500], 0); } inner.css({ transform: "rotateY(-180deg)" }); return setTimeout(function(){ frontFace.setBoxShadow("0px 0px 3px rgba(0,0,0,0.2)", 0); backFace.setBoxShadow("0px 0px 3px rgba(0,0,0,0.2)", 0); if (typeof backFace.setBorderColor == 'function') { backFace.setBorderColor(Color.white, 500); } return typeof callback == 'function' ? callback() : void 8; }, flipSpeed); }; div.wrong = function(callback){ div.css({ pointerEvents: "none" }); if (typeof frontFace.setBorderColor == 'function') { frontFace.setBorderColor(Color.red[500], 100); } return setTimeout(function(){ if (typeof frontFace.setBorderColor == 'function') { frontFace.setBorderColor(Color.white, 500); } div.css({ pointerEvents: "" }); return typeof callback == 'function' ? callback() : void 8; }, flipSpeed); }; div.adjustHeight = function(h){ return inc("adjustHeight/adjust")(h, div, frontFace, backFace); }; return div; }; })(); trainers/memory/cards/card/wideCard/cardFaces/_calcTextCss/calc.ls (function(){ return function(slide){ var that; if (that = slide.getParam("textAlign")) { return { width: "100%", textAlign: that }; } }; })(); trainers/memory/cards/card/wideCard/cardFaces/calcSeperatorCss/calc.ls (function(){ return function(slide){ var ref$; return { borderBottom: "1px solid " + Color.grey[300], margin: "0.8em 0", width: (ref$ = slide.getParam("textAlign")) === "left" || ref$ === "right" ? "100%" : "70%" }; }; })(); trainers/memory/cards/card/wideCard/cardFaces/doubleText.ls (function(){ return function(o){ var textCss, div; textCss = inc("_calcTextCss/calc")(o.slide); div = Div({ display: "flex", padding: "0.5em", backgroundColor: Color.grey[150], flexDirection: "column", border: "6px solid white", height: "100%", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", pointerEvents: "none" }).html(Div(textCss).addClass("currentAtomText1").secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(o.text1) : o.text1), o.text1 != null && o.text2 != null ? Div(inc("calcSeperatorCss/calc")(o.slide)) : void 8, Div(textCss).secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(o.text2) : o.text2)); div.setBorderColor = function(color, duration){ return div.css({ borderColor: color + "", transition: "border " + duration + "ms" }); }; div.setBoxShadow = function(bShadow, transition){ return div.css({ boxShadow: bShadow + "", transition: "box-shadow " + transition + "ms" }); }; return div; }; })(); trainers/memory/cards/card/wideCard/cardFaces/image.ls (function(){ return function(o){ var div, image; div = Div({ display: "flex", height: "100%", width: "100%", pointerEvents: "none" }).append(image = inc("imageOrLsg/imageOrLsg")(o).css({ flex: "0 0 auto", minHeight: "5em", height: "5em", width: "100%", backgroundColor: "white", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)" })); div.adjustHeight = function(height){ return image.css({ height: height + "px", width: height + "px", border: "6px solid white", boxSizing: "border-box", webkitBoxSizing: "border-box" }); }; div.setBorderColor = function(color, duration){ return div.css({ borderColor: color + "", transition: "border " + duration + "ms" }); }; div.setBoxShadow = function(bShadow, transition){ return div.css({ boxShadow: bShadow + "", transition: "box-shadow " + transition + "ms" }); }; return div; }; })(); trainers/memory/cards/card/wideCard/cardFaces/imageOrLsg/imageOrLsg.ls (function(){ return function(o){ if (o.image != null) { return inc("/shared/image/image")({ image: o.image, slide: o.slide }); } else if (o.lsg != null) { return inc("/shared/lsg/lsg")({ lsg: o.lsg, slide: o.slide }); } }; })(); trainers/memory/cards/card/wideCard/cardFaces/imageText.ls (function(){ return function(o){ var div, image, text, ref$; div = Div({ position: "relative", display: "flex", width: "100%", height: "100%", overflow: "hidden", backgroundColor: "white", border: "6px solid white", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", pointerEvents: "none" }).html(image = inc("imageOrLsg/imageOrLsg")(o).css({ display: "inline-block", flex: "0 0 auto", width: "4.5em", height: "4.5em", marginRight: "6px", backgroundColor: "white" }), text = Div({ display: "inline-block", flex: "0 1 auto", width: "100%", padding: "0.2em 0.2em", backgroundColor: "white" }).css((ref$ = inc("_calcTextCss/calc")(o.slide)) != null ? ref$ : { textAlign: "left" }).addClass("currentAtomText").secureHtml(o.text)); div.setBorderColor = function(color, duration){ return div.css({ borderColor: color + "", transition: "border " + duration + "ms" }); }; div.setBoxShadow = function(bShadow, transition){ return div.css({ boxShadow: bShadow + "", transition: "box-shadow " + transition + "ms" }); }; return div; }; })(); trainers/memory/cards/card/wideCard/cardFaces/text.ls (function(){ return function(o){ var div; div = Div({ display: "flex", padding: "0.5em", height: "100%", backgroundColor: Color.grey[150], border: "6px solid white", boxShadow: "2px 3px 7px 1px rgba(0,0,0,0.2)", pointerEvents: "none" }).append(Div({ display: "inline-flex", maxWidth: "100%" }).html(Span(inc("_calcTextCss/calc")(o.slide)).addClass("currentAtomText").secureHtml(o.slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(o.text) : o.text))); div.setBorderColor = function(color, duration){ return div.css({ borderColor: color + "", transition: "border " + duration + "ms" }); }; div.setBoxShadow = function(bShadow, transition){ return div.css({ boxShadow: bShadow + "", transition: "box-shadow " + transition + "ms" }); }; return div; }; })(); trainers/memory/cards/cards.ls (function(){ return function(slide){ var atoms, chooseMode, checkCorrect, click, playSoundB, finish, enableCards, useWideCards, ref$, div, cards, i, atom; atoms = slide.getParam("shuffleButtons") === false ? slide.atoms : _.shuffleWithSeed(slide.atoms); chooseMode = slide.getParam("chooseMode"); checkCorrect = function(atom){ if (chooseMode === "text") { return atom.b === slide.currentAtom.b; } else if (chooseMode === "image") { return atom === slide.currentAtom; } }; click = function(card){ var atom, i$, ref$, len$, c, that, ref1$; atom = atoms[card.tag]; if (checkCorrect(atom)) { for (i$ = 0, len$ = (ref$ = cards).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ pointerEvents: "none" }); } if (atom !== slide.currentAtom) { if (that = slide.currentAtom.c) { if ((ref$ = card.back.findFirst(".currentAtomText")) != null) { ref$.secureHtml(that); } } else if (that = slide.currentAtom.a) { if ((ref1$ = card.back.findFirst(".currentAtomText1")) != null) { ref1$.secureHtml(that); } } } card.correct(); card.solved = true; slide.lastSolvedAtom = atom; slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.currentAtom); playSoundB(function(){ var ref$; if ((ref$ = slide.currentSound) != null) { ref$.stop(); } return slide.score.log(slide.currentAtom, finish); }); } else { slide.score.addActionMistake(slide.currentAtom, { atom: atom }); slide.levelPlayer.progressBar.addElement().showRed(); card.wrong(); } return false; }; playSoundB = inc("playSoundB/play")(slide, atom); finish = function(){ slide.header.finish(); slide.startNext(); return enableCards(); }; enableCards = function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = cards).length; i$ < len$; ++i$) { c = ref$[i$]; if (!c.solved) { results$.push(c.css({ pointerEvents: "" })); } } return results$; }; useWideCards = (ref$ = slide.getParam("wideCards")) != null ? ref$ : false; slide.div.append(div = Div({ display: "inline-block", maxWidth: "95%", marginTop: "0.5em", marginBottom: "0.75em" }).append(cards = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; results$.push(inc("card/card")(slide, atom, i, click)); } return results$; }()))); if (!useWideCards && slide.atoms.length === 4) { cards[1].after(document.createElement("br")); } if (useWideCards) { inc("adjustWideCardHeight/adjust")(cards); } return div; }; })(); trainers/memory/cards/playSoundB/play.ls (function(){ return function(slide, atom){ var p; p = slide.getParam; return function(onDone){ var atom, text, ref$; atom = slide.currentAtom; text = atom.soundB || atom.sound || atom.b; if (text && ((ref$ = p("soundMode", atom)) === "b" || ref$ === "ab")) { return setTimeout(function(){ var ref$, ref1$, voice, ref2$, voiceLang, sound; if ((ref$ = slide.currentSound) != null) { ref$.stop(); } if ((ref1$ = slide.currentSoundA) != null) { ref1$.stop(); } voice = (ref2$ = p("voiceB", atom)) != null ? ref2$ : p("voice", atom); voiceLang = (ref2$ = p("voiceLangB", atom)) != null ? ref2$ : p("voiceLang", atom); sound = slide.sounds[text + voice + voiceLang]; sound.play(onDone); return slide.currentSound = sound; }, 300); } else { return setTimeout(onDone, 500); } }; }; })(); trainers/memory/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, chunks, i$, len$, chunk, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slides = []; chunks = _.chunk(atoms, 4); if (chunks.length > 1 && _.last(chunks).length === 1) { chunks[chunks.length - 1].unshift(chunks[chunks.length - 2].pop()); } for (i$ = 0, len$ = chunks.length; i$ < len$; ++i$) { chunk = chunks[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = chunk; slide.totalProgressElements = chunk.length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; slides.push(slide); } return slides; }; })(); trainers/memory/header/header.ls (function(){ return function(slide){ var div; Div({ width: "100%" }).html(div = slide.getParam("soundMode") === "askSound" ? inc("headerSound/headerSound")(slide) : inc("headerText/headerText")(slide)).appendTo(slide.div); return div; }; })(); trainers/memory/header/headerSound/headerSound.ls (function(){ return function(slide){ var text, atom, play, start, finish, speaker; play = function(){ return setTimeout(function(){ var voice; voice = slide.getParam("voiceA", atom) || slide.getParam("voice", atom); return speaker.play(text + voice); }, 500); }; start = function(){ atom = slide.currentAtom; text = atom.soundA || atom.sound || atom.a; if (!text) { speaker.hide(); return; } speaker.show().css({ opacity: 1, transition: "150ms opacity" }); return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: play }); }; finish = function(){ return speaker.css({ opacity: 0 }); }; speaker = inc("/shared/askSound/ask")(slide.sounds); speaker.start = start; speaker.finish = finish; return speaker; }; })(); trainers/memory/header/headerText/finish/finish.ls (function(){ return function(div){ return function(){ return div.css({ opacity: 0, transition: "" }); }; }; })(); trainers/memory/header/headerText/headerText.ls (function(){ return function(slide){ var div, ref$; div = Div({ display: "inline-flex", maxWidth: "35em", textAlign: (ref$ = slide.getParam("textAlign")) != null ? ref$ : "center", opacity: 0, padding: !slide.getParam("instruction") ? "1.4em 1em 0.4em" : "0 1em 0.4em" }).html(" "); div.start = inc("start/start")(slide, div); div.finish = inc("finish/finish")(div); return div; }; })(); trainers/memory/header/headerText/start/playSound/play.ls (function(){ return function(slide, atom){ return function(){ var p, ref$, text, voice, sound; p = slide.getParam; if ((ref$ = p("soundMode", atom)) !== "a" && ref$ !== "ab") { return; } if (atom !== slide.currentAtom) { return; } if (atom === slide.lastSolvedAtom) { return; } text = atom.soundA || atom.sound || atom.a; voice = (ref$ = p("voiceA", atom)) != null ? ref$ : p("voice", atom); sound = slide.sounds[text + voice]; if ((ref$ = slide.currentSoundA) != null) { ref$.stop(); } slide.currentSoundA = sound; return sound.play(); }; }; })(); trainers/memory/header/headerText/start/start.ls (function(){ return function(slide, div){ return function(){ var atom; atom = slide.currentAtom; if (!atom.a) { div.hide(); } else { div.show().secureHtml(Span().html(slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(atom.a) : atom.a)); } return setTimeout(function(){ div.css({ opacity: 1, transition: "opacity 500ms" }); return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: inc("playSound/play")(slide, atom) }); }, 500); }; }; })(); trainers/memory/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.elementsLeft = []; slide.elementsRight = []; slide.cardWidth = inc("calcCardWidth/calc")(); slide.instruction = inc("instruction/instruction")(slide); slide.header = inc("header/header")(slide); slide.cards = inc("cards/cards")(slide); return slide.startNext = inc("startNext/start")(slide); }; })(); trainers/memory/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/memory/startNext/start.ls (function(){ return function(slide){ return function(){ var atom, ref$; slide.currentIndex++; atom = slide.atoms[slide.currentIndex]; slide.cards.css({ pointerEvents: "" }); if (atom) { if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, atom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, atom); } slide.currentAtom = atom; return slide.header.start(); } else { slide.cards.css({ paddingBottom: "" }); slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 1000); } }; }; })(); trainers/multipleChoice/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/multipleChoice/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/multipleChoice/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, choices, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { choices = inc("/shared/convertPlusPlusArray/convert")(slide.atom.b); choices = _.filter(choices, { correct: true }); texts = _.map(choices, function(c){ return c.text; }); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: slide.getParam("voice", slide.atom), voiceLang: slide.getParam("voiceLang", slide.atom) }); } } return sounds; }; })(); trainers/multipleChoice/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/multipleChoice/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, choices, i$, ref$, len$, i, action, lresult$, j$, ref1$, len1$, ac, choice, results$ = []; scoreEvent = slide.score.getScoreEvent(slide.atom); slide.div.findFirst(".choicesSubmitButton").hide(); choices = slide.choices.choices; if (scoreEvent) { for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; lresult$ = []; for (j$ = 0, len1$ = (ref1$ = action.choices).length; j$ < len1$; ++j$) { ac = ref1$[j$]; choice = _.find(choices, fn$); if (ac.selected) { choice.iconCheckOn.show(); choice.iconCheckOff.hide(); } else { choice.iconCheckOff.show(); choice.iconCheckOn.hide(); } if (ac.correct) { if (ac.selected) { choice.iconCheckOn.setColor(Color.green[500]); } } else { if (ac.selected) { choice.iconCheckOn.setColor(Color.red[500]); } else { choice.iconCheckOff.setColor(Color.red[500]); } } } for (j$ = 0, len1$ = choices.length; j$ < len1$; ++j$) { choice = choices[j$]; lresult$.push(choice.showSolution("review")); } results$.push(lresult$); } return results$; } function fn$(c){ return c.label === ac.text; } }; })(); trainers/multipleChoice/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.choices, { padding: 20 }); }); }; })(); trainers/multipleChoice/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).appendTo(slide.wrapper); }; })(); trainers/multipleChoice/calcChoices/calc.ls (function(){ return function(slide){ var sounds; sounds = inc("/shared/convertPlusPlusArray/convert")(slide.atom.b); sounds = _.filter(sounds, { correct: true }); return sounds = _.map(sounds, function(c){ return c.text; }); }; })(); trainers/multipleChoice/choices/choices.ls (function(){ return function(slide){ var actions, finish, onSubmit, onAction, choices, ref$, div; actions = []; finish = function(){ slide.finish(); return slide.div.css({ pointerEvents: "none" }); }; onSubmit = function(correct){ var texts; if (correct) { slide.score.addActionCorrect(slide.atom, { choices: actions }); slide.levelPlayer.progressBar.showGreen(); } else { slide.score.addActionMistake(slide.atom, { choices: actions }); slide.levelPlayer.progressBar.showRed(); } slide.score.log(slide.atom); if (slide.getParam("soundMode", slide.atom) === "b") { if (slide.atom.sound) { return setTimeout(function(){ var voice, text; voice = slide.getParam("voice", slide.atom); text = slide.atom.sound; return slide.sounds[text + voice].play(); }, 300); } else { texts = inc("../calcChoices/calc")(slide); return inc("../playAllChoices/play")(slide, texts); } } }; onAction = function(action){ return actions.push(action); }; choices = inc("/shared/convertPlusPlusArray/convert")(slide.atom.b); if ((ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : false) { choices = _.shuffleWithSeed(choices); } slide.wrapper.append(div = inc("/shared/choices/choices")({ choices: choices, onFinish: finish, onSubmit: onSubmit, onActionCorrect: onAction, onActionMistake: onAction })); return div; }; })(); trainers/multipleChoice/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/multipleChoice/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.wrapper, wrapWithDiv: true }).appendTo(slide.wrapper); }; })(); trainers/multipleChoice/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.wrapper = inc("wrapper/wrapper")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); return slide.choices = inc("choices/choices")(slide); }; })(); trainers/multipleChoice/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/multipleChoice/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.wrapper, wrapWithDiv: true })) != null ? ref$.appendTo(slide.wrapper) : void 8; }; })(); trainers/multipleChoice/playAllChoices/play.ls (function(){ return function(slide, texts){ var voice, i, playAll; voice = slide.getParam("voice", slide.atom); i = 0; playAll = function(){ return setTimeout(function(){ var text; text = texts[i]; if (text) { slide.sounds[text + voice].play(function(){ return playAll(); }); return i++; } }, 500); }; return playAll(); }; })(); trainers/multipleChoice/textA/tap/tap.ls (function(){ return function(slide){ return function(){ var text, voice; text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); }; }; })(); trainers/multipleChoice/textA/text.ls (function(){ return function(slide){ var soundMode, div; if (!slide.atom.a) { return; } soundMode = slide.getParam("soundMode", slide.atom); if (soundMode === "askSound") { return; } Div().html(div = Div({ padding: "0.5em 1em", display: "inline-block", textAlign: slide.getParam("textAlign", slide.atom) || "center" }).html(slide.atom.a).tap(soundMode === "a" ? inc("tap/tap")(slide) : void 8)).appendTo(slide.wrapper); return div; }; })(); trainers/multipleChoice/wrapper/wrapper.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ display: "inline-block", width: "35em", maxWidth: "100%" })); return div; }; })(); trainers/multipleChoiceText/_media2/images/images.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom)); } return results$; }; })(); trainers/multipleChoiceText/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var i$, ref$, len$, atom, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom)); } return results$; }; })(); trainers/multipleChoiceText/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, soundMode, texts, texts2, j$, len1$, t, text; sounds = []; for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "a" && "b")).length; i$ < len$; ++i$) { atom = ref$[i$]; soundMode = slide.getParam("soundMode", atom); texts = []; if (atom.sound) { texts.push(atom.sound); } else if (soundMode === "a") { texts.push(atom.a); } else if (soundMode === "b") { texts2 = inc("/shared/convertPlusPlusArray/convert")(atom.b); texts2 = _.filter(texts2, { correct: true }); texts2 = _.map(texts2, fn$); for (j$ = 0, len1$ = texts2.length; j$ < len1$; ++j$) { t = texts2[j$]; texts.push(t); } } for (j$ = 0, len1$ = texts.length; j$ < len1$; ++j$) { t = texts[j$]; if (t != null) { sounds.push({ text: t, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } } for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "text")).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.sound || atom.speaker) { text = atom.sound || atom.text; text = _.replaceAll(text, "\n", " "); sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } for (i$ = 0, len$ = (ref$ = _.filter(slide.atoms, "example")).length; i$ < len$; ++i$) { atom = ref$[i$]; if (atom.example.sound) { text = atom.example.sound; text = _.replaceAll(text, "\n", " "); sounds.push({ text: text, voiceLang: slide.getParam("voiceLang", atom), voice: slide.getParam("voice", atom) }); } } return sounds; function fn$(c){ return c.text; } }; })(); trainers/multipleChoiceText/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = slide.content.childrenAll()).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.show()); } return results$; }; })(); trainers/multipleChoiceText/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, choicesDivs, choiceDiv, lresult$, action, b, ac, choice, results$ = []; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; actions.push(a); } } if (actions.length > 0) { choicesDivs = slide.div.find(".choicesDiv"); for (i$ = 0, len$ = choicesDivs.length; i$ < len$; ++i$) { choiceDiv = choicesDivs[i$]; lresult$ = []; action = _.find(actions, fn$); for (j$ = 0, len1$ = (ref$ = choiceDiv.findAll(".choicesContinueButton,.choicesSubmitButton")).length; j$ < len1$; ++j$) { b = ref$[j$]; b.remove(); } if ((action != null ? action.choices : void 8) == null) { continue; } for (j$ = 0, len1$ = (ref$ = action.choices).length; j$ < len1$; ++j$) { ac = ref$[j$]; choice = _.find(choiceDiv.choices, fn1$); if (ac.selected) { choice.iconCheckOn.show(); choice.iconCheckOff.hide(); } else { choice.iconCheckOff.show(); choice.iconCheckOn.hide(); } if (ac.correct) { if (ac.selected) { choice.iconCheckOn.setColor(Color.green[500]); } } else { if (ac.selected) { choice.iconCheckOn.setColor(Color.red[500]); } else { choice.iconCheckOff.setColor(Color.red[500]); } } } for (j$ = 0, len1$ = (ref$ = choiceDiv.choices).length; j$ < len1$; ++j$) { choice = ref$[j$]; lresult$.push(choice.showSolution("review")); } results$.push(lresult$); } return results$; } function fn$(a){ return a.scoreEvent === slide.score.getScoreEvent(choiceDiv.atom); } function fn1$(c){ return c.label === ac.text; } }; })(); trainers/multipleChoiceText/_skip/skip.ls (function(){ return function(slide){ slide.interactionStarted = true; if (slide.currentElement == null) { return slide.onFinishedSlide(); } if (slide.currentElement.atom.b) { slide.levelPlayer.progressBar.showGreen(); } slide.startNextElement(); return slide.levelPlayer.page.scrollElementIntoView(slide.currentElement.div, { padding: 20 }); }; })(); trainers/multipleChoiceText/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); return slide.startNextElement(); }; })(); trainers/multipleChoiceText/content/content.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ display: "inline-block", width: "40em", maxWidth: "90%", margin: "0 1em" })); return div; }; })(); trainers/multipleChoiceText/continueButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ var ref$; slide.userInteractionStarted = true; div.hide(); if ((ref$ = slide.currentSound) != null) { ref$.stop(); } return slide.startNextElement(); }; return div = Button({ label: T("continueButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "1.5em 0" }).addClass("keyManager-enter").bind("keyManager", click).tap(click); }; })(); trainers/multipleChoiceText/elements/element/choices/calcChoices/calc.ls (function(){ return function(slide){ var atom, sounds; atom = slide.atoms[slide.currentIndex]; sounds = inc("/shared/convertPlusPlusArray/convert")(atom.b); sounds = _.filter(sounds, { correct: true }); return sounds = _.map(sounds, function(c){ return c.text; }); }; })(); trainers/multipleChoiceText/elements/element/choices/choices.ls (function(){ return function(atom, i, slide){ var actions, start, onFinish, onSubmit, onAction, choices, ref$, div; actions = []; start = function(){ div.hide(); div.fadeIn(800); return inc("playSoundA/play")(atom, slide, choices); }; onFinish = function(score){ var i$, ref$, len$, s; for (i$ = 0, len$ = (ref$ = slide.div.find("span")).length; i$ < len$; ++i$) { s = ref$[i$]; s.css({ backgroundColor: "" }); } if (slide.currentIndex + 1 !== slide.elements.length) { div.remove(); } return slide.startNextElement(); }; onSubmit = function(correct){ var ref$, texts; if (correct) { slide.score.addActionCorrect(atom, { choices: actions }); slide.levelPlayer.progressBar.showGreen(); } else { slide.score.addActionMistake(atom, { choices: actions }); slide.levelPlayer.progressBar.showRed(); } if ((ref$ = slide.currentSound) != null) { ref$.stop(); } slide.score.log(atom); if (atom.highlightSpanClass != null) { inc("pulseHighlight/pulse")(slide, i, atom); } if (slide.getParam("soundMode", atom) === "b") { if (atom.sound) { return setTimeout(function(){ var voice; voice = slide.getParam("voice", atom); return slide.sounds[atom.sound + voice].play(); }, 300); } else { texts = inc("calcChoices/calc")(slide); return inc("playAllChoices/play")(slide, texts); } } }; onAction = function(action){ return actions.push(action); }; choices = inc("/shared/convertPlusPlusArray/convert")(atom.b); if ((ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : false) { choices = _.shuffleWithSeed(choices); } slide.content.append(div = Div({ paddingTop: "0.4em", textAlign: "center" }).addClass("choicesWrapper").append(atom.a ? Div({ padding: "1.2em 0 0.8em", textAlign: "center", margin: 0, fontStyle: "italic", color: Color.grey[650] }).html(atom.a) : void 8, choices = inc("/shared/choices/choices")({ choices: choices, onFinish: onFinish, onSubmit: onSubmit, onActionCorrect: onAction, onActionMistake: onAction }).addClass("choicesDiv")).hide()); choices.atom = atom; return { start: start, atom: atom, div: div }; }; })(); trainers/multipleChoiceText/elements/element/choices/playAllChoices/play.ls (function(){ return function(slide, texts){ var voice, i, playAll; voice = slide.getParam("voice", slide.atoms[slide.currentIndex]); i = 0; playAll = function(){ return setTimeout(function(){ var text; text = texts[i]; if (text) { slide.sounds[text + voice].play(function(){ return playAll(); }); return i++; } }, 500); }; return playAll(); }; })(); trainers/multipleChoiceText/elements/element/choices/playSoundA/play.ls (function(){ return function(atom, slide, choices){ var scroll, play; scroll = function(){ return slide.levelPlayer.page.scrollElementIntoView(choices, { padding: 20 }); }; play = function(){ var text, voice, ref$; if (slide.getParam("soundMode", atom) !== "a") { scroll(); return; } text = atom.sound || atom.a; voice = slide.getParam("voice", atom); if ((ref$ = slide.currentSound) != null) { ref$.stop(); } slide.currentSound = slide.sounds[text + voice]; return slide.currentSound.play(); }; return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: play }); }; })(); trainers/multipleChoiceText/elements/element/choices/pulseHighlight/pulse.ls (function(){ return function(slide, i, atom){ var texts, i$, j, el, c1, c2, d1, d2, delay, classId, len$, t, results$ = []; texts = []; for (i$ = i - 1; i$ >= 0; --i$) { j = i$; el = slide.elements[j]; if (el.atom.b && texts.length > 0) { break; } if (el.atom.text || el.atom.example) { texts.push(el.div); } } c1 = Color.amber[200]; c2 = Color.amber[75]; d1 = 300; d2 = 300; delay = 300; classId = atom.highlightSpanClass; for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { t = texts[i$]; results$.push(_.forEach(t.findAll("span." + classId), fn$)); } return results$; function fn$(s, j){ if (j === 0) { slide.levelPlayer.page.scrollElementIntoView(s, { padding: 20 }); } s.css({ backgroundColor: c1, transition: d1 + "ms background" }); return setTimeout(function(){ s.css({ backgroundColor: c2, transition: d2 + "ms background" }); return setTimeout(function(){ return s.css({ transition: "" }); }, delay); }, delay); } }; })(); trainers/multipleChoiceText/elements/element/element.ls (function(){ return function(atom, i, slide){ if (atom.title) { return inc("title/title")(atom, i, slide); } else if (atom.text) { return inc("text/text")(atom, i, slide); } else if (atom.example) { return inc("example/example")(atom, i, slide); } else if (atom.image) { return inc("image/image")(atom, i, slide); } else if (atom.lsg) { return inc("lsg/lsg")(atom, i, slide); } else if (atom.b) { return inc("choices/choices")(atom, i, slide); } else { debug("Atom-Typ " + _.keys(atom)[0] + " wird nicht unterstützt"); return null; } }; })(); trainers/multipleChoiceText/elements/element/example/example.ls (function(){ return function(atom, i, slide){ var click, play, start, div, speaker, textA, textB; slide.currentSound = null; click = function(){ var ref$; if ((ref$ = slide.currentSound) != null && (typeof ref$.isPlaying == 'function' && ref$.isPlaying())) { slide.currentSound.stop(); if (slide.currentSound !== speaker) { return play(); } } else { return play(); } }; play = function(){ var voice; slide.currentSound = speaker; voice = slide.getParam("voice", atom); return speaker.play(atom.example.sound + voice); }; start = function(){ if (atom.example.autoplay) { slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: click }); } div.hide(); div.fadeIn(); if (slide.getParam("continueButton", atom) === false) { return slide.startNextElement(); } else { div.after(slide.continueButton.show()); return requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.continueButton, { padding: 20 }); }); } }; slide.content.append(div = Div({ margin: "0.5em 0", padding: "0.8em", backgroundColor: Color.grey[200], textAlign: "left" }).append(atom.example.sound ? speaker = inc("speaker/speaker")(slide) : void 8, textA = inc("textA/textA")(slide, atom), textB = inc("textB/textB")(slide, atom)).hide()); if (atom.example.sound) { div.css({ paddingLeft: "2.2em", cursor: "pointer" }).addClass("speakerClickDiv").tap(click); } return { start: start, atom: atom, div: div }; }; })(); trainers/multipleChoiceText/elements/element/example/speaker/speaker.ls (function(){ return function(slide){ var sounds, currentSound, isPlaying, play, stop, div; sounds = slide.sounds; currentSound = null; isPlaying = false; play = function(newText, onDone){ if (!isPlaying) { isPlaying = true; currentSound = sounds[newText]; return currentSound.play(function(){ return isPlaying = false; }, div.update); } }; stop = function(){ div.reset(); currentSound.stop(); return isPlaying = false; }; div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: "1.2em", outline: true }).css({ position: "absolute", top: "0.85em", left: "0.65em", pointerEvents: "none" }); div.play = play; div.stop = stop; div.isPlaying = function(){ return isPlaying; }; return div; }; })(); trainers/multipleChoiceText/elements/element/example/textA/textA.ls (function(){ return function(slide, atom){ var label; label = atom.example.a || " "; return Div().html(label); }; })(); trainers/multipleChoiceText/elements/element/example/textB/textB.ls (function(){ return function(slide, atom){ if (!atom.example.b) { return; } return Div({ paddingTop: "0.3em", fontStyle: "italic", color: Color.grey[650] }).html(atom.example.b); }; })(); trainers/multipleChoiceText/elements/element/image/image.ls (function(){ return function(atom, i, slide){ var image, start, div; image = slide.getParam("image", atom); start = function(){ if (image) { div.hide().fadeIn(); slide.curDiv = image; return slide.startNextElement(); } }; if (image) { div = inc("/shared/image/image")({ image: image, slide: slide, parent: slide.content, wrapWithDiv: true }).hide().appendTo(slide.content); } return { start: start, atom: atom, div: div }; }; })(); trainers/multipleChoiceText/elements/element/lsg/lsg.ls (function(){ return function(atom, i, slide){ var start, lsg, div, ref$; start = function(){ if (div) { div.hide().fadeIn(); slide.curDiv = div; return slide.startNextElement(); } }; lsg = slide.getParam("lsg", atom); if (lsg) { div = (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.content, wrapWithDiv: true })) != null ? ref$.appendTo(slide.content).hide() : void 8; } return { start: start, atom: atom, div: div }; }; })(); trainers/multipleChoiceText/elements/element/text/sound/sound.ls (function(){ return function(slide){ var sounds, currentSound, isPlaying, play, stop, div; sounds = slide.sounds; currentSound = null; isPlaying = false; play = function(newText, onDone){ if (!isPlaying) { isPlaying = true; currentSound = sounds[newText]; return currentSound.play(function(){ return isPlaying = false; }, div.update); } }; stop = function(){ div.reset(); currentSound.stop(); return isPlaying = false; }; div = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ speakerType: "123", size: "1.2em", outline: true }).css({ verticalAlign: "-0.15em", marginRight: "0.2em", pointerEvents: "none" }); div.play = play; div.stop = stop; div.isPlaying = function(){ return isPlaying; }; return div; }; })(); trainers/multipleChoiceText/elements/element/text/text.ls (function(){ return function(atom, i, slide){ var voice, text, soundText, click, play, start, div, div2, sound; slide.currentSound = null; voice = null; text = atom.text; text = _.replaceAll(text, "\n", " "); soundText = atom.sound || text; click = function(){ var ref$; voice = slide.getParam("voice", atom); if ((ref$ = slide.currentSound) != null && (typeof ref$.isPlaying == 'function' && ref$.isPlaying())) { slide.currentSound.stop(); if (slide.currentSound !== sound) { return play(); } } else { return play(); } }; play = function(){ slide.currentSound = sound; return sound.play(soundText + voice); }; start = function(){ div.hide(); div.fadeIn(800); slide.curDiv = div; if (slide.getParam("continueButton", atom) === false) { slide.startNextElement(); } else { div.after(slide.continueButton.show()); requestAnimationFrame(function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.continueButton, { padding: 20 }); }); } if (atom.autoplay) { return slide.instruction.waitFirstPlayCompleted({ category: "sound", callback: click }); } }; div = Div({ margin: "0 auto", paddingTop: "0.4em", textAlign: slide.getParam("textAlign") || "center" }).addClass("text").html(div2 = Div({ display: "inline-block", textAlign: "left" }).html(atom.text)).appendTo(slide.content).hide(); if (atom.speaker || atom.sound) { div2.prepend(sound = inc("sound/sound")(slide)).tap({ up: click, animation: "none" }); } return { start: start, atom: atom, div: div }; }; })(); trainers/multipleChoiceText/elements/element/title/title.ls (function(){ return function(atom, i, slide){ var start, div; start = function(){ div.hide(); div.fadeIn(800); return slide.startNextElement(); }; slide.content.append(div = Div({ paddingTop: "0.6em", fontSize: "1.3em" }).html(atom.title).hide()); return { start: start, atom: atom, div: div }; }; })(); trainers/multipleChoiceText/elements/elements.ls (function(){ return function(slide){ var elements, res$, i$, ref$, len$, i, atom; res$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { i = i$; atom = ref$[i$]; res$.push(inc("element/element")(atom, i, slide)); } elements = res$; return elements = _.filter(elements, function(e){ return e; }); }; })(); trainers/multipleChoiceText/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; slide.totalProgressElements = _.filter(atoms, "b").length; slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : false; return slide; }; })(); trainers/multipleChoiceText/init.ls (function(){ return function(slide){ slide.currentIndex = -1; slide.continueButton = inc("continueButton/button")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.content = inc("content/content")(slide); slide.elements = inc("elements/elements")(slide); return slide.startNextElement = function(){ return inc("startNextElement/start")(slide); }; }; })(); trainers/multipleChoiceText/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/multipleChoiceText/startNextElement/start.ls (function(){ return function(slide){ var currentElement, currentAtom, ref$; slide.currentIndex++; if (slide.currentIndex === 0) { slide.levelPlayer.page.enableFreezeMinHeight(); } if (slide.currentIndex === slide.elements.length) { slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); } else { currentElement = slide.elements[slide.currentIndex]; slide.currentElement = currentElement; currentAtom = slide.atoms[slide.currentIndex]; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, currentAtom); } if (typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function') { ref$.setCalculator(slide, currentAtom); } currentElement.start(); if (slide.userInteractionStarted) { return slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return slide.levelPlayer.page.scrollElementIntoView(currentElement.div, { padding: 20 }); } }); } } }; })(); trainers/selectFrom100/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { debug("no soundMode b"); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/selectFrom100/_preview/preview.ls (function(){ return function(slide){ var ref$; if ((ref$ = slide.debugTrigger) != null) { ref$.remove(); } return slide.interactive.init(slide.getParam("init", slide.atom)); }; })(); trainers/selectFrom100/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, interactive, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.interactive.remove(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; interactive = inc("../../interactive/interactive")(slide); interactive.init(slide.getParam("init")); if (a.resolved) { interactive.solve(); } else { interactive.set(a.selectedValues); } results$.push(slide.div.append(Div({ margin: "3em 0" }).append(interactive, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))))); } return results$; } }; })(); trainers/selectFrom100/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/selectFrom100/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/selectFrom100/_start/start.ls (function(){ return function(slide){ var ref$; slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); slide.interactive.init(slide.getParam("init", slide.atom)); return typeof (ref$ = slide.interactive).onReady == 'function' ? ref$.onReady() : void 8; }; })(); trainers/selectFrom100/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/selectFrom100/buttons/buttons.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ margin: "1em 0" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.clearButton = inc("clearButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide))); return div; }; })(); trainers/selectFrom100/buttons/checkButton/button.ls (function(){ return function(slide){ var click; click = function(button){ var result; slide.buttons.css({ pointerEvents: "none" }); result = slide.interactive.validate(); if (result.isCorrect) { slide.score.addActionCorrect(slide.atom, { selectedValues: result.selected }); slide.score.log(slide.atom); button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); return setTimeout(slide.finish, 1000); } else { slide.score.addActionMistake(slide.atom, { selectedValues: result.selected }); button.setState("wrong"); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ button.setState("normal"); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } return slide.buttons.css({ pointerEvents: "" }); }, 500); } }; return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/selectFrom100/buttons/clearButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ return slide.interactive.clear(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/bin.svg"), action: click }).css({ margin: "0.5em" }); }; })(); trainers/selectFrom100/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/selectFrom100/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ slide.buttons.css({ pointerEvents: "none" }); slide.interactive.css({ pointerEvents: "none" }); slide.interactive.solve(); slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom); slide.score.log(slide.atom); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); slide.clearButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); return slide.buttons.css({ pointerEvents: "" }); }, 500); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/selectFrom100/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/selectFrom100/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); slide.interactive = inc("interactive/interactive")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/selectFrom100/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/selectFrom100/interactive/cell/cell.ls (function(){ return function(parent, cells, i){ var selected, triggered, disabled, start, down, up, click, changeValue, div; selected = false; triggered = false; disabled = false; start = function(){ return div.bind("mouseenter", function(e){ if (parent.mouseDown) { return changeValue(); } }).bind("touchmove", function(e){ var x, ref$, y, ref1$, div; e.preventDefault(); x = (ref$ = e.touches) != null ? ref$[0].pageX : void 8; y = (ref1$ = e.touches) != null ? ref1$[0].pageY : void 8; div = document.elementFromPoint(x, y); if (div != null && div.hasClass("cell")) { if (!div.isTriggered()) { div.changeValue(); return div.setTriggered(true); } } }).bind("touchend", function(e){ var i$, ref$, len$, c, results$ = []; up(); e.preventDefault(); for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.setTriggered(false)); } return results$; }).bind("mousedown touchstart", down).bind("mouseup", up); }; down = function(){ parent.mouseDown = true; return parent.selectMode = click(); }; up = function(){ return parent.mouseDown = false; }; click = function(){ if (!selected) { div.css({ backgroundColor: Color.blue[200] }); } else { div.css({ backgroundColor: 'white' }); } selected = !selected; return selected; }; changeValue = function(){ if (parent.selectMode) { div.css({ backgroundColor: Color.blue[200] }); } else { div.css({ backgroundColor: 'white' }); } if (parent.selectMode) { if (!selected) { return selected = !selected; } } else { if (selected) { return selected = !selected; } } }; div = Div().addClass("cell").css({ display: "inline-block", width: "10%", height: "10%", marginLeft: "-1px", marginTop: "-1px", border: "1px solid black", paddingTop: "0.2em", cursor: "pointer", backgroundClip: "border-box" }).html(Div({ pointerEvents: "none" }).html(i + 1)); div.isSelected = function(){ return selected; }; div.deselect = function(){ if (!disabled) { div.css({ backgroundColor: 'white' }); return selected = false; } }; div.select = function(){ if (!disabled) { div.css({ backgroundColor: Color.cyan[200] }); return selected = true; } }; div.disable = function(){ disabled = true; return div.css({ pointerEvents: "none", backgroundColor: Color.grey[300] }); }; div.isTriggered = function(){ return triggered; }; div.setTriggered = function(b){ return triggered = b; }; div.changeValue = changeValue; div.start = start; return div; }; })(); trainers/selectFrom100/interactive/interactive.ls (function(){ return function(slide){ var cells, mouseDown, selectMode, startValue, that, onReady, solve, init, set, clear, div, element, i, c; cells = []; mouseDown = false; selectMode = true; startValue = (that = slide.getParam("startValue")) ? that - 1 : 0; if (startValue > 901) { debug("startValue property cannot be > 901"); startValue = 900; } onReady = function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.start()); } return results$; }; solve = function(){ var solution, i$, len$, i; solution = _.ensureArray(slide.atom.b); clear(); for (i$ = 0, len$ = solution.length; i$ < len$; ++i$) { i = solution[i$]; cells[i - startValue - 1].select(); } return div.css({ pointerEvents: "none" }); }; init = function(vals){ var i$, ref$, len$, v, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = _.ensureArray(vals)).length; i$ < len$; ++i$) { v = ref$[i$]; results$.push((ref1$ = cells[v - startValue - 1]) != null ? ref1$.disable() : void 8); } return results$; }; set = function(vals){ var i$, len$, v, ref$, results$ = []; clear(); if (!vals) { return; } if (_.isString(vals)) { if (_.includes(vals, ",")) { vals = vals.split(","); } else { vals = vals.split(" "); } } for (i$ = 0, len$ = vals.length; i$ < len$; ++i$) { v = vals[i$]; results$.push((ref$ = cells[v - startValue - 1]) != null ? ref$.select() : void 8); } return results$; }; clear = function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.deselect()); } return results$; }; slide.div.append(div = Div().append(element = Div({ display: "inline-block", width: "20em", maxWidth: "95%", height: "20em" }))); element.append((function(){ var i$, to$, results$ = []; for (i$ = startValue, to$ = startValue + 99; i$ <= to$; ++i$) { i = i$; c = inc("cell/cell")(div, cells, i); cells.push(c); results$.push(c); } return results$; }())); div.onReady = onReady; div.cells = cells; div.selectMode = selectMode; div.set = set; div.init = init; div.solve = solve; div.clear = clear; div.validate = function(){ return inc("validate/validate")(slide, cells); }; return div; }; })(); trainers/selectFrom100/interactive/validate/validate.ls (function(){ return function(slide, cells){ var startValue, ref$, selected, res$, i$, len$, i, c, solution, isCorrect; startValue = (ref$ = slide.getParam("startValue")) != null ? ref$ : 1; res$ = []; for (i$ = 0, len$ = cells.length; i$ < len$; ++i$) { i = i$; c = cells[i$]; if (c.isSelected()) { res$.push(i + startValue); } } selected = res$; solution = _.ensureArray(slide.atom.b); isCorrect = _.isEqual(_.sortBy(solution), _.sortBy(selected)); return { isCorrect: isCorrect, selected: selected }; }; })(); trainers/selectFrom100/textA/text.ls (function(){ return function(slide){ var click, div; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } click = function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); } }; div = Div(); if (slide.atom.a) { slide.div.append(div.append(Div({ margin: "1em 0.5em", padding: "0 0.5em", display: "inline-block" }).html(slide.atom.a).tap(click))); } return div; }; })(); trainers/sentenceSlice/generateSlides.ls (function(){ return function(trainerParams, levelParams){ return inc("../wordSlice/generateSlides")(trainerParams, levelParams); }; })(); trainers/shapeMirror/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/shapeMirror/_preview/preview.ls (function(){ return function(slide){ slide.interactive.onReady(); return slide.interactive.init(); }; })(); trainers/shapeMirror/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, interactive, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (!e) { return; } slide.interactive.remove(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; interactive = inc("../../interactive/interactive")(slide); interactive.onReady(); interactive.init(); if (a.resolved) { interactive.validate(); interactive.set(slide.solutionPoints); } else { if (slide.drawMode === "points") { a.path.push(a.path[0]); } interactive.set(a.path); } results$.push(slide.div.append(Div({ margin: "3em 0" }).append(interactive, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))))); } return results$; }; })(); trainers/shapeMirror/_start/start.ls (function(){ return function(slide){ var ref$; slide.instruction.play(function(){ return inc('/shared/playAskSoundOrSoundA/play')(slide); }); if (typeof (ref$ = slide.interactive).onReady == 'function') { ref$.onReady(); } return slide.interactive.init(); }; })(); trainers/shapeMirror/buttons/buttons.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ margin: "1em 0" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.clearButton = inc("clearButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide))); return div; }; })(); trainers/shapeMirror/buttons/checkButton/button.ls (function(){ return function(slide){ var click; click = function(button){ var result; slide.buttons.css({ pointerEvents: "none" }); result = slide.interactive.validate(); if (result.isCorrect === true) { slide.score.addActionCorrect(slide.atom, { path: result.scorePath }); slide.score.log(slide.atom); button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 1000); } else { button.setState("wrong"); slide.score.addActionMistake(slide.atom, { path: result.scorePath }); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ button.setState("normal"); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } return slide.buttons.css({ pointerEvents: "" }); }, 500); } }; return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/shapeMirror/buttons/clearButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ return slide.interactive.clear(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/bin.svg"), action: click }).css({ margin: "0.5em" }); }; })(); trainers/shapeMirror/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/shapeMirror/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom); slide.score.log(slide.atom); slide.buttons.css({ pointerEvents: "none" }); slide.interactive.css({ pointerEvents: "none" }); slide.interactive.set(slide.solutionPoints); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); slide.clearButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); return slide.buttons.css({ pointerEvents: "" }); }, 500); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/shapeMirror/coordinatesButton/button.ls (function(){ return function(slide){ var debugCoordinates, div; if (!engine.isDebug) { return; } debugCoordinates = function(path){ var s, i$, len$, i, p; s = "b: ["; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { i = i$; p = path[i$]; s += "\"" + p.x + "," + p.y + "\""; if (path[i + 1]) { s += ", "; } } s += "]\n"; return debug(s); }; return div = Div({ position: "absolute", right: 0, bottom: "-1.5em", cursor: "pointer", color: Color.grey[300] }).addClass("levelDebugIcon").html("Debug: Show coordinates").tap(function(){ return debugCoordinates(_.map(slide.interactive.get(), function(p){ return { x: p.x, y: p.y }; })); }).appendTo(slide.interactive); }; })(); trainers/shapeMirror/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.drawMode = slide.getParam("drawMode") || "shape"; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/shapeMirror/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.textA = inc("textA/text")(slide); slide.interactive = inc("interactive/interactive")(slide); slide.coordinatesButton = inc("coordinatesButton/button")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/shapeMirror/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/shapeMirror/interactive/clickContainer/container.ls (function(){ return function(slide){ var lastDown, lastDownCrd, down, up, div, svg, drawer; lastDown = null; lastDownCrd = null; down = function(e){ lastDown = e; return lastDownCrd = inc("getCrd/get")(slide, div, e); }; up = function(e){ var downX, ref$, downY, upX, upY, xDiff, yDiff, crd; if (lastDown == null) { return; } downX = (ref$ = lastDown.pageX) != null ? ref$ : lastDown.touches[0].pageX; downY = (ref$ = lastDown.pageY) != null ? ref$ : lastDown.touches[0].pageY; upX = (ref$ = e.pageX) != null ? ref$ : e.touches[0].pageX; upY = (ref$ = e.pageY) != null ? ref$ : e.touches[0].pageY; xDiff = Math.abs(downX - upX); yDiff = Math.abs(downY - upY); crd = inc("getCrd/get")(slide, div, e); if (xDiff < 10 && yDiff < 10 && _.isEqual(lastDownCrd, crd)) { drawer.click(crd); } return lastDown = null; }; div = Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }).tap({ up: up, down: down, animation: "none" }).append(svg = inc("createSvg/create")(slide, "", true)); drawer = inc("drawer/drawer")(slide, div, svg); div.init = drawer.init; div.clear = drawer.clear; div.set = drawer.set; div.get = drawer.get; div.validate = drawer.validate; div.start = drawer.start; return div; }; })(); trainers/shapeMirror/interactive/clickContainer/createSvg/create.ls (function(){ return function(slide, path, isInitPath){ var makeSvg; makeSvg = inc("makeSvg/make"); return makeSvg('svg', { 'viewBox': "0 0 " + slide.gridSize + " " + slide.gridSize, 'preserve-aspect-ratio': 'none' }).css({ position: "absolute", top: 0, left: 0, overflow: "visible" }).append(makeSvg('path', { fill: slide.drawMode === "points" ? 'transparent' : isInitPath ? 'rgba(200, 200, 200, 0.4)' : 'rgba(200, 200, 255, 0.5)', stroke: 'black', 'stroke-width': "0.1", d: path })); }; })(); trainers/shapeMirror/interactive/clickContainer/createSvg/makeSvg/make.ls (function(){ return function(tag, attrs){ var element, a; element = document.createElementNS('http://www.w3.org/2000/svg', tag); for (a in attrs) { if (attrs[a] || attrs[a] === 0) { element.setAttribute(a, attrs[a]); } } return element; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/clear/clear.ls (function(){ return function(slide, o){ return function(){ var i$, ref$, len$, d, newSvg; for (i$ = 0, len$ = (ref$ = _.flatten(o.dots)).length; i$ < len$; ++i$) { d = ref$[i$]; if (!d.disabled) { d.hide(); o.visibleDots = 0; } } newSvg = inc("../../createSvg/create")(slide, ""); o.svg.before(newSvg); o.svg.remove(); o.svg = newSvg; return o.path = []; }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/click/click.ls (function(){ return function(slide, o){ return function(crd){ var dot, add; dot = o.dots[crd.y][crd.x]; if (slide.drawMode === "points" && o.path.length > 0 && dot.x === o.path[0].x && dot.y === o.path[0].y) { add = null; } else if (dot.isVisible()) { add = false; o.visibleDots--; dot.hide(); } else { add = true; o.visibleDots++; dot.show(); } if (o.visibleDots > o.maxDots) { slide.container.css({ pointerEvents: "none" }); o.visibleDots--; return setTimeout(function(){ return dot.fadeOut(300, function(){ return slide.container.css({ pointerEvents: "" }); }); }, 200); } else { return o.updatePath(dot, add); } }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/drawer.ls (function(){ return function(slide, container, svg){ var o, ref$; o = {}; o.container = container; o.maxDots = (ref$ = slide.getParam("maxDots", slide.atom)) != null ? ref$ : 10; o.visibleDots = 0; o.path = []; o.svg = svg; o.sideLengths = inc("lib/sideLengths"); o.numberOfSides = inc("lib/numberOfSides"); o.pointDist = inc("lib/pointDist"); o.pathLength = inc("lib/pathLength"); o.pathArea = inc("lib/pathArea"); o.pathAngles = inc("lib/pathAngles"); o.slope = inc("lib/slope"); o.clear = inc("clear/clear")(slide, o); o.set = inc("set/set")(slide, o); o.init = inc("init/init")(slide, o); o.get = inc("get/get")(o); o.validate = inc("validate/validate")(slide, o); o.click = inc("click/click")(slide, o); o.start = inc("start/start")(slide, o); o.insertPoint = inc("insertPoint/insert")(slide, o); o.removePoint = inc("removePoint/remove")(o); o.updatePath = inc("updatePath/update")(slide, o); return { start: o.start, click: o.click, validate: o.validate, clear: o.clear, set: o.set, init: o.init, get: o.get }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/get/get.ls (function(){ return function(o){ return function(){ return o.path; }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/init/init.ls (function(){ return function(slide, o){ return function(){ var i$, ref$, len$, v, x, y, dot, dot2, add; for (i$ = 0, len$ = (ref$ = slide.atom.b).length; i$ < len$; ++i$) { v = ref$[i$]; x = v.split(",")[0].trim(); y = v.split(",")[1].trim(); if (x > slide.gridSize || y > slide.gridSize) { debug("Achtung, unzulässige Figur vorgegeben (x:" + x + ", y:" + y + "), ein Wert ist > gridSize " + slide.gridSize); } dot = o.dots[y][x]; dot2 = dot.clone(); dot2.x = dot.x; dot2.y = dot.y; o.container.append(dot2); o.dots[y][x] = dot2; if (slide.drawMode === "points" && o.path.length > 0 && dot.x === o.path[0].x && dot.y === o.path[0].y) { add = null; } else if (dot.isVisible()) { add = false; dot.hide(); } else { dot.show(); add = true; } dot.disabled = true; dot.css({ backgroundColor: Color.grey[500] }); o.updatePath(dot, add, true); } o.initSvg = o.svg.clone(); o.svg.after(o.initSvg); o.svg.css({ visibility: "hidden" }); o.initPath = o.path; return o.path = []; }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/insertPoint/insert.ls (function(){ return function(slide, o){ return function(path, point){ var minDist, minPath, i$, to$, i, tempPath, d; if (slide.drawMode === "points") { return _.concat(path, point); } else { if (path.length < 2) { return _.concat(path, point); } minDist = 999999999; minPath = null; for (i$ = 0, to$ = path.length; i$ <= to$; ++i$) { i = i$; tempPath = _.concat(path.slice(0, i), point, path.slice(i, path.length)); d = o.pathLength(tempPath); if (d < minDist) { minDist = d; minPath = tempPath; } } return minPath; } }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/lib/numberOfSides.ls (function(){ return function(path, includePointsOnLines){ var angles; angles = inc("pathAngles")(path); if (!includePointsOnLines) { angles = _.filter(angles, function(a){ return !(a === 0 || a === 180); }); } return angles.length; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/lib/pathAngles.ls (function(){ return function(path){ var coordArray, i$, len$, p, areaFromCoords, totalArea, angles, angle, isBetween, isConvex, i, c, conv, ang; coordArray = []; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { p = path[i$]; coordArray.push(p.x); coordArray.push(p.y); } areaFromCoords = function(x){ var a, i, iLen; a = 0; if (x.length % 2) { return; } i = 0; iLen = x.length - 2; while (i < iLen) { a += x[i] * x[i + 3] - x[i + 2] * x[i + 1]; i += 2; } a += x[iLen] * x[1] - x[0] * x[iLen + 1]; return a / 2; }; totalArea = areaFromCoords(coordArray); angles = []; angle = function(x){ var a, b, skal, da, db, phi; a = [x[0] - x[2], x[1] - x[3]]; b = [x[4] - x[2], x[5] - x[3]]; skal = a[0] * b[0] + a[1] * b[1]; da = Math.sqrt(a[0] * a[0] + a[1] * a[1]); db = Math.sqrt(b[0] * b[0] + b[1] * b[1]); phi = Math.acos(skal / (da * db)); phi = phi * 180 / Math.PI; return phi = Math.round(phi * 100) / 100; }; isBetween = function(p0, p1, x){ var d01, dx0, dx1; d01 = Math.abs(p1[0] - p0[0]) + Math.abs(p1[1] - p0[1]); dx0 = Math.abs(p0[0] - x[0]) + Math.abs(p0[1] - x[1]); dx1 = Math.abs(p1[0] - x[0]) + Math.abs(p1[1] - x[1]); return d01 >= dx0 + dx1; }; isConvex = function(x){ var a, b, f, conv; a = [x[0] - x[2], x[1] - x[3]]; b = [x[4] - x[2], x[5] - x[3]]; f = a[0] * b[1] - b[0] * a[1]; conv = totalArea < 0 && f > 0 || totalArea > 0 && f < 0; return conv || f === 0 && !isBetween(a, b, x.slice(2, 4)); }; i = 0; while (i < coordArray.length) { c = coordArray.slice(i, i + 6); c = c.concat(coordArray.slice(0, 6 - c.length)); conv = isConvex(c); ang = angle(c); angles.push(conv ? ang : 360 - ang); i += 2; } ang = angles.pop(); angles.unshift(ang); return angles; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/lib/pathArea.ls (function(){ return function(path){ var coordArray, i$, len$, p, x, a, iLen, to$, i; coordArray = []; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { p = path[i$]; coordArray.push(p.x); coordArray.push(p.y); } x = coordArray; a = 0; if (x.length % 2) { return; } iLen = x.length - 2; for (i$ = 0, to$ = iLen - 1; i$ <= to$; i$ += 2) { i = i$; a += x[i] * x[i + 3] - x[i + 2] * x[i + 1]; } a += x[iLen] * x[1] - x[0] * x[iLen + 1]; return Math.abs(a / 2); }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/lib/pathLength.ls (function(){ var dist; dist = inc('pointDist'); return function(path){ var sum, i$, len$, i, p; sum = 0; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { i = i$; p = path[i$]; if (i === 0) { sum += dist(p, _.last(path)); } else { sum += dist(p, path[i - 1]); } } return sum; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/lib/pointDist.ls (function(){ return function(p1, p2){ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/lib/sideLengths.ls (function(){ return function(path){ var i$, len$, i, p, next, results$ = []; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { i = i$; p = path[i$]; next = path[i + 1] || path[0]; results$.push(inc("pointDist")(p, next)); } return results$; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/lib/slope.ls (function(){ return function(p1, p2){ var denom; denom = p1.x - p2.x; if (denom === 0) { return Infinity; } else { return (p1.y - p2.y) / denom; } }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/removePoint/remove.ls (function(){ return function(o){ return function(path, point){ return _.filter(path, function(p){ return !(p.x === point.x && p.y === point.y); }); }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/set/set.ls (function(){ return function(slide, o){ return function(path){ var i$, len$, p, x, y, dot, add, results$ = []; o.clear(); for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { p = path[i$]; if (_.isString(p)) { x = p.split(",")[0].trim() * 1; y = p.split(",")[1].trim() * 1; } else { x = p.x; y = p.y; } dot = o.dots[y][x]; if (slide.drawMode === "points" && o.path.length > 0 && dot.x === o.path[0].x && dot.y === o.path[0].y) { add = null; } else if (dot.isVisible()) { add = false; dot.hide(); } else { dot.show(); add = true; } dot.disabled = true; dot.css({ backgroundColor: Color.grey[500] }); results$.push(o.updatePath(dot, add)); } return results$; }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/start/dot/dot.ls (function(){ return function(slide, container, x, y){ var div; div = Div().addClass("shapesDot").css({ position: "absolute", left: (x * (container.offsetWidth / slide.gridSize) - 6) + "px", top: (y * (container.offsetWidth / slide.gridSize) - 6) + "px", width: 12 + "px", height: 12 + "px", backgroundColor: Color.blue[500], borderRadius: 6 + "px" }).hide(); div.x = x; div.y = y; return div; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/start/start.ls (function(){ return function(slide, o){ return function(){ var res$, i$, to$, y, lresult$, j$, to1$, x; res$ = []; for (i$ = 0, to$ = slide.gridSize; i$ <= to$; ++i$) { y = i$; lresult$ = []; for (j$ = 0, to1$ = slide.gridSize; j$ <= to1$; ++j$) { x = j$; lresult$.push(inc("dot/dot")(slide, o.container, x, y)); } res$.push(lresult$); } o.dots = res$; return o.container.append(_.flatten(o.dots)); }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/updatePath/update.ls (function(){ return function(slide, o){ return function(dot, added, isInitPath){ var p, i$, ref$, len$, i, node, newSvg; if (added === true) { o.path = o.insertPoint(o.path, dot); } else if (added === false) { o.path = o.removePoint(o.path, dot); } p = ''; for (i$ = 0, len$ = (ref$ = o.path).length; i$ < len$; ++i$) { i = i$; node = ref$[i$]; if (i === 0) { p += "M " + node.x + " " + node.y + " "; } else { p += "L " + node.x + " " + node.y + " "; } } if (slide.drawMode === "shape" || added === null) { p += 'Z'; } newSvg = inc("../../createSvg/create")(slide, p, isInitPath); o.svg.before(newSvg); o.svg.remove(); return o.svg = newSvg; }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/validate/mirror/mirror.ls (function(){ return function(slide, o, mode){ var s, pointsMirrored, res$, i$, ref$, len$, v, x, y, linesMirrored, i, m; s = slide.gridSize; res$ = []; for (i$ = 0, len$ = (ref$ = o.initPath).length; i$ < len$; ++i$) { v = ref$[i$]; if (mode === "horizontal") { res$.push({ x: v.x, y: s - v.y }); } else if (mode === "vertical") { res$.push({ x: s - v.x, y: v.y }); } else if (mode === "diagonalRight") { res$.push({ x: s - v.y, y: s - v.x }); } else if (mode === "diagonalLeft") { res$.push({ x: v.y, y: v.x }); } else if (mode === "point") { x = s - v.x; y = v.y; res$.push({ x: x, y: s - y }); } } pointsMirrored = res$; res$ = []; for (i$ = 0, len$ = pointsMirrored.length; i$ < len$; ++i$) { i = i$; m = pointsMirrored[i$]; if (i + 1 === pointsMirrored.length) { res$.push(_.sortBy([m, pointsMirrored[0]], JSON.stringify)); } else { res$.push(_.sortBy([m, pointsMirrored[i + 1]], JSON.stringify)); } } linesMirrored = res$; return { points: pointsMirrored, lines: linesMirrored }; }; })(); trainers/shapeMirror/interactive/clickContainer/drawer/validate/validate.ls (function(){ return function(slide, o){ return function(){ var sol, dots, selectedLines, res$, i$, len$, i, p, isCorrect, scorePath; sol = inc("mirror/mirror")(slide, o, slide.mirror); slide.solutionLines = sol.lines; slide.solutionPoints = sol.points; dots = _.map(o.path, function(p){ return _.pick(p, ["x", "y"]); }); res$ = []; for (i$ = 0, len$ = dots.length; i$ < len$; ++i$) { i = i$; p = dots[i$]; if (i + 1 === o.path.length) { res$.push(_.sortBy([p, dots[0]], JSON.stringify)); } else { res$.push(_.sortBy([p, dots[i + 1]], JSON.stringify)); } } selectedLines = res$; isCorrect = _.isEqual(_.sortBy(slide.solutionLines, JSON.stringify), _.sortBy(selectedLines, JSON.stringify)); scorePath = _.map(o.path, function(p){ return { x: p.x, y: p.y }; }); return { isCorrect: isCorrect, scorePath: scorePath }; }; }; })(); trainers/shapeMirror/interactive/clickContainer/getCrd/get.ls (function(){ return function(slide, div, e){ var x, ref$, y, divisor; x = ((ref$ = e.pageX) != null ? ref$ : e.touches[0].pageX) - div.offset().left; y = ((ref$ = e.pageY) != null ? ref$ : e.touches[0].pageY) - div.offset().top; divisor = div.width() / slide.gridSize; return { x: _.round(x / divisor), y: _.round(y / divisor) }; }; })(); trainers/shapeMirror/interactive/gridSize/gridSize.ls (function(){ return function(slide){ var s, ref$; s = (ref$ = slide.getParam("gridSize", slide.atom)) != null ? ref$ : 10; if (s % 2 !== 0) { debug("Achtung, shapeMirror sollte eine gerade Zahl als gridSize haben!"); } if (s < 6) { debug("Achtung, eine gridSize < 6 ist nicht zulässig"); s = 6; } else if (s > 14) { debug("Achtung, eine gridSize > 14 ist nicht zulässig"); s = 14; } return s; }; })(); trainers/shapeMirror/interactive/interactive.ls (function(){ return function(slide){ var div, container; slide.gridSize = inc("gridSize/gridSize")(slide); slide.mirror = slide.getParam("mirror", slide.atom); slide.div.append(div = inc("lsg/lsg")(slide).append(container = inc("clickContainer/container")(slide))); inc("mirror/mirror")(slide, div); div.init = container.init; div.clear = container.clear; div.set = container.set; div.get = container.get; div.validate = container.validate; div.onReady = container.start; slide.container = container; return div; }; })(); trainers/shapeMirror/interactive/lsg/lsg.ls (function(){ return function(slide){ var lsg; lsg = { lsg: path("/../c-renderer/squared-paper/renderer.lsr"), horizontalBoxes: slide.gridSize, verticalBoxes: slide.gridSize, width: body.width() < 420 ? 300 : 400, overlap: false }; return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }); }; })(); trainers/shapeMirror/interactive/mirror/drawMirror/draw.ls (function(){ return function(slide, parent){ var mode, div; mode = slide.mirror; return div = mode === "point" ? inc("point/point")(parent, mode) : inc("line/line")(parent, mode); }; })(); trainers/shapeMirror/interactive/mirror/drawMirror/line/line.ls (function(){ return function(parent, mode){ var svg, line, pw, ph; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; line = svg("line"); line.setAttribute("stroke-width", 4); line.setAttribute("stroke", Color.red[400]); parent.append(line); pw = parent.offset().width; ph = parent.offset().height; if (mode === "vertical") { line.setAttribute("x1", pw / 2); line.setAttribute("y1", 0); line.setAttribute("x2", pw / 2); return line.setAttribute("y2", ph); } else if (mode === "horizontal") { line.setAttribute("x1", 0); line.setAttribute("y1", ph / 2); line.setAttribute("x2", pw); return line.setAttribute("y2", ph / 2); } else if (mode === "diagonalRight") { line.setAttribute("x1", pw); line.setAttribute("y1", 0); line.setAttribute("x2", 0); return line.setAttribute("y2", ph); } else if (mode === "diagonalLeft") { line.setAttribute("x1", 0); line.setAttribute("y1", 0); line.setAttribute("x2", pw); return line.setAttribute("y2", ph); } }; })(); trainers/shapeMirror/interactive/mirror/drawMirror/point/point.ls (function(){ return function(parent, mode){ var center, x, y, svg, circle; center = "5,5"; x = center.split(",")[0] * 1; y = center.split(",")[1] * 1; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; circle = svg("circle"); circle.setAttribute("stroke-width", 4); circle.setAttribute("stroke", Color.red[400]); parent.append(circle); circle.setAttribute("cx", x * (parent.offset().width / 10)); circle.setAttribute("cy", y * (parent.offset().height / 10)); return circle.setAttribute("r", 4); }; })(); trainers/shapeMirror/interactive/mirror/mirror.ls (function(){ return function(slide, parent){ var svg, div; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; div = svg("svg"); div.setAttribute("width", 1.04 * parent.offsetWidth); div.setAttribute("height", 1.04 * parent.offsetHeight); div.css({ position: "absolute", left: "-2.1%", top: "-2%", pointerEvents: "none" }); div.appendTo(parent); inc("drawMirror/draw")(slide, div); return div; }; })(); trainers/shapeMirror/textA/text.ls (function(){ return function(slide){ var click, div; if (!slide.atom.a) { return; } click = function(){ var text, voice; text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); }; slide.div.append(div = Div().append(div = Div({ margin: "1em 0.5em", padding: "0 0.5em", display: "inline-block" }).html(slide.atom.a || ""))); if (slide.getParam("soundMode", slide.atom) === "a") { div.tap(click); } return div; }; })(); trainers/shapes/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/shapes/_preview/preview.ls (function(){ return function(slide){ var ref$; if (slide.atom.init) { slide.interactive.onReady(); slide.interactive.init(); } return (ref$ = slide.coordinatesButton) != null ? ref$.remove() : void 8; }; })(); trainers/shapes/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, interactive, path, res$, j$, ref1$, len1$, p, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.interactive.remove(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; interactive = inc("../../interactive/interactive")(slide); interactive.onReady(); interactive.init(); if (a.resolved) { interactive.set(slide.solution); } else { res$ = []; for (j$ = 0, len1$ = (ref1$ = a.path).length; j$ < len1$; ++j$) { p = ref1$[j$]; res$.push(p.x + "," + p.y); } path = res$; if (slide.drawMode === "points") { path.push(path[0]); } interactive.set(path); } results$.push(slide.div.append(Div({ margin: "3em 0" }).append(interactive, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))))); } return results$; } }; })(); trainers/shapes/_start/start.ls (function(){ return function(slide){ var ref$; slide.instruction.play(function(){ return inc('/shared/playAskSoundOrSoundA/play')(slide); }); if (typeof (ref$ = slide.interactive).onReady == 'function') { ref$.onReady(); } return slide.interactive.init(); }; })(); trainers/shapes/buttons/buttons.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ margin: "1em 0" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.clearButton = inc("clearButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide))); return div; }; })(); trainers/shapes/buttons/checkButton/button.ls (function(){ return function(slide){ var click; click = function(button){ var result; slide.buttons.css({ pointerEvents: "none" }); result = slide.interactive.validate(); if (result.isCorrect === true) { slide.score.addActionCorrect(slide.atom, { path: result.scorePath }); slide.score.log(slide.atom); button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); slide.div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 1000); } else { button.setState("wrong"); slide.score.addActionMistake(slide.atom, { path: result.scorePath }); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ button.setState("normal"); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } return slide.buttons.css({ pointerEvents: "" }); }, 500); } }; return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/shapes/buttons/clearButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ return slide.interactive.clear(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/bin.svg"), action: click }).css({ margin: "0.5em" }); }; })(); trainers/shapes/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/shapes/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ if (!slide.solution) { return; } div.hide(); return div.fadeIn(); }; click = function(){ if (!slide.solution) { return; } slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom); slide.score.log(slide.atom); slide.buttons.css({ pointerEvents: "none" }); slide.interactive.css({ pointerEvents: "none" }); slide.interactive.set(slide.solution); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); slide.clearButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); return slide.buttons.css({ pointerEvents: "" }); }, 500); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/shapes/coordinatesButton/button.ls (function(){ return function(slide){ var tap; if (!engine.isDebug) { return; } tap = function(path){ var s, i$, len$, i, p; s = "\nsolution: ["; path = _.map(slide.interactive.get(), function(p){ return { x: p.x, y: p.y }; }); for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { i = i$; p = path[i$]; s += "\"" + p.x + "," + p.y + "\""; if (path[i + 1]) { s += ", "; } } s += "]\n"; return debug(s); }; return Div({ position: "absolute", right: 0, bottom: "-1.5em", cursor: "pointer", color: Color.grey[300] }).addClass("levelDebugIcon").html("Debug: Show coordinates").tap(tap).appendTo(slide.interactive); }; })(); trainers/shapes/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; if (slide.atom.solution) { slide.solution = slide.atom.solution; } slide.drawMode = slide.getParam("drawMode") || "shape"; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/shapes/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.textA = inc("textA/text")(slide); slide.interactive = inc("interactive/interactive")(slide); slide.coordinatesButton = inc("coordinatesButton/button")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/shapes/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/shapes/interactive/clickContainer/container.ls (function(){ return function(slide){ var lastDown, lastDownCrd, down, up, div, svg, drawer; lastDown = null; lastDownCrd = null; down = function(e){ lastDown = e; return lastDownCrd = inc("getCrd/get")(slide, div, e); }; up = function(e){ var downX, ref$, downY, upX, upY, xDiff, yDiff, crd; if (lastDown == null) { return; } downX = (ref$ = lastDown.pageX) != null ? ref$ : lastDown.touches[0].pageX; downY = (ref$ = lastDown.pageY) != null ? ref$ : lastDown.touches[0].pageY; upX = (ref$ = e.pageX) != null ? ref$ : e.touches[0].pageX; upY = (ref$ = e.pageY) != null ? ref$ : e.touches[0].pageY; xDiff = Math.abs(downX - upX); yDiff = Math.abs(downY - upY); crd = inc("getCrd/get")(slide, div, e); if (xDiff < 10 && yDiff < 10 && _.isEqual(lastDownCrd, crd)) { drawer.click(crd); } return lastDown = null; }; div = Div({ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }).tap({ up: up, down: down, animation: "none" }).append(svg = inc("createSvg/create")(slide, "")); drawer = inc("drawer/drawer")(slide, div, svg); div.init = drawer.init; div.clear = drawer.clear; div.set = drawer.set; div.get = drawer.get; div.validate = drawer.validate; div.start = drawer.start; return div; }; })(); trainers/shapes/interactive/clickContainer/createSvg/create.ls (function(){ return function(slide, path){ var makeSvg; makeSvg = inc("makeSvg/make"); return makeSvg('svg', { 'viewBox': "0 0 " + slide.gridSize + " " + slide.gridSize, 'preserve-aspect-ratio': 'none' }).css({ position: "absolute", top: 0, left: 0, overflow: "visible" }).append(makeSvg('path', { fill: slide.drawMode === "points" ? 'transparent' : 'rgba(200, 200, 255, 0.5)', stroke: 'black', 'stroke-width': "0.1", d: path })); }; })(); trainers/shapes/interactive/clickContainer/createSvg/makeSvg/make.ls (function(){ return function(tag, attrs){ var element, a; element = document.createElementNS('http://www.w3.org/2000/svg', tag); for (a in attrs) { if (attrs[a] || attrs[a] === 0) { element.setAttribute(a, attrs[a]); } } return element; }; })(); trainers/shapes/interactive/clickContainer/drawer/clear/clear.ls (function(){ return function(slide, o){ return function(){ var i$, ref$, len$, d, newSvg; for (i$ = 0, len$ = (ref$ = _.flatten(o.dots)).length; i$ < len$; ++i$) { d = ref$[i$]; if (!d.disabled) { d.hide(); o.visibleDots = 0; } } newSvg = inc("../../createSvg/create")(slide, ""); o.svg.before(newSvg); o.svg.remove(); o.svg = newSvg; return o.path = []; }; }; })(); trainers/shapes/interactive/clickContainer/drawer/click/click.ls (function(){ return function(slide, o){ return function(crd){ var dot, add; dot = o.dots[crd.y][crd.x]; if (!dot) { return; } if (slide.drawMode === "points" && o.path.length > 0 && dot.x === o.path[0].x && dot.y === o.path[0].y) { add = null; } else if (dot.isVisible()) { add = false; o.visibleDots--; dot.hide(); } else { add = true; o.visibleDots++; dot.show(); } if (o.visibleDots > o.maxDots) { slide.container.css({ pointerEvents: "none" }); o.visibleDots--; return setTimeout(function(){ return dot.fadeOut(300, function(){ return slide.container.css({ pointerEvents: "" }); }); }, 200); } else { return o.updatePath(dot, add); } }; }; })(); trainers/shapes/interactive/clickContainer/drawer/drawer.ls (function(){ return function(slide, container, svg){ var o, ref$; o = {}; o.container = container; o.maxDots = (ref$ = slide.getParam("maxDots", slide.atom)) != null ? ref$ : 10; o.visibleDots = 0; o.path = []; o.svg = svg; o.sideLengths = inc("lib/sideLengths"); o.numberOfSides = inc("lib/numberOfSides"); o.pointDist = inc("lib/pointDist"); o.pathLength = inc("lib/pathLength"); o.pathArea = inc("lib/pathArea"); o.pathAngles = inc("lib/pathAngles"); o.slope = inc("lib/slope"); o.clear = inc("clear/clear")(slide, o); o.set = inc("set/set")(slide, o); o.init = inc("init/init")(slide, o); o.get = inc("get/get")(o); o.validate = inc("validate/validate")(slide, o); o.click = inc("click/click")(slide, o); o.start = inc("start/start")(slide, o); o.insertPoint = inc("insertPoint/insert")(slide, o); o.removePoint = inc("removePoint/remove")(o); o.updatePath = inc("updatePath/update")(slide, o); return { start: o.start, click: o.click, validate: o.validate, clear: o.clear, set: o.set, init: o.init, get: o.get }; }; })(); trainers/shapes/interactive/clickContainer/drawer/get/get.ls (function(){ return function(o){ return function(){ return o.path; }; }; })(); trainers/shapes/interactive/clickContainer/drawer/init/drawInitPath/draw.ls (function(){ return function(slide, o){ var i$, ref$, len$, v, x, y, dot, dot2, add; if (!slide.atom.init) { return; } for (i$ = 0, len$ = (ref$ = slide.atom.init).length; i$ < len$; ++i$) { v = ref$[i$]; x = v.split(",")[0].trim(); y = v.split(",")[1].trim(); dot = o.dots[y][x]; dot2 = dot.clone(); dot2.x = dot.x; dot2.y = dot.y; o.container.append(dot2); o.dots[y][x] = dot2; if (slide.drawMode === "points" && o.path.length > 0 && dot.x === o.path[0].x && dot.y === o.path[0].y) { add = null; } else if (dot.isVisible()) { add = false; dot.hide(); } else { dot.show(); add = true; } dot.disabled = true; dot.css({ backgroundColor: Color.grey[500] }); o.updatePath(dot, add); } o.initSvg = o.svg.clone(); o.svg.after(o.initSvg); o.svg.css({ visibility: "hidden" }); o.initPath = o.path; return o.path = []; }; })(); trainers/shapes/interactive/clickContainer/drawer/init/init.ls (function(){ return function(slide, o){ return function(){ inc("drawInitPath/draw")(slide, o); return inc("initConditions/init")(slide, o); }; }; })(); trainers/shapes/interactive/clickContainer/drawer/init/initConditions/calcMoveSolution/calc.ls (function(){ return function(slide, o, move){ var v, vx, vy, correctPath, p; v = move.vector; vx = v.split(",")[0].trim() * 1; vy = v.split(",")[1].trim() * 1; return correctPath = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = o.initPath).length; i$ < len$; ++i$) { p = ref$[i$]; results$.push({ x: p.x + vx, y: p.y + vy }); } return results$; }()); }; })(); trainers/shapes/interactive/clickContainer/drawer/init/initConditions/drawArrow/draw.ls (function(){ return function(slide, o, move){ var makeSvg, s, sx, sy, v, vx, vy, ex, ey, i$, ref$, len$, crd, path, svg; makeSvg = inc("makeSvg/make"); s = move.arrowStart; sx = s.split(",")[0].trim() * 1; sy = s.split(",")[1].trim() * 1; v = move.vector; vx = v.split(",")[0].trim() * 1; vy = v.split(",")[1].trim() * 1; ex = sx + vx; ey = sy + vy; for (i$ = 0, len$ = (ref$ = [sx, sy, ex, ey]).length; i$ < len$; ++i$) { crd = ref$[i$]; if (!(0 <= crd && crd <= slide.gridSize)) { debug("Please define valid coordinates for the arrow!"); break; } } path = "M " + sx + " " + sy + " L " + ex + " " + ey; svg = makeSvg('svg', { 'viewBox': "0 0 " + slide.gridSize + " " + slide.gridSize, 'preserve-aspect-ratio': 'none' }).css({ position: "absolute", top: 0, left: 0, overflow: "visible" }).append(inc("marker/marker")(), makeSvg('path', { stroke: 'black', 'stroke-width': "0.1", d: path, 'marker-end': "url(#arrowEnd)" })); return o.container.append(svg); }; })(); trainers/shapes/interactive/clickContainer/drawer/init/initConditions/drawArrow/makeSvg/make.ls (function(){ return function(tag, attrs){ var element, a; element = document.createElementNS('http://www.w3.org/2000/svg', tag); for (a in attrs) { if (attrs[a] || attrs[a] === 0) { element.setAttribute(a, attrs[a]); } } return element; }; })(); trainers/shapes/interactive/clickContainer/drawer/init/initConditions/drawArrow/marker/marker.ls (function(){ return function(){ var defs; defs = document.createElementNS('http://www.w3.org/2000/svg', "defs"); defs.setAttribute("id", "arrowHeads"); defs.innerHTML = "\n\n"; return defs; }; })(); trainers/shapes/interactive/clickContainer/drawer/init/initConditions/init.ls (function(){ return function(slide, o){ var c; c = slide.getParam("conditions", slide.atom); if (c.move != null) { slide.solution = inc("calcMoveSolution/calc")(slide, o, c.move); } if (!slide.solution) { debug("Bitte definiere eine Musterlösung für diese Figur!"); } if (c.move != null) { return inc("drawArrow/draw")(slide, o, c.move); } }; })(); trainers/shapes/interactive/clickContainer/drawer/insertPoint/insert.ls (function(){ return function(slide, o){ return function(path, point){ var minDist, minPath, i$, to$, i, tempPath, d; if (slide.drawMode === "points") { return _.concat(path, point); } else { if (path.length < 2) { return _.concat(path, point); } minDist = 999999999; minPath = null; for (i$ = 0, to$ = path.length; i$ <= to$; ++i$) { i = i$; tempPath = _.concat(path.slice(0, i), point, path.slice(i, path.length)); d = o.pathLength(tempPath); if (d < minDist) { minDist = d; minPath = tempPath; } } return minPath; } }; }; })(); trainers/shapes/interactive/clickContainer/drawer/lib/numberOfSides.ls (function(){ return function(path, includePointsOnLines){ var angles; angles = inc("pathAngles")(path); if (!includePointsOnLines) { angles = _.filter(angles, function(a){ return !(a === 0 || a === 180); }); } return angles.length; }; })(); trainers/shapes/interactive/clickContainer/drawer/lib/pathAngles.ls (function(){ return function(path){ var coordArray, i$, len$, p, areaFromCoords, totalArea, angles, angle, isBetween, isConvex, i, c, conv, ang; coordArray = []; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { p = path[i$]; coordArray.push(p.x); coordArray.push(p.y); } areaFromCoords = function(x){ var a, i, iLen; a = 0; if (x.length % 2) { return; } i = 0; iLen = x.length - 2; while (i < iLen) { a += x[i] * x[i + 3] - x[i + 2] * x[i + 1]; i += 2; } a += x[iLen] * x[1] - x[0] * x[iLen + 1]; return a / 2; }; totalArea = areaFromCoords(coordArray); angles = []; angle = function(x){ var a, b, skal, da, db, phi; a = [x[0] - x[2], x[1] - x[3]]; b = [x[4] - x[2], x[5] - x[3]]; skal = a[0] * b[0] + a[1] * b[1]; da = Math.sqrt(a[0] * a[0] + a[1] * a[1]); db = Math.sqrt(b[0] * b[0] + b[1] * b[1]); phi = Math.acos(skal / (da * db)); phi = phi * 180 / Math.PI; return phi = Math.round(phi * 100) / 100; }; isBetween = function(p0, p1, x){ var d01, dx0, dx1; d01 = Math.abs(p1[0] - p0[0]) + Math.abs(p1[1] - p0[1]); dx0 = Math.abs(p0[0] - x[0]) + Math.abs(p0[1] - x[1]); dx1 = Math.abs(p1[0] - x[0]) + Math.abs(p1[1] - x[1]); return d01 >= dx0 + dx1; }; isConvex = function(x){ var a, b, f, conv; a = [x[0] - x[2], x[1] - x[3]]; b = [x[4] - x[2], x[5] - x[3]]; f = a[0] * b[1] - b[0] * a[1]; conv = totalArea < 0 && f > 0 || totalArea > 0 && f < 0; return conv || f === 0 && !isBetween(a, b, x.slice(2, 4)); }; i = 0; while (i < coordArray.length) { c = coordArray.slice(i, i + 6); c = c.concat(coordArray.slice(0, 6 - c.length)); conv = isConvex(c); ang = angle(c); angles.push(conv ? ang : 360 - ang); i += 2; } ang = angles.pop(); angles.unshift(ang); return angles; }; })(); trainers/shapes/interactive/clickContainer/drawer/lib/pathArea.ls (function(){ return function(path){ var coordArray, i$, len$, p, x, a, iLen, to$, i; coordArray = []; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { p = path[i$]; coordArray.push(p.x); coordArray.push(p.y); } x = coordArray; a = 0; if (x.length % 2) { return; } iLen = x.length - 2; for (i$ = 0, to$ = iLen - 1; i$ <= to$; i$ += 2) { i = i$; a += x[i] * x[i + 3] - x[i + 2] * x[i + 1]; } a += x[iLen] * x[1] - x[0] * x[iLen + 1]; return Math.abs(a / 2); }; })(); trainers/shapes/interactive/clickContainer/drawer/lib/pathLength.ls (function(){ var dist; dist = inc('pointDist'); return function(path){ var sum, i$, len$, i, p; sum = 0; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { i = i$; p = path[i$]; if (i === 0) { sum += dist(p, _.last(path)); } else { sum += dist(p, path[i - 1]); } } return sum; }; })(); trainers/shapes/interactive/clickContainer/drawer/lib/pointDist.ls (function(){ return function(p1, p2){ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); }; })(); trainers/shapes/interactive/clickContainer/drawer/lib/sideLengths.ls (function(){ return function(path){ var i$, len$, i, p, next, results$ = []; for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { i = i$; p = path[i$]; next = path[i + 1] || path[0]; results$.push(inc("pointDist")(p, next)); } return results$; }; })(); trainers/shapes/interactive/clickContainer/drawer/lib/slope.ls (function(){ return function(p1, p2){ var denom; denom = p1.x - p2.x; if (denom === 0) { return Infinity; } else { return (p1.y - p2.y) / denom; } }; })(); trainers/shapes/interactive/clickContainer/drawer/removePoint/remove.ls (function(){ return function(o){ return function(path, point){ return _.filter(path, function(p){ return !(p.x === point.x && p.y === point.y); }); }; }; })(); trainers/shapes/interactive/clickContainer/drawer/set/set.ls (function(){ return function(slide, o){ return function(path){ var i$, len$, p, x, y, dot, add, results$ = []; o.clear(); for (i$ = 0, len$ = path.length; i$ < len$; ++i$) { p = path[i$]; if (!p) { continue; } x = p.x || p.split(",")[0].trim(); y = p.y || p.split(",")[1].trim(); dot = o.dots[y][x]; if (slide.drawMode === "points" && o.path.length > 0 && dot.x === o.path[0].x && dot.y === o.path[0].y) { add = null; } else if (dot.isVisible()) { add = false; dot.hide(); } else { dot.show(); add = true; } dot.disabled = true; dot.css({ backgroundColor: Color.grey[500] }); results$.push(o.updatePath(dot, add)); } return results$; }; }; })(); trainers/shapes/interactive/clickContainer/drawer/start/dot/dot.ls (function(){ return function(slide, container, x, y){ var div; div = Div().addClass("shapesDot").css({ position: "absolute", left: (x * (container.width() / slide.gridSize) - 6) + "px", top: (y * (container.width() / slide.gridSize) - 6) + "px", width: 12 + "px", height: 12 + "px", backgroundColor: Color.blue[500], borderRadius: 6 + "px" }).hide(); div.x = x; div.y = y; return div; }; })(); trainers/shapes/interactive/clickContainer/drawer/start/start.ls (function(){ return function(slide, o){ return function(){ var res$, i$, to$, y, lresult$, j$, to1$, x; res$ = []; for (i$ = 0, to$ = slide.gridSize; i$ <= to$; ++i$) { y = i$; lresult$ = []; for (j$ = 0, to1$ = slide.gridSize; j$ <= to1$; ++j$) { x = j$; lresult$.push(inc("dot/dot")(slide, o.container, x, y)); } res$.push(lresult$); } o.dots = res$; return o.container.append(_.flatten(o.dots)); }; }; })(); trainers/shapes/interactive/clickContainer/drawer/updatePath/update.ls (function(){ return function(slide, o){ return function(dot, added){ var p, i$, ref$, len$, i, node, newSvg; if (added === true) { o.path = o.insertPoint(o.path, dot); } else if (added === false) { o.path = o.removePoint(o.path, dot); } p = ''; for (i$ = 0, len$ = (ref$ = o.path).length; i$ < len$; ++i$) { i = i$; node = ref$[i$]; if (i === 0) { p += "M " + node.x + " " + node.y + " "; } else { p += "L " + node.x + " " + node.y + " "; } } if (slide.drawMode === "shape" || added === null) { p += 'Z'; } newSvg = inc("../../createSvg/create")(slide, p); o.svg.before(newSvg); o.svg.remove(); return o.svg = newSvg; }; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/area/area.ls (function(){ return function(slide, o, value, path){ return value === o.pathArea(path); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/circumference/circumference.ls (function(){ return function(slide, o, value, path){ return value === o.pathLength(path); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/move/move.ls (function(){ return function(slide, o, value, path){ var move, correctPath, i$, to$, i, allCorrect, res$, j$, to1$, j, correct; move = slide.getParam("conditions", slide.atom).move; correctPath = slide.solution; path = _.map(path, function(p){ return { x: p.x, y: p.y }; }); if (path.length !== correctPath.length) { return false; } for (i$ = 0, to$ = correctPath.length; i$ < to$; ++i$) { i = i$; res$ = []; for (j$ = 0, to1$ = correctPath.length; j$ < to1$; ++j$) { j = j$; res$.push(correct = correctPath[j].x === path[j].x && correctPath[j].y === path[j].y); } allCorrect = res$; if (!_.includes(allCorrect, false)) { return true; } correctPath.unshift(correctPath.pop()); } _.reverse(correctPath); for (i$ = 0, to$ = correctPath.length; i$ < to$; ++i$) { i = i$; res$ = []; for (j$ = 0, to1$ = correctPath.length; j$ < to1$; ++j$) { j = j$; res$.push(correct = correctPath[j].x === path[j].x && correctPath[j].y === path[j].y); } allCorrect = res$; if (!_.includes(allCorrect, false)) { return true; } correctPath.unshift(correctPath.pop()); } return false; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/numberOfSides/numberOfSides.ls (function(){ return function(slide, o, v, path){ var sides; sides = o.numberOfSides(path); if (_.isNumber(v)) { if (v >= 3) { return sides === v && path.length === v; } else { debug("Bitte wähle als Seitenzahl mindestens 3."); return false; } } else if (v.min != null) { return sides >= v.min; } else { debug("Gib bitte entweder eine Zahl oder einen min Wert an."); return false; } }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/scale/scale.ls (function(){ return function(slide, o, value, path){ var r, angles, initAngles, sideLengths, initSideLengths, i$, to$, i, allCorrect, res$, j$, to1$, j, correct; r = function(v){ return _.round(v, 3); }; angles = o.pathAngles(path); initAngles = o.pathAngles(o.initPath); sideLengths = o.sideLengths(path); initSideLengths = o.sideLengths(o.initPath); if (angles.length !== initAngles.length) { return false; } for (i$ = 0, to$ = sideLengths.length; i$ < to$; ++i$) { i = i$; res$ = []; for (j$ = 0, to1$ = sideLengths.length; j$ < to1$; ++j$) { j = j$; res$.push(correct = r(sideLengths[j]) === r(initSideLengths[j] * value) && angles[j] === initAngles[j]); } allCorrect = res$; if (!_.includes(allCorrect, false)) { return true; } sideLengths.unshift(sideLengths.pop()); angles.unshift(angles.pop()); } _.reverse(sideLengths); _.reverse(angles); angles.unshift(angles.pop()); for (i$ = 0, to$ = sideLengths.length; i$ < to$; ++i$) { i = i$; res$ = []; for (j$ = 0, to1$ = sideLengths.length; j$ < to1$; ++j$) { j = j$; res$.push(correct = r(sideLengths[j]) === r(initSideLengths[j] * value) && angles[j] === initAngles[j]); } allCorrect = res$; if (!_.includes(allCorrect, false)) { return true; } sideLengths.unshift(sideLengths.pop()); angles.unshift(angles.pop()); } return false; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/kite/kite.ls (function(){ return function(o, v, path){ var s; s = o.sideLengths(path); return inc("../quadrangle/quadrangle")(o, v, path) && ((s[0] === s[1] && s[2] === s[3]) || (s[0] === s[3] && s[1] === s[2])); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/parallelogram/parallelogram.ls (function(){ return function(o, v, path){ return o.numberOfSides(path) === 4 && path.length === 4 && o.slope(path[0], path[1]) === o.slope(path[2], path[3]) && o.slope(path[1], path[2]) === o.slope(path[3], path[0]); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/quadrangle/quadrangle.ls (function(){ return function(o, v, path){ return o.numberOfSides(path) === 4 && path.length === 4; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/rectangle/rectangle.ls (function(){ return function(o, v, path){ return o.numberOfSides(path) === 4 && o.pathAngles(path).every(function(a){ return a === 90; }); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/rhombus/rhombus.ls (function(){ return function(o, v, path){ var sideLengths; sideLengths = o.sideLengths(path); return inc("../quadrangle/quadrangle")(o, v, path) && sideLengths.every(function(l){ return l === sideLengths[0]; }); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/shape.ls (function(){ return function(slide, o, v, path){ return inc(v + "/" + v)(o, v, path); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/square/square.ls (function(){ return function(o, v, path){ var sideLengths; sideLengths = o.sideLengths(path); return inc("../rectangle/rectangle")(o, v, path) && sideLengths.every(function(l){ return l === sideLengths[0]; }); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/symmetricTriangle/symmetricTriangle.ls (function(){ return function(o, v, path){ return inc("../triangle/triangle")(o, v, path) && _.uniq(o.pathAngles(path)).length <= 2; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/trapeze/trapeze.ls (function(){ return function(o, v, path){ return o.numberOfSides(path) === 4 && path.length === 4 && (o.slope(path[0], path[1]) === o.slope(path[2], path[3]) || o.slope(path[1], path[2]) === o.slope(path[3], path[0])); }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/shape/triangle/triangle.ls (function(){ return function(o, v, path){ return o.numberOfSides(path) === 3 && path.length === 3; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/sideLengths/rectangle/rectangle.ls (function(){ return function(o, value, path){ var sides, correct; sides = o.sideLengths(path); if (_.isNumber(value)) { correct = _.includes(sides, value); } else if (_.isArray(value)) { sides = _.sortBy(_.uniq(sides)); if (value.length > 2) { debug("Das sideLength array darf nur 2 Einträge enthalten"); return false; } correct = _.every(_.sortBy(value), function(v, i){ return sides[i] === v; }); } else { debug("Bitte gib entweder eine Zahl oder ein Array an"); return false; } return correct; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/sideLengths/sideLengths.ls (function(){ return function(slide, o, value, path){ var c; c = slide.getParam("conditions", slide.atom); if (c.shape === "symmetricTriangle") { return inc("symmetricTriangle/symmetricTriangle")(o, value, path); } else if (c.shape === "rectangle") { return inc("rectangle/rectangle")(o, value, path); } else if (c.shape === "square") { return inc("square/square")(o, value, path); } }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/sideLengths/square/square.ls (function(){ return function(o, value, path){ var sides; if (!_.isNumber(value)) { debug("Please specify the side lengths of a square with a number"); return; } sides = o.sideLengths(path); return value === sides[0]; }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/conditions/sideLengths/symmetricTriangle/symmetricTriangle.ls (function(){ return function(o, value, path){ var sides, base; sides = o.sideLengths(path); if (_.uniq(sides).length === 1) { return sides[0] === value; } else { base = _.find(sides, function(s){ return sides.indexOf(s) === sides.lastIndexOf(s); }); return base === value; } }; })(); trainers/shapes/interactive/clickContainer/drawer/validate/validate.ls (function(){ return function(slide, o){ return function(){ var conditions, correct, k, v, scorePath; conditions = slide.getParam("conditions", slide.atom); correct = true; for (k in conditions) { v = conditions[k]; correct = correct && inc("conditions/" + k + "/" + k)(slide, o, v, o.path); } scorePath = _.map(o.path, function(p){ return { x: p.x, y: p.y }; }); return { isCorrect: correct, scorePath: scorePath }; }; }; })(); trainers/shapes/interactive/clickContainer/getCrd/get.ls (function(){ return function(slide, div, e){ var x, ref$, y, divisor; x = ((ref$ = e.pageX) != null ? ref$ : e.touches[0].pageX) - div.offset().left; y = ((ref$ = e.pageY) != null ? ref$ : e.touches[0].pageY) - div.offset().top; divisor = div.width() / slide.gridSize; return { x: _.round(x / divisor), y: _.round(y / divisor) }; }; })(); trainers/shapes/interactive/gridSize/gridSize.ls (function(){ return function(slide){ var s, ref$; s = (ref$ = slide.getParam("gridSize", slide.atom)) != null ? ref$ : 10; if (s < 6) { debug("Achtung, eine gridSize < 6 ist nicht zulässig"); s = 6; } else if (s > 14) { debug("Achtung, eine gridSize > 14 ist nicht zulässig"); s = 14; } return s; }; })(); trainers/shapes/interactive/interactive.ls (function(){ return function(slide){ var div, container; slide.gridSize = inc("gridSize/gridSize")(slide); slide.div.append(div = inc("lsg/lsg")(slide).append(container = inc("clickContainer/container")(slide))); div.init = container.init; div.clear = container.clear; div.set = container.set; div.get = container.get; div.validate = container.validate; div.onReady = container.start; slide.container = container; return div; }; })(); trainers/shapes/interactive/lsg/lsg.ls (function(){ return function(slide){ var lsg; lsg = { lsg: path("/../c-renderer/squared-paper/renderer.lsr"), horizontalBoxes: slide.gridSize, verticalBoxes: slide.gridSize, width: body.width() < 420 ? 300 : 400, overlap: false }; return inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide }); }; })(); trainers/shapes/textA/text.ls (function(){ return function(slide){ var click, div; if (!slide.atom.a) { return; } click = function(){ var text, voice; text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); }; slide.div.append(Div().append(div = Div({ margin: "1em 0.5em", padding: "0 0.5em", display: "inline-block" }).html(slide.atom.a || ""))); if (slide.getParam("soundMode", slide.atom) === "a") { div.tap(click); } return div; }; })(); trainers/soundButtons/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/soundButtons/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/soundButtons/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); texts = _.map(slide.choices, "sound"); if (soundMode === "a" || soundMode === "askSound") { _.push(texts, slide.atom.sound || slide.atom.a); } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/soundButtons/_preview/preview.ls (function(){ return function(slide){ return requestAnimationFrame(function(){ return inc("../fixLayout/fix")(slide); }); }; })(); trainers/soundButtons/_review/scoreActions/_speaker/speaker.ls (function(){ return function(action, slide){ var voice, voiceLang, sound, isPlaying, tap, div, speaker; voice = slide.getParam("voice", slide.atom); voiceLang = slide.getParam("voiceLang", slide.atom); sound = slide.sounds[action.sound + voice + voiceLang]; isPlaying = false; tap = function(){ var ref$; if (isPlaying) { isPlaying = false; delete slide.currentButton; speaker.reset(); return sound.stop(); } else { isPlaying = true; if ((ref$ = slide.currentButton) != null) { ref$.toggle(); } slide.currentButton = div; return sound.play(function(){ var ref$; isPlaying = false; return ref$ = slide.currentButton, delete slide.currentButton, ref$; }, function(c, t, l){ return speaker.update(c, t, l); }); } }; div = Div({ flex: "0 0 auto", display: "flex", height: "1.5em", width: "1.5em", marginTop: "-0.1em", pointerEvents: "auto" }).append(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "1.4em", progressbarType: "none", speakerType: "123" }).css({ position: "absolute", top: "0.15em" })).tap({ up: tap, tapZone: "0.5em" }); div.toggle = tap; return div; }; })(); trainers/soundButtons/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (!scoreEvent) { return; } return slide.div.append(Div().css({ textAlign: "left", marginBottom: "1em" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(inc("_speaker/speaker")(action, slide))); } return results$; }()))); }; })(); trainers/soundButtons/_start/start.ls (function(){ return function(slide){ inc("../fixLayout/fix")(slide); return slide.instruction.play(function(){ slide.levelPlayer.page.scrollElementIntoView(_.last(slide.buttons), { padding: 20 }); return inc("/shared/playAskSoundOrSoundA/play")(slide); }); }; })(); trainers/soundButtons/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/soundButtons/buttons/buttons.ls (function(){ return function(slide){ var shuffleButtons, ref$, choices, buttons, choice; slide.totalGreen = _.filter(slide.choices, { correct: true }).length; slide.currentGreen = 0; shuffleButtons = (ref$ = slide.getParam("shuffleButtons", slide.atom)) != null ? ref$ : true; choices = shuffleButtons ? _.shuffleWithSeed(slide.choices) : slide.choices; slide.div.append(slide.buttonsDiv = Div({ padding: "1em 0.5em 0" }).append(buttons = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(inc("soundButton/button")(slide, choice)); } return results$; }()))); return buttons; }; })(); trainers/soundButtons/buttons/soundButton/button.ls (function(){ return function(slide, choice){ var voice, correctChoices, wrongChoices, isPlaying, toggle, check, onMistake, onCorrect, div, speaker, button, buttonIcon; voice = slide.getParam("voice", slide.atom); correctChoices = _.filter(slide.choices, { correct: true }); wrongChoices = _.filter(slide.choices, function(c){ return c.correct == null; }); isPlaying = false; toggle = function(){ var text, ref$; text = choice.sound + voice; if (isPlaying) { isPlaying = false; delete slide.currentButton; speaker.reset(); return slide.sounds[text].stop(); } else { isPlaying = true; if ((ref$ = slide.currentButton) != null) { ref$.toggle(); } slide.currentButton = div; return slide.sounds[text].play(function(){ var ref$; isPlaying = false; return ref$ = slide.currentButton, delete slide.currentButton, ref$; }, function(c, t, l){ return speaker.update(c, t, l); }); } }; check = function(){ button.css({ pointerEvents: "none" }); if (choice.correct) { return onCorrect(); } else { return onMistake(); } }; onMistake = function(){ var d1, index; slide.levelPlayer.progressBar.addElement().showRed(); button.css({ backgroundColor: Color.red[500] }); buttonIcon.setColor(Color.white); d1 = new Date(); index = _.indexOf(wrongChoices, choice); return slide.score.addActionMistake(slide.atom, { sound: choice.sound, index: index }, function(){ var duration; duration = new Date() - d1; return setTimeout(function(){ button.css({ backgroundColor: Color.grey[150] }); buttonIcon.setColor(Color.grey[450]); return button.css({ pointerEvents: "" }); }, Math.max(0, 500 - duration)); }); }; onCorrect = function(){ var isFinished, index; slide.currentGreen++; isFinished = slide.currentGreen === slide.totalGreen; slide.levelPlayer.progressBar.showGreen(); button.css({ backgroundColor: Color.green[500] }); buttonIcon.setColor(Color.white); if (isFinished) { slide.buttonsDiv.css({ pointerEvents: "none" }); } index = _.indexOf(correctChoices, choice); return slide.score.addActionCorrect(slide.atom, { sound: choice.sound, index: index }, function(){ if (isFinished) { return slide.score.log(slide.atom, function(){ return setTimeout(slide.finish, 500); }); } }); }; div = Div({ display: "inline-flex", margin: "0.5em", border: "2px solid " + Color.grey[250], flexDirection: "columns" }).append(Div({ height: "3em", width: "3em", display: "flex", marginRight: "0.2em" }).append(speaker = inc("/../app01/lib/gui/speakerAnimate/speakerAnimate")({ size: "2.4em", progressbarType: "none", speakerType: "123" })).tap(toggle), button = Div({ width: "3em", height: "3em", display: "flex", backgroundColor: Color.grey[150] }).append(buttonIcon = SvgIcon({ svg: path("/../app01/lib/svg/shape/check.svg"), color: Color.grey[450], width: "1.3em" })).tap(check)); div.toggle = toggle; return div; }; })(); trainers/soundButtons/calcChoices/automatic/calc.ls (function(){ return function(slide){ var calcChoice, choice, choices, otherAtoms, totalButtons, i$, len$, atom; calcChoice = function(correct, b){ var choice, k, v; choice = { correct: correct }; if (_.isString(b)) { choice.sound = b; } else { for (k in b) { v = b[k]; choice[k] = v; } } return choice; }; choice = calcChoice(true, slide.atom.b); choices = [choice]; otherAtoms = _.shuffleWithSeed(_.filter(slide.trainerParams.atoms, function(atom){ return atom.b !== slide.atom.b; })); totalButtons = slide.trainerParams.totalButtons || 3; otherAtoms = otherAtoms.slice(0, totalButtons - 1); for (i$ = 0, len$ = otherAtoms.length; i$ < len$; ++i$) { atom = otherAtoms[i$]; choice = calcChoice(false, atom.b); choices.push(choice); } return choices; }; })(); trainers/soundButtons/calcChoices/calc.ls (function(){ return function(slide){ var choices; choices = _.ensureArray(slide.atom.b); if (_.filter(choices, "correct").length === 0) { choices = inc("automatic/calc")(slide); } return choices; }; })(); trainers/soundButtons/fixLayout/fix.ls (function(){ return function(slide){ var b, lastWindowWidth, linebreak, top, f; b = slide.buttons; lastWindowWidth = 0; linebreak = Div({ marginBottom: "-1.2em" }).html("
"); top = function(b){ return b.offset().top; }; f = function(){ var windowWidth, ref$; windowWidth = body.width(); if (lastWindowWidth !== windowWidth) { linebreak.remove(); lastWindowWidth = windowWidth; if (b.length === 4 && (top(b[0]) === (ref$ = top(b[1])) && ref$ === top(b[2])) && top(b[2]) !== top(b[3])) { b[1].after(linebreak); } } if (slide.div.isVisible()) { return requestAnimationFrame(f); } }; return f(); }; })(); trainers/soundButtons/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.choices = inc("calcChoices/calc")(slide); slide.totalProgressElements = _.filter(slide.choices, "correct").length; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/soundButtons/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/soundButtons/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.textA = inc("textA/text")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/soundButtons/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/soundButtons/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/soundButtons/textA/text.ls (function(){ return function(slide){ var image, lsg, div; if (slide.getParam("soundMode", slide.atom) === "askSound" || !slide.atom.a) { return; } image = slide.getParam("image", slide.atom); lsg = slide.getParam("lsg", slide.atom); div = inc("/shared/textA/text")(slide); div.css({ maxWidth: "90%", width: "30em", padding: image || lsg ? "0.5em 1em" : "0 1em" }); if (slide.atom.a) { slide.div.append(div); } return div; }; })(); trainers/squareMirror/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { debug("no soundMode b"); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/squareMirror/_preview/preview.ls (function(){ return function(slide){ return slide.interactive.init(slide.atom.b); }; })(); trainers/squareMirror/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, interactive, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.interactive.remove(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; interactive = inc("../../interactive/interactive")(slide); interactive.init(slide.atom.b); if (a.resolved) { interactive.solve(); } else { interactive.set(a.selectedValues); } results$.push(slide.div.append(Div({ margin: "3em 0" }).append(interactive, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : a.resolved ? Color.grey[500] : Color.red[500] }).html(a.correct ? T("correct") : a.resolved ? T("solutionClicked") : T("wrong")))))); } return results$; } }; })(); trainers/squareMirror/_start/start.ls (function(){ return function(slide){ var ref$; slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); slide.interactive.init(slide.atom.b); return typeof (ref$ = slide.interactive).onReady == 'function' ? ref$.onReady() : void 8; }; })(); trainers/squareMirror/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/squareMirror/buttons/buttons.ls (function(){ return function(slide){ var div; slide.div.append(div = Div({ margin: "1em 0" }).append(slide.solveButton = inc("solveButton/button")(slide), slide.clearButton = inc("clearButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide))); return div; }; })(); trainers/squareMirror/buttons/checkButton/button.ls (function(){ return function(slide){ var click; click = function(button){ var result; slide.buttons.css({ pointerEvents: "none" }); result = slide.interactive.validate(); if (result.isCorrect === true) { slide.score.addActionCorrect(slide.atom, { selectedValues: result.selectedValues }); slide.score.log(slide.atom); button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); return setTimeout(slide.finish, 1000); } else { slide.score.addActionMistake(slide.atom, { selectedValues: result.selectedValues }); button.setState("wrong"); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ button.setState("normal"); if (!slide.solveButton.isVisible()) { slide.solveButton.showButton(); } return slide.buttons.css({ pointerEvents: "" }); }, 500); } }; return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/squareMirror/buttons/clearButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ return slide.interactive.clear(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/bin.svg"), action: click }).css({ margin: "0.5em" }); }; })(); trainers/squareMirror/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/squareMirror/buttons/solveButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ slide.buttons.css({ pointerEvents: "none" }); slide.interactive.css({ pointerEvents: "none" }); slide.interactive.solve(); slide.levelPlayer.progressBar.showGrey(); slide.score.addActionResolved(slide.atom); slide.score.log(slide.atom); return setTimeout(function(){ var ref$; div.hide(); slide.checkButton.hide(); slide.clearButton.hide(); if ((ref$ = slide.backButton) != null) { ref$.hide(); } slide.continueButton.showButton(); return slide.buttons.css({ pointerEvents: "" }); }, 500); }; div = Button({ label: T("solveButton"), icon: path("/../app01/lib/svg/icon/lock-open.svg") }).css({ margin: "0.5em" }).tap(click).hide(); div.showButton = showButton; return div; }; })(); trainers/squareMirror/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/squareMirror/gridSize/gridSize.ls (function(){ return function(slide){ var s, ref$; s = (ref$ = slide.getParam("gridSize", slide.atom)) != null ? ref$ : 10; if (s % 2 !== 0) { debug("Achtung, squareMirror sollte eine gerade Zahl als gridSize haben!"); } if (s < 6) { debug("Achtung, eine gridSize < 6 ist nicht zulässig"); s = 6; } else if (s > 14) { debug("Achtung, eine gridSize > 14 ist nicht zulässig"); s = 14; } return s; }; })(); trainers/squareMirror/init.ls (function(){ return function(slide){ slide.gridSize = inc("gridSize/gridSize")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); slide.interactive = inc("interactive/interactive")(slide); slide.buttons = inc("buttons/buttons")(slide); return slide.div.onWindowResize(function(){ return inc("onWindowResize/resize")(slide); }); }; })(); trainers/squareMirror/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/squareMirror/interactive/cell/cell.ls (function(){ return function(slide, parent, cells, i){ var selected, disabled, triggered, start, isSelected, down, up, click, changeValue, s, div; selected = false; disabled = false; triggered = false; start = function(){ return div.bind("mouseenter", function(e){ if (parent.mouseDown) { return changeValue(); } }).bind("touchmove", function(e){ var x, ref$, y, ref1$, div; e.preventDefault(); x = (ref$ = e.touches) != null ? ref$[0].pageX : void 8; y = (ref1$ = e.touches) != null ? ref1$[0].pageY : void 8; div = document.elementFromPoint(x, y); if (div != null && div.hasClass("cell")) { if (!div.isTriggered()) { div.changeValue(); } return div.setTriggered(true); } }).bind("touchend", function(e){ var i$, ref$, len$, c, results$ = []; e.preventDefault(); for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.setTriggered(false)); } return results$; }).bind("mousedown touchstart", down).bind("mouseup", up); }; isSelected = function(){ return selected; }; down = function(){ parent.mouseDown = true; return parent.selectMode = click(); }; up = function(){ return parent.mouseDown = false; }; click = function(){ if (!selected) { div.css({ backgroundColor: Color.blue[200] }); } else { div.css({ backgroundColor: 'white' }); } selected = !selected; return selected; }; changeValue = function(){ if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } if (parent.selectMode) { div.css({ backgroundColor: Color.blue[200] }); } else { div.css({ backgroundColor: 'white' }); } if (parent.selectMode) { if (!selected) { return selected = !selected; } } else { if (selected) { return selected = !selected; } } }; s = slide.gridSize; div = Div().addClass("cell").css({ position: "absolute", left: i % s * (100 / s) + "%", top: _.floor(i / s) * (100 / s) + "%", height: 100 / s + "%", width: 100 / s + "%", outline: "1px solid black", cursor: "pointer", backgroundColor: "white", backgroundClip: "border-box" }).html(" "); div.isSelected = isSelected; div.deselect = function(){ if (selected) { div.css({ backgroundColor: 'white' }); return selected = false; } }; div.select = function(){ if (!selected && !disabled) { div.css({ backgroundColor: Color.blue[200] }); return selected = true; } }; div.disable = function(){ disabled = true; return div.css({ pointerEvents: "none", backgroundColor: Color.grey[400] }); }; div.isTriggered = function(){ return triggered; }; div.setTriggered = function(b){ return triggered = b; }; div.changeValue = changeValue; div.start = start; return div; }; })(); trainers/squareMirror/interactive/interactive.ls (function(){ return function(slide){ var o, cells, mouseDown, selectMode, validate, onReady, solve, clear, get, set, init, redraw, size, div, element, i, c; o = {}; o.mirror = slide.getParam("mirror", slide.atom) || "vertical"; cells = []; mouseDown = false; selectMode = true; validate = function(){ return inc("validate/validate")(slide, o, cells); }; onReady = function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.start()); } return results$; }; solve = function(){ var i$, ref$, len$, cell, ref1$; clear(); if (!o.solution) { validate(); } for (i$ = 0, len$ = (ref$ = o.solution).length; i$ < len$; ++i$) { cell = ref$[i$]; if ((ref1$ = cells[cell - 1]) != null) { ref1$.select(); } } return div.css({ pointerEvents: "none" }); }; clear = function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.deselect()); } return results$; }; get = function(){ var i$, ref$, len$, i, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; if (c.isSelected()) { results$.push(i + 1); } } return results$; }; set = function(vals){ var i$, len$, v, ref$, results$ = []; for (i$ = 0, len$ = vals.length; i$ < len$; ++i$) { v = vals[i$]; results$.push((ref$ = cells[v - 1]) != null ? ref$.select() : void 8); } return results$; }; init = function(vals){ var i$, len$, v, ref$, results$ = []; for (i$ = 0, len$ = vals.length; i$ < len$; ++i$) { v = vals[i$]; results$.push((ref$ = cells[v - 1]) != null ? ref$.disable() : void 8); } return results$; }; redraw = function(){ div.findFirst(".mirror").remove(); return element.append(inc("mirror/mirror")(o, cells)); }; size = body.width() < inc("/../app01/lib/util/emToPx/emToPx")(22) ? "16em" : "20em"; slide.div.append(div = Div().append(element = Div({ display: "inline-block", width: size, height: size }))); element.append((function(){ var i$, to$, results$ = []; for (i$ = 0, to$ = Math.pow(slide.gridSize, 2) - 1; i$ <= to$; ++i$) { i = i$; c = inc("cell/cell")(slide, div, cells, i); cells.push(c); results$.push(c); } return results$; }()), inc("mirror/mirror")(o, cells)); element.bind("mouseleave", function(){ return div.mouseDown = false; }); div.cells = cells; div.solve = solve; div.selectMode = selectMode; div.mouseDown = mouseDown; div.validate = validate; div.get = get; div.set = set; div.init = init; div.clear = clear; div.onReady = onReady; div.redraw = redraw; return div; }; })(); trainers/squareMirror/interactive/mirror/drawMirror/draw.ls (function(){ return function(parent, mode){ var div; return div = mode === "point" ? inc("point/point")(parent) : inc("line/line")(parent, mode); }; })(); trainers/squareMirror/interactive/mirror/drawMirror/line/line.ls (function(){ return function(parent, mode){ var svg, line, w, h; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; line = svg("line"); line.setAttribute("stroke-width", "0.2em"); line.setAttribute("stroke", "black"); w = parent.offset().width; h = parent.offset().height; parent.append(line); if (mode === "vertical") { line.setAttribute("x1", w / 2); line.setAttribute("y1", 0); line.setAttribute("x2", w / 2); return line.setAttribute("y2", h); } else if (mode === "horizontal") { line.setAttribute("x1", 0); line.setAttribute("y1", h / 2); line.setAttribute("x2", w); return line.setAttribute("y2", h / 2); } else if (mode === "diagonalRight") { line.setAttribute("x1", w); line.setAttribute("y1", 0); line.setAttribute("x2", 0); return line.setAttribute("y2", h); } else { line.setAttribute("x1", 0); line.setAttribute("y1", 0); line.setAttribute("x2", w); return line.setAttribute("y2", h); } }; })(); trainers/squareMirror/interactive/mirror/drawMirror/point/point.ls (function(){ return function(parent){ var svg, circle; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; circle = svg("circle"); circle.setAttribute("stroke-width", 4); circle.setAttribute("stroke", "black"); parent.append(circle); circle.setAttribute("cx", parent.offset().width / 2); circle.setAttribute("cy", parent.offset().height / 2); return circle.setAttribute("r", 4); }; })(); trainers/squareMirror/interactive/mirror/mirror.ls (function(){ return function(o, cells){ var svg, div; svg = function(tag){ return document.createElementNS("http://www.w3.org/2000/svg", tag); }; div = svg("svg").addClass("mirror"); div.setAttribute("width", "104%"); div.setAttribute("height", "104%"); div.css({ position: "absolute", left: "-2%", top: "-2%", pointerEvents: "none" }).onDomAppendAndVisible(function(){ return inc("drawMirror/draw")(div, o.mirror); }); return div; }; })(); trainers/squareMirror/interactive/validate/fixDiagonal/fix.ls (function(){ return function(o, slide, values){ var doubleCells, res$, i$, to$, i, intersection; if (o.mirror === "diagonalRight") { res$ = []; for (i$ = 1, to$ = slide.gridSize; i$ <= to$; ++i$) { i = i$; if (i === 1) { res$.push(slide.gridSize); } else { res$.push(i * slide.gridSize - (i - 1)); } } doubleCells = res$; } else if (o.mirror === "diagonalLeft") { res$ = []; for (i$ = 0, to$ = slide.gridSize - 1; i$ <= to$; ++i$) { i = i$; res$.push(i * 11 + 1); } doubleCells = res$; } intersection = _.intersection(doubleCells, slide.atom.b); return values.concat(intersection); }; })(); trainers/squareMirror/interactive/validate/mirror/mirror.ls (function(){ return function(slide, mode){ var vs, s, mirrored, res$, i$, len$, v, tens, one, newV, x, y, v1; vs = slide.atom.b; s = slide.gridSize; if (s % 2 !== 0) { debug("Achtung, die gridSize muss gerade sein!"); } vs = _.map(vs, function(v){ return v - 1; }); res$ = []; for (i$ = 0, len$ = vs.length; i$ < len$; ++i$) { v = vs[i$]; tens = Math.floor(v / s) * s; one = v - tens; if (mode === "horizontal") { res$.push(newV = tens <= (s * s) / 2 ? v + ((s * s) / 2 - tens) * 2 - s : v - (tens - (s * s) / 2) * 2 - s); } else if (mode === "vertical") { res$.push(newV = one < s / 2 ? v + (s / 2 - one) * 2 - 1 : v - (one - s / 2) * 2 - 1); } else if (mode === "diagonalRight") { x = one; y = s - 1 - tens / s; res$.push(newV = (s - 1 - x) * s + y); } else if (mode === "diagonalLeft") { x = one; y = tens / s; res$.push(newV = x * s + y); } else if (mode === "point") { v1 = one < s / 2 ? v + (s / 2 - one) * 2 - 1 : v - (one - s / 2) * 2 - 1; res$.push(newV = tens <= (s * s) / 2 ? v1 + ((s * s) / 2 - tens) * 2 - s : v1 - (tens - (s * s) / 2) * 2 - s); } } mirrored = res$; return _.sortBy(_.map(mirrored, function(v){ return v + 1; })); }; })(); trainers/squareMirror/interactive/validate/validate.ls (function(){ return function(slide, o, cells){ var mirror, uniqSolutions, selectedValues, res$, i$, len$, i, c, isCorrect; mirror = function(){ return inc("mirror/mirror")(slide, o.mirror); }; if (!o.solution) { o.solution = mirror(); } uniqSolutions = _.uniq(o.solution); if (uniqSolutions.length !== o.solution.length) { debug("Achtung! Es sind doppelte Felder spezifiziert!"); o.solution = uniqSolutions; } res$ = []; for (i$ = 0, len$ = cells.length; i$ < len$; ++i$) { i = i$; c = cells[i$]; if (c.isSelected()) { res$.push(i + 1); } } selectedValues = res$; if (_.startsWith(o.mirror, "diagonal")) { selectedValues = inc("fixDiagonal/fix")(o, slide, selectedValues); } selectedValues = _.sortBy(selectedValues); isCorrect = _.isEqual(o.solution, selectedValues); return { isCorrect: isCorrect, selectedValues: selectedValues }; }; })(); trainers/squareMirror/onWindowResize/resize.ls (function(){ return function(slide){ return requestAnimationFrame(function(){ return slide.interactive.redraw(); }); }; })(); trainers/squareMirror/textA/text.ls (function(){ return function(slide){ var click, div; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } click = function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); } }; div = Div(); if (slide.atom.a) { slide.div.append(div.append(Div({ margin: "1em 0.5em", padding: "0 0.5em", display: "inline-block" }).html(slide.atom.a).tap(click))); } return div; }; })(); trainers/squareShader/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "b") { debug("no soundMode b"); } else if (soundMode === "a" || soundMode === "askSound") { texts = [slide.atom.a]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/squareShader/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/squareShader/_review/scoreActions/actions.ls (function(){ return function(slide){ var e, i$, ref$, len$, i, a, interactive, results$ = []; e = slide.score.getScoreEvent(slide.atom); if (e) { slide.interactive.remove(); slide.buttons.remove(); for (i$ = 0, len$ = (ref$ = e.actions).length; i$ < len$; ++i$) { i = i$; a = ref$[i$]; interactive = inc("../../interactive/interactive")(slide); interactive.set(a.selectedValues); results$.push(slide.div.append(Div({ margin: "3em 0" }).append(interactive, Div({ position: "absolute", top: "-1.8em", left: "0.8em" }).html(T("numTries", i + 1)).append(Div({ display: "inline-block", color: a.correct ? Color.green[500] : Color.red[500] }).html(a.correct ? T("correct") : T("wrong")))))); } return results$; } }; })(); trainers/squareShader/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/squareShader/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/squareShader/_start/start.ls (function(){ return function(slide){ var ref$; slide.instruction.play(function(){ return inc("/shared/playAskSoundOrSoundA/play")(slide); }); return typeof (ref$ = slide.interactive).onReady == 'function' ? ref$.onReady() : void 8; }; })(); trainers/squareShader/buttons/buttons.ls (function(){ return function(slide){ return Div({ margin: "1em 0" }).append(slide.clearButton = inc("clearButton/button")(slide), slide.checkButton = inc("checkButton/button")(slide), slide.continueButton = inc("continueButton/button")(slide)).appendTo(slide.div); }; })(); trainers/squareShader/buttons/checkButton/button.ls (function(){ return function(slide){ var click; click = function(button){ var result; slide.buttons.css({ pointerEvents: "none" }); result = slide.interactive.validate(); if (result === true) { button.setState("correct"); slide.levelPlayer.progressBar.showGreen(); return setTimeout(slide.finish, 1000); } else { button.setState("wrong"); slide.levelPlayer.progressBar.addElement().showRed(); return setTimeout(function(){ button.setState("normal"); return slide.buttons.css({ pointerEvents: "" }); }, 500); } }; return Button({ label: T("checkButton"), icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right", action: click, key: "enter" }).css({ margin: "0.5em" }); }; })(); trainers/squareShader/buttons/clearButton/button.ls (function(){ return function(slide){ var click, div; click = function(){ return slide.interactive.clear(); }; return div = Button({ icon: path("/../app01/lib/svg/icon/bin.svg"), action: click }).css({ margin: "0.5em" }); }; })(); trainers/squareShader/buttons/continueButton/button.ls (function(){ return function(slide){ var showButton, click, div; showButton = function(){ div.hide(); return div.fadeIn(); }; click = function(){ div.css({ pointerEvents: "none" }); return setTimeout(slide.finish, 500); }; div = Button({ label: T("continueButton"), action: click, icon: path("/../app01/lib/svg/icon/arrow-right-small.svg"), iconPosition: "right" }).css({ margin: "0.5em" }).hide(); div.showButton = showButton; return div; }; })(); trainers/squareShader/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/squareShader/gridSize/gridSize.ls (function(){ return function(slide){ var s, ref$; s = (ref$ = slide.getParam("gridSize", slide.atom)) != null ? ref$ : 10; if (s < 6) { debug("Achtung, eine gridSize < 6 ist nicht zulässig"); s = 6; } else if (s > 14) { debug("Achtung, eine gridSize > 14 ist nicht zulässig"); s = 14; } return s; }; })(); trainers/squareShader/init.ls (function(){ return function(slide){ slide.gridSize = inc("gridSize/gridSize")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.textA = inc("textA/text")(slide); slide.interactive = inc("interactive/interactive")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/squareShader/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/squareShader/interactive/cell/cell.ls (function(){ return function(slide, parent, cells, i){ var selected, triggered, start, down, up, click, changeValue, s, div; selected = false; triggered = false; start = function(){ return div.bind("mouseenter", function(e){ if (parent.mouseDown) { return changeValue(); } }).bind("touchmove", function(e){ var x, ref$, y, ref1$, div; e.preventDefault(); x = (ref$ = e.touches) != null ? ref$[0].pageX : void 8; y = (ref1$ = e.touches) != null ? ref1$[0].pageY : void 8; div = document.elementFromPoint(x, y); if (div != null && div.hasClass("cell")) { if (!div.isTriggered()) { div.changeValue(); return div.setTriggered(true); } } }).bind("touchend", function(e){ var i$, ref$, len$, c, results$ = []; up(); e.preventDefault(); for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.setTriggered(false)); } return results$; }).bind("mousedown touchstart", down).bind("mouseup", up); }; down = function(){ parent.mouseDown = true; return parent.selectMode = click(); }; up = function(){ return parent.mouseDown = false; }; click = function(){ if (!selected) { div.css({ backgroundColor: Color.blue[200] }); } else { div.css({ backgroundColor: 'white' }); } selected = !selected; return selected; }; changeValue = function(){ if (typeof vibrate == 'function') { vibrate(VIBRATION_TYPES.selection); } if (parent.selectMode) { div.css({ backgroundColor: Color.blue[200] }); } else { div.css({ backgroundColor: 'white' }); } if (parent.selectMode) { if (!selected) { return selected = !selected; } } else { if (selected) { return selected = !selected; } } }; s = slide.gridSize; div = Div().addClass("cell").css({ position: "absolute", left: i % s * (100 / s) + "%", top: _.floor(i / s) * (100 / s) + "%", height: 100 / s + "%", width: 100 / s + "%", outline: "1px solid black", cursor: "pointer", backgroundColor: "white", backgroundClip: "border-box" }).html(" "); div.isSelected = function(){ return selected; }; div.deselect = function(){ div.css({ backgroundColor: 'white' }); return selected = false; }; div.select = function(){ div.css({ backgroundColor: Color.blue[200] }); return selected = true; }; div.isTriggered = function(){ return triggered; }; div.setTriggered = function(b){ return triggered = b; }; div.changeValue = changeValue; div.start = start; return div; }; })(); trainers/squareShader/interactive/interactive.ls (function(){ return function(slide){ var o, cells, mouseDown, selectMode, validate, onReady, solve, clear, get, set, size, div, element, i, c; o = {}; cells = []; mouseDown = false; selectMode = true; validate = function(){ return inc("validate/validate")(slide, cells, o); }; onReady = function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.start()); } return results$; }; solve = function(b){ debug("todo"); return clear(); }; clear = function(){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.deselect()); } return results$; }; get = function(){ var i$, ref$, len$, i, c, results$ = []; for (i$ = 0, len$ = (ref$ = cells).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; if (c.isSelected()) { results$.push(i + 1); } } return results$; }; set = function(vals){ var i$, len$, v, ref$, results$ = []; clear(); if (!vals) { return; } if (_.isString(vals)) { if (_.includes(vals, ",")) { vals = vals.split(","); } else { vals = vals.split(" "); } } for (i$ = 0, len$ = vals.length; i$ < len$; ++i$) { v = vals[i$]; results$.push((ref$ = cells[v - 1]) != null ? ref$.select() : void 8); } return results$; }; size = body.width() < 420 ? 300 : 400; slide.div.append(div = Div().append(element = Div({ display: "inline-block", width: size + "px", height: size + "px" }))); element.append((function(){ var i$, to$, results$ = []; for (i$ = 0, to$ = Math.pow(slide.gridSize, 2) - 1; i$ <= to$; ++i$) { i = i$; c = inc("cell/cell")(slide, div, cells, i); cells.push(c); results$.push(c); } return results$; }())); element.bind("mouseleave", function(){ return div.mouseDown = false; }); div.cells = cells; div.selectMode = selectMode; div.mouseDown = mouseDown; div.validate = validate; div.get = get; div.set = set; div.onReady = onReady; div.solve = solve; div.clear = clear; return div; }; })(); trainers/squareShader/interactive/validate/validate.ls (function(){ return function(slide, cells, o){ var s, selectedValues, res$, i$, len$, i, c, hasNeighbor, getNeighbors, getShape, allHaveNeighbors, numberOfAreas, correct; s = slide.gridSize; res$ = []; for (i$ = 0, len$ = cells.length; i$ < len$; ++i$) { i = i$; c = cells[i$]; if (c.isSelected()) { res$.push(i + 1); } } selectedValues = res$; hasNeighbor = function(v, vs){ return _.includes(vs, v - 1) || _.includes(vs, v + 1) || _.includes(vs, v - s) || _.includes(vs, v + s); }; getNeighbors = function(v, vs){ var ns, ns1, n; ns = [v - 1, v + 1, v - s, v + s]; return ns1 = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = ns).length; i$ < len$; ++i$) { n = ref$[i$]; if (_.includes(vs, n)) { results$.push(n); } } return results$; }()); }; getShape = function(v, vs){ var allNs, r, i$, ref$, len$, n; allNs = []; r = function(_n, _vs){ var ns, news, i$, len$, oneNew, results$ = []; ns = getNeighbors(_n, _vs); news = _.difference(ns, allNs); if (news) { allNs = allNs.concat(news); for (i$ = 0, len$ = news.length; i$ < len$; ++i$) { oneNew = news[i$]; results$.push(r(oneNew, _vs)); } return results$; } }; for (i$ = 0, len$ = (ref$ = getNeighbors(v, vs)).length; i$ < len$; ++i$) { n = ref$[i$]; r(n, vs); } return _.sortBy(allNs); }; allHaveNeighbors = function(vs){ var i$, len$, v; for (i$ = 0, len$ = vs.length; i$ < len$; ++i$) { v = vs[i$]; if (!hasNeighbor(v, vs)) { return false; } } return true; }; numberOfAreas = function(vs){ var usedVs, i, i$, len$, v; usedVs = []; i = 0; for (i$ = 0, len$ = vs.length; i$ < len$; ++i$) { v = vs[i$]; if (!_.includes(usedVs, v)) { usedVs = usedVs.concat(getShape(v, vs)); i++; } } return i; }; correct = true; if (selectedValues.length !== slide.atom.b) { correct = false; } if (!allHaveNeighbors(selectedValues)) { correct = false; } if (numberOfAreas(selectedValues) > 1) { correct = false; } if (correct) { slide.score.addActionCorrect(slide.atom, { selectedValues: selectedValues }); slide.score.log(slide.atom); } else { slide.score.addActionMistake(slide.atom, { selectedValues: selectedValues }); } return correct; }; })(); trainers/squareShader/textA/text.ls (function(){ return function(slide){ var click, div; if (!slide.atom.a) { return; } click = function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); } }; slide.div.append(Div().append(div = Div({ margin: "1em 0.5em", padding: "0 0.5em", display: "inline-block" }).tap(click).html(slide.atom.a || ""))); return div; }; })(); trainers/syllabifier/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/syllabifier/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/syllabifier/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, elements, word, res$, i$, len$, e, voiceLang, voice, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); if (slide.atom.sound) { texts = [slide.atom.sound]; } else if (soundMode === "a" || soundMode === "b") { elements = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); elements = _.filter(elements, { correct: true }); res$ = []; for (i$ = 0, len$ = elements.length; i$ < len$; ++i$) { e = elements[i$]; res$.push(e.text); } word = res$; word = word.join(""); texts = [word]; } else { texts = []; } voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/syllabifier/_preview/preview.ls (function(){ return function(slide){ var i$, ref$, len$, c, results$ = []; for (i$ = 0, len$ = (ref$ = slide.div.find(".clickContainer")).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.css({ pointerEvents: "none" })); } return results$; }; })(); trainers/syllabifier/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", margin: "2em 0" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/syllabifier/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ var l1, l2; l1 = action.betweenChars[0]; l2 = action.betweenChars[1]; return Div({ display: "inline-block" }).html(T("betweenXAndY", l1, l2)); }; })(); trainers/syllabifier/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return inc("../correct/correct")(action, slide); }; })(); trainers/syllabifier/_start/start.ls (function(){ return function(slide){ slide.instruction.play(function(){ return inc("/shared/playSoundA/play")(slide.atom, slide); }); if (slide.word.length > 8) { return debug("Syllabifier-Warnung: Dein Wort ist länger als 8 Buchstaben. Bitte prüfe, ob es auf einem iPhone 5 passt."); } }; })(); trainers/syllabifier/_t.ls (function(){ return { betweenXAndY: { de: "Zwischen $1 und $2", en: "Between $1 and $2", fr: "Entre $1 et $2", es: "Entre $1 y $2", pt: "Entre $1 e $2" } }; })(); trainers/syllabifier/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, parts, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; parts = inc("/shared/convertPlusPlusString/convert")(atom.b); if (parts.length > 1) { slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.totalProgressElements = _.filter(parts, { correct: true }).length - 1; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : true; results$.push(slide); } } return results$; }()); }; })(); trainers/syllabifier/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/syllabifier/init.ls (function(){ return function(slide){ slide.currentGreen = 0; slide.instruction = inc("instruction/instruction")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.text = inc("text/text")(slide); return slide.playSoundAndFinish = function(){ return inc("playSoundAndFinish/play")(slide); }; }; })(); trainers/syllabifier/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/syllabifier/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/syllabifier/playSoundAndFinish/play.ls (function(){ return function(slide){ var finish; finish = function(){ var i$, ref$, len$, c, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.div.find(".clickContainer")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ pointerEvents: "none" }); } slide.div.css({ pointerEvents: "none" }); slide.finish(); for (i$ = 0, len$ = (ref$ = slide.characters).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push((ref1$ = c.divider) != null ? ref1$.removeIcons() : void 8); } return results$; }; return setTimeout(function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "b") { text = slide.atom.sound || slide.word; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(finish); } else { return finish(); } }, 300); }; })(); trainers/syllabifier/text/calcSeparations/calc.ls (function(){ return function(slide){ var charCounter, separations, res$, i$, ref$, len$, e; charCounter = 0; res$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { e = ref$[i$]; res$.push(charCounter += e.text.length); } separations = res$; return separations.slice(void 8, -1); }; })(); trainers/syllabifier/text/character/character.ls (function(){ return function(slide, c, i){ var div, divider; div = Div({ display: "inline-block", padding: "0 0.2em", fontSize: "2em", pointerEvents: "none" }).html(c); if (i + 1 !== slide.word.length) { div.append(divider = inc("divider/divider")(slide, i + 1)); } div.divider = divider; return div; }; })(); trainers/syllabifier/text/character/divider/animate/animate.ls (function(){ return function(divider, line, isCorrect, onAnimateDone){ line.animateStart(isCorrect); setTimeout(function(){ return line.animateEnd(isCorrect); }, 300); if (isCorrect) { setTimeout(function(){ divider.css({ transition: "100ms" }); return divider.removeIcons(); }, 500); } return setTimeout(function(){ divider.css({ transition: "" }); line.css({ transition: "" }); return onAnimateDone(isCorrect); }, 600); }; })(); trainers/syllabifier/text/character/divider/animate/start.ls (function(){ return function(divider, line){ return line.animateStart(); }; })(); trainers/syllabifier/text/character/divider/divider.ls (function(){ return function(slide, i){ var removeIcons, down, up, cancel, onAnimateDone, onCorrect, onWrong, div, line; removeIcons = function(){ var ref$, ref1$; if ((ref$ = line.iconTop) != null) { ref$.remove(); } return (ref1$ = line.iconBottom) != null ? ref1$.remove() : void 8; }; down = function(){ return inc("animate/start")(div, line); }; up = function(){ div.css({ pointerEvents: "none" }); if (_.includes(slide.separations, i)) { return onCorrect(); } else { return onWrong(); } }; cancel = function(){ return inc("animate/animate")(div, line, undefined, onAnimateDone); }; onAnimateDone = function(isCorrect){ if (div.isDisabled) { return; } if (!isCorrect) { return div.css({ pointerEvents: "auto" }); } }; onCorrect = function(){ var i$, ref$, len$, c; slide.currentGreen++; slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atom, { betweenChars: slide.word[i - 1] + slide.word[i] }); inc("animate/animate")(div, line, true, onAnimateDone); if (slide.currentGreen === slide.separations.length) { slide.score.log(slide.atom); for (i$ = 0, len$ = (ref$ = slide.div.find(".clickContainer")).length; i$ < len$; ++i$) { c = ref$[i$]; c.css({ pointerEvents: "none" }); c.isDisabled = true; } return setTimeout(function(){ return slide.playSoundAndFinish(); }, 500); } }; onWrong = function(){ slide.levelPlayer.progressBar.addElement().showRed(); slide.score.addActionMistake(slide.atom, { betweenChars: slide.word[i - 1] + slide.word[i] }); return inc("animate/animate")(div, line, false, onAnimateDone); }; div = Div().addClass("clickContainer").css({ display: "inline-block", position: "absolute", right: "-0.5em", top: "-0.6em", height: "2.9em", width: "1em", verticalAlign: "middle", cursor: "pointer", pointerEvents: "auto" }).append(line = inc("line/line")()).tap({ down: down, up: up, cancel: cancel, animation: "none" }); div.removeIcons = removeIcons; return div; }; })(); trainers/syllabifier/text/character/divider/line/iconBottom/icon.ls (function(){ return function(){ var div; return div = SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-up.svg"), color: Color.grey[500] }).css({ position: "absolute", top: "1.15em", left: "-0.227em", width: "0.5em", height: "0.5em" }); }; })(); trainers/syllabifier/text/character/divider/line/iconTop/icon.ls (function(){ return function(){ var div; return div = SvgIcon({ svg: path("/../app01/lib/svg/icon/arrow-down.svg"), color: Color.grey[500] }).css({ position: "absolute", top: "-0.38em", left: "-0.227em", width: "0.5em", height: "0.5em" }); }; })(); trainers/syllabifier/text/character/divider/line/line.ls (function(){ return function(){ var animateStart, animateEnd, div, iconTop, iconBottom; animateStart = function(isCorrect){ var color; color = isCorrect != null ? isCorrect ? Color.green[500] : Color.red[500] : Color.grey[500]; div.css({ transform: "scale(1.3)", backgroundColor: color }); iconTop.css({ transition: "" }); iconBottom.css({ transition: "" }); iconTop.setColor(color); return iconBottom.setColor(color); }; animateEnd = function(isCorrect){ var color; color = isCorrect ? Color.black : "transparent"; div.css({ transition: "500ms", transform: "scale(1)", backgroundColor: color }); iconTop.css({ transition: "500ms" }); iconBottom.css({ transition: "500ms" }); iconTop.setColor(Color.grey[500]); return iconBottom.setColor(Color.grey[500]); }; div = Div({ position: "absolute", top: "0.65em", left: "0.5em", pointerEvents: "none", width: "1.4px", height: "1.3em" }).append(iconTop = inc("iconTop/icon")(), iconBottom = inc("iconBottom/icon")()); div.iconTop = iconTop; div.iconBottom = iconBottom; div.animateStart = animateStart; div.animateEnd = animateEnd; return div; }; })(); trainers/syllabifier/text/fixCharacterWidth/fix.ls (function(){ return function(slide){ var maxW, i$, ref$, len$, c, results$ = []; maxW = _.max(_.map(slide.characters, function(c){ return c.width(); })); for (i$ = 0, len$ = (ref$ = slide.characters).length; i$ < len$; ++i$) { c = ref$[i$]; results$.push(c.css({ width: maxW + "px" })); } return results$; }; })(); trainers/syllabifier/text/text.ls (function(){ return function(slide){ var elements, t, div, res$, i$, ref$, len$, i, c, character; elements = inc("/shared/convertPlusPlusString/convert")(slide.atom.b); slide.elements = _.filter(elements, { correct: true }); slide.word = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.elements).length; i$ < len$; ++i$) { t = ref$[i$]; results$.push(t.text); } return results$; }()).join(""); slide.separations = inc("calcSeparations/calc")(slide); slide.div.append(div = Div({ whiteSpace: "nowrap", margin: "2em 0" })); res$ = []; for (i$ = 0, len$ = (ref$ = slide.word).length; i$ < len$; ++i$) { i = i$; c = ref$[i$]; character = inc("character/character")(slide, c, i); div.append(character); res$.push(character); } slide.characters = res$; inc("fixCharacterWidth/fix")(slide); return div; }; })(); trainers/table/_media2/images/images.ls (function(){ return function(slide){ var images, atom; return images = _.concat(slide.getParam("image"), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("image", atom.b)); } return results$; }())); }; })(); trainers/table/_media2/lsgs/lsgs.ls (function(){ return function(slide){ var images, atom; return images = _.concat(slide.getParam("lsg"), (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; results$.push(slide.getParam("lsg", atom.b)); } return results$; }())); }; })(); trainers/table/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, i$, ref$, len$, atom, voiceLang, voice, texts2, solutions, j$, len1$, t; sounds = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; voiceLang = slide.getParam("voiceLang", atom); voice = slide.getParam("voice", atom); if (!(_.includes(atom.b, "((") || _.includes(atom.b, ""))) { continue; } if (atom.sound != null) { sounds.push({ text: atom.sound, voice: voice, voiceLang: voiceLang }); } else if (slide.getParam("soundMode", atom) === "b") { texts2 = []; solutions = inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.b }); texts2 = texts2.concat(solutions); for (j$ = 0, len1$ = texts2.length; j$ < len1$; ++j$) { t = texts2[j$]; if (t != null) { sounds.push({ text: t, voice: voice, voiceLang: voiceLang }); } } } } return sounds; }; })(); trainers/table/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/table/_review/scoreActions/action/action.ls (function(){ return function(slide, action){ var element; element = _.find(slide.elements, function(el){ return el.atom.id === action.scoreEvent.atom.id; }); if (!element) { return; } return inc("/shared/gapComponent/scoreActions/actions")({ slide: slide, gapComponent: element, actions: [action], showYellowTag: true, yellowTagsCountPerSlide: true }); }; })(); trainers/table/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvents, i$, ref$, len$, a, e, actions, j$, len1$, div, action; scoreEvents = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { a = ref$[i$]; e = slide.score.getScoreEvent(a); if (e) { scoreEvents.push(e); } } actions = []; for (i$ = 0, len$ = scoreEvents.length; i$ < len$; ++i$) { e = scoreEvents[i$]; for (j$ = 0, len1$ = (ref$ = e.actions).length; j$ < len1$; ++j$) { a = ref$[j$]; a.scoreEvent = e; actions.push(a); } } actions = _.orderBy(actions, "position"); if (actions.length > 0) { return div = Div({ margin: "1em auto", maxWidth: "95%" }).appendTo(slide.div).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = actions).length; i$ < len$; ++i$) { action = ref$[i$]; results$.push(inc("action/action")(slide, action)); } return results$; }())); } }; })(); trainers/table/_start/start.ls (function(){ return function(slide){ slide.levelPlayer.page.bottom.html(slide.buttonsDiv).show(); slide.startNextElement(); slide.instruction.play(); return slide.tableScrollDiv.css({ pointerEvents: "auto" }); }; })(); trainers/table/buttonsDiv/buttonsDiv.ls (function(){ return function(slide){ return ScrollDiv({ scrollbarMode: "show" }).addClass("gapTextButtonsDiv").css({ width: "100%", textAlign: "center", maxHeight: body.height() / 2 + "px" }).hide(); }; })(); trainers/table/elements/element/element.ls (function(){ return function(atom, slide){ var div, ref$, ref1$; div = ((ref$ = atom.b) != null && ref$.image) || ((ref1$ = atom.b) != null && ref1$.lsg) ? inc("imageOrLsg/imageOrLsg")(atom, slide) : inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b) === 0 ? inc("text/text")(atom, slide) : inc("gapComponent/gapComponent")(atom, slide); div.atom = atom; return div; }; })(); trainers/table/elements/element/gapComponent/gapComponent.ls (function(){ return function(atom, slide){ var p, gapMode; p = slide.getParam; gapMode = p("gapMode", atom); return inc("/shared/gapComponent/component/component")({ slide: slide, atom: atom, text: atom.b, mode: gapMode, buttonsDiv: slide.buttonsDiv, onStart: function(){ var ref$; if (typeof (ref$ = slide.levelPlayer.page).setTrainerHint == 'function') { ref$.setTrainerHint(slide, atom); } return typeof (ref$ = slide.levelPlayer.page).setCalculator == 'function' ? ref$.setCalculator(slide, atom) : void 8; }, onActionCorrect: function(action, callback){ return slide.score.addActionCorrect(atom, action, callback); }, onActionMistake: function(action){ return slide.score.addActionMistake(atom, action); }, onActionResolved: function(action){ return slide.score.addActionResolved(atom, action); }, onFinish: function(result){ return slide.score.log(atom, function(){ return inc("/shared/playSoundB/play")(atom, slide, result != null ? result.correctValue : void 8, slide.startNextElement); }); } }); }; })(); trainers/table/elements/element/imageOrLsg/imageOrLsg.ls (function(){ return function(atom, slide){ var div; if (atom.b.lsg) { div = inc("/shared/lsg/lsg")({ lsg: slide.getParam("lsg", atom.b), slide: slide }); } else if (atom.b.image) { div = inc("/shared/image/image")({ image: slide.getParam("image", atom.b), slide: slide }); } else { return; } div.isDone = function(){ return true; }; return div; }; })(); trainers/table/elements/element/text/text.ls (function(){ return function(atom, slide){ var div; div = Div({ lineHeight: "1.5em" }).html(atom.b); div.isDone = function(){ return true; }; return div; }; })(); trainers/table/elements/elements.ls (function(){ return function(slide){ var elements, atom, element, tableCell; return elements = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; element = inc("element/element")(atom, slide); tableCell = slide.table.findFirst("." + atom.id); if (tableCell != null) { tableCell.html(element); } results$.push(element); } return results$; }()); }; })(); trainers/table/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, slide, totalProgressElements, i$, len$, atom, ref$; atoms = _.ensureArray(trainerParams.atoms); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atoms = atoms; totalProgressElements = 0; for (i$ = 0, len$ = atoms.length; i$ < len$; ++i$) { atom = atoms[i$]; if (_.isString(atom.b)) { totalProgressElements += inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b); } } slide.totalProgressElements = Math.max(1, totalProgressElements); slide.finishButton = (ref$ = slide.getParam("finishButton")) != null ? ref$ : true; return slide; }; })(); trainers/table/imageOrLsg/imageOrLsg.ls (function(){ return function(slide){ var p, lsg, image, div; p = slide.getParam; lsg = p("lsg"); image = p("image"); if (lsg) { div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); } else if (image) { div = inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }); } else { return; } return div != null ? div.appendTo(slide.div) : void 8; }; })(); trainers/table/init.ls (function(){ return function(slide){ slide.instruction = inc("instruction/instruction")(slide); slide.imageOrLsg = inc("imageOrLsg/imageOrLsg")(slide); slide.table = inc("table/table")(slide); slide.buttonsDiv = inc("buttonsDiv/buttonsDiv")(slide); slide.elements = inc("elements/elements")(slide); return slide.startNextElement = inc("startNextElement/startNextElement")(slide); }; })(); trainers/table/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/table/startNextElement/startNextElement.ls (function(){ return function(slide){ return function(){ var element, page, ref$; element = _.find(slide.elements, function(e){ return !e.isDone(); }); page = slide.levelPlayer.page; if (element) { if (slide.getParam("gapMode", element.atom) === "buttons") { if ((ref$ = slide.buttonsDiv) != null) { ref$.show(); } } element.start(); inc("/shared/playSoundA/play")(element.atom, slide); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ slide.tableScrollDiv.scrollElementIntoView(element, { padding: 50 }); return page.scrollElementIntoView(element, { padding: 150 }); } }); return slide.currentElement = element; } else { slide.div.css({ pointerEvents: "none" }); if (slide.score.totalScoredAtoms() === 0) { slide.levelPlayer.progressBar.showGreen(); } return setTimeout(slide.finish, 1000); } }; }; })(); trainers/table/table/parseLayout/calcBackgroundColor/calc.ls (function(){ return function(cell, columnHeader, rowHeader, ri, ci){ var that; if (that = cell != null ? cell.color : void 8) { return that; } else if ((columnHeader && ri === 0) || (rowHeader && ci === 0)) { return Color.grey[100]; } else { return Color.white; } }; })(); trainers/table/table/parseLayout/parse.ls (function(){ return function(slide){ var layout, columnHeader, rowHeader, layout2, i$, ref$, len$, ri, r, borderLeft, borderRight, row, cells, j$, len1$, ci, id, cell, c; layout = slide.getParam("layout"); columnHeader = slide.getParam("columnHeader"); rowHeader = slide.getParam("rowHeader"); layout2 = []; for (i$ = 0, len$ = (ref$ = layout.split("\n")).length; i$ < len$; ++i$) { ri = i$; r = ref$[i$]; borderLeft = false; borderRight = false; layout2.push([]); row = r.trim(); cells = row.split(/([\s-|])+/); for (j$ = 0, len1$ = cells.length; j$ < len1$; ++j$) { ci = j$; id = cells[j$]; if (id === "" && ci === 0) { continue; } if (id === "" && ci === cells.length - 1) { _.last(layout2[ri]).borderRight = true; continue; } if (ci % 2 !== 0) { borderLeft = id === "|"; continue; } cell = { ci: ci, id: id }; if (borderLeft) { cell.borderLeft = borderLeft; } if (borderRight) { cell.borderRight = borderRight; } cell.color = inc("calcBackgroundColor/calc")(_.find(slide.atoms, fn$), columnHeader, rowHeader, ri, ci); if (!(id === " " || id === "|")) { if (/_+/.test(id)) { c = _.findLast(layout2[ri], fn1$); if (c != null) { c.colspan += 1; } cell.colspan = 0; } else { cell.colspan = 1; } } layout2[ri].push(cell); } } return layout2; function fn$(el){ return el.id === id; } function fn1$(c){ return c.colspan > 0; } }; })(); trainers/table/table/table.ls (function(){ return function(slide){ var cells, layout, table, ri, row, cell, ci, id, atom, d; cells = []; layout = inc("parseLayout/parse")(slide); slide.tableScrollDiv = ScrollDiv({ scrollbarMode: "hide", enableScrollX: true }).css({ maxWidth: "95%", width: "30em", margin: "0 auto" }).append(table = Table().css({ margin: "0.5em auto 1em", backgroundColor: Color.grey[300] }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = layout).length; i$ < len$; ++i$) { ri = i$; row = ref$[i$]; results$.push(Tr().append((fn$()))); } return results$; function fn$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = row).length; i$ < len$; ++i$) { cell = ref$[i$]; ci = cell.ci; id = cell.id; atom = _.find(slide.atoms, fn$); if (cell.colspan === 0) { continue; } d = Td(); d.attr({ colspan: cell.colspan }); d.addClass(id).css({ wordWrap: "break-word", padding: "0.5em", backgroundColor: cell.color, textAlign: slide.getParam("textAlign", atom), minWidth: slide.getParam("columnWidth") !== "small" ? "5em" : "2.5em", borderLeft: cell.borderLeft ? "2px solid " + Color.grey[300] : void 8, borderRight: cell.borderRight ? "2px solid " + Color.grey[300] : void 8 }); cells.push(d); results$.push(d); } return results$; function fn$(atom){ return atom.id === id; } } }()))).appendTo(slide.div); return table; }; })(); trainers/wordBuilder/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/wordBuilder/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/wordBuilder/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, p, atom, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; p = slide.getParam; atom = slide.atom; soundMode = p("soundMode", atom); texts = soundMode === "a" || soundMode === "askSound" ? [atom.soundA || atom.sound || atom.a] : soundMode === "b" ? inc("/shared/gapComponent/calcGapStringSolutions/calc")({ text: atom.soundB || atom.sound || atom.b }) : []; voiceLang = p("voiceLang", atom); voice = p("voice", atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/wordBuilder/_preview/preview.ls (function(){ return function(slide){ var lsg, ref$, width; lsg = (ref$ = slide.lsg) != null ? ref$.findFirst("svg") : void 8; if (!lsg) { return; } width = lsg.css("width"); return lsg.css({ width: width.replace("em", "") * 0.4 + "em" }); }; })(); trainers/wordBuilder/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return inc("/shared/gapComponent/scoreActions/actions")({ slide: slide, gapComponent: slide.textB, actions: scoreEvent.actions, showYellowTag: slide.textB.gaps().length > 1 }).appendTo(slide.div).css({ paddingTop: "1em" }); } }; })(); trainers/wordBuilder/_start/start.ls (function(){ return function(slide){ slide.instruction.play(); slide.levelPlayer.page.enableFreezeMinHeight(); slide.instruction.waitFirstPlayCompleted({ category: "scroll", callback: function(){ return slide.levelPlayer.page.scrollElementIntoView(slide.textB, { padding: 50 }); } }); inc("/shared/playSoundA/play")(slide.atom, slide); if (slide.totalGaps === 0) { slide.finishButton = true; slide.levelPlayer.page.setBottomFreeze("5em"); slide.levelPlayer.progressBar.showGreen(); return slide.finish(); } }; })(); trainers/wordBuilder/animateFinish/animate.ls (function(){ return function(slide){ return function(onDone){ var a, i$, len$, el; a = slide.textB.findAll(".solution"); for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { el = a[i$]; el.css({ pointerEvents: "none" }); el.offsetSave(); } for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { el = a[i$]; el.css({ background: "" }); if (el !== _.first(a)) { el.css({ marginLeft: "", paddingLeft: "" }); } if (el !== _.last(a)) { el.css({ marginRight: "", paddingRight: "" }); } } slide.textB.css({ display: "flex" }).secureHtml(a); for (i$ = 0, len$ = a.length; i$ < len$; ++i$) { el = a[i$]; el.offsetAnimate(); } return setTimeout(function(){ if (slide.totalGaps === 0) { slide.levelPlayer.progressBar.showGreen(); } return onDone(); }, 500); }; }; })(); trainers/wordBuilder/askSound/askSound.ls (function(){ return function(slide){ if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } return inc("/shared/askSound/ask")(slide.sounds).appendTo(slide.div).css({ margin: "-0.4em 0 0" }); }; })(); trainers/wordBuilder/calcTotalGaps/calc.ls (function(){ return function(slide){ return slide.totalGaps = _.filter(slide.parts, function(p){ var choices; if (p.gap != null) { choices = inc("/shared/convertPlusPlusString/convert")(p.gap); return _.some(choices, "correct"); } else { return false; } }).length; }; })(); trainers/wordBuilder/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, slide, totalProgressElements; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; totalProgressElements = inc("/shared/gapComponent/calcTotalGaps/calc")(atom.b); slide.totalProgressElements = Math.max(1, totalProgressElements); slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/wordBuilder/imageOrLsg/imageOrLsg.ls (function(){ return function(slide){ var p, lsg, image, div; p = slide.getParam; lsg = p("lsg", slide.atom); image = p("image", slide.atom); if (lsg) { div = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true }); } else if (image) { div = inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }); } else { return; } return div != null ? div.appendTo(slide.div) : void 8; }; })(); trainers/wordBuilder/init.ls (function(){ return function(slide){ var ref$, separator; slide.div.css({ paddingBottom: "1em", width: "35em", maxWidth: "90%", margin: "0 auto" }); slide.instruction = inc("instruction/instruction")(slide); slide.imageOrLsg = inc("imageOrLsg/imageOrLsg")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.parts = inc("/shared/convertGapString/convert")((ref$ = slide.atom.b.text) != null ? ref$ : slide.atom.b); slide.totalGaps = inc("calcTotalGaps/calc")(slide); slide.totalSolved = 0; slide.animateFinish = inc("animateFinish/animate")(slide); return slide.div.append(slide.textA = inc("textA/textA")(slide), separator = inc("separator/separator")(slide), inc("wrapper/wrapper")().append(slide.textB = inc("textB/textB")(slide))); }; })(); trainers/wordBuilder/instruction/instruction.ls (function(){ return function(slide){ return inc("/shared/instruction/instruction")(slide).appendTo(slide.div); }; })(); trainers/wordBuilder/separator/separator.ls (function(){ return function(slide){ return Div({ height: slide.imageOrLsg ? "1em" : "2em" }); }; })(); trainers/wordBuilder/textA/textA.ls (function(){ return function(slide){ if (!slide.atom.a) { return; } if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } return Div({ padding: "0.4em 0 0.2em" }).secureHtml(slide.trainerParams.learnListMode ? inc("/shared/colorBracket/color")(slide.atom.a) : slide.atom.a); }; })(); trainers/wordBuilder/textB/calcCorrectValue/calc.ls (function(){ return function(slide){ var re, s; re = new RegExp(String.fromCharCode(160), "g"); return s = _.map(slide.textB.findAll(".solution"), function(el){ return el.text().replace(re, " "); }).join(""); }; })(); trainers/wordBuilder/textB/part/gapButtons/button/button.ls (function(){ return function(choice, choices, part, slide){ var isDummyElement, playSoundBAndFinish, tapCorrect, tapWrong, div; isDummyElement = choices.length === 1 && !choice.correct; playSoundBAndFinish = function(){ var correctValue; correctValue = slide.textB.calcCorrectValue(); return inc("/shared/playSoundB/play")(slide.atom, slide, correctValue, function(){ return slide.score.log(slide.atom, slide.finish); }); }; tapCorrect = function(){ var i$, ref$, len$, el; slide.levelPlayer.progressBar.showGreen(); slide.score.addActionCorrect(slide.atom, { gap: part.gapIndex, text: choice.text }); div.css({ background: Color.green[400], pointerEvents: "none" }).addClass("solution"); for (i$ = 0, len$ = (ref$ = div.parent().childrenAll()).length; i$ < len$; ++i$) { el = ref$[i$]; if (el !== div) { el.css({ opacity: 0.2, pointerEvents: "none", background: "" }); } } slide.totalSolved++; if (slide.totalSolved === slide.totalGaps) { return setTimeout(function(){ return slide.animateFinish(playSoundBAndFinish); }, 500); } }; tapWrong = function(){ var solution, ref$; slide.levelPlayer.progressBar.addElement().showRed(); solution = (ref$ = _.find(choices, "correct")) != null ? ref$.text : void 8; slide.score.addActionMistake(slide.atom, { gap: part.gapIndex, text: choice.text, solution: solution || "dummy element" }); return div.keyframeAnimate({ keyframes: { "0%": { background: Color.red[500] }, "80%": { background: Color.red[500] }, "100%": { background: Color.grey[100] } }, duration: 800 }); }; return div = Div({ background: Color.grey[100], padding: "0.3em", margin: "0.2em" }).addClass(isDummyElement ? "solution" : void 8).secureHtml(choice.text).tap(choice.correct ? tapCorrect : tapWrong); }; })(); trainers/wordBuilder/textB/part/gapButtons/buttons.ls (function(){ return function(part, slide){ var choices, shuffleButtons, ref$, choice; choices = inc("/shared/convertPlusPlusString/convert")(part.gap); shuffleButtons = (ref$ = slide.getParam("shuffleButtons")) != null ? ref$ : true; choices = shuffleButtons ? _.shuffleWithSeed(choices) : _.orderBy(choices, function(c){ return c.text; }); return Div({ display: "inline-block" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = choices).length; i$ < len$; ++i$) { choice = ref$[i$]; results$.push(inc("button/button")(choice, choices, part, slide)); } return results$; }())); }; })(); trainers/wordBuilder/textB/part/part.ls (function(){ return function(part, i, slide){ return Div({ display: "inline-block" }).addClass(part.gap ? "gap" + part.gapIndex : void 8).html(part.space ? inc("space/space")() : part.word ? inc("word/word")(part, i, slide) : inc("gapButtons/buttons")(part, slide)); }; })(); trainers/wordBuilder/textB/part/space/space.ls (function(){ return function(){ return Div({ padding: "0.3em 0", margin: "0.2em 0.1em" }).addClass("solution").html(" "); }; })(); trainers/wordBuilder/textB/part/word/word.ls (function(){ return function(part, i, slide){ var ref$, ref1$, ref2$; return Div({ padding: (ref$ = slide.parts[i + 1]) != null && ref$.word ? "0.3em 0 0.3em 0.1em" : (ref1$ = slide.parts[i - 1]) != null && ref1$.word ? "0.3em 0.1em 0.3em 0" : "0.3em 0.1em", margin: (ref2$ = slide.parts[i - 1]) != null && ref2$.word ? "0.2em 0.2em 0.2em -0.2em" : "0.2em", textDecoration: part.underline ? "underline" : void 8, backgroundColor: part.markColor, color: part.textColor, fontWeight: part.bold ? "bold" : void 8, fontStyle: part.italic ? "italic" : void 8 }).addClass("solution").secureHtml(part.word); }; })(); trainers/wordBuilder/textB/textB.ls (function(){ return function(slide){ var div, parts, i, part; div = Div({ display: "flex", fontSize: !slide.textA ? "1.1em" : void 8 }).addClass("gapText").html(parts = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = slide.parts).length; i$ < len$; ++i$) { i = i$; part = ref$[i$]; results$.push(inc("part/part")(part, i, slide)); } return results$; }())); div.gaps = function(){ return parts; }; div.calcCorrectValue = function(){ return inc("calcCorrectValue/calc")(slide); }; return div; }; })(); trainers/wordBuilder/wrapper/wrapper.ls (function(){ return function(){ return ScrollDiv({ enableScrollX: true, enableScrollY: false }); }; })(); trainers/wordSlice/_media2/images/images.ls (function(){ return function(slide){ return slide.getParam("image", slide.atom); }; })(); trainers/wordSlice/_media2/lsgs/lsgs.ls (function(){ return function(slide){ return slide.getParam("lsg", slide.atom); }; })(); trainers/wordSlice/_media2/sounds/sounds.ls (function(){ return function(slide){ var sounds, soundMode, texts, voiceLang, voice, i$, len$, text; sounds = []; soundMode = slide.getParam("soundMode", slide.atom); texts = slide.atom.sound ? [slide.atom.sound] : soundMode === "a" || soundMode === "askSound" ? [slide.atom.a] : slide.getParam("soundMode", slide.atom) === "b" ? [inc("../../calcSolutionString/calc")(slide)] : []; voiceLang = slide.getParam("voiceLang", slide.atom); voice = slide.getParam("voice", slide.atom); for (i$ = 0, len$ = texts.length; i$ < len$; ++i$) { text = texts[i$]; if (text != null) { sounds.push({ text: text, voice: voice, voiceLang: voiceLang }); } } return sounds; }; })(); trainers/wordSlice/_preview/preview.ls (function(){ return function(slide){}; })(); trainers/wordSlice/_review/scoreActions/actions.ls (function(){ return function(slide){ var scoreEvent, i, action; scoreEvent = slide.score.getScoreEvent(slide.atom); if (scoreEvent) { return slide.div.append(Div({ textAlign: "left", margin: "2em 0" }).append((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = scoreEvent.actions).length; i$ < len$; ++i$) { i = i$; action = ref$[i$]; results$.push(inc("/shared/scoreActionRow/row")(action, i).append(action.correct ? inc("correct/correct")(action, slide) : inc("mistake/mistake")(action, slide))); } return results$; }()))); } }; })(); trainers/wordSlice/_review/scoreActions/correct/correct.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/wordSlice/_review/scoreActions/mistake/mistake.ls (function(){ return function(action, slide){ return Div({ display: "inline-block" }).html(action.text); }; })(); trainers/wordSlice/_start/start.ls (function(){ return function(slide){ return slide.instruction.play(function(){ inc("/shared/playAskSoundOrSoundA/play")(slide); return slide.levelPlayer.page.scrollElementIntoView(slide.buttons, { padding: 10 }); }); }; })(); trainers/wordSlice/askSound/askSound.ls (function(){ return function(slide){ var div; if (slide.getParam("soundMode", slide.atom) !== "askSound") { return; } slide.div.append(div = inc("/shared/askSound/ask")(slide.sounds)); return div; }; })(); trainers/wordSlice/buttons/button/button.ls (function(){ return function(slide, choice, i, playSoundAndFinish){ var click, div; click = function(){ var choice, a, isCorrect, isLast, i$, ref$, len$, s, correctchoice, b; choice = div.choice; a = slide.solvedSequence.concat([choice.id]); isCorrect = false; isLast = false; for (i$ = 0, len$ = (ref$ = slide.solutionSequences).length; i$ < len$; ++i$) { s = ref$[i$]; if (s.join(",").indexOf(a.join(",")) === 0) { isCorrect = true; if (s.length === a.length) { isLast = true; } break; } } if (isCorrect) { slide.solvedSequence.push(choice.id); slide.score.addActionCorrect(slide.atom, { text: choice.text }); div.setState("correct"); slide.levelPlayer.progressBar.showGreen(); correctchoice = _.filter(slide.choices, { correct: true })[slide.solvedSequence.length - 1]; slide.textB.addPart(correctchoice); if (isLast) { for (i$ = 0, len$ = (ref$ = slide.buttons.childrenAll()).length; i$ < len$; ++i$) { b = ref$[i$]; b.css({ pointerEvents: "none" }); } slide.score.log(slide.atom); playSoundAndFinish(); } setTimeout(function(){ div.setState("normal"); return div.setEnabled(false); }, 500); } else { slide.score.addActionMistake(slide.atom, { text: choice.text }); slide.levelPlayer.progressBar.addElement().showRed(); div.setState("wrong"); setTimeout(function(){ return div.setState("normal"); }, 500); } return false; }; div = Button({ label: slide.getParam("showCase") ? choice.text : choice.cleanText, labelAllowWrap: true, action: click }).css({ margin: "0.5em" }); div.choice = choice; return div; }; })(); trainers/wordSlice/buttons/buttons.ls (function(){ return function(slide){ var playSoundAndFinish, i, choice; slide.solvedSequence = []; playSoundAndFinish = function(){ var text, voice, checkAnimation; slide.div.css({ pointerEvents: "none" }); if (slide.getParam("soundMode", slide.atom) === "b") { text = slide.atom.sound || slide.solutionString; voice = slide.getParam("voice", slide.atom); return setTimeout(function(){ return slide.sounds[text + voice].play(function(){ return setTimeout(slide.finish, 500); }); }, 300); } else { checkAnimation = function(){ var ref$; if (typeof (ref$ = slide.textB).animationRunning == 'function' && ref$.animationRunning()) { return setTimeout(checkAnimation, 100); } else { return setTimeout(slide.finish, 1000); } }; return checkAnimation(); } }; return Div({ maxWidth: "30em", margin: "0 auto" }).html((function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.shuffleWithSeed(slide.choices)).length; i$ < len$; ++i$) { i = i$; choice = ref$[i$]; results$.push(inc("button/button")(slide, choice, i, playSoundAndFinish)); } return results$; }())).appendTo(slide.div); }; })(); trainers/wordSlice/calcChoices/calc.ls (function(){ return function(s, trainerParams){ var clean; clean = inc("clean/clean"); if (_.includes(s, "++")) { return inc("calcPlusPlus/calc")(s, clean); } else if (trainerParams.trainer === "wordSlice") { return inc("calcAutoWord/calc")(s, clean); } else { return inc("calcAutoSentence/calc")(s, clean); } }; })(); trainers/wordSlice/calcChoices/calcAutoSentence/calc.ls (function(){ return function(s, clean){ var result, i, word; return result = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = s.split(" ")).length; i$ < len$; ++i$) { i = i$; word = ref$[i$]; results$.push({ id: i, text: word, cleanText: clean(word), correct: true }); } return results$; }()); }; })(); trainers/wordSlice/calcChoices/calcAutoWord/calc.ls (function(){ return function(s, clean){ var minLength, maxLength, min, max, total, a, x, result, i, text; minLength = [1, 1, 1, 2, 2, 2]; maxLength = [1, 2, 2, 2, 3, 3]; min = s.length <= minLength.length ? minLength[s.length - 1] : 3; max = s.length <= maxLength.length ? maxLength[s.length - 1] : 4; total = 0; a = []; while (total < s.length) { x = _.randomWithSeed(min, max + 1); x = Math.min(x, s.length - total); a.push(x); total += x; } if (s.length > 2 && a[a.length - 1] === 1) { a.pop(); a[a.length - 1]++; } return result = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = _.shuffleWithSeed(a)).length; i$ < len$; ++i$) { i = i$; x = ref$[i$]; text = s.substr(0, x); s = s.substr(x, 1000); results$.push({ id: i, text: text, cleanText: clean(text), correct: true }); } return results$; }()); }; })(); trainers/wordSlice/calcChoices/calcPlusPlus/calc.ls (function(){ return function(s, clean){ var choices, i$, len$, i, e, results$ = []; choices = inc("/shared/convertPlusPlusString/convert")(s); for (i$ = 0, len$ = choices.length; i$ < len$; ++i$) { i = i$; e = choices[i$]; results$.push({ id: i, text: e.text, cleanText: clean(e.text), correct: e.correct }); } return results$; }; })(); trainers/wordSlice/calcChoices/clean/clean.ls (function(){ return function(s){ s = s.toLowerCase(); if (s.length > 1) { s = _.replaceAll(s, "!", ""); s = _.replaceAll(s, "?", ""); s = _.replaceAll(s, ".", ""); s = _.replaceAll(s, ",", ""); } return s; }; })(); trainers/wordSlice/calcSolutionSequences/calc.ls (function(){ return function(slide){ var solutions, s, separator, f, parts, sequences, sequence, p; solutions = []; s = slide.solutionString; separator = slide.trainerParams.trainer === "wordSlice" ? "" : slide.trainerParams.trainer === "sentenceSlice" ? " " : void 8; f = function(availableParts, solutionParts){ var s2, i$, len$, p, s3, newAvailableParts, newSolutionParts, results$ = []; s2 = _.map(solutionParts, function(p){ return p.cleanText; }); s2 = s2.join(separator); if (s2 === s) { return solutions.push(solutionParts); } else { for (i$ = 0, len$ = availableParts.length; i$ < len$; ++i$) { p = availableParts[i$]; if (s2 === "") { s3 = p.cleanText; } else { s3 = s2 + separator + p.cleanText; } if (s3 === s.substr(0, s3.length)) { newAvailableParts = _.filter(availableParts, fn$); newSolutionParts = solutionParts.concat([p]); results$.push(f(newAvailableParts, newSolutionParts)); } } return results$; } function fn$(p2){ return p2 !== p; } }; parts = _.filter(slide.choices, { correct: true }); f(parts, []); return sequences = (function(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = solutions).length; i$ < len$; ++i$) { s = ref$[i$]; results$.push(sequence = (fn$())); } return results$; function fn$(){ var i$, ref$, len$, results$ = []; for (i$ = 0, len$ = (ref$ = s).length; i$ < len$; ++i$) { p = ref$[i$]; results$.push(p.id); } return results$; } }()); }; })(); trainers/wordSlice/calcSolutionString/calc.ls (function(){ return function(slide){ var s, i$, ref$, len$, p; s = []; for (i$ = 0, len$ = (ref$ = slide.choices).length; i$ < len$; ++i$) { p = ref$[i$]; if (p.correct) { s.push(p.cleanText); } } return s = slide.trainerParams.trainer === "wordSlice" ? s.join("") : s.join(" "); }; })(); trainers/wordSlice/generateSlides.ls (function(){ return function(trainerParams, levelParams){ var atoms, ref$, slides, atom, choices, slide; atoms = _.ensureArray(trainerParams.atoms); if ((ref$ = trainerParams.shuffleAtoms) != null ? ref$ : levelParams.shuffleAtoms) { atoms = _.shuffleWithSeed(atoms); } return slides = (function(){ var i$, ref$, len$, ref1$, results$ = []; for (i$ = 0, len$ = (ref$ = atoms).length; i$ < len$; ++i$) { atom = ref$[i$]; choices = inc("calcChoices/calc")(atom.b, trainerParams); slide = inc("/shared/slide/slide")(trainerParams, levelParams, THISFILE); slide.atom = atom; slide.choices = choices; slide.totalProgressElements = _.filter(choices, { correct: true }).length; slide.finishButton = (ref1$ = slide.getParam("finishButton", slide.atom)) != null ? ref1$ : false; results$.push(slide); } return results$; }()); }; })(); trainers/wordSlice/image/image.ls (function(){ return function(slide){ var image; image = slide.getParam("image", slide.atom); if (!image) { return; } return inc("/shared/image/image")({ image: image, slide: slide, parent: slide.div, wrapWithDiv: true }).appendTo(slide.div); }; })(); trainers/wordSlice/init.ls (function(){ return function(slide){ slide.visibleString = ""; slide.solutionString = inc("calcSolutionString/calc")(slide); slide.solutionSequences = inc("calcSolutionSequences/calc")(slide); slide.instruction = inc("instruction/instruction")(slide); slide.image = inc("image/image")(slide); slide.lsg = inc("lsg/lsg")(slide); slide.askSound = inc("askSound/askSound")(slide); slide.textA = inc("textA/text")(slide); slide.textB = inc("textB/textB")(slide); return slide.buttons = inc("buttons/buttons")(slide); }; })(); trainers/wordSlice/instruction/instruction.ls (function(){ return function(slide){ var div; slide.div.append(div = inc("/shared/instruction/instruction")(slide)); return div; }; })(); trainers/wordSlice/lsg/lsg.ls (function(){ return function(slide){ var lsg, ref$; lsg = slide.getParam("lsg", slide.atom); if (!lsg) { return; } return (ref$ = inc("/shared/lsg/lsg")({ lsg: lsg, slide: slide, parent: slide.div, wrapWithDiv: true })) != null ? ref$.appendTo(slide.div) : void 8; }; })(); trainers/wordSlice/textA/calcTextAlign/calc.ls (function(){ return function(slide){ var ref$; if (slide.trainerParams.trainer === "wordSlice") { return "center"; } return (ref$ = slide.getParam("textAlign")) != null ? ref$ : "center"; }; })(); trainers/wordSlice/textA/tap/tap.ls (function(){ return function(slide){ return function(){ var text, voice; if (slide.getParam("soundMode", slide.atom) === "a") { text = slide.atom.sound || slide.atom.a; voice = slide.getParam("voice", slide.atom); return slide.sounds[text + voice].play(); } }; }; })(); trainers/wordSlice/textA/text.ls (function(){ return function(slide){ var textAlign, image, lsg, div; if (slide.getParam("soundMode", slide.atom) === "askSound") { return; } if (!slide.atom.a) { return; } textAlign = inc("calcTextAlign/calc")(slide); image = slide.getParam("image", slide.atom); lsg = slide.getParam("lsg", slide.atom); Div().html(div = Div(image || lsg ? { padding: "0.5em" } : { padding: "0 0.5em" }).css({ display: "inline-block", textAlign: textAlign, width: "90%", maxWidth: "35em" }).html(slide.atom.a).tap(inc("tap/tap")(slide))).appendTo(slide.div); return div; }; })(); trainers/wordSlice/textB/textB.ls (function(){ return function(slide){ var div; slide.div.append(slide.trainerParams.trainer === "wordSlice" ? div = inc("textBWord/text")(slide) : div = inc("textBSentence/text")(slide)); return div; }; })(); trainers/wordSlice/textB/textBSentence/reduceEllipsis/reduce.ls (function(){ return function(slide, correction){ var remainingChars; remainingChars = slide.solutionString.length - slide.visibleString.length - correction; if (remainingChars === 0) { return slide.ellipsis.css({ opacity: 0 }); } }; })(); trainers/wordSlice/textB/textBSentence/text.ls (function(){ return function(slide){ var pendingString, interval, isFirst, afterSpanishPunctuation, remainingCharCorrection, startInverval, onInterval, addPart, div, ref$; pendingString = ""; interval = null; isFirst = true; afterSpanishPunctuation = false; remainingCharCorrection = 0; startInverval = function(){ return interval = setInterval(onInterval, 50); }; onInterval = function(){ var c; if (!div.isVisible()) { clearInterval(interval); interval = null; } inc("reduceEllipsis/reduce")(slide, remainingCharCorrection); if (pendingString.length > 0) { c = pendingString[0]; pendingString = pendingString.slice(1); slide.visibleString += c; return slide.ellipsis.before(Span({ fontSize: "1.5em" }).html(c)); } else { clearInterval(interval); return interval = null; } }; addPart = function(part){ var ref$; if (((ref$ = part.text) === "," || ref$ === ";" || ref$ === "." || ref$ === "?" || ref$ === "!") || afterSpanishPunctuation) { remainingCharCorrection++; } else { if (!isFirst) { pendingString += " "; } } if ((ref$ = part.text) === "¡" || ref$ === "¿") { afterSpanishPunctuation = true; } else { afterSpanishPunctuation = false; } isFirst = false; pendingString += part.text; if (interval === null) { return startInverval(); } }; div = Div({ display: "inline-block", padding: "1.5em 0.5em", margin: "1em auto 1.5em", textAlign: (ref$ = slide.getParam("textAlign")) != null ? ref$ : "center", width: "90%", maxWidth: "35em" }).html(slide.ellipsis = Span({ fontSize: "1.5em" }).html(" …")); div.addPart = addPart; div.animationRunning = function(){ return interval != null; }; return div; }; })(); trainers/wordSlice/textB/textBWord/text.ls (function(){ return function(slide){ var addPart, div; addPart = function(part){ if (div.innerHTML === " ") { div.empty(); } return div.append(part.text); }; div = Div({ display: "inline-block", padding: "0.7em", margin: "1em 0 1.5em", backgroundColor: Color.grey[100] }).html(" "); div.addPart = addPart; return div; }; })();