lido-player 0.0.2-alpha-49 → 0.0.2-alpha-43-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/cjs/{index-fe562525.js → index-6a69c33a.js} +36 -3
  2. package/dist/cjs/index.cjs.js +2 -2
  3. package/dist/cjs/{lido-avatar_19.cjs.entry.js → lido-avatar_21.cjs.entry.js} +431 -180
  4. package/dist/cjs/lido-player.cjs.js +2 -2
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/{utils-96ce5641.js → utils-079a5e7d.js} +1032 -165
  7. package/dist/collection/collection-manifest.json +2 -0
  8. package/dist/collection/components/calculator/lido-calculator.css +87 -0
  9. package/dist/collection/components/calculator/lido-calculator.js +321 -0
  10. package/dist/collection/components/cell/lido-cell.js +1 -1
  11. package/dist/collection/components/column/lido-col.js +1 -1
  12. package/dist/collection/components/container/lido-container.js +20 -1
  13. package/dist/collection/components/flashCard/lido-flash-card.js +1 -1
  14. package/dist/collection/components/float/lido-float.js +1 -1
  15. package/dist/collection/components/home/lido-home.js +9 -29
  16. package/dist/collection/components/keyboard/lido-keyboard.js +2 -2
  17. package/dist/collection/components/mathMatrix/lido-math-matrix.css +10 -2
  18. package/dist/collection/components/mathMatrix/lido-math-matrix.js +226 -20
  19. package/dist/collection/components/position/lido-pos.js +1 -1
  20. package/dist/collection/components/random/lido-random.js +1 -1
  21. package/dist/collection/components/row/lido-row.js +1 -1
  22. package/dist/collection/components/scale/lido-balance.css +114 -0
  23. package/dist/collection/components/scale/lido-balance.js +549 -0
  24. package/dist/collection/components/shape/lido-shape.js +1 -1
  25. package/dist/collection/components/slideFill/lido-slide-fill.js +1 -1
  26. package/dist/collection/components/text/lido-text.js +1 -1
  27. package/dist/collection/components/trace/lido-trace.js +49 -128
  28. package/dist/collection/components/wrap/lido-wrap.js +1 -1
  29. package/dist/collection/css/animation.css +21 -0
  30. package/dist/collection/css/index.css +45 -0
  31. package/dist/collection/stories/Templates/Fill-Up/fill-up.stories.js +24 -25
  32. package/dist/collection/stories/Templates/RocketGame/rocketGame.stories.js +0 -3
  33. package/dist/collection/stories/Templates/balancing/balancing.stories.js +67 -0
  34. package/dist/collection/stories/Templates/checker-block/checkerBlock.stories.js +156 -0
  35. package/dist/collection/stories/Templates/checkerBlock/checkerBlock.stories.js +49 -0
  36. package/dist/collection/stories/Templates/fillAnswer/fill-answer.stories.js +66 -0
  37. package/dist/collection/stories/Templates/foodJar/food-jar.stories.js +65 -0
  38. package/dist/collection/stories/Templates/matchBox/matchBox.stories.js +105 -0
  39. package/dist/collection/stories/Templates/matchBox/matchBox2.stories.js +92 -0
  40. package/dist/collection/stories/Templates/matchingCard/matching-card.stories.js +47 -0
  41. package/dist/collection/stories/Templates/multiplyBeeds/multiplyBeeds.stories.js +59 -0
  42. package/dist/collection/stories/Templates/nimbleTable/nimbleTable.stories.js +93 -0
  43. package/dist/collection/stories/Templates/numberBoardTwo/numberBoardTwo.stories.js +100 -0
  44. package/dist/collection/stories/Templates/numberPair/numberPair.stories.js +212 -0
  45. package/dist/collection/stories/Templates/order-tractor/order-tractor-ascending-order.stories.js +6 -7
  46. package/dist/collection/stories/Templates/order-tractor/order-tractor.stories.js +6 -7
  47. package/dist/collection/stories/Templates/questionBoard/questionBoard.stories.js +158 -0
  48. package/dist/collection/stories/Templates/sequenceBox/sequenceBox1.stories.js +102 -0
  49. package/dist/collection/stories/Templates/sequenceBox/sequenceBox2.stories.js +94 -0
  50. package/dist/collection/stories/Templates/shapePair/shape-pair.stories.js +184 -0
  51. package/dist/collection/stories/Templates/shapeTractor/shape-tractor.stories.js +213 -0
  52. package/dist/collection/stories/Templates/sumTogether/sumTogether.stories.js +109 -0
  53. package/dist/collection/stories/Templates/total/total.stories.js +59 -0
  54. package/dist/collection/stories/Templates/writeNumber/writeNumber.stories.js +96 -0
  55. package/dist/collection/stories/Templates/writeSet/writeSet.stories.js +55 -0
  56. package/dist/collection/stories/Templates/writeWord/writeWord.stories.js +5 -6
  57. package/dist/collection/utils/utils.js +439 -81
  58. package/dist/collection/utils/utilsHandlers/clickHandler.js +21 -25
  59. package/dist/collection/utils/utilsHandlers/dragDropHandler.js +95 -42
  60. package/dist/collection/utils/utilsHandlers/lidoBalanceHandler.js +67 -0
  61. package/dist/collection/utils/utilsHandlers/lidoCalculatorHandler.js +94 -0
  62. package/dist/collection/utils/utilsHandlers/matrixHandler.js +298 -0
  63. package/dist/collection/utils/utilsHandlers/slideHandler.js +4 -2
  64. package/dist/collection/utils/utilsHandlers/sortHandler.js +21 -12
  65. package/dist/components/index.js +1 -1
  66. package/dist/components/lido-avatar.js +1 -1
  67. package/dist/components/lido-balance.d.ts +11 -0
  68. package/dist/components/lido-balance.js +6 -0
  69. package/dist/components/lido-calculator.d.ts +11 -0
  70. package/dist/components/lido-calculator.js +6 -0
  71. package/dist/components/lido-cell.js +1 -1
  72. package/dist/components/lido-col.js +1 -1
  73. package/dist/components/lido-container.js +1 -1
  74. package/dist/components/lido-flash-card.js +1 -1
  75. package/dist/components/lido-float.js +1 -1
  76. package/dist/components/lido-home.js +1 -1
  77. package/dist/components/lido-image.js +1 -1
  78. package/dist/components/lido-keyboard.js +1 -1
  79. package/dist/components/lido-math-matrix.js +1 -1
  80. package/dist/components/lido-pos.js +1 -1
  81. package/dist/components/lido-random.js +1 -1
  82. package/dist/components/lido-root.js +32 -20
  83. package/dist/components/lido-row.js +1 -1
  84. package/dist/components/lido-shape.js +1 -1
  85. package/dist/components/lido-slide-fill.js +1 -1
  86. package/dist/components/lido-text.js +1 -1
  87. package/dist/components/lido-trace.js +1 -1
  88. package/dist/components/lido-wrap.js +1 -1
  89. package/dist/components/p-08d0deab.js +254 -0
  90. package/dist/components/{p-b5b6ad27.js → p-15971ede.js} +1 -1
  91. package/dist/components/{p-0bf92c7f.js → p-1fbdb431.js} +2 -2
  92. package/dist/components/{p-b43ce4e1.js → p-29bdd953.js} +2 -2
  93. package/dist/components/{p-b8af26e6.js → p-322acda6.js} +40 -48
  94. package/dist/components/{p-51943db6.js → p-3f406017.js} +2 -2
  95. package/dist/components/p-44808985.js +186 -0
  96. package/dist/components/{p-4cabbf28.js → p-52844fa4.js} +2 -2
  97. package/dist/components/{p-4882df37.js → p-73e31a86.js} +2 -2
  98. package/dist/components/{p-af54a485.js → p-74849cdd.js} +4 -4
  99. package/dist/components/{p-9c56f378.js → p-7f7e5672.js} +2 -2
  100. package/dist/components/{p-4dbae73b.js → p-835b973d.js} +2 -2
  101. package/dist/components/{p-b55af747.js → p-90465904.js} +50 -129
  102. package/dist/components/{p-cae021c6.js → p-904711c8.js} +2 -2
  103. package/dist/components/{p-e735dce9.js → p-9be56729.js} +5 -3
  104. package/dist/components/{p-cac6c8bf.js → p-afbc196f.js} +2 -2
  105. package/dist/components/{p-cfa2aec8.js → p-bed94c37.js} +1047 -164
  106. package/dist/components/{p-7f11a624.js → p-cbac3cbc.js} +1 -1
  107. package/dist/components/{p-61d97438.js → p-d37ab4dc.js} +2 -2
  108. package/dist/components/p-e36ddcc1.js +166 -0
  109. package/dist/components/{p-03e4cafe.js → p-e4e42677.js} +2 -2
  110. package/dist/esm/{index-f47852d4.js → index-170e58c7.js} +36 -4
  111. package/dist/esm/index.js +2 -2
  112. package/dist/esm/{lido-avatar_19.entry.js → lido-avatar_21.entry.js} +430 -181
  113. package/dist/esm/lido-player.js +3 -3
  114. package/dist/esm/loader.js +3 -3
  115. package/dist/esm/{utils-9ce243d8.js → utils-5df09162.js} +1031 -164
  116. package/dist/lido-player/index.esm.js +1 -1
  117. package/dist/lido-player/lido-player.css +1 -1
  118. package/dist/lido-player/lido-player.esm.js +1 -1
  119. package/dist/lido-player/p-137c99ce.js +2 -0
  120. package/dist/lido-player/p-7556e652.js +9 -0
  121. package/dist/lido-player/p-eb956325.entry.js +1 -0
  122. package/dist/types/components/calculator/lido-calculator.d.ts +40 -0
  123. package/dist/types/components/container/lido-container.d.ts +4 -0
  124. package/dist/types/components/home/lido-home.d.ts +0 -1
  125. package/dist/types/components/mathMatrix/lido-math-matrix.d.ts +24 -4
  126. package/dist/types/components/scale/lido-balance.d.ts +160 -0
  127. package/dist/types/components/trace/lido-trace.d.ts +0 -1
  128. package/dist/types/components.d.ts +342 -14
  129. package/dist/types/stories/Templates/balancing/balancing.stories.d.ts +4 -0
  130. package/dist/types/stories/Templates/checker-block/checkerBlock.stories.d.ts +4 -0
  131. package/dist/types/stories/Templates/checkerBlock/checkerBlock.stories.d.ts +4 -0
  132. package/dist/types/stories/Templates/fillAnswer/fill-answer.stories.d.ts +4 -0
  133. package/dist/types/stories/Templates/foodJar/food-jar.stories.d.ts +4 -0
  134. package/dist/types/stories/Templates/matchBox/matchBox.stories.d.ts +4 -0
  135. package/dist/types/stories/Templates/matchBox/matchBox2.stories.d.ts +4 -0
  136. package/dist/types/stories/Templates/matchingCard/matching-card.stories.d.ts +4 -0
  137. package/dist/types/stories/Templates/multiplyBeeds/multiplyBeeds.stories.d.ts +9 -0
  138. package/dist/types/stories/Templates/nimbleTable/nimbleTable.stories.d.ts +4 -0
  139. package/dist/types/stories/Templates/numberBoardTwo/numberBoardTwo.stories.d.ts +4 -0
  140. package/dist/types/stories/Templates/numberPair/numberPair.stories.d.ts +4 -0
  141. package/dist/types/stories/Templates/questionBoard/questionBoard.stories.d.ts +15 -0
  142. package/dist/types/stories/Templates/sequenceBox/sequenceBox1.stories.d.ts +11 -0
  143. package/dist/types/stories/Templates/sequenceBox/sequenceBox2.stories.d.ts +11 -0
  144. package/dist/types/stories/Templates/shapePair/shape-pair.stories.d.ts +4 -0
  145. package/dist/types/stories/Templates/shapeTractor/shape-tractor.stories.d.ts +12 -0
  146. package/dist/types/stories/Templates/sumTogether/sumTogether.stories.d.ts +11 -0
  147. package/dist/types/stories/Templates/total/total.stories.d.ts +4 -0
  148. package/dist/types/stories/Templates/writeNumber/writeNumber.stories.d.ts +13 -0
  149. package/dist/types/stories/Templates/writeSet/writeSet.stories.d.ts +4 -0
  150. package/dist/types/utils/utils.d.ts +8 -2
  151. package/dist/types/utils/utilsHandlers/dragDropHandler.d.ts +4 -0
  152. package/dist/types/utils/utilsHandlers/lidoBalanceHandler.d.ts +2 -0
  153. package/dist/types/utils/utilsHandlers/lidoCalculatorHandler.d.ts +1 -0
  154. package/dist/types/utils/utilsHandlers/matrixHandler.d.ts +1 -0
  155. package/package.json +1 -1
  156. package/dist/components/p-a8ab771b.js +0 -160
  157. package/dist/lido-player/p-90212aa9.js +0 -9
  158. package/dist/lido-player/p-d3911ee1.entry.js +0 -1
  159. package/dist/lido-player/p-ddf627b0.js +0 -2
