lido-player 0.0.2-alpha-50 → 0.0.2-alpha-50-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.
- package/dist/cjs/{index-fe562525.js → index-6a69c33a.js} +36 -3
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{lido-avatar_19.cjs.entry.js → lido-avatar_21.cjs.entry.js} +433 -182
- package/dist/cjs/lido-player.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{utils-c3e7cbcc.js → utils-079a5e7d.js} +1033 -169
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/calculator/lido-calculator.css +87 -0
- package/dist/collection/components/calculator/lido-calculator.js +321 -0
- package/dist/collection/components/cell/lido-cell.js +1 -1
- package/dist/collection/components/column/lido-col.js +1 -1
- package/dist/collection/components/container/lido-container.js +20 -2
- package/dist/collection/components/flashCard/lido-flash-card.js +1 -1
- package/dist/collection/components/float/lido-float.js +1 -1
- package/dist/collection/components/home/lido-home.css +0 -4
- package/dist/collection/components/home/lido-home.js +10 -29
- package/dist/collection/components/keyboard/lido-keyboard.js +2 -2
- package/dist/collection/components/mathMatrix/lido-math-matrix.css +10 -2
- package/dist/collection/components/mathMatrix/lido-math-matrix.js +226 -20
- package/dist/collection/components/position/lido-pos.js +1 -1
- package/dist/collection/components/random/lido-random.js +1 -1
- package/dist/collection/components/row/lido-row.js +1 -1
- package/dist/collection/components/scale/lido-balance.css +114 -0
- package/dist/collection/components/scale/lido-balance.js +549 -0
- package/dist/collection/components/shape/lido-shape.js +1 -1
- package/dist/collection/components/slideFill/lido-slide-fill.js +1 -1
- package/dist/collection/components/text/lido-text.js +1 -1
- package/dist/collection/components/trace/lido-trace.js +49 -128
- package/dist/collection/components/wrap/lido-wrap.js +1 -1
- package/dist/collection/css/animation.css +21 -0
- package/dist/collection/css/index.css +45 -0
- package/dist/collection/stories/Templates/Fill-Up/fill-up.stories.js +24 -25
- package/dist/collection/stories/Templates/RocketGame/rocketGame.stories.js +0 -3
- package/dist/collection/stories/Templates/balancing/balancing.stories.js +67 -0
- package/dist/collection/stories/Templates/checker-block/checkerBlock.stories.js +156 -0
- package/dist/collection/stories/Templates/checkerBlock/checkerBlock.stories.js +49 -0
- package/dist/collection/stories/Templates/fillAnswer/fill-answer.stories.js +66 -0
- package/dist/collection/stories/Templates/foodJar/food-jar.stories.js +65 -0
- package/dist/collection/stories/Templates/matchBox/matchBox.stories.js +105 -0
- package/dist/collection/stories/Templates/matchBox/matchBox2.stories.js +92 -0
- package/dist/collection/stories/Templates/matchingCard/matching-card.stories.js +47 -0
- package/dist/collection/stories/Templates/multiplyBeeds/multiplyBeeds.stories.js +59 -0
- package/dist/collection/stories/Templates/nimbleTable/nimbleTable.stories.js +93 -0
- package/dist/collection/stories/Templates/numberBoardTwo/numberBoardTwo.stories.js +100 -0
- package/dist/collection/stories/Templates/numberPair/numberPair.stories.js +212 -0
- package/dist/collection/stories/Templates/order-tractor/order-tractor-ascending-order.stories.js +6 -7
- package/dist/collection/stories/Templates/order-tractor/order-tractor.stories.js +6 -7
- package/dist/collection/stories/Templates/questionBoard/questionBoard.stories.js +158 -0
- package/dist/collection/stories/Templates/sequenceBox/sequenceBox1.stories.js +102 -0
- package/dist/collection/stories/Templates/sequenceBox/sequenceBox2.stories.js +94 -0
- package/dist/collection/stories/Templates/shapePair/shape-pair.stories.js +184 -0
- package/dist/collection/stories/Templates/shapeTractor/shape-tractor.stories.js +213 -0
- package/dist/collection/stories/Templates/sumTogether/sumTogether.stories.js +109 -0
- package/dist/collection/stories/Templates/total/total.stories.js +59 -0
- package/dist/collection/stories/Templates/writeNumber/writeNumber.stories.js +96 -0
- package/dist/collection/stories/Templates/writeSet/writeSet.stories.js +55 -0
- package/dist/collection/stories/Templates/writeWord/writeWord.stories.js +5 -6
- package/dist/collection/utils/utils.js +440 -84
- package/dist/collection/utils/utilsHandlers/clickHandler.js +21 -26
- package/dist/collection/utils/utilsHandlers/dragDropHandler.js +95 -42
- package/dist/collection/utils/utilsHandlers/lidoBalanceHandler.js +67 -0
- package/dist/collection/utils/utilsHandlers/lidoCalculatorHandler.js +94 -0
- package/dist/collection/utils/utilsHandlers/matrixHandler.js +298 -0
- package/dist/collection/utils/utilsHandlers/slideHandler.js +4 -2
- package/dist/collection/utils/utilsHandlers/sortHandler.js +21 -12
- package/dist/components/index.js +1 -1
- package/dist/components/lido-avatar.js +1 -1
- package/dist/components/lido-balance.d.ts +11 -0
- package/dist/components/lido-balance.js +6 -0
- package/dist/components/lido-calculator.d.ts +11 -0
- package/dist/components/lido-calculator.js +6 -0
- package/dist/components/lido-cell.js +1 -1
- package/dist/components/lido-col.js +1 -1
- package/dist/components/lido-container.js +1 -1
- package/dist/components/lido-flash-card.js +1 -1
- package/dist/components/lido-float.js +1 -1
- package/dist/components/lido-home.js +1 -1
- package/dist/components/lido-image.js +1 -1
- package/dist/components/lido-keyboard.js +1 -1
- package/dist/components/lido-math-matrix.js +1 -1
- package/dist/components/lido-pos.js +1 -1
- package/dist/components/lido-random.js +1 -1
- package/dist/components/lido-root.js +32 -20
- package/dist/components/lido-row.js +1 -1
- package/dist/components/lido-shape.js +1 -1
- package/dist/components/lido-slide-fill.js +1 -1
- package/dist/components/lido-text.js +1 -1
- package/dist/components/lido-trace.js +1 -1
- package/dist/components/lido-wrap.js +1 -1
- package/dist/components/p-08d0deab.js +254 -0
- package/dist/components/{p-7fc73a13.js → p-15971ede.js} +1 -1
- package/dist/components/{p-1cb590fb.js → p-1fbdb431.js} +2 -2
- package/dist/components/{p-b2d7b151.js → p-29bdd953.js} +2 -2
- package/dist/components/{p-20ffe2e9.js → p-322acda6.js} +42 -49
- package/dist/components/{p-d489f16f.js → p-3f406017.js} +2 -2
- package/dist/components/p-44808985.js +186 -0
- package/dist/components/{p-6917debf.js → p-52844fa4.js} +2 -2
- package/dist/components/{p-ababe351.js → p-73e31a86.js} +2 -2
- package/dist/components/{p-513a03e1.js → p-74849cdd.js} +4 -4
- package/dist/components/{p-6c98fc03.js → p-7f7e5672.js} +2 -2
- package/dist/components/{p-76423463.js → p-835b973d.js} +2 -2
- package/dist/components/{p-3d732e48.js → p-90465904.js} +50 -129
- package/dist/components/{p-6405d878.js → p-904711c8.js} +2 -2
- package/dist/components/{p-926348de.js → p-9be56729.js} +5 -4
- package/dist/components/{p-b83c7a68.js → p-afbc196f.js} +2 -2
- package/dist/components/{p-135e98bf.js → p-bed94c37.js} +1048 -168
- package/dist/components/{p-33588c7a.js → p-cbac3cbc.js} +1 -1
- package/dist/components/{p-a9689087.js → p-d37ab4dc.js} +2 -2
- package/dist/components/p-e36ddcc1.js +166 -0
- package/dist/components/{p-868beaa6.js → p-e4e42677.js} +2 -2
- package/dist/esm/{index-f47852d4.js → index-170e58c7.js} +36 -4
- package/dist/esm/index.js +2 -2
- package/dist/esm/{lido-avatar_19.entry.js → lido-avatar_21.entry.js} +432 -183
- package/dist/esm/lido-player.js +3 -3
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{utils-99110070.js → utils-5df09162.js} +1032 -168
- package/dist/lido-player/index.esm.js +1 -1
- package/dist/lido-player/lido-player.css +1 -1
- package/dist/lido-player/lido-player.esm.js +1 -1
- package/dist/lido-player/p-137c99ce.js +2 -0
- package/dist/lido-player/p-7556e652.js +9 -0
- package/dist/lido-player/p-eb956325.entry.js +1 -0
- package/dist/types/components/calculator/lido-calculator.d.ts +40 -0
- package/dist/types/components/container/lido-container.d.ts +4 -0
- package/dist/types/components/home/lido-home.d.ts +0 -1
- package/dist/types/components/mathMatrix/lido-math-matrix.d.ts +24 -4
- package/dist/types/components/scale/lido-balance.d.ts +160 -0
- package/dist/types/components/trace/lido-trace.d.ts +0 -1
- package/dist/types/components.d.ts +342 -14
- package/dist/types/stories/Templates/balancing/balancing.stories.d.ts +4 -0
- package/dist/types/stories/Templates/checker-block/checkerBlock.stories.d.ts +4 -0
- package/dist/types/stories/Templates/checkerBlock/checkerBlock.stories.d.ts +4 -0
- package/dist/types/stories/Templates/fillAnswer/fill-answer.stories.d.ts +4 -0
- package/dist/types/stories/Templates/foodJar/food-jar.stories.d.ts +4 -0
- package/dist/types/stories/Templates/matchBox/matchBox.stories.d.ts +4 -0
- package/dist/types/stories/Templates/matchBox/matchBox2.stories.d.ts +4 -0
- package/dist/types/stories/Templates/matchingCard/matching-card.stories.d.ts +4 -0
- package/dist/types/stories/Templates/multiplyBeeds/multiplyBeeds.stories.d.ts +9 -0
- package/dist/types/stories/Templates/nimbleTable/nimbleTable.stories.d.ts +4 -0
- package/dist/types/stories/Templates/numberBoardTwo/numberBoardTwo.stories.d.ts +4 -0
- package/dist/types/stories/Templates/numberPair/numberPair.stories.d.ts +4 -0
- package/dist/types/stories/Templates/questionBoard/questionBoard.stories.d.ts +15 -0
- package/dist/types/stories/Templates/sequenceBox/sequenceBox1.stories.d.ts +11 -0
- package/dist/types/stories/Templates/sequenceBox/sequenceBox2.stories.d.ts +11 -0
- package/dist/types/stories/Templates/shapePair/shape-pair.stories.d.ts +4 -0
- package/dist/types/stories/Templates/shapeTractor/shape-tractor.stories.d.ts +12 -0
- package/dist/types/stories/Templates/sumTogether/sumTogether.stories.d.ts +11 -0
- package/dist/types/stories/Templates/total/total.stories.d.ts +4 -0
- package/dist/types/stories/Templates/writeNumber/writeNumber.stories.d.ts +13 -0
- package/dist/types/stories/Templates/writeSet/writeSet.stories.d.ts +4 -0
- package/dist/types/utils/utils.d.ts +8 -2
- package/dist/types/utils/utilsHandlers/dragDropHandler.d.ts +4 -0
- package/dist/types/utils/utilsHandlers/lidoBalanceHandler.d.ts +2 -0
- package/dist/types/utils/utilsHandlers/lidoCalculatorHandler.d.ts +1 -0
- package/dist/types/utils/utilsHandlers/matrixHandler.d.ts +1 -0
- package/package.json +1 -1
- package/dist/components/p-58b69b3f.js +0 -160
- package/dist/lido-player/p-b83634bf.entry.js +0 -1
- package/dist/lido-player/p-c8c00dcb.js +0 -9
- package/dist/lido-player/p-ddf627b0.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActivityScoreKey,
|
|
1
|
+
import { ActivityScoreKey, DragMapKey, SelectedValuesKey, DropMode, DropToAttr, DropTimeAttr, LidoContainer, DropAction, } from "./constants";
|
|
2
2
|
import { dispatchActivityEndEvent, dispatchLessonEndEvent, dispatchNextContainerEvent, dispatchPrevContainerEvent } from "./customEvents";
|
|
3
3
|
import GameScore from "./constants";
|
|
4
4
|
import { RiveService } from "./rive-service";
|
|
@@ -11,7 +11,43 @@ import { addClickListenerForClickType, onTouchListenerForOnTouch } from "./utils
|
|
|
11
11
|
import { evaluate, isArray } from "mathjs";
|
|
12
12
|
import { fillSlideHandle } from "./utilsHandlers/floatHandler";
|
|
13
13
|
import { stopHighlightForSpeakingElement } from "./utilsHandlers/highlightHandler";
|
|
14
|
+
import { handleSolvedEquationSubmissionAndScoreUpdate } from "./utilsHandlers/lidoCalculatorHandler";
|
|
15
|
+
import { handlingMatrix } from "./utilsHandlers/matrixHandler";
|
|
16
|
+
import { balanceResult } from "./utilsHandlers/lidoBalanceHandler";
|
|
14
17
|
const gameScore = new GameScore();
|
|
18
|
+
export function buildDragSelectedMapFromDOM() {
|
|
19
|
+
const map = {};
|
|
20
|
+
const draggedEls = document.querySelectorAll(`[${DropToAttr}]`);
|
|
21
|
+
draggedEls.forEach(dragEl => {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const to = dragEl.getAttribute(DropToAttr);
|
|
24
|
+
if (!to)
|
|
25
|
+
return;
|
|
26
|
+
const dropEl = document.getElementById(to);
|
|
27
|
+
if (!dropEl)
|
|
28
|
+
return;
|
|
29
|
+
const tabIndex = (_a = dropEl.getAttribute('tab-index')) !== null && _a !== void 0 ? _a : to;
|
|
30
|
+
if (!map[tabIndex])
|
|
31
|
+
map[tabIndex] = [];
|
|
32
|
+
const value = (_c = (_b = dragEl.getAttribute('value')) !== null && _b !== void 0 ? _b : dragEl.value) !== null && _c !== void 0 ? _c : '';
|
|
33
|
+
map[tabIndex].push(value);
|
|
34
|
+
});
|
|
35
|
+
return map;
|
|
36
|
+
}
|
|
37
|
+
export function getSortedValuesArrayFromMap(map) {
|
|
38
|
+
const sortedKeys = Object.keys(map).sort((a, b) => parseInt(a) - parseInt(b));
|
|
39
|
+
const sortedValues = sortedKeys.reduce((acc, key) => {
|
|
40
|
+
const values = map[key];
|
|
41
|
+
if (values.length > 1) {
|
|
42
|
+
acc.push(`(${values.join('|')})`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
acc.push(values[0]);
|
|
46
|
+
}
|
|
47
|
+
return acc;
|
|
48
|
+
}, []);
|
|
49
|
+
return sortedValues;
|
|
50
|
+
}
|
|
15
51
|
export function format(first, middle, last) {
|
|
16
52
|
return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
|
|
17
53
|
}
|
|
@@ -56,6 +92,10 @@ export const initEventsForElement = async (element, type) => {
|
|
|
56
92
|
enableOptionArea(element);
|
|
57
93
|
break;
|
|
58
94
|
}
|
|
95
|
+
case 'checkerBlock': {
|
|
96
|
+
handlingMatrix(element);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
59
99
|
default:
|
|
60
100
|
break;
|
|
61
101
|
}
|
|
@@ -63,9 +103,8 @@ export const initEventsForElement = async (element, type) => {
|
|
|
63
103
|
};
|
|
64
104
|
// Function to execute actions parsed from the onMatch string
|
|
65
105
|
export const executeActions = async (actionsString, thisElement, element) => {
|
|
66
|
-
var _a;
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
67
107
|
const actions = parseActions(actionsString);
|
|
68
|
-
body.style.pointerEvents = 'none';
|
|
69
108
|
for (let i = 0; i < actions.length; i++) {
|
|
70
109
|
const action = actions[i];
|
|
71
110
|
const queriedElement = document.querySelector(action.actor);
|
|
@@ -78,13 +117,25 @@ export const executeActions = async (actionsString, thisElement, element) => {
|
|
|
78
117
|
targetElement.style.transform = currentTransform !== 'none' ? `${currentTransform} ${action.value}` : action.value;
|
|
79
118
|
break;
|
|
80
119
|
}
|
|
120
|
+
case 'revealImageValue': {
|
|
121
|
+
if (targetElement) {
|
|
122
|
+
revealImageValue(targetElement); // call your function here
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'scrollCellAfterEquationSolved': {
|
|
127
|
+
if (targetElement) {
|
|
128
|
+
handleSolvedEquationSubmissionAndScoreUpdate();
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
81
132
|
case 'alignMatch': {
|
|
82
133
|
const dropElement = targetElement;
|
|
83
134
|
const dragElement = element;
|
|
84
135
|
const container = document.getElementById(LidoContainer);
|
|
85
136
|
const containerScale = getElementScale(container);
|
|
86
137
|
dragElement.style.transform = 'translate(0,0)';
|
|
87
|
-
console.log(
|
|
138
|
+
console.log("logg alinmatch");
|
|
88
139
|
const dropRect = dropElement.getBoundingClientRect();
|
|
89
140
|
const dragRect = dragElement.getBoundingClientRect();
|
|
90
141
|
const dropCenterX = dropRect.left + dropRect.width / 2;
|
|
@@ -130,7 +181,7 @@ export const executeActions = async (actionsString, thisElement, element) => {
|
|
|
130
181
|
if (container.getAttribute('is-continue-on-correct') !== 'true') {
|
|
131
182
|
targetElement.style.pointerEvents = 'none';
|
|
132
183
|
}
|
|
133
|
-
|
|
184
|
+
validateObjectiveStatus();
|
|
134
185
|
break;
|
|
135
186
|
}
|
|
136
187
|
case 'prevBtn': {
|
|
@@ -170,10 +221,76 @@ export const executeActions = async (actionsString, thisElement, element) => {
|
|
|
170
221
|
}
|
|
171
222
|
break;
|
|
172
223
|
}
|
|
224
|
+
case 'highlightStarsAndDisapper': {
|
|
225
|
+
const value = action.value;
|
|
226
|
+
if (value && targetElement) {
|
|
227
|
+
console.log('highlightStar action triggered');
|
|
228
|
+
console.log('Target Element:', targetElement);
|
|
229
|
+
await HighlightStarsOneByOne(targetElement, value);
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
case 'boxAnimationOneByOne': {
|
|
234
|
+
const value = action.value;
|
|
235
|
+
if (value && targetElement) {
|
|
236
|
+
await animateBoxCells(targetElement, value);
|
|
237
|
+
}
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
case 'questionBoxAnimate': {
|
|
241
|
+
const value = action.value;
|
|
242
|
+
if (value && targetElement) {
|
|
243
|
+
await questionBoxAnimation(targetElement, value);
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
173
247
|
case 'slideAnimation': {
|
|
174
248
|
slideAnimation();
|
|
175
249
|
break;
|
|
176
250
|
}
|
|
251
|
+
case 'showBalanceSymbol': {
|
|
252
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
253
|
+
if (!balanceEl)
|
|
254
|
+
break;
|
|
255
|
+
const leftVal = Number((_b = balanceEl.leftVal) !== null && _b !== void 0 ? _b : Number((_d = (_c = balanceEl.dataset) === null || _c === void 0 ? void 0 : _c.leftVal) !== null && _d !== void 0 ? _d : 0));
|
|
256
|
+
const rightVal = Number((_e = balanceEl.rightVal) !== null && _e !== void 0 ? _e : Number((_g = (_f = balanceEl.dataset) === null || _f === void 0 ? void 0 : _f.rightVal) !== null && _g !== void 0 ? _g : 0));
|
|
257
|
+
const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
|
|
258
|
+
balanceEl.balanceSymbol = symbol;
|
|
259
|
+
balanceEl.dataset.balanceSymbol = symbol;
|
|
260
|
+
if (balanceEl.revealSymbol) {
|
|
261
|
+
await balanceEl.revealSymbol();
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
balanceEl.showSymbol = true;
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
case 'hideBalanceSymbol': {
|
|
269
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
270
|
+
if (!balanceEl)
|
|
271
|
+
break;
|
|
272
|
+
if (balanceEl.hideSymbol) {
|
|
273
|
+
await balanceEl.hideSymbol();
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
balanceEl.showSymbol = false;
|
|
277
|
+
}
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case 'sumTogetherAnimation': {
|
|
281
|
+
const value = action.value;
|
|
282
|
+
if (value) {
|
|
283
|
+
SumTogetherAnimation(targetElement, value);
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
case 'addText': {
|
|
288
|
+
const value = action.value;
|
|
289
|
+
if (value) {
|
|
290
|
+
targetElement.textContent += value;
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
177
294
|
default: {
|
|
178
295
|
targetElement.style[action.action] = action.value;
|
|
179
296
|
break;
|
|
@@ -181,7 +298,6 @@ export const executeActions = async (actionsString, thisElement, element) => {
|
|
|
181
298
|
}
|
|
182
299
|
}
|
|
183
300
|
}
|
|
184
|
-
body.style.pointerEvents = 'auto';
|
|
185
301
|
};
|
|
186
302
|
const afterDropDragHandling = (dragElement, dropElement) => {
|
|
187
303
|
const container = document.getElementById(LidoContainer);
|
|
@@ -272,6 +388,9 @@ export const matchStringPattern = (pattern, arr) => {
|
|
|
272
388
|
const patternGroups = pattern.split(',').map(group => group.trim());
|
|
273
389
|
let arrIndex = 0;
|
|
274
390
|
let options = new Set();
|
|
391
|
+
if (patternGroups.length == 0) { // If pattern is empty
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
275
394
|
if (patternGroups.length > 0) {
|
|
276
395
|
if (arr.length === 0)
|
|
277
396
|
return false; // If pattern is not empty but user provided array is empty, return false
|
|
@@ -356,20 +475,29 @@ export const calculateScore = () => {
|
|
|
356
475
|
gameScore.wrongMoves = 0;
|
|
357
476
|
};
|
|
358
477
|
export async function onActivityComplete(dragElement, dropElement) {
|
|
359
|
-
var _a
|
|
478
|
+
var _a;
|
|
360
479
|
const container = document.getElementById(LidoContainer);
|
|
361
480
|
if (!container)
|
|
362
481
|
return;
|
|
363
482
|
await executeActions("this.alignMatch='true'", dropElement, dragElement);
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
483
|
+
if (dragElement && dropElement) {
|
|
484
|
+
const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
|
|
485
|
+
if (isCorrect) {
|
|
486
|
+
const onCorrect = dropElement.getAttribute('onCorrect');
|
|
487
|
+
if (onCorrect) {
|
|
488
|
+
await executeActions(onCorrect, dropElement, dragElement);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
const onInCorrect = dropElement.getAttribute('onInCorrect');
|
|
493
|
+
await executeActions(onInCorrect, dropElement, dragElement);
|
|
494
|
+
}
|
|
368
495
|
}
|
|
369
|
-
dragScore
|
|
370
|
-
|
|
496
|
+
let dragScore = buildDragSelectedMapFromDOM();
|
|
497
|
+
const sortedValues = getSortedValuesArrayFromMap(dragScore);
|
|
498
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
|
|
371
499
|
//localStorage
|
|
372
|
-
let drag = JSON.parse((
|
|
500
|
+
let drag = JSON.parse((_a = localStorage.getItem(DragMapKey)) !== null && _a !== void 0 ? _a : '{}');
|
|
373
501
|
const index = dropElement.getAttribute('tab-index');
|
|
374
502
|
if (!drag[index]) {
|
|
375
503
|
drag[index] = [];
|
|
@@ -377,17 +505,6 @@ export async function onActivityComplete(dragElement, dropElement) {
|
|
|
377
505
|
drag[index].push(dragElement.id);
|
|
378
506
|
// localStorage.setItem(DragMapKey, JSON.stringify(drag));
|
|
379
507
|
const sortedKeys = Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
|
|
380
|
-
const sortedValues = sortedKeys.reduce((acc, key) => {
|
|
381
|
-
const values = dragScore[key];
|
|
382
|
-
if (values.length > 1) {
|
|
383
|
-
acc.push(`(${values.join('|')})`);
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
acc.push(values[0]);
|
|
387
|
-
}
|
|
388
|
-
return acc;
|
|
389
|
-
}, []);
|
|
390
|
-
localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
|
|
391
508
|
if (dragElement && dropElement) {
|
|
392
509
|
const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
|
|
393
510
|
if (isCorrect) {
|
|
@@ -404,8 +521,7 @@ export async function onActivityComplete(dragElement, dropElement) {
|
|
|
404
521
|
const allElements = document.querySelectorAll("[type='drop']");
|
|
405
522
|
allElements.forEach(otherElement => {
|
|
406
523
|
var _a;
|
|
407
|
-
const
|
|
408
|
-
const storedTabIndexes = Object.keys(dropObject).map(Number);
|
|
524
|
+
const storedTabIndexes = Object.keys(dragScore).map(Number);
|
|
409
525
|
if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
|
|
410
526
|
if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
|
|
411
527
|
if (otherElement.tagName.toLowerCase() === 'lido-text') {
|
|
@@ -457,77 +573,97 @@ export const handleShowCheck = () => {
|
|
|
457
573
|
var _a, _b;
|
|
458
574
|
const container = document.getElementById(LidoContainer);
|
|
459
575
|
const objectiveString = container['objective'];
|
|
460
|
-
const selectValues = (_a =
|
|
576
|
+
const selectValues = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
|
|
461
577
|
const checkButton = document.querySelector('#lido-checkButton');
|
|
462
|
-
if (!selectValues || countPatternWords(selectValues)
|
|
578
|
+
if (!selectValues || countPatternWords(selectValues) < countPatternWords(objectiveString)) {
|
|
463
579
|
executeActions("this.addClass='lido-disable-check-button'", checkButton);
|
|
464
580
|
return;
|
|
465
581
|
}
|
|
466
582
|
const showCheck = container.getAttribute('show-check') == 'true';
|
|
467
583
|
if (showCheck) {
|
|
468
584
|
(_b = checkButton === null || checkButton === void 0 ? void 0 : checkButton.classList) === null || _b === void 0 ? void 0 : _b.remove('lido-disable-check-button');
|
|
585
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
586
|
+
if (balanceEl) {
|
|
587
|
+
if (!checkButton.hasAttribute('data-balance-listener')) {
|
|
588
|
+
checkButton.addEventListener('click', async function onClick() {
|
|
589
|
+
if (balanceResult && res) {
|
|
590
|
+
await executeActions("this.showBalanceSymbol='true'", checkButton);
|
|
591
|
+
checkButton.removeEventListener('click', onClick);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
checkButton.setAttribute('data-balance-listener', 'true');
|
|
595
|
+
}
|
|
596
|
+
}
|
|
469
597
|
}
|
|
470
598
|
else {
|
|
471
599
|
validateObjectiveStatus();
|
|
472
600
|
}
|
|
473
601
|
};
|
|
474
|
-
|
|
602
|
+
let res;
|
|
475
603
|
export const validateObjectiveStatus = async () => {
|
|
476
|
-
var _a;
|
|
604
|
+
var _a, _b;
|
|
477
605
|
const container = document.getElementById(LidoContainer);
|
|
478
606
|
if (!container)
|
|
479
607
|
return;
|
|
480
608
|
const objectiveString = container['objective'];
|
|
609
|
+
const additionalCheck = container.getAttribute('equationCheck');
|
|
610
|
+
console.log('🚀 ~ validateObjectiveStatus ~ additionalCheck:', additionalCheck);
|
|
611
|
+
let equationGiven = false;
|
|
481
612
|
if (objectiveString == null || objectiveString.length === 0) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
613
|
+
if (additionalCheck) {
|
|
614
|
+
equationGiven = true;
|
|
615
|
+
}
|
|
616
|
+
if (!equationGiven) {
|
|
617
|
+
const onCorrect = container.getAttribute('onCorrect');
|
|
618
|
+
if (onCorrect) {
|
|
619
|
+
await executeActions(onCorrect, container);
|
|
620
|
+
}
|
|
621
|
+
storeActivityScore(100);
|
|
622
|
+
storingEachActivityScore(true);
|
|
623
|
+
triggerNextContainer();
|
|
624
|
+
return;
|
|
486
625
|
}
|
|
487
|
-
storeActivityScore(100);
|
|
488
|
-
storingEachActivityScore(true);
|
|
489
|
-
triggerNextContainer();
|
|
490
|
-
return;
|
|
491
626
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
if (!!additionalCheck) {
|
|
627
|
+
const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
|
|
628
|
+
if (!!additionalCheck) {
|
|
629
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
630
|
+
if (!balanceEl) {
|
|
497
631
|
res = equationCheck(additionalCheck);
|
|
498
|
-
console.log('🚀 ~ handleShowCheck ~ res:', res);
|
|
499
632
|
}
|
|
500
633
|
else {
|
|
501
|
-
res =
|
|
634
|
+
res = balanceResult(container, objectiveString);
|
|
502
635
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
setTimeout(() => {
|
|
515
|
-
triggerNextContainer();
|
|
516
|
-
}, 2000);
|
|
636
|
+
console.log('🚀 ~ handleShowCheck ~ res:', res);
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
res = matchStringPattern(objectiveString, objectiveArray);
|
|
640
|
+
}
|
|
641
|
+
if (res) {
|
|
642
|
+
const attach = container.getAttribute('appendToDropOnCompletion');
|
|
643
|
+
const onCorrect = container.getAttribute('onCorrect');
|
|
644
|
+
if (onCorrect) {
|
|
645
|
+
if (attach === 'true') {
|
|
646
|
+
appendingDragElementsInDrop();
|
|
517
647
|
}
|
|
518
|
-
|
|
648
|
+
await executeActions(onCorrect, container);
|
|
649
|
+
}
|
|
650
|
+
if (container.getAttribute('dropAttr') === 'EnableAnimation') {
|
|
651
|
+
setTimeout(() => {
|
|
519
652
|
triggerNextContainer();
|
|
520
|
-
}
|
|
521
|
-
await calculateScore();
|
|
653
|
+
}, 2000);
|
|
522
654
|
}
|
|
523
655
|
else {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
656
|
+
triggerNextContainer();
|
|
657
|
+
}
|
|
658
|
+
await calculateScore();
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
const onInCorrect = container.getAttribute('onInCorrect');
|
|
662
|
+
await executeActions(onInCorrect, container);
|
|
663
|
+
const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
|
|
664
|
+
if (!isContinueOnCorrect) {
|
|
665
|
+
triggerNextContainer();
|
|
666
|
+
await calculateScore();
|
|
531
667
|
}
|
|
532
668
|
}
|
|
533
669
|
};
|
|
@@ -546,16 +682,16 @@ export const triggerPrevcontainer = () => {
|
|
|
546
682
|
export function convertUrlToRelative(url) {
|
|
547
683
|
const container = document.getElementById(LidoContainer);
|
|
548
684
|
const baseUrl = container.getAttribute('baseUrl');
|
|
549
|
-
if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))
|
|
685
|
+
if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))) {
|
|
550
686
|
return url;
|
|
551
687
|
}
|
|
552
|
-
if (baseUrl) {
|
|
553
|
-
const newUrl = url.startsWith('/') ? url.
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
688
|
+
else if (baseUrl) {
|
|
689
|
+
const newUrl = !url.startsWith('/') ? url : url.substring(1);
|
|
690
|
+
return baseUrl + (baseUrl.endsWith('/') ? newUrl : '/' + newUrl);
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
return getAssetPath(url);
|
|
557
694
|
}
|
|
558
|
-
return getAssetPath(url);
|
|
559
695
|
}
|
|
560
696
|
/**
|
|
561
697
|
* Asynchronously speaks the given text using the browser's text-to-speech API.
|
|
@@ -744,7 +880,10 @@ export const equationCheck = (additionalCheck) => {
|
|
|
744
880
|
});
|
|
745
881
|
// 3. Join the modified parts back into one string
|
|
746
882
|
const resultString = modifiedParts.join('');
|
|
883
|
+
console.log('🚀 ~ equationCheck ~ resultString:', resultString);
|
|
884
|
+
// 4. Evaluate the final string as a mathematical expression
|
|
747
885
|
const finalRes = evaluate(resultString);
|
|
886
|
+
console.log('🚀 ~ equationCheck ~ finalRes:', finalRes);
|
|
748
887
|
return finalRes;
|
|
749
888
|
};
|
|
750
889
|
const getElementsForQueries = (query) => {
|
|
@@ -813,13 +952,6 @@ export const attachSpeakIcon = async (element) => {
|
|
|
813
952
|
}
|
|
814
953
|
element.appendChild(speakIconElement);
|
|
815
954
|
};
|
|
816
|
-
export const clearLocalStorage = () => {
|
|
817
|
-
localStorage.removeItem(DragSelectedMapKey);
|
|
818
|
-
localStorage.removeItem(DragMapKey);
|
|
819
|
-
localStorage.removeItem(SelectedValuesKey);
|
|
820
|
-
localStorage.removeItem(DropHasDrag);
|
|
821
|
-
localStorage.removeItem(DropLength);
|
|
822
|
-
};
|
|
823
955
|
/**
|
|
824
956
|
* Applies a delay to the element's visibility based on `delayVisible`.
|
|
825
957
|
*/
|
|
@@ -905,3 +1037,227 @@ export function generateUUIDFallback() {
|
|
|
905
1037
|
return v.toString(16);
|
|
906
1038
|
});
|
|
907
1039
|
}
|
|
1040
|
+
export const revealImageValue = (imageEl) => {
|
|
1041
|
+
if (!imageEl)
|
|
1042
|
+
return;
|
|
1043
|
+
const value = imageEl.getAttribute('value');
|
|
1044
|
+
if (!value)
|
|
1045
|
+
return;
|
|
1046
|
+
let valueElement = imageEl.querySelector('.lido-display-hiddenvalue');
|
|
1047
|
+
if (!valueElement) {
|
|
1048
|
+
valueElement = document.createElement('div');
|
|
1049
|
+
valueElement.classList.add('lido-display-hiddenvalue');
|
|
1050
|
+
imageEl.style.position = 'relative';
|
|
1051
|
+
imageEl.appendChild(valueElement);
|
|
1052
|
+
}
|
|
1053
|
+
valueElement.innerText = value;
|
|
1054
|
+
};
|
|
1055
|
+
const setImageBackground = (el, color) => {
|
|
1056
|
+
if (!el)
|
|
1057
|
+
return;
|
|
1058
|
+
el.classList.add('lido-image-colorize');
|
|
1059
|
+
const img = el.querySelector('img');
|
|
1060
|
+
if (img) {
|
|
1061
|
+
// use same image as mask
|
|
1062
|
+
el.style.setProperty('--mask-url', `url(${img.src})`);
|
|
1063
|
+
}
|
|
1064
|
+
if (color === 'red') {
|
|
1065
|
+
el.style.setProperty('--tint-color', '#ff0000');
|
|
1066
|
+
}
|
|
1067
|
+
else if (color === 'green') {
|
|
1068
|
+
el.style.setProperty('--tint-color', '#00c853');
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
el.style.removeProperty('--tint-color');
|
|
1072
|
+
el.style.removeProperty('--mask-url');
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
export const HighlightStarsOneByOne = async (element, value) => {
|
|
1076
|
+
if (!element)
|
|
1077
|
+
return;
|
|
1078
|
+
if (!value)
|
|
1079
|
+
return;
|
|
1080
|
+
// Dynamically find the parent row of stars
|
|
1081
|
+
const stars = Array.from(element.children);
|
|
1082
|
+
console.log('starRow', stars);
|
|
1083
|
+
for (const star of stars) {
|
|
1084
|
+
// Highlight the star
|
|
1085
|
+
star.classList.add('lido-glow');
|
|
1086
|
+
// Play star sound
|
|
1087
|
+
await AudioPlayer.getI().play(star);
|
|
1088
|
+
// Fade out the star (disappear)
|
|
1089
|
+
star.style.opacity = '0';
|
|
1090
|
+
star.style.visibility = 'hidden';
|
|
1091
|
+
await new Promise(resolve => setTimeout(resolve, 300)); // Wait for fade-out to complete
|
|
1092
|
+
// Remove the highlight
|
|
1093
|
+
star.classList.remove('lido-glow');
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
export const animateBoxCells = async (element, value) => {
|
|
1097
|
+
if (!element)
|
|
1098
|
+
return;
|
|
1099
|
+
if (!value)
|
|
1100
|
+
return;
|
|
1101
|
+
// Select all cells with the attribute type="box"
|
|
1102
|
+
const boxCells = Array.from(element.children);
|
|
1103
|
+
console.log('boxCells', boxCells);
|
|
1104
|
+
if (!boxCells)
|
|
1105
|
+
return;
|
|
1106
|
+
boxCells.forEach(cell => {
|
|
1107
|
+
// Reset any previous styles
|
|
1108
|
+
cell.style.visibility = 'hidden';
|
|
1109
|
+
});
|
|
1110
|
+
// Animate each cell one by one
|
|
1111
|
+
for (const cell of boxCells) {
|
|
1112
|
+
cell.style.visibility = 'visible';
|
|
1113
|
+
cell.style.opacity = '1';
|
|
1114
|
+
// Apply the "come from top" animation
|
|
1115
|
+
cell.classList.add('lido-box-highlight');
|
|
1116
|
+
// Delay for each cell to come one after another
|
|
1117
|
+
await new Promise(resolve => setTimeout(resolve, 600)); // Adjust delay as needed
|
|
1118
|
+
cell.classList.remove('lido-box-highlight');
|
|
1119
|
+
}
|
|
1120
|
+
// After all cells have come down, apply the bounce animation
|
|
1121
|
+
for (const cell of boxCells) {
|
|
1122
|
+
// play the text child inside cell
|
|
1123
|
+
await AudioPlayer.getI().play(cell);
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
export const questionBoxAnimation = async (element, value) => {
|
|
1127
|
+
if (!element)
|
|
1128
|
+
return;
|
|
1129
|
+
if (!value)
|
|
1130
|
+
return;
|
|
1131
|
+
// Select all drag elements and drop elements
|
|
1132
|
+
const dragElements = Array.from(element.querySelectorAll("[type='drag']"));
|
|
1133
|
+
// Ensure all drag childrens which is dropped disappear
|
|
1134
|
+
dragElements.forEach(dragElement => {
|
|
1135
|
+
if (dragElement.hasAttribute('drop-to')) {
|
|
1136
|
+
dragElement.style.transition = 'opacity 0.5s ease';
|
|
1137
|
+
dragElement.style.opacity = '0'; // Fade out
|
|
1138
|
+
setTimeout(() => {
|
|
1139
|
+
dragElement.remove(); // Remove from view after fade-out
|
|
1140
|
+
}, 500);
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
// Reveal all drop childrens which is hidden
|
|
1144
|
+
const dropElements = Array.from(element.querySelectorAll("[type='drop']"));
|
|
1145
|
+
let check = false;
|
|
1146
|
+
dropElements.forEach(dropEl => {
|
|
1147
|
+
const dropVal = dropEl.getAttribute("value");
|
|
1148
|
+
if (dropVal && dropEl.innerText.trim() === "?") {
|
|
1149
|
+
dropEl.innerText = dropVal;
|
|
1150
|
+
if (dropElements.length > 1 && check == false) {
|
|
1151
|
+
if (window.innerWidth > window.innerHeight) {
|
|
1152
|
+
dropEl.style.marginRight = "-45px";
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
dropEl.style.marginRight = "-65px";
|
|
1156
|
+
}
|
|
1157
|
+
check = true;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
};
|
|
1162
|
+
export const SumTogetherAnimation = async (element, value) => {
|
|
1163
|
+
if (!element)
|
|
1164
|
+
return;
|
|
1165
|
+
if (!value)
|
|
1166
|
+
return;
|
|
1167
|
+
const container = document.getElementById(LidoContainer);
|
|
1168
|
+
if (!container)
|
|
1169
|
+
return;
|
|
1170
|
+
// Expecting structure: [_, TopRow, questionRow, optionRow, ...]
|
|
1171
|
+
const TopRow = Array.from(element.children)[1];
|
|
1172
|
+
const questionRow = Array.from(element.children)[2];
|
|
1173
|
+
const optionRow = Array.from(element.children)[3];
|
|
1174
|
+
if (!TopRow || !questionRow || !optionRow)
|
|
1175
|
+
return;
|
|
1176
|
+
const topRowChildren = Array.from(TopRow.children);
|
|
1177
|
+
const questionRowChildren = Array.from(questionRow.children);
|
|
1178
|
+
const firstNumberEl = questionRowChildren[0];
|
|
1179
|
+
const signElement = questionRowChildren[1];
|
|
1180
|
+
const secondNumberEl = questionRowChildren[2];
|
|
1181
|
+
const equalElement = questionRowChildren[3];
|
|
1182
|
+
const answerElement = questionRowChildren[4];
|
|
1183
|
+
// helper functions
|
|
1184
|
+
const showElement = (el) => {
|
|
1185
|
+
if (!el)
|
|
1186
|
+
return;
|
|
1187
|
+
el.style.visibility = 'visible';
|
|
1188
|
+
el.style.display = '';
|
|
1189
|
+
el.style.opacity = '1';
|
|
1190
|
+
};
|
|
1191
|
+
const readNumber = (el) => {
|
|
1192
|
+
if (!el)
|
|
1193
|
+
return 0;
|
|
1194
|
+
const v = (el.getAttribute && (el.getAttribute('value') || el.getAttribute('string'))) || el.textContent || '';
|
|
1195
|
+
return parseInt(String(v).trim(), 10) || 0;
|
|
1196
|
+
};
|
|
1197
|
+
const elementAppearance = async (flag) => {
|
|
1198
|
+
if (flag) {
|
|
1199
|
+
if (firstNumberEl) {
|
|
1200
|
+
await new Promise(r => setTimeout(r, 200));
|
|
1201
|
+
showElement(firstNumberEl);
|
|
1202
|
+
}
|
|
1203
|
+
if (signElement) {
|
|
1204
|
+
await new Promise(r => setTimeout(r, 200));
|
|
1205
|
+
showElement(signElement);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
if (secondNumberEl) {
|
|
1210
|
+
await new Promise(r => setTimeout(r, 200));
|
|
1211
|
+
showElement(secondNumberEl);
|
|
1212
|
+
}
|
|
1213
|
+
if (equalElement) {
|
|
1214
|
+
await new Promise(r => setTimeout(r, 300));
|
|
1215
|
+
showElement(equalElement);
|
|
1216
|
+
}
|
|
1217
|
+
if (optionRow) {
|
|
1218
|
+
await new Promise(r => setTimeout(r, 300));
|
|
1219
|
+
showElement(optionRow);
|
|
1220
|
+
}
|
|
1221
|
+
if (answerElement) {
|
|
1222
|
+
await new Promise(r => setTimeout(r, 200));
|
|
1223
|
+
showElement(answerElement);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
const number1 = readNumber(firstNumberEl);
|
|
1228
|
+
const number2 = readNumber(secondNumberEl);
|
|
1229
|
+
const sign = ((signElement && ((signElement.getAttribute('string') || signElement.textContent) || '')).toString().trim() === '+') ? '+' : '-';
|
|
1230
|
+
if (sign === '-') {
|
|
1231
|
+
// '-' flow: reveal one by one then change bgColor of last B to red
|
|
1232
|
+
for (let i = 0; i < topRowChildren.length; i++) {
|
|
1233
|
+
await new Promise(resolve => setTimeout(resolve, 75));
|
|
1234
|
+
showElement(topRowChildren[i]);
|
|
1235
|
+
}
|
|
1236
|
+
elementAppearance(true);
|
|
1237
|
+
await new Promise(r => setTimeout(r, 500));
|
|
1238
|
+
for (let k = 0; k < Math.min(number2, topRowChildren.length); k++) {
|
|
1239
|
+
const idx = topRowChildren.length - 1 - k;
|
|
1240
|
+
setImageBackground(topRowChildren[idx], 'red');
|
|
1241
|
+
await new Promise(r => setTimeout(r, 200));
|
|
1242
|
+
}
|
|
1243
|
+
elementAppearance(false);
|
|
1244
|
+
}
|
|
1245
|
+
else {
|
|
1246
|
+
// '+' flow: hide all, then showElement first A, then showElement next B in green
|
|
1247
|
+
for (let i = 0; i < Math.min(number1, topRowChildren.length); i++) {
|
|
1248
|
+
await new Promise(resolve => setTimeout(resolve, 120));
|
|
1249
|
+
showElement(topRowChildren[i]);
|
|
1250
|
+
}
|
|
1251
|
+
elementAppearance(true);
|
|
1252
|
+
await new Promise(r => setTimeout(r, 500));
|
|
1253
|
+
for (let j = 0; j < Math.min(number2, Math.max(0, topRowChildren.length - number1)); j++) {
|
|
1254
|
+
const idx = number1 + j;
|
|
1255
|
+
if (topRowChildren[idx]) {
|
|
1256
|
+
showElement(topRowChildren[idx]);
|
|
1257
|
+
setImageBackground(topRowChildren[idx], 'green');
|
|
1258
|
+
}
|
|
1259
|
+
await new Promise(r => setTimeout(r, 80));
|
|
1260
|
+
}
|
|
1261
|
+
elementAppearance(false);
|
|
1262
|
+
}
|
|
1263
|
+
};
|