@@ -1,6 +1,6 @@
1
- import { countPatternWords, executeActions, handleShowCheck, handlingElementFlexibleWidth, storingEachActivityScore, validateObjectiveStatus } from "../utils";
1
+ import { countPatternWords, buildDragSelectedMapFromDOM, executeActions, handleShowCheck, handlingElementFlexibleWidth, storingEachActivityScore, validateObjectiveStatus } from "../utils";
2
2
  import { AudioPlayer } from "../audioPlayer";
3
- import { DragSelectedMapKey, LidoContainer, SelectedValuesKey } from "../constants";
3
+ import { LidoContainer, SelectedValuesKey } from "../constants";
4
4
  import { dispatchClickEvent } from "../customEvents";
5
5
  import tinycolor from "tinycolor2";
6
6
  import { setDraggingDisabled } from "./dragDropHandler";
@@ -59,6 +59,7 @@ export function addClickListenerForClickType(element) {
59
59
  return;
60
60
  }
61
61
  const onClick = async () => {
62
+ var _a;
62
63
  const lido_buttons = element.getAttribute('id');
63
64
  if (lido_buttons === 'lido-arrow-left' || lido_buttons === 'lido-arrow-right') {
64
65
  return;
@@ -75,24 +76,15 @@ export function addClickListenerForClickType(element) {
75
76
  }
76
77
  if (container['objective'].length === 0)
77
78
  return;
78
- // element.style.border = '2px solid yellow';
79
- // element.style.boxShadow = '0px 0px 10px rgba(255, 255, 0, 0.7)';
80
- // element.style.transition = 'transform 0.2s ease, border 0.5s ease';
81
- // element.style.transform = 'scale(1.1)';
82
- // element.style.transform = 'scale(1)';
83
- // element.style.border = '';
84
- // element.style.boxShadow = '';
85
79
  const isActivated = element.classList.contains('lido-element-selected');
86
- let selectedValue = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
80
+ let selectedValue = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
87
81
  if (objective.length === 1) {
88
- localStorage.setItem(SelectedValuesKey, JSON.stringify([element['value']]));
82
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
89
83
  const isCorrect = objective.includes(element['value']);
90
84
  dispatchClickEvent(element, isCorrect);
91
85
  if (isCorrect) {
92
86
  const onCorrect = element.getAttribute('onCorrect');
93
- if (!(element.id && element.id.startsWith('key-button'))) {
94
- element.style.pointerEvents = 'none';
95
- }
87
+ // element.style.pointerEvents = 'none';
96
88
  await executeActions(onCorrect, element);
97
89
  }
98
90
  else {
@@ -100,7 +92,11 @@ export function addClickListenerForClickType(element) {
100
92
  await executeActions(onInCorrect, element);
101
93
  // showWrongAnswerAnimation([element]);
102
94
  }
103
- storingEachActivityScore(isCorrect);
95
+ // const calciEl=document.querySelector('#lidoCalculator') as any;
96
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
97
+ if (!isInsideCalculator) {
98
+ storingEachActivityScore(isCorrect);
99
+ }
104
100
  handleShowCheck();
105
101
  return;
106
102
  }
@@ -111,8 +107,8 @@ export function addClickListenerForClickType(element) {
111
107
  element.classList.remove('lido-element-selected');
112
108
  executeActions(element.getAttribute('onEntry'), element);
113
109
  selectedValue = selectedValue.filter(item => item != element['value']);
114
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
115
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
110
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
111
+ let multiOptionScore = buildDragSelectedMapFromDOM();
116
112
  const valueToRemove = element['value'];
117
113
  const keyToRemove = Object.keys(multiOptionScore).find(key => multiOptionScore[key].includes(valueToRemove));
118
114
  if (keyToRemove) {
@@ -120,10 +116,9 @@ export function addClickListenerForClickType(element) {
120
116
  if (multiOptionScore[keyToRemove].length === 0) {
121
117
  delete multiOptionScore[keyToRemove];
122
118
  }
123
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
124
119
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
125
120
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
126
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
121
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
127
122
  }
128
123
  if (showCheck && selectedValue.length === 0) {
129
124
  checkButton.classList.add('lido-disable-check-button');
@@ -134,20 +129,18 @@ export function addClickListenerForClickType(element) {
134
129
  element.classList.add('lido-element-selected');
135
130
  const valueToFind = element['value'];
136
131
  const key = Object.keys(objective).find(key => objective[key] === valueToFind);
137
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
132
+ let multiOptionScore = buildDragSelectedMapFromDOM();
138
133
  if (!key) {
139
134
  multiOptionScore[objective.length + selectedValue.length] = [valueToFind];
140
135
  }
141
136
  else {
142
137
  multiOptionScore[key] = [valueToFind];
143
138
  }
144
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
145
139
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
146
140
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
147
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
141
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
148
142
  const isCorrect = objective.includes(element['value']);
149
143
  dispatchClickEvent(element, isCorrect);
150
- AudioPlayer.getI().stop();
151
144
  if (isCorrect) {
152
145
  const onCorrect = element.getAttribute('onCorrect');
153
146
  await executeActions(onCorrect, element);
@@ -159,8 +152,11 @@ export function addClickListenerForClickType(element) {
159
152
  }
160
153
  storingEachActivityScore(isCorrect);
161
154
  }
162
- if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
163
- validateObjectiveStatus();
155
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
156
+ if (!isInsideCalculator) {
157
+ if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
158
+ validateObjectiveStatus();
159
+ }
164
160
  }
165
161
  };
166
162
  element.addEventListener('click', onClick);
@@ -1,8 +1,24 @@
1
- import { calculateScale, countPatternWords, handleShowCheck, handlingElementFlexibleWidth, onActivityComplete, storingEachActivityScore } from "../utils";
1
+ import { calculateScale, countPatternWords, buildDragSelectedMapFromDOM, executeActions, handleShowCheck, handlingElementFlexibleWidth, onActivityComplete, storingEachActivityScore } from "../utils";
2
+ import { updateBalanceOnDrop } from "./lidoBalanceHandler";
2
3
  import { AudioPlayer } from "../audioPlayer";
3
- import { DragSelectedMapKey, DragMapKey, DropHasDrag, DropLength, SelectedValuesKey, DropMode, DropToAttr, DropTimeAttr, LidoContainer, DropAction } from "../constants";
4
+ import { DropLength, SelectedValuesKey, DropMode, DropToAttr, DropTimeAttr, LidoContainer, DropAction, NextContainerKey, } from "../constants";
4
5
  import { dispatchElementDropEvent } from "../customEvents";
5
6
  import { removeHighlight } from "./highlightHandler";
7
+ export function buildDropHasDragFromDOM() {
8
+ const dropHasDrag = {};
9
+ const dropElements = document.querySelectorAll("[type='drop']");
10
+ dropElements.forEach(drop => {
11
+ const tabIndex = drop.getAttribute("tab-index") || drop.id;
12
+ const assignedDrag = document.querySelector(`[${DropToAttr}="${drop.id}"]`);
13
+ const isFull = !!assignedDrag;
14
+ drop.setAttribute("is-full", String(isFull));
15
+ dropHasDrag[tabIndex] = {
16
+ drop: drop.id,
17
+ isFull
18
+ };
19
+ });
20
+ return dropHasDrag;
21
+ }
6
22
  // Function to get the scale of an element
7
23
  export const getElementScale = (el) => {
8
24
  el.style.animation = 'unset';
@@ -56,7 +72,7 @@ export function enableDraggingWithScaling(element) {
56
72
  isDragging = false;
57
73
  return;
58
74
  }
59
- AudioPlayer.getI().stop();
75
+ // AudioPlayer.getI().stop();
60
76
  removeHighlight(element);
61
77
  isDragging = true;
62
78
  isClicked = true;
@@ -164,7 +180,6 @@ export function enableDraggingWithScaling(element) {
164
180
  // Start observing the element
165
181
  observer.observe(container, observerConfig);
166
182
  const onMove = (event) => {
167
- console.log("moved");
168
183
  if (!isDragging)
169
184
  return;
170
185
  if (isDraggingDisabled) {
@@ -173,7 +188,7 @@ export function enableDraggingWithScaling(element) {
173
188
  }
174
189
  isClicked = false;
175
190
  element.style.transition = 'none';
176
- const containerScale = calculateScale();
191
+ const containerScale = getElementScale(container);
177
192
  let dx = 0;
178
193
  let dy = 0;
179
194
  if (event instanceof MouseEvent) {
@@ -195,7 +210,7 @@ export function enableDraggingWithScaling(element) {
195
210
  // Reset styles for all elements
196
211
  allElements.forEach(otherElement => {
197
212
  var _a;
198
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
213
+ const dropObject = buildDragSelectedMapFromDOM();
199
214
  const storedTabIndexes = Object.keys(dropObject).map(Number);
200
215
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
201
216
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -253,7 +268,7 @@ export function enableDraggingWithScaling(element) {
253
268
  allElements.forEach(otherElement => {
254
269
  allElements.forEach(otherElement => {
255
270
  var _a;
256
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
271
+ const dropObject = buildDragSelectedMapFromDOM();
257
272
  const storedTabIndexes = Object.keys(dropObject).map(Number);
258
273
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
259
274
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -417,14 +432,18 @@ export function handleResetDragElement(dragElement, dropElement, dropHasDrag, se
417
432
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
418
433
  if (prevDropItem) {
419
434
  prevDropItem.isFull = false;
420
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
435
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
436
+ const dropEl = document.getElementById(prevDropItem.drop);
437
+ if (dropEl) {
438
+ dropEl.removeAttribute('is-full');
439
+ }
421
440
  }
422
441
  dragToDropMap.delete(dragElement);
423
442
  }
424
443
  if (selectedValueData) {
425
444
  let selectedValue = JSON.parse(selectedValueData);
426
445
  selectedValue = selectedValue.filter(value => value != dragElement['value']);
427
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
446
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValue));
428
447
  }
429
448
  if (dragSelectedData) {
430
449
  let dragSelected = JSON.parse(dragSelectedData);
@@ -432,14 +451,15 @@ export function handleResetDragElement(dragElement, dropElement, dropHasDrag, se
432
451
  if (dragPreDropElement) {
433
452
  delete dragSelected[dragPreDropElement.getAttribute('tab-index')];
434
453
  }
435
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
454
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
436
455
  dragElement.removeAttribute(DropToAttr);
437
456
  updateDropBorder(currentDrop);
457
+ updateBalanceOnDrop(dragElement, dropElement);
438
458
  }
439
459
  const allElements = document.querySelectorAll("[type='drop']");
440
460
  allElements.forEach(otherElement => {
441
461
  var _a;
442
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
462
+ const dropObject = buildDragSelectedMapFromDOM();
443
463
  const storedTabIndexes = Object.keys(dropObject).map(Number);
444
464
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
445
465
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -464,20 +484,22 @@ export function handleResetDragElement(dragElement, dropElement, dropHasDrag, se
464
484
  });
465
485
  handleShowCheck();
466
486
  }
487
+ const tempVanishedValues = [];
467
488
  export async function onElementDropComplete(dragElement, dropElement) {
468
- var _a, _b, _c, _d, _e;
469
- const selectedValueData = localStorage.getItem(SelectedValuesKey) || '';
470
- const dragSelectedData = localStorage.getItem(DragSelectedMapKey);
471
- const dropSelectedData = localStorage.getItem(DragMapKey);
472
- console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
473
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
489
+ var _a, _b, _c, _d, _e, _f, _g, _h;
474
490
  const container = document.getElementById(LidoContainer);
491
+ const selectedValueData = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : "[]";
492
+ const dragSelectedData = JSON.stringify(buildDragSelectedMapFromDOM());
493
+ const dropSelectedDataobject = buildDragSelectedMapFromDOM();
494
+ const dropSelectedData = JSON.stringify(dropSelectedDataobject);
495
+ console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
496
+ let dropHasDrag = buildDropHasDragFromDOM();
475
497
  if (!dropElement) {
476
498
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
477
499
  return;
478
500
  }
479
501
  const dropTabIndex = dropElement.getAttribute('tab-index');
480
- if ((_a = dropHasDrag[dropTabIndex]) === null || _a === void 0 ? void 0 : _a.isFull) {
502
+ if ((_b = dropHasDrag[dropTabIndex]) === null || _b === void 0 ? void 0 : _b.isFull) {
481
503
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
482
504
  return;
483
505
  }
@@ -489,9 +511,10 @@ export async function onElementDropComplete(dragElement, dropElement) {
489
511
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
490
512
  return;
491
513
  }
514
+ // let isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
492
515
  let isCorrect;
493
- const dragValue = ((_b = dragElement.getAttribute('value')) === null || _b === void 0 ? void 0 : _b.trim()) || "";
494
- const dropValue = ((_c = dropElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
516
+ const dragValue = ((_c = dragElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
517
+ const dropValue = ((_d = dropElement.getAttribute('value')) === null || _d === void 0 ? void 0 : _d.trim()) || "";
495
518
  if (Number(dragValue)) {
496
519
  const dragNum = Number(dragValue);
497
520
  //array of numbers
@@ -505,8 +528,7 @@ export async function onElementDropComplete(dragElement, dropElement) {
505
528
  }
506
529
  }
507
530
  else {
508
- //strings
509
- isCorrect = dropValue.toLowerCase().includes(dragValue.toLowerCase());
531
+ isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
510
532
  }
511
533
  if (!isCorrect) {
512
534
  const localStorageKey = `${LidoContainer}_dropData`;
@@ -522,7 +544,7 @@ export async function onElementDropComplete(dragElement, dropElement) {
522
544
  // delete stored[oldDropIndex];
523
545
  // localStorage.setItem(localStorageKey, JSON.stringify(stored));
524
546
  // }
525
- // handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
547
+ handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
526
548
  }, 500);
527
549
  if (dragElement['type'] === 'option') {
528
550
  const childs = Array.from(container.querySelectorAll(`[value="${dragElement['value']}"]`));
@@ -541,6 +563,7 @@ export async function onElementDropComplete(dragElement, dropElement) {
541
563
  if (checkdropAttr && checkdropAttr.toLowerCase() === DropMode.EnableAnimation.toLowerCase()) {
542
564
  container.style.pointerEvents = "none";
543
565
  setTimeout(() => {
566
+ var _a, _b, _c;
544
567
  const div = document.createElement('div');
545
568
  container.append(div);
546
569
  div.classList.add('after-drop-popup-container');
@@ -549,6 +572,11 @@ export async function onElementDropComplete(dragElement, dropElement) {
549
572
  const allDragElements = container.querySelectorAll('[type="drag"]');
550
573
  const dragParents = Array.from(allDragElements).map(el => el.parentElement);
551
574
  const allSameParent = dragParents.every(parent => parent === dragElement.parentElement);
575
+ const selectedValues = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
576
+ const vanishedValue = (_b = dragElement.getAttribute('value')) !== null && _b !== void 0 ? _b : (_c = dragElement.textContent) === null || _c === void 0 ? void 0 : _c.trim();
577
+ if (vanishedValue) {
578
+ tempVanishedValues.push(vanishedValue);
579
+ }
552
580
  // Remove from old parents
553
581
  if (allSameParent) {
554
582
  dragElement.remove();
@@ -572,6 +600,16 @@ export async function onElementDropComplete(dragElement, dropElement) {
572
600
  setTimeout(() => {
573
601
  div.remove();
574
602
  container.style.pointerEvents = 'auto';
603
+ const objective = container.getAttribute('objective');
604
+ if (objective && tempVanishedValues.map(v => v.trim()).sort().join(',') === objective.split(',').map(v => v.trim()).sort().join(',')) {
605
+ (async () => {
606
+ isCorrect = true;
607
+ const onCorrect = (container === null || container === void 0 ? void 0 : container.getAttribute('onCorrect')) || '';
608
+ await executeActions(onCorrect, container);
609
+ window.dispatchEvent(new CustomEvent(NextContainerKey));
610
+ tempVanishedValues.length = 0;
611
+ })();
612
+ }
575
613
  }, 800); // match animation duration
576
614
  }, 2000); // stay for 2 seconds
577
615
  }, 250);
@@ -579,6 +617,12 @@ export async function onElementDropComplete(dragElement, dropElement) {
579
617
  }
580
618
  }
581
619
  if (dropElement) {
620
+ let selectedValues = JSON.parse((_e = container.getAttribute(SelectedValuesKey)) !== null && _e !== void 0 ? _e : "[]");
621
+ const dragValue = dragElement.getAttribute('value');
622
+ if (dragValue && !selectedValues.includes(dragValue)) {
623
+ selectedValues.push(dragValue);
624
+ }
625
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValues));
582
626
  if (dropElement.getAttribute('drop-attr') === 'stretch') {
583
627
  if (!dropElement.hasAttribute('data-original-width')) {
584
628
  const computedStyle = window.getComputedStyle(dropElement);
@@ -587,15 +631,16 @@ export async function onElementDropComplete(dragElement, dropElement) {
587
631
  const dragWidth = dragElement.offsetWidth;
588
632
  dropElement.style.width = `${dragWidth}px`;
589
633
  }
590
- if (!(((_d = dropElement.getAttribute('dropAttr')) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
634
+ if (!(((_f = dropElement.getAttribute('dropAttr')) === null || _f === void 0 ? void 0 : _f.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
591
635
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
592
636
  if (isisFull) {
593
637
  isisFull.isFull = true;
638
+ dropElement.setAttribute('is-full', 'true');
594
639
  }
595
640
  else {
596
641
  console.warn('No matching drop item found for', dropElement);
597
642
  }
598
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
643
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
599
644
  if (dragSelectedData) {
600
645
  let dragSelected = JSON.parse(dragSelectedData);
601
646
  for (const key in dragSelected) {
@@ -608,7 +653,7 @@ export async function onElementDropComplete(dragElement, dropElement) {
608
653
  }
609
654
  }
610
655
  }
611
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
656
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
612
657
  }
613
658
  dragElement.classList.add('dropped');
614
659
  if (dragElement) {
@@ -621,7 +666,7 @@ export async function onElementDropComplete(dragElement, dropElement) {
621
666
  dragElement.setAttribute(DropTimeAttr, new Date().getTime().toString());
622
667
  }
623
668
  // Check for overlaps and highlight only the most overlapping element
624
- if (dropElement && !((_e = dropHasDrag[dropTabIndex]) === null || _e === void 0 ? void 0 : _e.isFull)) {
669
+ if (dropElement && !((_g = dropHasDrag[dropTabIndex]) === null || _g === void 0 ? void 0 : _g.isFull)) {
625
670
  let mostOverlappedElement = findMostoverlappedElement(dragElement, 'drag');
626
671
  const isAllowOnlyOneDrop = dropElement.getAttribute('is-allow-only-one-drop') === 'true' || '';
627
672
  if (mostOverlappedElement && isAllowOnlyOneDrop) {
@@ -630,7 +675,7 @@ export async function onElementDropComplete(dragElement, dropElement) {
630
675
  const allElements = document.querySelectorAll("[type='drop']");
631
676
  allElements.forEach(otherElement => {
632
677
  var _a;
633
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
678
+ const dropObject = buildDragSelectedMapFromDOM();
634
679
  const storedTabIndexes = Object.keys(dropObject).map(Number);
635
680
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
636
681
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -662,13 +707,14 @@ export async function onElementDropComplete(dragElement, dropElement) {
662
707
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
663
708
  return;
664
709
  }
710
+ updateBalanceOnDrop(dragElement, dropElement);
665
711
  if (dragSelectedData) {
666
712
  let currentDrop = dragToDropMap.get(dragElement);
667
713
  if (currentDrop) {
668
714
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
669
715
  if (prevDropItem) {
670
716
  prevDropItem.isFull = false;
671
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
717
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
672
718
  reduceSizeToOriginal();
673
719
  }
674
720
  }
@@ -681,9 +727,9 @@ export async function onElementDropComplete(dragElement, dropElement) {
681
727
  // }
682
728
  // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
683
729
  }
684
- let dropLength = JSON.parse(localStorage.getItem(DropLength)) || 0;
730
+ let dropLength = parseInt((_h = container.getAttribute(DropLength)) !== null && _h !== void 0 ? _h : '0');
685
731
  dropLength += 1;
686
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
732
+ container.setAttribute(DropLength, String(dropLength));
687
733
  if (dropLength === countPatternWords(dropElement['value'])) {
688
734
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
689
735
  if (isisFull) {
@@ -692,9 +738,10 @@ export async function onElementDropComplete(dragElement, dropElement) {
692
738
  else {
693
739
  console.warn('No matching drop item found for', dropElement);
694
740
  }
695
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
741
+ // memoryStorage[DropHasDrag] = dropHasDrag;
742
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
696
743
  dropLength = 0;
697
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
744
+ container.setAttribute(DropLength, String(dropLength));
698
745
  }
699
746
  dragToDropMap.set(dragElement, dropElement);
700
747
  // Add pulse and highlight effect for a successful match
@@ -702,9 +749,9 @@ export async function onElementDropComplete(dragElement, dropElement) {
702
749
  dispatchElementDropEvent(dragElement, dropElement, isCorrect);
703
750
  storingEachActivityScore(isCorrect);
704
751
  dragElement.style.opacity = '1';
752
+ await onActivityComplete(dragElement, dropElement);
705
753
  const allDropElements = document.querySelectorAll('.drop-element');
706
754
  allDropElements.forEach(el => updateDropBorder(el));
707
- await onActivityComplete(dragElement, dropElement);
708
755
  }
709
756
  export function updateDropBorder(element) {
710
757
  if (!element || !element.classList.contains('drop-element'))
@@ -723,7 +770,9 @@ export function updateDropBorder(element) {
723
770
  element.classList.remove('empty');
724
771
  }
725
772
  else {
726
- element.classList.add('empty');
773
+ if (!element.classList.contains('math-matrix')) {
774
+ element.classList.add('empty');
775
+ }
727
776
  element.classList.remove('filled');
728
777
  }
729
778
  }
@@ -731,15 +780,15 @@ export function handleDropElement(element) {
731
780
  // let nextIndex = Object.keys(dropHas).length; // Get next index
732
781
  // dropHas[nextIndex] = { drop: element, isFull: false };
733
782
  element.classList.add('drop-element');
734
- let dropHas = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
783
+ let dropHas = buildDragSelectedMapFromDOM();
735
784
  const tabIndex = element.getAttribute('tab-index');
736
785
  if (typeof dropHas !== 'object' || dropHas === null) {
737
786
  dropHas = {};
738
787
  }
739
- if (!dropHas[tabIndex]) {
740
- dropHas[tabIndex] = { drop: element.id, isFull: false };
741
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
742
- }
788
+ // if (!dropHas[tabIndex]) {
789
+ // dropHas[tabIndex] = { drop: element.id, isFull: false };
790
+ // // localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
791
+ // }
743
792
  element.onclick = () => {
744
793
  onClickDropOrDragElement(element, 'drop');
745
794
  };
@@ -806,7 +855,7 @@ export async function onClickDropOrDragElement(element, type) {
806
855
  export const dragToDropMap = new Map();
807
856
  async function onClickDragElement(element) {
808
857
  AudioPlayer.getI().stop();
809
- const dropElements = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
858
+ const dropElements = buildDropHasDragFromDOM();
810
859
  const dragEl = element;
811
860
  if (!dragEl) {
812
861
  console.error('Element not found');
@@ -852,9 +901,12 @@ export const appendingDragElementsInDrop = () => {
852
901
  });
853
902
  });
854
903
  };
904
+ const container = document.getElementById(LidoContainer);
855
905
  export const reduceSizeToOriginal = () => {
856
906
  const dropItems = document.querySelectorAll("[type='drop']");
857
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
907
+ let dropHasDrag = buildDragSelectedMapFromDOM();
908
+ if (!dropItems || !container)
909
+ return;
858
910
  if (!dropHasDrag || !dropItems)
859
911
  return;
860
912
  dropItems.forEach(dropElement => {
@@ -863,6 +915,7 @@ export const reduceSizeToOriginal = () => {
863
915
  const tabIndex = drop.getAttribute('tab-index');
864
916
  if (((_a = drop === null || drop === void 0 ? void 0 : drop.getAttribute('drop-attr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Stretch && dropHasDrag[tabIndex].isFull === false) {
865
917
  const originalWidth = drop.getAttribute('data-original-width');
918
+ dropElement.removeAttribute('is-full');
866
919
  if (originalWidth) {
867
920
  drop.style.width = originalWidth;
868
921
  drop.removeAttribute('data-original-width');
@@ -0,0 +1,67 @@
1
+ import { equationCheck } from "../utils";
2
+ export function updateBalanceOnDrop(dragElement, dropElement) {
3
+ const balanceEl = document.querySelector('lido-balance');
4
+ if (!balanceEl)
5
+ return;
6
+ const leftDrag = Array.from(document.querySelectorAll('[drop-to^="lefthandle"]'));
7
+ const rightDrag = Array.from(document.querySelectorAll('[drop-to^="righthandle"]'));
8
+ balanceEl.leftVal = calculateValue(leftDrag, balanceEl.operation);
9
+ balanceEl.rightVal = calculateValue(rightDrag, balanceEl.operation);
10
+ console.log("leftpan:", balanceEl.leftVal, "rightpan:", balanceEl.rightVal);
11
+ if (balanceEl.updateTilt) {
12
+ balanceEl.updateTilt(balanceEl.leftVal, balanceEl.rightVal);
13
+ }
14
+ }
15
+ function calculateValue(elements, operation) {
16
+ if (elements.length === 0)
17
+ return 0;
18
+ if (operation === "count") {
19
+ return elements.length;
20
+ }
21
+ const ADD = ["add", "+"];
22
+ const SUBTRACT = ["subtract", "-"];
23
+ const MULTIPLY = ["multiply", "*"];
24
+ const DIVIDE = ["divide", "/"];
25
+ const expr = elements
26
+ .map(el => el.getAttribute("value") || "0")
27
+ .join(ADD.includes(operation) ? " + " :
28
+ SUBTRACT.includes(operation) ? " - " :
29
+ MULTIPLY.includes(operation) ? " * " :
30
+ DIVIDE.includes(operation) ? " / " : " + ");
31
+ try {
32
+ const res = equationCheck(expr);
33
+ if (typeof res === "number") {
34
+ return res;
35
+ }
36
+ else if (typeof res === "boolean") {
37
+ return res ? 1 : 0;
38
+ }
39
+ else {
40
+ return parseFloat(expr) || 0;
41
+ }
42
+ }
43
+ catch (e) {
44
+ console.warn("invalid exp", expr);
45
+ return 0;
46
+ }
47
+ }
48
+ export function balanceResult(container, objectiveString) {
49
+ var _a, _b, _c, _d, _e, _f;
50
+ const additionalCheck = container.getAttribute('equationCheck');
51
+ if (!additionalCheck)
52
+ return false;
53
+ const balanceEl = document.querySelector('lido-balance');
54
+ if (!balanceEl)
55
+ return false;
56
+ const leftVal = Number((_c = (_a = balanceEl.leftVal) !== null && _a !== void 0 ? _a : (_b = balanceEl.dataset) === null || _b === void 0 ? void 0 : _b.leftVal) !== null && _c !== void 0 ? _c : 0);
57
+ const rightVal = Number((_f = (_d = balanceEl.rightVal) !== null && _d !== void 0 ? _d : (_e = balanceEl.dataset) === null || _e === void 0 ? void 0 : _e.rightVal) !== null && _f !== void 0 ? _f : 0);
58
+ const hasLeft = !isNaN(leftVal) && leftVal !== 0;
59
+ const hasRight = !isNaN(rightVal) && rightVal !== 0;
60
+ if (!hasLeft || !hasRight) {
61
+ return false;
62
+ }
63
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
64
+ const res = objectiveString === symbol;
65
+ console.log("Result:", res);
66
+ return res;
67
+ }
@@ -0,0 +1,94 @@
1
+ import { triggerNextContainer } from "../utils";
2
+ // Helper to animate and remove the active equation cell
3
+ const animationToRemoveEquationSolvedCellForNimbleTable = (activeCell, allCalculateTypes) => {
4
+ return new Promise((resolve) => {
5
+ const keyframes = `
6
+ @keyframes widthDecrease {
7
+ 0% {
8
+ background-color: ${activeCell.style.backgroundColor};
9
+ height: ${activeCell.style.height};
10
+ margin: ${activeCell.style.margin};
11
+ ${activeCell.innerHTML = ""}
12
+ }
13
+ 100% { background-color: transparent; height: 0px; margin: 0px; }
14
+ }`;
15
+ const styleSheet = document.styleSheets[0];
16
+ styleSheet.insertRule(keyframes, styleSheet.cssRules.length);
17
+ activeCell.style.animation = `widthDecrease 0.1s`;
18
+ activeCell.addEventListener('animationend', () => {
19
+ activeCell.style.height = '0px';
20
+ activeCell.style.margin = '0px';
21
+ activeCell.style.backgroundColor = 'transparent';
22
+ activeCell.remove();
23
+ // Trigger next container if last cell
24
+ if (allCalculateTypes.length === 1) {
25
+ setTimeout(() => triggerNextContainer(), 2000);
26
+ }
27
+ resolve();
28
+ });
29
+ });
30
+ };
31
+ // Function: checks and animates equation when correct
32
+ const checkEquationOfActiveCell = async (container) => {
33
+ var _a;
34
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
35
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
36
+ const activeCell = allCalculateTypes[0];
37
+ const activeCellValue = Number(activeCell["value"]);
38
+ const calculteValue = Number(calculatorValue);
39
+ if (!activeCell || calculteValue !== activeCellValue)
40
+ return;
41
+ const equation = activeCell["string"];
42
+ // Replace equation after a short delay
43
+ //await new Promise(r => setTimeout(r, 200));
44
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
45
+ const element2 = container.querySelector("#dummy112");
46
+ element2.innerHTML = activeCell.innerHTML;
47
+ // Animate and clean up
48
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
49
+ };
50
+ // Function: handles equation check when clicked on OK
51
+ let score = 0;
52
+ export const handleSolvedEquationSubmissionAndScoreUpdate = async () => {
53
+ var _a;
54
+ const container = document.getElementById('lido-container');
55
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
56
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
57
+ const activeCell = allCalculateTypes[0];
58
+ const isContinueOnCorrect = container.getAttribute("is-continue-on-correct") === "true";
59
+ const activeCellValue = Number(activeCell["value"]);
60
+ const calculteValue = Number(calculatorValue);
61
+ const element1 = container.querySelector("#dummy111");
62
+ const element2 = container.querySelector("#dummy112");
63
+ // PRACTICE MODE (continue only if correct)
64
+ if (isContinueOnCorrect) {
65
+ if (element2.innerHTML.length > 0 && activeCellValue === calculteValue) {
66
+ element1.innerHTML = element2.innerHTML;
67
+ }
68
+ await checkEquationOfActiveCell(container);
69
+ }
70
+ // TEST MODE (store all, animate regardless of correctness)
71
+ else {
72
+ if (calculatorValue.length > 0) {
73
+ if (calculatorValue === activeCell["value"]) {
74
+ score++;
75
+ console.log("SCOREEEE", score);
76
+ }
77
+ else {
78
+ if (score > 0) {
79
+ score--;
80
+ }
81
+ console.log("SCOREEEE", score);
82
+ }
83
+ if (element2.innerHTML.length > 0) {
84
+ element1.innerHTML = element2.innerHTML;
85
+ }
86
+ const equation = activeCell["string"];
87
+ // Replace value visually
88
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
89
+ element2.innerHTML = activeCell.innerHTML;
90
+ // Animate
91
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
92
+ }
93
+ }
94
+ };