lido-player 0.0.2-alpha-50 → 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.
- 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,5 +1,5 @@
|
|
|
1
1
|
const NAMESPACE = 'lido-player';
|
|
2
|
-
const BUILD = /* lido-player */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event:
|
|
2
|
+
const BUILD = /* lido-player */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: false, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
Stencil Client Platform v4.20.0 | MIT Licensed | https://stenciljs.com
|
|
@@ -258,6 +258,22 @@ var parsePropertyValue = (propValue, propType) => {
|
|
|
258
258
|
}
|
|
259
259
|
return propValue;
|
|
260
260
|
};
|
|
261
|
+
var getElement = (ref) => ref;
|
|
262
|
+
|
|
263
|
+
// src/runtime/event-emitter.ts
|
|
264
|
+
var createEvent = (ref, name, flags) => {
|
|
265
|
+
const elm = getElement(ref);
|
|
266
|
+
return {
|
|
267
|
+
emit: (detail) => {
|
|
268
|
+
return emitEvent(elm, name, {
|
|
269
|
+
bubbles: !!(flags & 4 /* Bubbles */),
|
|
270
|
+
composed: !!(flags & 2 /* Composed */),
|
|
271
|
+
cancelable: !!(flags & 1 /* Cancellable */),
|
|
272
|
+
detail
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
};
|
|
261
277
|
var emitEvent = (elm, name, opts) => {
|
|
262
278
|
const ev = plt$1.ce(name, opts);
|
|
263
279
|
elm.dispatchEvent(ev);
|
|
@@ -1324,7 +1340,6 @@ var setNonce = (nonce) => plt$1.$nonce$ = nonce;
|
|
|
1324
1340
|
// src/runtime/platform-options.ts
|
|
1325
1341
|
var setPlatformOptions = (opts) => Object.assign(plt$1, opts);
|
|
1326
1342
|
|
|
1327
|
-
const DragSelectedMapKey = 'lidoDragSelectedMap';
|
|
1328
1343
|
const DragMapKey = 'lidoDragMap';
|
|
1329
1344
|
const SelectedValuesKey = 'lidoSelectedValues';
|
|
1330
1345
|
const ActivityScoreKey = 'lidoActivityScore';
|
|
@@ -1338,7 +1353,6 @@ const GameExitKey = 'lidoGameExit';
|
|
|
1338
1353
|
const ElementDropKey = 'lidoElementDrop';
|
|
1339
1354
|
const ElementClickKey = 'lidoElementClick';
|
|
1340
1355
|
const DropLength = 'dropLength';
|
|
1341
|
-
const DropHasDrag = 'dropHasDrag';
|
|
1342
1356
|
const DropToAttr = 'drop-to';
|
|
1343
1357
|
const DropTimeAttr = 'drop-time';
|
|
1344
1358
|
const LidoContainer = 'lido-container';
|
|
@@ -1557,6 +1571,88 @@ function stopHighlightForSpeakingElement(element) {
|
|
|
1557
1571
|
// element.style.border = '';
|
|
1558
1572
|
}
|
|
1559
1573
|
|
|
1574
|
+
function updateBalanceOnDrop(dragElement, dropElement) {
|
|
1575
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
1576
|
+
if (!balanceEl)
|
|
1577
|
+
return;
|
|
1578
|
+
const leftDrag = Array.from(document.querySelectorAll('[drop-to^="lefthandle"]'));
|
|
1579
|
+
const rightDrag = Array.from(document.querySelectorAll('[drop-to^="righthandle"]'));
|
|
1580
|
+
balanceEl.leftVal = calculateValue(leftDrag, balanceEl.operation);
|
|
1581
|
+
balanceEl.rightVal = calculateValue(rightDrag, balanceEl.operation);
|
|
1582
|
+
console.log("leftpan:", balanceEl.leftVal, "rightpan:", balanceEl.rightVal);
|
|
1583
|
+
if (balanceEl.updateTilt) {
|
|
1584
|
+
balanceEl.updateTilt(balanceEl.leftVal, balanceEl.rightVal);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
function calculateValue(elements, operation) {
|
|
1588
|
+
if (elements.length === 0)
|
|
1589
|
+
return 0;
|
|
1590
|
+
if (operation === "count") {
|
|
1591
|
+
return elements.length;
|
|
1592
|
+
}
|
|
1593
|
+
const ADD = ["add", "+"];
|
|
1594
|
+
const SUBTRACT = ["subtract", "-"];
|
|
1595
|
+
const MULTIPLY = ["multiply", "*"];
|
|
1596
|
+
const DIVIDE = ["divide", "/"];
|
|
1597
|
+
const expr = elements
|
|
1598
|
+
.map(el => el.getAttribute("value") || "0")
|
|
1599
|
+
.join(ADD.includes(operation) ? " + " :
|
|
1600
|
+
SUBTRACT.includes(operation) ? " - " :
|
|
1601
|
+
MULTIPLY.includes(operation) ? " * " :
|
|
1602
|
+
DIVIDE.includes(operation) ? " / " : " + ");
|
|
1603
|
+
try {
|
|
1604
|
+
const res = equationCheck(expr);
|
|
1605
|
+
if (typeof res === "number") {
|
|
1606
|
+
return res;
|
|
1607
|
+
}
|
|
1608
|
+
else if (typeof res === "boolean") {
|
|
1609
|
+
return res ? 1 : 0;
|
|
1610
|
+
}
|
|
1611
|
+
else {
|
|
1612
|
+
return parseFloat(expr) || 0;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
catch (e) {
|
|
1616
|
+
console.warn("invalid exp", expr);
|
|
1617
|
+
return 0;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function balanceResult(container, objectiveString) {
|
|
1621
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1622
|
+
const additionalCheck = container.getAttribute('equationCheck');
|
|
1623
|
+
if (!additionalCheck)
|
|
1624
|
+
return false;
|
|
1625
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
1626
|
+
if (!balanceEl)
|
|
1627
|
+
return false;
|
|
1628
|
+
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);
|
|
1629
|
+
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);
|
|
1630
|
+
const hasLeft = !isNaN(leftVal) && leftVal !== 0;
|
|
1631
|
+
const hasRight = !isNaN(rightVal) && rightVal !== 0;
|
|
1632
|
+
if (!hasLeft || !hasRight) {
|
|
1633
|
+
return false;
|
|
1634
|
+
}
|
|
1635
|
+
const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
|
|
1636
|
+
const res = objectiveString === symbol;
|
|
1637
|
+
console.log("Result:", res);
|
|
1638
|
+
return res;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
function buildDropHasDragFromDOM() {
|
|
1642
|
+
const dropHasDrag = {};
|
|
1643
|
+
const dropElements = document.querySelectorAll("[type='drop']");
|
|
1644
|
+
dropElements.forEach(drop => {
|
|
1645
|
+
const tabIndex = drop.getAttribute("tab-index") || drop.id;
|
|
1646
|
+
const assignedDrag = document.querySelector(`[${DropToAttr}="${drop.id}"]`);
|
|
1647
|
+
const isFull = !!assignedDrag;
|
|
1648
|
+
drop.setAttribute("is-full", String(isFull));
|
|
1649
|
+
dropHasDrag[tabIndex] = {
|
|
1650
|
+
drop: drop.id,
|
|
1651
|
+
isFull
|
|
1652
|
+
};
|
|
1653
|
+
});
|
|
1654
|
+
return dropHasDrag;
|
|
1655
|
+
}
|
|
1560
1656
|
// Function to get the scale of an element
|
|
1561
1657
|
const getElementScale$1 = (el) => {
|
|
1562
1658
|
el.style.animation = 'unset';
|
|
@@ -1607,7 +1703,7 @@ function enableDraggingWithScaling(element) {
|
|
|
1607
1703
|
isDragging = false;
|
|
1608
1704
|
return;
|
|
1609
1705
|
}
|
|
1610
|
-
AudioPlayer.getI().stop();
|
|
1706
|
+
// AudioPlayer.getI().stop();
|
|
1611
1707
|
removeHighlight(element);
|
|
1612
1708
|
isDragging = true;
|
|
1613
1709
|
isClicked = true;
|
|
@@ -1711,7 +1807,6 @@ function enableDraggingWithScaling(element) {
|
|
|
1711
1807
|
// Start observing the element
|
|
1712
1808
|
observer.observe(container, observerConfig);
|
|
1713
1809
|
const onMove = (event) => {
|
|
1714
|
-
console.log("moved");
|
|
1715
1810
|
if (!isDragging)
|
|
1716
1811
|
return;
|
|
1717
1812
|
if (isDraggingDisabled) {
|
|
@@ -1720,7 +1815,7 @@ function enableDraggingWithScaling(element) {
|
|
|
1720
1815
|
}
|
|
1721
1816
|
isClicked = false;
|
|
1722
1817
|
element.style.transition = 'none';
|
|
1723
|
-
const containerScale =
|
|
1818
|
+
const containerScale = getElementScale$1(container);
|
|
1724
1819
|
let dx = 0;
|
|
1725
1820
|
let dy = 0;
|
|
1726
1821
|
if (event instanceof MouseEvent) {
|
|
@@ -1742,7 +1837,7 @@ function enableDraggingWithScaling(element) {
|
|
|
1742
1837
|
// Reset styles for all elements
|
|
1743
1838
|
allElements.forEach(otherElement => {
|
|
1744
1839
|
var _a;
|
|
1745
|
-
const dropObject =
|
|
1840
|
+
const dropObject = buildDragSelectedMapFromDOM();
|
|
1746
1841
|
const storedTabIndexes = Object.keys(dropObject).map(Number);
|
|
1747
1842
|
if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
|
|
1748
1843
|
if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
|
|
@@ -1800,7 +1895,7 @@ function enableDraggingWithScaling(element) {
|
|
|
1800
1895
|
allElements.forEach(otherElement => {
|
|
1801
1896
|
allElements.forEach(otherElement => {
|
|
1802
1897
|
var _a;
|
|
1803
|
-
const dropObject =
|
|
1898
|
+
const dropObject = buildDragSelectedMapFromDOM();
|
|
1804
1899
|
const storedTabIndexes = Object.keys(dropObject).map(Number);
|
|
1805
1900
|
if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
|
|
1806
1901
|
if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
|
|
@@ -1964,14 +2059,18 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
|
|
|
1964
2059
|
let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
|
|
1965
2060
|
if (prevDropItem) {
|
|
1966
2061
|
prevDropItem.isFull = false;
|
|
1967
|
-
|
|
2062
|
+
// container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
|
|
2063
|
+
const dropEl = document.getElementById(prevDropItem.drop);
|
|
2064
|
+
if (dropEl) {
|
|
2065
|
+
dropEl.removeAttribute('is-full');
|
|
2066
|
+
}
|
|
1968
2067
|
}
|
|
1969
2068
|
dragToDropMap.delete(dragElement);
|
|
1970
2069
|
}
|
|
1971
2070
|
if (selectedValueData) {
|
|
1972
2071
|
let selectedValue = JSON.parse(selectedValueData);
|
|
1973
2072
|
selectedValue = selectedValue.filter(value => value != dragElement['value']);
|
|
1974
|
-
|
|
2073
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValue));
|
|
1975
2074
|
}
|
|
1976
2075
|
if (dragSelectedData) {
|
|
1977
2076
|
let dragSelected = JSON.parse(dragSelectedData);
|
|
@@ -1979,14 +2078,15 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
|
|
|
1979
2078
|
if (dragPreDropElement) {
|
|
1980
2079
|
delete dragSelected[dragPreDropElement.getAttribute('tab-index')];
|
|
1981
2080
|
}
|
|
1982
|
-
|
|
2081
|
+
// container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
|
|
1983
2082
|
dragElement.removeAttribute(DropToAttr);
|
|
1984
2083
|
updateDropBorder(currentDrop);
|
|
2084
|
+
updateBalanceOnDrop();
|
|
1985
2085
|
}
|
|
1986
2086
|
const allElements = document.querySelectorAll("[type='drop']");
|
|
1987
2087
|
allElements.forEach(otherElement => {
|
|
1988
2088
|
var _a;
|
|
1989
|
-
const dropObject =
|
|
2089
|
+
const dropObject = buildDragSelectedMapFromDOM();
|
|
1990
2090
|
const storedTabIndexes = Object.keys(dropObject).map(Number);
|
|
1991
2091
|
if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
|
|
1992
2092
|
if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
|
|
@@ -2011,20 +2111,22 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
|
|
|
2011
2111
|
});
|
|
2012
2112
|
handleShowCheck();
|
|
2013
2113
|
}
|
|
2114
|
+
const tempVanishedValues = [];
|
|
2014
2115
|
async function onElementDropComplete(dragElement, dropElement) {
|
|
2015
|
-
var _a, _b, _c, _d, _e;
|
|
2016
|
-
const selectedValueData = localStorage.getItem(SelectedValuesKey) || '';
|
|
2017
|
-
const dragSelectedData = localStorage.getItem(DragSelectedMapKey);
|
|
2018
|
-
localStorage.getItem(DragMapKey);
|
|
2019
|
-
console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
|
|
2020
|
-
let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
|
|
2116
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2021
2117
|
const container = document.getElementById(LidoContainer);
|
|
2118
|
+
const selectedValueData = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : "[]";
|
|
2119
|
+
const dragSelectedData = JSON.stringify(buildDragSelectedMapFromDOM());
|
|
2120
|
+
const dropSelectedDataobject = buildDragSelectedMapFromDOM();
|
|
2121
|
+
JSON.stringify(dropSelectedDataobject);
|
|
2122
|
+
console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
|
|
2123
|
+
let dropHasDrag = buildDropHasDragFromDOM();
|
|
2022
2124
|
if (!dropElement) {
|
|
2023
2125
|
handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
|
|
2024
2126
|
return;
|
|
2025
2127
|
}
|
|
2026
2128
|
const dropTabIndex = dropElement.getAttribute('tab-index');
|
|
2027
|
-
if ((
|
|
2129
|
+
if ((_b = dropHasDrag[dropTabIndex]) === null || _b === void 0 ? void 0 : _b.isFull) {
|
|
2028
2130
|
handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
|
|
2029
2131
|
return;
|
|
2030
2132
|
}
|
|
@@ -2036,9 +2138,10 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2036
2138
|
handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
|
|
2037
2139
|
return;
|
|
2038
2140
|
}
|
|
2141
|
+
// let isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
|
|
2039
2142
|
let isCorrect;
|
|
2040
|
-
const dragValue = ((
|
|
2041
|
-
const dropValue = ((
|
|
2143
|
+
const dragValue = ((_c = dragElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
|
|
2144
|
+
const dropValue = ((_d = dropElement.getAttribute('value')) === null || _d === void 0 ? void 0 : _d.trim()) || "";
|
|
2042
2145
|
if (Number(dragValue)) {
|
|
2043
2146
|
const dragNum = Number(dragValue);
|
|
2044
2147
|
//array of numbers
|
|
@@ -2052,8 +2155,7 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2052
2155
|
}
|
|
2053
2156
|
}
|
|
2054
2157
|
else {
|
|
2055
|
-
|
|
2056
|
-
isCorrect = dropValue.toLowerCase().includes(dragValue.toLowerCase());
|
|
2158
|
+
isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
|
|
2057
2159
|
}
|
|
2058
2160
|
if (!isCorrect) {
|
|
2059
2161
|
dragElement.style.transition = 'transform 0.5s ease';
|
|
@@ -2068,7 +2170,7 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2068
2170
|
// delete stored[oldDropIndex];
|
|
2069
2171
|
// localStorage.setItem(localStorageKey, JSON.stringify(stored));
|
|
2070
2172
|
// }
|
|
2071
|
-
|
|
2173
|
+
handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
|
|
2072
2174
|
}, 500);
|
|
2073
2175
|
if (dragElement['type'] === 'option') {
|
|
2074
2176
|
const childs = Array.from(container.querySelectorAll(`[value="${dragElement['value']}"]`));
|
|
@@ -2087,6 +2189,7 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2087
2189
|
if (checkdropAttr && checkdropAttr.toLowerCase() === DropMode.EnableAnimation.toLowerCase()) {
|
|
2088
2190
|
container.style.pointerEvents = "none";
|
|
2089
2191
|
setTimeout(() => {
|
|
2192
|
+
var _a, _b, _c;
|
|
2090
2193
|
const div = document.createElement('div');
|
|
2091
2194
|
container.append(div);
|
|
2092
2195
|
div.classList.add('after-drop-popup-container');
|
|
@@ -2095,6 +2198,11 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2095
2198
|
const allDragElements = container.querySelectorAll('[type="drag"]');
|
|
2096
2199
|
const dragParents = Array.from(allDragElements).map(el => el.parentElement);
|
|
2097
2200
|
const allSameParent = dragParents.every(parent => parent === dragElement.parentElement);
|
|
2201
|
+
JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
|
|
2202
|
+
const vanishedValue = (_b = dragElement.getAttribute('value')) !== null && _b !== void 0 ? _b : (_c = dragElement.textContent) === null || _c === void 0 ? void 0 : _c.trim();
|
|
2203
|
+
if (vanishedValue) {
|
|
2204
|
+
tempVanishedValues.push(vanishedValue);
|
|
2205
|
+
}
|
|
2098
2206
|
// Remove from old parents
|
|
2099
2207
|
if (allSameParent) {
|
|
2100
2208
|
dragElement.remove();
|
|
@@ -2118,6 +2226,16 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2118
2226
|
setTimeout(() => {
|
|
2119
2227
|
div.remove();
|
|
2120
2228
|
container.style.pointerEvents = 'auto';
|
|
2229
|
+
const objective = container.getAttribute('objective');
|
|
2230
|
+
if (objective && tempVanishedValues.map(v => v.trim()).sort().join(',') === objective.split(',').map(v => v.trim()).sort().join(',')) {
|
|
2231
|
+
(async () => {
|
|
2232
|
+
isCorrect = true;
|
|
2233
|
+
const onCorrect = (container === null || container === void 0 ? void 0 : container.getAttribute('onCorrect')) || '';
|
|
2234
|
+
await executeActions(onCorrect, container);
|
|
2235
|
+
window.dispatchEvent(new CustomEvent(NextContainerKey));
|
|
2236
|
+
tempVanishedValues.length = 0;
|
|
2237
|
+
})();
|
|
2238
|
+
}
|
|
2121
2239
|
}, 800); // match animation duration
|
|
2122
2240
|
}, 2000); // stay for 2 seconds
|
|
2123
2241
|
}, 250);
|
|
@@ -2125,6 +2243,12 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2125
2243
|
}
|
|
2126
2244
|
}
|
|
2127
2245
|
if (dropElement) {
|
|
2246
|
+
let selectedValues = JSON.parse((_e = container.getAttribute(SelectedValuesKey)) !== null && _e !== void 0 ? _e : "[]");
|
|
2247
|
+
const dragValue = dragElement.getAttribute('value');
|
|
2248
|
+
if (dragValue && !selectedValues.includes(dragValue)) {
|
|
2249
|
+
selectedValues.push(dragValue);
|
|
2250
|
+
}
|
|
2251
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValues));
|
|
2128
2252
|
if (dropElement.getAttribute('drop-attr') === 'stretch') {
|
|
2129
2253
|
if (!dropElement.hasAttribute('data-original-width')) {
|
|
2130
2254
|
const computedStyle = window.getComputedStyle(dropElement);
|
|
@@ -2133,15 +2257,16 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2133
2257
|
const dragWidth = dragElement.offsetWidth;
|
|
2134
2258
|
dropElement.style.width = `${dragWidth}px`;
|
|
2135
2259
|
}
|
|
2136
|
-
if (!(((
|
|
2260
|
+
if (!(((_f = dropElement.getAttribute('dropAttr')) === null || _f === void 0 ? void 0 : _f.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
|
|
2137
2261
|
const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
|
|
2138
2262
|
if (isisFull) {
|
|
2139
2263
|
isisFull.isFull = true;
|
|
2264
|
+
dropElement.setAttribute('is-full', 'true');
|
|
2140
2265
|
}
|
|
2141
2266
|
else {
|
|
2142
2267
|
console.warn('No matching drop item found for', dropElement);
|
|
2143
2268
|
}
|
|
2144
|
-
|
|
2269
|
+
// container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
|
|
2145
2270
|
if (dragSelectedData) {
|
|
2146
2271
|
let dragSelected = JSON.parse(dragSelectedData);
|
|
2147
2272
|
for (const key in dragSelected) {
|
|
@@ -2154,7 +2279,7 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2154
2279
|
}
|
|
2155
2280
|
}
|
|
2156
2281
|
}
|
|
2157
|
-
|
|
2282
|
+
// container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
|
|
2158
2283
|
}
|
|
2159
2284
|
dragElement.classList.add('dropped');
|
|
2160
2285
|
if (dragElement) {
|
|
@@ -2167,7 +2292,7 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2167
2292
|
dragElement.setAttribute(DropTimeAttr, new Date().getTime().toString());
|
|
2168
2293
|
}
|
|
2169
2294
|
// Check for overlaps and highlight only the most overlapping element
|
|
2170
|
-
if (dropElement && !((
|
|
2295
|
+
if (dropElement && !((_g = dropHasDrag[dropTabIndex]) === null || _g === void 0 ? void 0 : _g.isFull)) {
|
|
2171
2296
|
let mostOverlappedElement = findMostoverlappedElement$1(dragElement, 'drag');
|
|
2172
2297
|
const isAllowOnlyOneDrop = dropElement.getAttribute('is-allow-only-one-drop') === 'true' || '';
|
|
2173
2298
|
if (mostOverlappedElement && isAllowOnlyOneDrop) {
|
|
@@ -2176,7 +2301,7 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2176
2301
|
const allElements = document.querySelectorAll("[type='drop']");
|
|
2177
2302
|
allElements.forEach(otherElement => {
|
|
2178
2303
|
var _a;
|
|
2179
|
-
const dropObject =
|
|
2304
|
+
const dropObject = buildDragSelectedMapFromDOM();
|
|
2180
2305
|
const storedTabIndexes = Object.keys(dropObject).map(Number);
|
|
2181
2306
|
if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
|
|
2182
2307
|
if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
|
|
@@ -2208,13 +2333,14 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2208
2333
|
handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
|
|
2209
2334
|
return;
|
|
2210
2335
|
}
|
|
2336
|
+
updateBalanceOnDrop();
|
|
2211
2337
|
if (dragSelectedData) {
|
|
2212
2338
|
let currentDrop = dragToDropMap.get(dragElement);
|
|
2213
2339
|
if (currentDrop) {
|
|
2214
2340
|
let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
|
|
2215
2341
|
if (prevDropItem) {
|
|
2216
2342
|
prevDropItem.isFull = false;
|
|
2217
|
-
|
|
2343
|
+
// container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
|
|
2218
2344
|
reduceSizeToOriginal();
|
|
2219
2345
|
}
|
|
2220
2346
|
}
|
|
@@ -2227,9 +2353,9 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2227
2353
|
// }
|
|
2228
2354
|
// localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
|
|
2229
2355
|
}
|
|
2230
|
-
let dropLength =
|
|
2356
|
+
let dropLength = parseInt((_h = container.getAttribute(DropLength)) !== null && _h !== void 0 ? _h : '0');
|
|
2231
2357
|
dropLength += 1;
|
|
2232
|
-
|
|
2358
|
+
container.setAttribute(DropLength, String(dropLength));
|
|
2233
2359
|
if (dropLength === countPatternWords(dropElement['value'])) {
|
|
2234
2360
|
const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
|
|
2235
2361
|
if (isisFull) {
|
|
@@ -2238,9 +2364,10 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2238
2364
|
else {
|
|
2239
2365
|
console.warn('No matching drop item found for', dropElement);
|
|
2240
2366
|
}
|
|
2241
|
-
|
|
2367
|
+
// memoryStorage[DropHasDrag] = dropHasDrag;
|
|
2368
|
+
// container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
|
|
2242
2369
|
dropLength = 0;
|
|
2243
|
-
|
|
2370
|
+
container.setAttribute(DropLength, String(dropLength));
|
|
2244
2371
|
}
|
|
2245
2372
|
dragToDropMap.set(dragElement, dropElement);
|
|
2246
2373
|
// Add pulse and highlight effect for a successful match
|
|
@@ -2248,9 +2375,9 @@ async function onElementDropComplete(dragElement, dropElement) {
|
|
|
2248
2375
|
dispatchElementDropEvent(dragElement, dropElement, isCorrect);
|
|
2249
2376
|
storingEachActivityScore(isCorrect);
|
|
2250
2377
|
dragElement.style.opacity = '1';
|
|
2378
|
+
await onActivityComplete(dragElement, dropElement);
|
|
2251
2379
|
const allDropElements = document.querySelectorAll('.drop-element');
|
|
2252
2380
|
allDropElements.forEach(el => updateDropBorder(el));
|
|
2253
|
-
await onActivityComplete(dragElement, dropElement);
|
|
2254
2381
|
}
|
|
2255
2382
|
function updateDropBorder(element) {
|
|
2256
2383
|
if (!element || !element.classList.contains('drop-element'))
|
|
@@ -2269,7 +2396,9 @@ function updateDropBorder(element) {
|
|
|
2269
2396
|
element.classList.remove('empty');
|
|
2270
2397
|
}
|
|
2271
2398
|
else {
|
|
2272
|
-
element.classList.
|
|
2399
|
+
if (!element.classList.contains('math-matrix')) {
|
|
2400
|
+
element.classList.add('empty');
|
|
2401
|
+
}
|
|
2273
2402
|
element.classList.remove('filled');
|
|
2274
2403
|
}
|
|
2275
2404
|
}
|
|
@@ -2277,15 +2406,12 @@ function handleDropElement(element) {
|
|
|
2277
2406
|
// let nextIndex = Object.keys(dropHas).length; // Get next index
|
|
2278
2407
|
// dropHas[nextIndex] = { drop: element, isFull: false };
|
|
2279
2408
|
element.classList.add('drop-element');
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
if (
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
dropHas[tabIndex] = { drop: element.id, isFull: false };
|
|
2287
|
-
localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
|
|
2288
|
-
}
|
|
2409
|
+
buildDragSelectedMapFromDOM();
|
|
2410
|
+
element.getAttribute('tab-index');
|
|
2411
|
+
// if (!dropHas[tabIndex]) {
|
|
2412
|
+
// dropHas[tabIndex] = { drop: element.id, isFull: false };
|
|
2413
|
+
// // localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
|
|
2414
|
+
// }
|
|
2289
2415
|
element.onclick = () => {
|
|
2290
2416
|
onClickDropOrDragElement(element, 'drop');
|
|
2291
2417
|
};
|
|
@@ -2352,7 +2478,7 @@ async function onClickDropOrDragElement(element, type) {
|
|
|
2352
2478
|
const dragToDropMap = new Map();
|
|
2353
2479
|
async function onClickDragElement(element) {
|
|
2354
2480
|
AudioPlayer.getI().stop();
|
|
2355
|
-
const dropElements =
|
|
2481
|
+
const dropElements = buildDropHasDragFromDOM();
|
|
2356
2482
|
const dragEl = element;
|
|
2357
2483
|
if (!dragEl) {
|
|
2358
2484
|
console.error('Element not found');
|
|
@@ -2398,9 +2524,12 @@ const appendingDragElementsInDrop = () => {
|
|
|
2398
2524
|
});
|
|
2399
2525
|
});
|
|
2400
2526
|
};
|
|
2527
|
+
const container = document.getElementById(LidoContainer);
|
|
2401
2528
|
const reduceSizeToOriginal = () => {
|
|
2402
2529
|
const dropItems = document.querySelectorAll("[type='drop']");
|
|
2403
|
-
let dropHasDrag =
|
|
2530
|
+
let dropHasDrag = buildDragSelectedMapFromDOM();
|
|
2531
|
+
if (!dropItems || !container)
|
|
2532
|
+
return;
|
|
2404
2533
|
if (!dropHasDrag || !dropItems)
|
|
2405
2534
|
return;
|
|
2406
2535
|
dropItems.forEach(dropElement => {
|
|
@@ -2409,6 +2538,7 @@ const reduceSizeToOriginal = () => {
|
|
|
2409
2538
|
const tabIndex = drop.getAttribute('tab-index');
|
|
2410
2539
|
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) {
|
|
2411
2540
|
const originalWidth = drop.getAttribute('data-original-width');
|
|
2541
|
+
dropElement.removeAttribute('is-full');
|
|
2412
2542
|
if (originalWidth) {
|
|
2413
2543
|
drop.style.width = originalWidth;
|
|
2414
2544
|
drop.removeAttribute('data-original-width');
|
|
@@ -2599,7 +2729,7 @@ function enableReorderDrag(element) {
|
|
|
2599
2729
|
isClicked = false;
|
|
2600
2730
|
event.preventDefault();
|
|
2601
2731
|
const containerRect = container.getBoundingClientRect();
|
|
2602
|
-
const containerScale =
|
|
2732
|
+
const containerScale = getElementScale(container);
|
|
2603
2733
|
const newLeft = (point.clientX - containerRect.left - offsetXInElement) / containerScale;
|
|
2604
2734
|
const newTop = (point.clientY - containerRect.top - offsetYInElement) / containerScale;
|
|
2605
2735
|
element.style.left = `${newLeft}px`;
|
|
@@ -2666,16 +2796,18 @@ function enableReorderDrag(element) {
|
|
|
2666
2796
|
else {
|
|
2667
2797
|
if (element.parentElement['type'] !== 'category') {
|
|
2668
2798
|
executeActions('this.alignMatch=true', divEl, element);
|
|
2669
|
-
|
|
2799
|
+
setTimeout(() => {
|
|
2800
|
+
divEl.replaceWith(element);
|
|
2801
|
+
}, 500);
|
|
2670
2802
|
}
|
|
2671
2803
|
else {
|
|
2672
2804
|
const categoryElement = element.parentElement;
|
|
2673
|
-
const dragValues =
|
|
2805
|
+
const dragValues = buildDragSelectedMapFromDOM();
|
|
2674
2806
|
const tabKey = categoryElement.getAttribute('tab-index');
|
|
2675
2807
|
const targetValue = element['value'];
|
|
2676
2808
|
if (dragValues[tabKey]) {
|
|
2677
2809
|
dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
|
|
2678
|
-
localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
|
|
2810
|
+
// localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
|
|
2679
2811
|
}
|
|
2680
2812
|
optionArea.scrollTo({
|
|
2681
2813
|
top: optionArea.scrollHeight,
|
|
@@ -2683,6 +2815,7 @@ function enableReorderDrag(element) {
|
|
|
2683
2815
|
});
|
|
2684
2816
|
optionArea.appendChild(element);
|
|
2685
2817
|
element.classList.remove('dropped');
|
|
2818
|
+
element.removeAttribute('drop-to');
|
|
2686
2819
|
if (dummy) {
|
|
2687
2820
|
dummy.remove();
|
|
2688
2821
|
}
|
|
@@ -2721,12 +2854,12 @@ function enableReorderDrag(element) {
|
|
|
2721
2854
|
category = categoryArr[0];
|
|
2722
2855
|
}
|
|
2723
2856
|
if (element.parentElement.getAttribute('type') === 'category') {
|
|
2724
|
-
const dragValues =
|
|
2857
|
+
const dragValues = buildDragSelectedMapFromDOM();
|
|
2725
2858
|
const tabKey = category.getAttribute('tab-index');
|
|
2726
2859
|
const targetValue = element['value'];
|
|
2727
2860
|
if (dragValues[tabKey]) {
|
|
2728
2861
|
dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
|
|
2729
|
-
localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
|
|
2862
|
+
// localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
|
|
2730
2863
|
}
|
|
2731
2864
|
const dummy = createDummyElement(element);
|
|
2732
2865
|
optionArea.appendChild(dummy);
|
|
@@ -2740,6 +2873,7 @@ function enableReorderDrag(element) {
|
|
|
2740
2873
|
resetElementStyles(element);
|
|
2741
2874
|
dummy.replaceWith(element);
|
|
2742
2875
|
element.classList.remove('dropped');
|
|
2876
|
+
element.removeAttribute('drop-to');
|
|
2743
2877
|
}, 100);
|
|
2744
2878
|
return;
|
|
2745
2879
|
}
|
|
@@ -2888,13 +3022,15 @@ function moveWithAnimation(target, overlapped) {
|
|
|
2888
3022
|
}
|
|
2889
3023
|
// Drop Completed
|
|
2890
3024
|
const wordDropComplete = (block, element) => {
|
|
3025
|
+
var _a;
|
|
3026
|
+
console.log("worddrop");
|
|
2891
3027
|
const container = document.getElementById(LidoContainer);
|
|
2892
3028
|
const objective = container.getAttribute('objective');
|
|
2893
3029
|
const objectiveArray = objective.split(',');
|
|
2894
|
-
let wordArray = JSON.parse(
|
|
3030
|
+
let wordArray = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
|
|
2895
3031
|
const wordBlock = block.children;
|
|
2896
3032
|
wordArray = Array.from(wordBlock).map(child => child.getAttribute('value'));
|
|
2897
|
-
|
|
3033
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(wordArray));
|
|
2898
3034
|
const elementIndex = wordArray.indexOf(element['value']);
|
|
2899
3035
|
if (elementIndex >= 0) {
|
|
2900
3036
|
const res = matchStringPattern(element['value'], [objectiveArray[elementIndex].trim()]);
|
|
@@ -2909,7 +3045,7 @@ const wordDropComplete = (block, element) => {
|
|
|
2909
3045
|
};
|
|
2910
3046
|
async function onDropToCategory(dragElement, categoryElement) {
|
|
2911
3047
|
dragElement.classList.add('dropped');
|
|
2912
|
-
let dragSelected =
|
|
3048
|
+
let dragSelected = buildDragSelectedMapFromDOM();
|
|
2913
3049
|
let elementArr = dragSelected[categoryElement.getAttribute('tab-index')];
|
|
2914
3050
|
if (Array.isArray(elementArr)) {
|
|
2915
3051
|
if (elementArr.includes(dragElement['value']))
|
|
@@ -2921,7 +3057,10 @@ async function onDropToCategory(dragElement, categoryElement) {
|
|
|
2921
3057
|
dragSelected[key].splice(index, 1);
|
|
2922
3058
|
}
|
|
2923
3059
|
}
|
|
2924
|
-
|
|
3060
|
+
if (categoryElement === null || categoryElement === void 0 ? void 0 : categoryElement.id) {
|
|
3061
|
+
dragElement.setAttribute(DropToAttr, categoryElement.id);
|
|
3062
|
+
}
|
|
3063
|
+
// localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
|
|
2925
3064
|
await onActivityComplete(dragElement, categoryElement);
|
|
2926
3065
|
}
|
|
2927
3066
|
|
|
@@ -3140,13 +3279,15 @@ function slidingWithScaling(element) {
|
|
|
3140
3279
|
});
|
|
3141
3280
|
}
|
|
3142
3281
|
const slideCompleted = (slideElement) => {
|
|
3143
|
-
|
|
3282
|
+
var _a;
|
|
3283
|
+
const container = document.getElementById(LidoContainer);
|
|
3284
|
+
const slideArr = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
|
|
3144
3285
|
const allSlideElements = document.querySelectorAll("[type='slide']");
|
|
3145
3286
|
let index = 0;
|
|
3146
3287
|
allSlideElements.forEach(item => {
|
|
3147
3288
|
slideArr[index++] = item['value'];
|
|
3148
3289
|
});
|
|
3149
|
-
|
|
3290
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(slideArr));
|
|
3150
3291
|
const objectiveString = document.getElementById(LidoContainer)['objective'];
|
|
3151
3292
|
const objectiveArray = objectiveString.split(',');
|
|
3152
3293
|
const elementIndex = slideArr.indexOf(slideElement['value']);
|
|
@@ -4408,6 +4549,7 @@ function addClickListenerForClickType(element) {
|
|
|
4408
4549
|
return;
|
|
4409
4550
|
}
|
|
4410
4551
|
const onClick = async () => {
|
|
4552
|
+
var _a;
|
|
4411
4553
|
const lido_buttons = element.getAttribute('id');
|
|
4412
4554
|
if (lido_buttons === 'lido-arrow-left' || lido_buttons === 'lido-arrow-right') {
|
|
4413
4555
|
return;
|
|
@@ -4424,25 +4566,15 @@ function addClickListenerForClickType(element) {
|
|
|
4424
4566
|
}
|
|
4425
4567
|
if (container['objective'].length === 0)
|
|
4426
4568
|
return;
|
|
4427
|
-
// element.style.border = '2px solid yellow';
|
|
4428
|
-
// element.style.boxShadow = '0px 0px 10px rgba(255, 255, 0, 0.7)';
|
|
4429
|
-
// element.style.transition = 'transform 0.2s ease, border 0.5s ease';
|
|
4430
|
-
// element.style.transform = 'scale(1.1)';
|
|
4431
|
-
// element.style.transform = 'scale(1)';
|
|
4432
|
-
// element.style.border = '';
|
|
4433
|
-
// element.style.boxShadow = '';
|
|
4434
4569
|
const isActivated = element.classList.contains('lido-element-selected');
|
|
4435
|
-
let selectedValue = JSON.parse(
|
|
4570
|
+
let selectedValue = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
|
|
4436
4571
|
if (objective.length === 1) {
|
|
4437
|
-
|
|
4572
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
|
|
4438
4573
|
const isCorrect = objective.includes(element['value']);
|
|
4439
4574
|
dispatchClickEvent(element, isCorrect);
|
|
4440
4575
|
if (isCorrect) {
|
|
4441
4576
|
const onCorrect = element.getAttribute('onCorrect');
|
|
4442
|
-
|
|
4443
|
-
element.style.pointerEvents = 'none';
|
|
4444
|
-
}
|
|
4445
|
-
document.body.style.pointerEvents = 'none';
|
|
4577
|
+
// element.style.pointerEvents = 'none';
|
|
4446
4578
|
await executeActions(onCorrect, element);
|
|
4447
4579
|
}
|
|
4448
4580
|
else {
|
|
@@ -4450,7 +4582,11 @@ function addClickListenerForClickType(element) {
|
|
|
4450
4582
|
await executeActions(onInCorrect, element);
|
|
4451
4583
|
// showWrongAnswerAnimation([element]);
|
|
4452
4584
|
}
|
|
4453
|
-
|
|
4585
|
+
// const calciEl=document.querySelector('#lidoCalculator') as any;
|
|
4586
|
+
const isInsideCalculator = element.closest('#lidoCalculator') !== null;
|
|
4587
|
+
if (!isInsideCalculator) {
|
|
4588
|
+
storingEachActivityScore(isCorrect);
|
|
4589
|
+
}
|
|
4454
4590
|
handleShowCheck();
|
|
4455
4591
|
return;
|
|
4456
4592
|
}
|
|
@@ -4461,8 +4597,8 @@ function addClickListenerForClickType(element) {
|
|
|
4461
4597
|
element.classList.remove('lido-element-selected');
|
|
4462
4598
|
executeActions(element.getAttribute('onEntry'), element);
|
|
4463
4599
|
selectedValue = selectedValue.filter(item => item != element['value']);
|
|
4464
|
-
|
|
4465
|
-
let multiOptionScore =
|
|
4600
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
|
|
4601
|
+
let multiOptionScore = buildDragSelectedMapFromDOM();
|
|
4466
4602
|
const valueToRemove = element['value'];
|
|
4467
4603
|
const keyToRemove = Object.keys(multiOptionScore).find(key => multiOptionScore[key].includes(valueToRemove));
|
|
4468
4604
|
if (keyToRemove) {
|
|
@@ -4470,10 +4606,9 @@ function addClickListenerForClickType(element) {
|
|
|
4470
4606
|
if (multiOptionScore[keyToRemove].length === 0) {
|
|
4471
4607
|
delete multiOptionScore[keyToRemove];
|
|
4472
4608
|
}
|
|
4473
|
-
localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
|
|
4474
4609
|
const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
|
|
4475
4610
|
const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
|
|
4476
|
-
|
|
4611
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
|
|
4477
4612
|
}
|
|
4478
4613
|
if (showCheck && selectedValue.length === 0) {
|
|
4479
4614
|
checkButton.classList.add('lido-disable-check-button');
|
|
@@ -4484,20 +4619,18 @@ function addClickListenerForClickType(element) {
|
|
|
4484
4619
|
element.classList.add('lido-element-selected');
|
|
4485
4620
|
const valueToFind = element['value'];
|
|
4486
4621
|
const key = Object.keys(objective).find(key => objective[key] === valueToFind);
|
|
4487
|
-
let multiOptionScore =
|
|
4622
|
+
let multiOptionScore = buildDragSelectedMapFromDOM();
|
|
4488
4623
|
if (!key) {
|
|
4489
4624
|
multiOptionScore[objective.length + selectedValue.length] = [valueToFind];
|
|
4490
4625
|
}
|
|
4491
4626
|
else {
|
|
4492
4627
|
multiOptionScore[key] = [valueToFind];
|
|
4493
4628
|
}
|
|
4494
|
-
localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
|
|
4495
4629
|
const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
|
|
4496
4630
|
const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
|
|
4497
|
-
|
|
4631
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
|
|
4498
4632
|
const isCorrect = objective.includes(element['value']);
|
|
4499
4633
|
dispatchClickEvent(element, isCorrect);
|
|
4500
|
-
AudioPlayer.getI().stop();
|
|
4501
4634
|
if (isCorrect) {
|
|
4502
4635
|
const onCorrect = element.getAttribute('onCorrect');
|
|
4503
4636
|
await executeActions(onCorrect, element);
|
|
@@ -4509,8 +4642,11 @@ function addClickListenerForClickType(element) {
|
|
|
4509
4642
|
}
|
|
4510
4643
|
storingEachActivityScore(isCorrect);
|
|
4511
4644
|
}
|
|
4512
|
-
|
|
4513
|
-
|
|
4645
|
+
const isInsideCalculator = element.closest('#lidoCalculator') !== null;
|
|
4646
|
+
if (!isInsideCalculator) {
|
|
4647
|
+
if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
|
|
4648
|
+
validateObjectiveStatus();
|
|
4649
|
+
}
|
|
4514
4650
|
}
|
|
4515
4651
|
};
|
|
4516
4652
|
element.addEventListener('click', onClick);
|
|
@@ -69328,7 +69464,431 @@ function calculateFill(input, currentFill = 0) {
|
|
|
69328
69464
|
return Math.max(0, Math.min(100, value));
|
|
69329
69465
|
}
|
|
69330
69466
|
|
|
69467
|
+
// Helper to animate and remove the active equation cell
|
|
69468
|
+
const animationToRemoveEquationSolvedCellForNimbleTable = (activeCell, allCalculateTypes) => {
|
|
69469
|
+
return new Promise((resolve) => {
|
|
69470
|
+
const keyframes = `
|
|
69471
|
+
@keyframes widthDecrease {
|
|
69472
|
+
0% {
|
|
69473
|
+
background-color: ${activeCell.style.backgroundColor};
|
|
69474
|
+
height: ${activeCell.style.height};
|
|
69475
|
+
margin: ${activeCell.style.margin};
|
|
69476
|
+
${activeCell.innerHTML = ""}
|
|
69477
|
+
}
|
|
69478
|
+
100% { background-color: transparent; height: 0px; margin: 0px; }
|
|
69479
|
+
}`;
|
|
69480
|
+
const styleSheet = document.styleSheets[0];
|
|
69481
|
+
styleSheet.insertRule(keyframes, styleSheet.cssRules.length);
|
|
69482
|
+
activeCell.style.animation = `widthDecrease 0.1s`;
|
|
69483
|
+
activeCell.addEventListener('animationend', () => {
|
|
69484
|
+
activeCell.style.height = '0px';
|
|
69485
|
+
activeCell.style.margin = '0px';
|
|
69486
|
+
activeCell.style.backgroundColor = 'transparent';
|
|
69487
|
+
activeCell.remove();
|
|
69488
|
+
// Trigger next container if last cell
|
|
69489
|
+
if (allCalculateTypes.length === 1) {
|
|
69490
|
+
setTimeout(() => triggerNextContainer(), 2000);
|
|
69491
|
+
}
|
|
69492
|
+
resolve();
|
|
69493
|
+
});
|
|
69494
|
+
});
|
|
69495
|
+
};
|
|
69496
|
+
// Function: checks and animates equation when correct
|
|
69497
|
+
const checkEquationOfActiveCell = async (container) => {
|
|
69498
|
+
var _a;
|
|
69499
|
+
const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
|
|
69500
|
+
const allCalculateTypes = document.querySelectorAll("[type='calculate']");
|
|
69501
|
+
const activeCell = allCalculateTypes[0];
|
|
69502
|
+
const activeCellValue = Number(activeCell["value"]);
|
|
69503
|
+
const calculteValue = Number(calculatorValue);
|
|
69504
|
+
if (!activeCell || calculteValue !== activeCellValue)
|
|
69505
|
+
return;
|
|
69506
|
+
const equation = activeCell["string"];
|
|
69507
|
+
// Replace equation after a short delay
|
|
69508
|
+
//await new Promise(r => setTimeout(r, 200));
|
|
69509
|
+
activeCell.innerHTML = equation.replaceAll("?", calculteValue);
|
|
69510
|
+
const element2 = container.querySelector("#dummy112");
|
|
69511
|
+
element2.innerHTML = activeCell.innerHTML;
|
|
69512
|
+
// Animate and clean up
|
|
69513
|
+
await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
|
|
69514
|
+
};
|
|
69515
|
+
// Function: handles equation check when clicked on OK
|
|
69516
|
+
let score = 0;
|
|
69517
|
+
const handleSolvedEquationSubmissionAndScoreUpdate = async () => {
|
|
69518
|
+
var _a;
|
|
69519
|
+
const container = document.getElementById('lido-container');
|
|
69520
|
+
const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
|
|
69521
|
+
const allCalculateTypes = document.querySelectorAll("[type='calculate']");
|
|
69522
|
+
const activeCell = allCalculateTypes[0];
|
|
69523
|
+
const isContinueOnCorrect = container.getAttribute("is-continue-on-correct") === "true";
|
|
69524
|
+
const activeCellValue = Number(activeCell["value"]);
|
|
69525
|
+
const calculteValue = Number(calculatorValue);
|
|
69526
|
+
const element1 = container.querySelector("#dummy111");
|
|
69527
|
+
const element2 = container.querySelector("#dummy112");
|
|
69528
|
+
// PRACTICE MODE (continue only if correct)
|
|
69529
|
+
if (isContinueOnCorrect) {
|
|
69530
|
+
if (element2.innerHTML.length > 0 && activeCellValue === calculteValue) {
|
|
69531
|
+
element1.innerHTML = element2.innerHTML;
|
|
69532
|
+
}
|
|
69533
|
+
await checkEquationOfActiveCell(container);
|
|
69534
|
+
}
|
|
69535
|
+
// TEST MODE (store all, animate regardless of correctness)
|
|
69536
|
+
else {
|
|
69537
|
+
if (calculatorValue.length > 0) {
|
|
69538
|
+
if (calculatorValue === activeCell["value"]) {
|
|
69539
|
+
score++;
|
|
69540
|
+
console.log("SCOREEEE", score);
|
|
69541
|
+
}
|
|
69542
|
+
else {
|
|
69543
|
+
if (score > 0) {
|
|
69544
|
+
score--;
|
|
69545
|
+
}
|
|
69546
|
+
console.log("SCOREEEE", score);
|
|
69547
|
+
}
|
|
69548
|
+
if (element2.innerHTML.length > 0) {
|
|
69549
|
+
element1.innerHTML = element2.innerHTML;
|
|
69550
|
+
}
|
|
69551
|
+
const equation = activeCell["string"];
|
|
69552
|
+
// Replace value visually
|
|
69553
|
+
activeCell.innerHTML = equation.replaceAll("?", calculteValue);
|
|
69554
|
+
element2.innerHTML = activeCell.innerHTML;
|
|
69555
|
+
// Animate
|
|
69556
|
+
await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
|
|
69557
|
+
}
|
|
69558
|
+
}
|
|
69559
|
+
};
|
|
69560
|
+
|
|
69561
|
+
function handlingMatrix(element) {
|
|
69562
|
+
const container = document.querySelector(LidoContainer);
|
|
69563
|
+
if (!container)
|
|
69564
|
+
return;
|
|
69565
|
+
const defualtMatrix = element;
|
|
69566
|
+
adjustSizeForSlots(container, defualtMatrix);
|
|
69567
|
+
splitSlots(container, defualtMatrix);
|
|
69568
|
+
}
|
|
69569
|
+
const splitSlots = (container, defualtMatrix) => {
|
|
69570
|
+
const defualtElements = defualtMatrix.querySelectorAll('.slot');
|
|
69571
|
+
const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
|
|
69572
|
+
const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
|
|
69573
|
+
let slot = 1;
|
|
69574
|
+
for (let i = 0; i < allDropMatrixes.length; i++) {
|
|
69575
|
+
const el = allDropMatrixes[i];
|
|
69576
|
+
const rowCount = el.getAttribute('rows') ? parseInt(el.getAttribute('rows')) : 1;
|
|
69577
|
+
const colCount = el.getAttribute('cols') ? parseInt(el.getAttribute('cols')) : 1;
|
|
69578
|
+
if (rowCount === 1 || colCount === 1) {
|
|
69579
|
+
if (rowCount === colCount) {
|
|
69580
|
+
const numbers = Array.from({ length: 100 }, (_, i) => i + 1)
|
|
69581
|
+
.sort(() => Math.random() - 0.5) // Shuffle
|
|
69582
|
+
.slice(0, 10); // Take first 10 unique numbers
|
|
69583
|
+
allDropMatrixes.forEach((item, index) => {
|
|
69584
|
+
const dropElement = item;
|
|
69585
|
+
const dropPosition = defualtElements[numbers[index]];
|
|
69586
|
+
// Safeguard if index > available numbers
|
|
69587
|
+
if (!dropPosition)
|
|
69588
|
+
return;
|
|
69589
|
+
postioningDropElement(dropElement, dropPosition);
|
|
69590
|
+
const dragElement = allDragMatrixes[index];
|
|
69591
|
+
dragElement.setAttribute('text', (numbers[index] + 1).toString());
|
|
69592
|
+
});
|
|
69593
|
+
// return;
|
|
69594
|
+
}
|
|
69595
|
+
if (rowCount === 2 && colCount === 1) {
|
|
69596
|
+
const pairs = generateDoubleSquares(10);
|
|
69597
|
+
console.log('pairs double : ', pairs);
|
|
69598
|
+
allDropMatrixes.forEach((item, index) => {
|
|
69599
|
+
const dropElement = item;
|
|
69600
|
+
const dropPosition = defualtElements[pairs[index][0] - 1];
|
|
69601
|
+
postioningDropElement(dropElement, dropPosition);
|
|
69602
|
+
});
|
|
69603
|
+
allDragMatrixes.forEach((item, index) => {
|
|
69604
|
+
const dragElement = item;
|
|
69605
|
+
dragElement.setAttribute('text', pairs[index].toString());
|
|
69606
|
+
});
|
|
69607
|
+
break;
|
|
69608
|
+
}
|
|
69609
|
+
if (rowCount === 5) {
|
|
69610
|
+
const dropPositionElements = generateHalfHorizontalStripes(i);
|
|
69611
|
+
const dropPosition = defualtElements[dropPositionElements[0] - 1];
|
|
69612
|
+
const dragElement = allDragMatrixes[i];
|
|
69613
|
+
dragElement.setAttribute('text', dropPositionElements.toString());
|
|
69614
|
+
postioningDropElement(el, dropPosition);
|
|
69615
|
+
}
|
|
69616
|
+
if (rowCount === 10) {
|
|
69617
|
+
const dropPosition = defualtElements[slot];
|
|
69618
|
+
const dragElement = allDragMatrixes[i];
|
|
69619
|
+
dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => slot + 1 + i * 10).toString());
|
|
69620
|
+
postioningDropElement(el, dropPosition);
|
|
69621
|
+
slot = slot + 2;
|
|
69622
|
+
}
|
|
69623
|
+
else if (colCount === 10) {
|
|
69624
|
+
const dropPosition = defualtElements[10 + (slot - 1)];
|
|
69625
|
+
const dragElement = allDragMatrixes[i];
|
|
69626
|
+
dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => i + 10 + slot).toString());
|
|
69627
|
+
postioningDropElement(el, dropPosition);
|
|
69628
|
+
slot = slot + 20;
|
|
69629
|
+
}
|
|
69630
|
+
}
|
|
69631
|
+
else if (rowCount === 3 || colCount === 3) {
|
|
69632
|
+
const slotCell = generateSlotsFromDrops(container);
|
|
69633
|
+
const cellNumbers = Object.keys(slotCell).map(key => slotCell[key].cells);
|
|
69634
|
+
allDragMatrixes.forEach((matrix, index) => {
|
|
69635
|
+
const dragElement = matrix;
|
|
69636
|
+
// let dragTextAttr = dragElement.getAttribute('text');
|
|
69637
|
+
if (dragElement) {
|
|
69638
|
+
dragElement.setAttribute('text', cellNumbers[index].toString());
|
|
69639
|
+
}
|
|
69640
|
+
});
|
|
69641
|
+
allDropMatrixes.forEach((matrix, index) => {
|
|
69642
|
+
const dropElement = matrix;
|
|
69643
|
+
const dropPosition = defualtElements[slotCell[`slot-${index + 1}`].cells[0] - 1];
|
|
69644
|
+
postioningDropElement(dropElement, dropPosition);
|
|
69645
|
+
});
|
|
69646
|
+
break; // stops the loop immediately
|
|
69647
|
+
}
|
|
69648
|
+
else if (rowCount === 2 || colCount === 2) {
|
|
69649
|
+
if (rowCount === colCount) {
|
|
69650
|
+
const pairs = generate2by2Squares(10);
|
|
69651
|
+
allDropMatrixes.forEach((item, index) => {
|
|
69652
|
+
const dropElement = item;
|
|
69653
|
+
const dropPosition = defualtElements[pairs[index][0] - 1];
|
|
69654
|
+
postioningDropElement(dropElement, dropPosition);
|
|
69655
|
+
});
|
|
69656
|
+
allDragMatrixes.forEach((item, index) => {
|
|
69657
|
+
const dragElement = item;
|
|
69658
|
+
dragElement.setAttribute('text', pairs[index].toString());
|
|
69659
|
+
});
|
|
69660
|
+
break;
|
|
69661
|
+
}
|
|
69662
|
+
}
|
|
69663
|
+
}
|
|
69664
|
+
};
|
|
69665
|
+
function generateSlotsFromDrops(container) {
|
|
69666
|
+
const gridSize = 10;
|
|
69667
|
+
let availableCells = Array.from({ length: 100 }, (_, i) => i + 1);
|
|
69668
|
+
const occupied = new Set();
|
|
69669
|
+
const slots = {};
|
|
69670
|
+
let generated = 0;
|
|
69671
|
+
const getCell = (row, col) => row * gridSize + col + 1;
|
|
69672
|
+
// Get all <lido-math-matrix type="drop">
|
|
69673
|
+
const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
|
|
69674
|
+
for (const matrix of Array.from(allDropMatrixes)) {
|
|
69675
|
+
const width = parseInt(matrix.getAttribute('cols') || '1');
|
|
69676
|
+
const height = parseInt(matrix.getAttribute('rows') || '1');
|
|
69677
|
+
const possiblePositions = [];
|
|
69678
|
+
// generate all possible top-left positions
|
|
69679
|
+
for (let row = 0; row <= gridSize - height; row++) {
|
|
69680
|
+
for (let col = 0; col <= gridSize - width; col++) {
|
|
69681
|
+
const cells = [];
|
|
69682
|
+
let canPlace = true;
|
|
69683
|
+
for (let r = 0; r < height; r++) {
|
|
69684
|
+
for (let c = 0; c < width; c++) {
|
|
69685
|
+
const cell = getCell(row + r, col + c);
|
|
69686
|
+
if (occupied.has(cell)) {
|
|
69687
|
+
canPlace = false;
|
|
69688
|
+
break;
|
|
69689
|
+
}
|
|
69690
|
+
cells.push(cell);
|
|
69691
|
+
}
|
|
69692
|
+
if (!canPlace)
|
|
69693
|
+
break;
|
|
69694
|
+
}
|
|
69695
|
+
if (canPlace)
|
|
69696
|
+
possiblePositions.push(cells);
|
|
69697
|
+
}
|
|
69698
|
+
}
|
|
69699
|
+
if (possiblePositions.length === 0) {
|
|
69700
|
+
console.warn(`No space left for matrix ${generated + 1}`);
|
|
69701
|
+
continue;
|
|
69702
|
+
}
|
|
69703
|
+
// Pick a random valid position
|
|
69704
|
+
const randomCells = possiblePositions[Math.floor(Math.random() * possiblePositions.length)];
|
|
69705
|
+
// Mark as occupied & remove from available
|
|
69706
|
+
randomCells.forEach(c => {
|
|
69707
|
+
occupied.add(c);
|
|
69708
|
+
availableCells = availableCells.filter(x => x !== c);
|
|
69709
|
+
});
|
|
69710
|
+
generated++;
|
|
69711
|
+
slots[`slot-${generated}`] = { cells: randomCells, width, height };
|
|
69712
|
+
}
|
|
69713
|
+
return slots;
|
|
69714
|
+
}
|
|
69715
|
+
const postioningDropElement = (dropElement, dropPosition) => {
|
|
69716
|
+
const container = document.getElementById(LidoContainer);
|
|
69717
|
+
const containerScale = getElementScale$1(container);
|
|
69718
|
+
dropElement.style.transform = 'translate(0,0)';
|
|
69719
|
+
const posRect = dropPosition.getBoundingClientRect();
|
|
69720
|
+
const dropRect = dropElement.getBoundingClientRect();
|
|
69721
|
+
const posCenterX = posRect.left + posRect.width / 2;
|
|
69722
|
+
const posCenterY = posRect.top + posRect.height / 2;
|
|
69723
|
+
const dropCenterX = dropRect.left + dropRect.width / 2;
|
|
69724
|
+
const dropCenterY = dropRect.top + dropRect.height / 2;
|
|
69725
|
+
const scaledLeft = (posCenterX - dropCenterX) / containerScale;
|
|
69726
|
+
const scaledTop = (posCenterY - dropCenterY) / containerScale;
|
|
69727
|
+
const rowCount = dropElement.getAttribute('rows') ? parseInt(dropElement.getAttribute('rows')) : 1;
|
|
69728
|
+
const colCount = dropElement.getAttribute('cols') ? parseInt(dropElement.getAttribute('cols')) : 1;
|
|
69729
|
+
const elementWidth = parseInt(dropPosition.style.width);
|
|
69730
|
+
if (rowCount === 1 || colCount === 1) {
|
|
69731
|
+
if (rowCount === colCount) {
|
|
69732
|
+
dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop}px)`;
|
|
69733
|
+
return;
|
|
69734
|
+
}
|
|
69735
|
+
else if (rowCount > colCount) {
|
|
69736
|
+
if (rowCount === 10) {
|
|
69737
|
+
dropElement.style.transform = `translate(${scaledLeft + (elementWidth * 4 + elementWidth / 2)}px, ${scaledTop}px)`;
|
|
69738
|
+
}
|
|
69739
|
+
else if (rowCount === 5) {
|
|
69740
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth * 2}px, ${scaledTop}px)`;
|
|
69741
|
+
}
|
|
69742
|
+
else if (rowCount === 2) {
|
|
69743
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
|
|
69744
|
+
}
|
|
69745
|
+
}
|
|
69746
|
+
else if (rowCount < colCount) {
|
|
69747
|
+
if (colCount === 10) {
|
|
69748
|
+
dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 4 + elementWidth * 0.2 + elementWidth / 2}px)`;
|
|
69749
|
+
}
|
|
69750
|
+
else if (colCount === 5) {
|
|
69751
|
+
dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 2 + elementWidth * 0.0921}px)`;
|
|
69752
|
+
}
|
|
69753
|
+
}
|
|
69754
|
+
return;
|
|
69755
|
+
}
|
|
69756
|
+
if (rowCount === colCount) {
|
|
69757
|
+
if (rowCount === 2) {
|
|
69758
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth / 2 + 4}px)`;
|
|
69759
|
+
return;
|
|
69760
|
+
}
|
|
69761
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth + 4}px)`;
|
|
69762
|
+
return;
|
|
69763
|
+
}
|
|
69764
|
+
if (rowCount === 3) {
|
|
69765
|
+
if (colCount === 2) {
|
|
69766
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth / 2 + 4}px)`;
|
|
69767
|
+
return;
|
|
69768
|
+
}
|
|
69769
|
+
else if (colCount === 1) {
|
|
69770
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop}px)`;
|
|
69771
|
+
return;
|
|
69772
|
+
}
|
|
69773
|
+
}
|
|
69774
|
+
if (rowCount === 2) {
|
|
69775
|
+
if (colCount === 3) {
|
|
69776
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth + 4}px)`;
|
|
69777
|
+
return;
|
|
69778
|
+
}
|
|
69779
|
+
else if (colCount === 1) {
|
|
69780
|
+
dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
|
|
69781
|
+
return;
|
|
69782
|
+
}
|
|
69783
|
+
}
|
|
69784
|
+
};
|
|
69785
|
+
const adjustSizeForSlots = (container, defualtMatrix) => {
|
|
69786
|
+
const defualtElement = defualtMatrix.querySelector('.slot');
|
|
69787
|
+
const width = defualtElement.style.width;
|
|
69788
|
+
const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
|
|
69789
|
+
const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
|
|
69790
|
+
allDragMatrixes.forEach(item => {
|
|
69791
|
+
const el = item;
|
|
69792
|
+
Array.from(el.querySelectorAll('.slot')).forEach(slot => {
|
|
69793
|
+
const slotEl = slot;
|
|
69794
|
+
slotEl.parentElement.style.width = width;
|
|
69795
|
+
slotEl.style.width = width;
|
|
69796
|
+
slotEl.style.height = width;
|
|
69797
|
+
});
|
|
69798
|
+
});
|
|
69799
|
+
allDropMatrixes.forEach(item => {
|
|
69800
|
+
const el = item;
|
|
69801
|
+
Array.from(el.querySelectorAll('.slot')).forEach(slot => {
|
|
69802
|
+
const slotEl = slot;
|
|
69803
|
+
slotEl.parentElement.style.width = width;
|
|
69804
|
+
slotEl.style.width = width;
|
|
69805
|
+
slotEl.style.height = width;
|
|
69806
|
+
});
|
|
69807
|
+
});
|
|
69808
|
+
};
|
|
69809
|
+
function generateHalfHorizontalStripes(index) {
|
|
69810
|
+
const numbers = Array.from({ length: 10 }, (_, i) => index + 1 + i * 10);
|
|
69811
|
+
const randomPlace = Math.floor(Math.random() * 6);
|
|
69812
|
+
const startSlot = numbers[randomPlace];
|
|
69813
|
+
console.log('kedachuruchu', Array.from({ length: 5 }, (_, i) => startSlot + i * 10));
|
|
69814
|
+
return Array.from({ length: 5 }, (_, i) => startSlot + i * 10);
|
|
69815
|
+
}
|
|
69816
|
+
function generate2by2Squares(count = 16) {
|
|
69817
|
+
const gridSize = 10;
|
|
69818
|
+
const squares = [];
|
|
69819
|
+
const usedCells = new Set();
|
|
69820
|
+
function getCell(row, col) {
|
|
69821
|
+
return (row - 1) * gridSize + col;
|
|
69822
|
+
}
|
|
69823
|
+
while (squares.length < count) {
|
|
69824
|
+
const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
|
|
69825
|
+
const col = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
|
|
69826
|
+
const square = [getCell(row, col), getCell(row, col + 1), getCell(row + 1, col), getCell(row + 1, col + 1)];
|
|
69827
|
+
// Skip if overlapping with previous
|
|
69828
|
+
if (square.some(cell => usedCells.has(cell)))
|
|
69829
|
+
continue;
|
|
69830
|
+
// Mark cells as used
|
|
69831
|
+
square.forEach(cell => usedCells.add(cell));
|
|
69832
|
+
squares.push(square);
|
|
69833
|
+
}
|
|
69834
|
+
return squares;
|
|
69835
|
+
}
|
|
69836
|
+
function generateDoubleSquares(count = 16) {
|
|
69837
|
+
const gridSize = 10;
|
|
69838
|
+
const pairs = [];
|
|
69839
|
+
const usedCells = new Set();
|
|
69840
|
+
function getCell(row, col) {
|
|
69841
|
+
return (row - 1) * gridSize + col;
|
|
69842
|
+
}
|
|
69843
|
+
while (pairs.length < count) {
|
|
69844
|
+
const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
|
|
69845
|
+
const col = Math.floor(Math.random() * gridSize) + 1; // 1–10
|
|
69846
|
+
const top = getCell(row, col);
|
|
69847
|
+
const bottom = getCell(row + 1, col);
|
|
69848
|
+
// Skip if already used
|
|
69849
|
+
if (usedCells.has(top) || usedCells.has(bottom))
|
|
69850
|
+
continue;
|
|
69851
|
+
pairs.push([top, bottom]);
|
|
69852
|
+
usedCells.add(top);
|
|
69853
|
+
usedCells.add(bottom);
|
|
69854
|
+
}
|
|
69855
|
+
return pairs;
|
|
69856
|
+
}
|
|
69857
|
+
|
|
69331
69858
|
const gameScore = new GameScore();
|
|
69859
|
+
function buildDragSelectedMapFromDOM() {
|
|
69860
|
+
const map = {};
|
|
69861
|
+
const draggedEls = document.querySelectorAll(`[${DropToAttr}]`);
|
|
69862
|
+
draggedEls.forEach(dragEl => {
|
|
69863
|
+
var _a, _b, _c;
|
|
69864
|
+
const to = dragEl.getAttribute(DropToAttr);
|
|
69865
|
+
if (!to)
|
|
69866
|
+
return;
|
|
69867
|
+
const dropEl = document.getElementById(to);
|
|
69868
|
+
if (!dropEl)
|
|
69869
|
+
return;
|
|
69870
|
+
const tabIndex = (_a = dropEl.getAttribute('tab-index')) !== null && _a !== void 0 ? _a : to;
|
|
69871
|
+
if (!map[tabIndex])
|
|
69872
|
+
map[tabIndex] = [];
|
|
69873
|
+
const value = (_c = (_b = dragEl.getAttribute('value')) !== null && _b !== void 0 ? _b : dragEl.value) !== null && _c !== void 0 ? _c : '';
|
|
69874
|
+
map[tabIndex].push(value);
|
|
69875
|
+
});
|
|
69876
|
+
return map;
|
|
69877
|
+
}
|
|
69878
|
+
function getSortedValuesArrayFromMap(map) {
|
|
69879
|
+
const sortedKeys = Object.keys(map).sort((a, b) => parseInt(a) - parseInt(b));
|
|
69880
|
+
const sortedValues = sortedKeys.reduce((acc, key) => {
|
|
69881
|
+
const values = map[key];
|
|
69882
|
+
if (values.length > 1) {
|
|
69883
|
+
acc.push(`(${values.join('|')})`);
|
|
69884
|
+
}
|
|
69885
|
+
else {
|
|
69886
|
+
acc.push(values[0]);
|
|
69887
|
+
}
|
|
69888
|
+
return acc;
|
|
69889
|
+
}, []);
|
|
69890
|
+
return sortedValues;
|
|
69891
|
+
}
|
|
69332
69892
|
function format(first, middle, last) {
|
|
69333
69893
|
return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
|
|
69334
69894
|
}
|
|
@@ -69373,14 +69933,17 @@ const initEventsForElement = async (element, type) => {
|
|
|
69373
69933
|
enableOptionArea(element);
|
|
69374
69934
|
break;
|
|
69375
69935
|
}
|
|
69936
|
+
case 'checkerBlock': {
|
|
69937
|
+
handlingMatrix(element);
|
|
69938
|
+
break;
|
|
69939
|
+
}
|
|
69376
69940
|
}
|
|
69377
69941
|
onTouchListenerForOnTouch(element);
|
|
69378
69942
|
};
|
|
69379
69943
|
// Function to execute actions parsed from the onMatch string
|
|
69380
69944
|
const executeActions = async (actionsString, thisElement, element) => {
|
|
69381
|
-
var _a;
|
|
69945
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
69382
69946
|
const actions = parseActions(actionsString);
|
|
69383
|
-
body.style.pointerEvents = 'none';
|
|
69384
69947
|
for (let i = 0; i < actions.length; i++) {
|
|
69385
69948
|
const action = actions[i];
|
|
69386
69949
|
const queriedElement = document.querySelector(action.actor);
|
|
@@ -69393,13 +69956,25 @@ const executeActions = async (actionsString, thisElement, element) => {
|
|
|
69393
69956
|
targetElement.style.transform = currentTransform !== 'none' ? `${currentTransform} ${action.value}` : action.value;
|
|
69394
69957
|
break;
|
|
69395
69958
|
}
|
|
69959
|
+
case 'revealImageValue': {
|
|
69960
|
+
if (targetElement) {
|
|
69961
|
+
revealImageValue(targetElement); // call your function here
|
|
69962
|
+
}
|
|
69963
|
+
break;
|
|
69964
|
+
}
|
|
69965
|
+
case 'scrollCellAfterEquationSolved': {
|
|
69966
|
+
if (targetElement) {
|
|
69967
|
+
handleSolvedEquationSubmissionAndScoreUpdate();
|
|
69968
|
+
}
|
|
69969
|
+
break;
|
|
69970
|
+
}
|
|
69396
69971
|
case 'alignMatch': {
|
|
69397
69972
|
const dropElement = targetElement;
|
|
69398
69973
|
const dragElement = element;
|
|
69399
69974
|
const container = document.getElementById(LidoContainer);
|
|
69400
69975
|
const containerScale = getElementScale$1(container);
|
|
69401
69976
|
dragElement.style.transform = 'translate(0,0)';
|
|
69402
|
-
console.log(
|
|
69977
|
+
console.log("logg alinmatch");
|
|
69403
69978
|
const dropRect = dropElement.getBoundingClientRect();
|
|
69404
69979
|
const dragRect = dragElement.getBoundingClientRect();
|
|
69405
69980
|
const dropCenterX = dropRect.left + dropRect.width / 2;
|
|
@@ -69445,7 +70020,7 @@ const executeActions = async (actionsString, thisElement, element) => {
|
|
|
69445
70020
|
if (container.getAttribute('is-continue-on-correct') !== 'true') {
|
|
69446
70021
|
targetElement.style.pointerEvents = 'none';
|
|
69447
70022
|
}
|
|
69448
|
-
|
|
70023
|
+
validateObjectiveStatus();
|
|
69449
70024
|
break;
|
|
69450
70025
|
}
|
|
69451
70026
|
case 'prevBtn': {
|
|
@@ -69485,10 +70060,76 @@ const executeActions = async (actionsString, thisElement, element) => {
|
|
|
69485
70060
|
}
|
|
69486
70061
|
break;
|
|
69487
70062
|
}
|
|
70063
|
+
case 'highlightStarsAndDisapper': {
|
|
70064
|
+
const value = action.value;
|
|
70065
|
+
if (value && targetElement) {
|
|
70066
|
+
console.log('highlightStar action triggered');
|
|
70067
|
+
console.log('Target Element:', targetElement);
|
|
70068
|
+
await HighlightStarsOneByOne(targetElement, value);
|
|
70069
|
+
}
|
|
70070
|
+
break;
|
|
70071
|
+
}
|
|
70072
|
+
case 'boxAnimationOneByOne': {
|
|
70073
|
+
const value = action.value;
|
|
70074
|
+
if (value && targetElement) {
|
|
70075
|
+
await animateBoxCells(targetElement, value);
|
|
70076
|
+
}
|
|
70077
|
+
break;
|
|
70078
|
+
}
|
|
70079
|
+
case 'questionBoxAnimate': {
|
|
70080
|
+
const value = action.value;
|
|
70081
|
+
if (value && targetElement) {
|
|
70082
|
+
await questionBoxAnimation(targetElement, value);
|
|
70083
|
+
}
|
|
70084
|
+
break;
|
|
70085
|
+
}
|
|
69488
70086
|
case 'slideAnimation': {
|
|
69489
70087
|
slideAnimation();
|
|
69490
70088
|
break;
|
|
69491
70089
|
}
|
|
70090
|
+
case 'showBalanceSymbol': {
|
|
70091
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
70092
|
+
if (!balanceEl)
|
|
70093
|
+
break;
|
|
70094
|
+
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));
|
|
70095
|
+
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));
|
|
70096
|
+
const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
|
|
70097
|
+
balanceEl.balanceSymbol = symbol;
|
|
70098
|
+
balanceEl.dataset.balanceSymbol = symbol;
|
|
70099
|
+
if (balanceEl.revealSymbol) {
|
|
70100
|
+
await balanceEl.revealSymbol();
|
|
70101
|
+
}
|
|
70102
|
+
else {
|
|
70103
|
+
balanceEl.showSymbol = true;
|
|
70104
|
+
}
|
|
70105
|
+
break;
|
|
70106
|
+
}
|
|
70107
|
+
case 'hideBalanceSymbol': {
|
|
70108
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
70109
|
+
if (!balanceEl)
|
|
70110
|
+
break;
|
|
70111
|
+
if (balanceEl.hideSymbol) {
|
|
70112
|
+
await balanceEl.hideSymbol();
|
|
70113
|
+
}
|
|
70114
|
+
else {
|
|
70115
|
+
balanceEl.showSymbol = false;
|
|
70116
|
+
}
|
|
70117
|
+
break;
|
|
70118
|
+
}
|
|
70119
|
+
case 'sumTogetherAnimation': {
|
|
70120
|
+
const value = action.value;
|
|
70121
|
+
if (value) {
|
|
70122
|
+
SumTogetherAnimation(targetElement, value);
|
|
70123
|
+
}
|
|
70124
|
+
break;
|
|
70125
|
+
}
|
|
70126
|
+
case 'addText': {
|
|
70127
|
+
const value = action.value;
|
|
70128
|
+
if (value) {
|
|
70129
|
+
targetElement.textContent += value;
|
|
70130
|
+
}
|
|
70131
|
+
break;
|
|
70132
|
+
}
|
|
69492
70133
|
default: {
|
|
69493
70134
|
targetElement.style[action.action] = action.value;
|
|
69494
70135
|
break;
|
|
@@ -69496,7 +70137,6 @@ const executeActions = async (actionsString, thisElement, element) => {
|
|
|
69496
70137
|
}
|
|
69497
70138
|
}
|
|
69498
70139
|
}
|
|
69499
|
-
body.style.pointerEvents = 'auto';
|
|
69500
70140
|
};
|
|
69501
70141
|
const afterDropDragHandling = (dragElement, dropElement) => {
|
|
69502
70142
|
const container = document.getElementById(LidoContainer);
|
|
@@ -69587,6 +70227,9 @@ const matchStringPattern = (pattern, arr) => {
|
|
|
69587
70227
|
const patternGroups = pattern.split(',').map(group => group.trim());
|
|
69588
70228
|
let arrIndex = 0;
|
|
69589
70229
|
let options = new Set();
|
|
70230
|
+
if (patternGroups.length == 0) { // If pattern is empty
|
|
70231
|
+
return true;
|
|
70232
|
+
}
|
|
69590
70233
|
if (patternGroups.length > 0) {
|
|
69591
70234
|
if (arr.length === 0)
|
|
69592
70235
|
return false; // If pattern is not empty but user provided array is empty, return false
|
|
@@ -69671,38 +70314,36 @@ const calculateScore = () => {
|
|
|
69671
70314
|
gameScore.wrongMoves = 0;
|
|
69672
70315
|
};
|
|
69673
70316
|
async function onActivityComplete(dragElement, dropElement) {
|
|
69674
|
-
var _a
|
|
70317
|
+
var _a;
|
|
69675
70318
|
const container = document.getElementById(LidoContainer);
|
|
69676
70319
|
if (!container)
|
|
69677
70320
|
return;
|
|
69678
70321
|
await executeActions("this.alignMatch='true'", dropElement, dragElement);
|
|
69679
|
-
|
|
69680
|
-
|
|
69681
|
-
|
|
69682
|
-
|
|
70322
|
+
if (dragElement && dropElement) {
|
|
70323
|
+
const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
|
|
70324
|
+
if (isCorrect) {
|
|
70325
|
+
const onCorrect = dropElement.getAttribute('onCorrect');
|
|
70326
|
+
if (onCorrect) {
|
|
70327
|
+
await executeActions(onCorrect, dropElement, dragElement);
|
|
70328
|
+
}
|
|
70329
|
+
}
|
|
70330
|
+
else {
|
|
70331
|
+
const onInCorrect = dropElement.getAttribute('onInCorrect');
|
|
70332
|
+
await executeActions(onInCorrect, dropElement, dragElement);
|
|
70333
|
+
}
|
|
69683
70334
|
}
|
|
69684
|
-
dragScore
|
|
69685
|
-
|
|
70335
|
+
let dragScore = buildDragSelectedMapFromDOM();
|
|
70336
|
+
const sortedValues = getSortedValuesArrayFromMap(dragScore);
|
|
70337
|
+
container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
|
|
69686
70338
|
//localStorage
|
|
69687
|
-
let drag = JSON.parse((
|
|
70339
|
+
let drag = JSON.parse((_a = localStorage.getItem(DragMapKey)) !== null && _a !== void 0 ? _a : '{}');
|
|
69688
70340
|
const index = dropElement.getAttribute('tab-index');
|
|
69689
70341
|
if (!drag[index]) {
|
|
69690
70342
|
drag[index] = [];
|
|
69691
70343
|
}
|
|
69692
70344
|
drag[index].push(dragElement.id);
|
|
69693
70345
|
// localStorage.setItem(DragMapKey, JSON.stringify(drag));
|
|
69694
|
-
|
|
69695
|
-
const sortedValues = sortedKeys.reduce((acc, key) => {
|
|
69696
|
-
const values = dragScore[key];
|
|
69697
|
-
if (values.length > 1) {
|
|
69698
|
-
acc.push(`(${values.join('|')})`);
|
|
69699
|
-
}
|
|
69700
|
-
else {
|
|
69701
|
-
acc.push(values[0]);
|
|
69702
|
-
}
|
|
69703
|
-
return acc;
|
|
69704
|
-
}, []);
|
|
69705
|
-
localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
|
|
70346
|
+
Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
|
|
69706
70347
|
if (dragElement && dropElement) {
|
|
69707
70348
|
const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
|
|
69708
70349
|
if (isCorrect) {
|
|
@@ -69719,8 +70360,7 @@ async function onActivityComplete(dragElement, dropElement) {
|
|
|
69719
70360
|
const allElements = document.querySelectorAll("[type='drop']");
|
|
69720
70361
|
allElements.forEach(otherElement => {
|
|
69721
70362
|
var _a;
|
|
69722
|
-
const
|
|
69723
|
-
const storedTabIndexes = Object.keys(dropObject).map(Number);
|
|
70363
|
+
const storedTabIndexes = Object.keys(dragScore).map(Number);
|
|
69724
70364
|
if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
|
|
69725
70365
|
if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
|
|
69726
70366
|
if (otherElement.tagName.toLowerCase() === 'lido-text') {
|
|
@@ -69772,77 +70412,97 @@ const handleShowCheck = () => {
|
|
|
69772
70412
|
var _a, _b;
|
|
69773
70413
|
const container = document.getElementById(LidoContainer);
|
|
69774
70414
|
const objectiveString = container['objective'];
|
|
69775
|
-
const selectValues = (_a =
|
|
70415
|
+
const selectValues = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
|
|
69776
70416
|
const checkButton = document.querySelector('#lido-checkButton');
|
|
69777
|
-
if (!selectValues || countPatternWords(selectValues)
|
|
70417
|
+
if (!selectValues || countPatternWords(selectValues) < countPatternWords(objectiveString)) {
|
|
69778
70418
|
executeActions("this.addClass='lido-disable-check-button'", checkButton);
|
|
69779
70419
|
return;
|
|
69780
70420
|
}
|
|
69781
70421
|
const showCheck = container.getAttribute('show-check') == 'true';
|
|
69782
70422
|
if (showCheck) {
|
|
69783
70423
|
(_b = checkButton === null || checkButton === void 0 ? void 0 : checkButton.classList) === null || _b === void 0 ? void 0 : _b.remove('lido-disable-check-button');
|
|
70424
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
70425
|
+
if (balanceEl) {
|
|
70426
|
+
if (!checkButton.hasAttribute('data-balance-listener')) {
|
|
70427
|
+
checkButton.addEventListener('click', async function onClick() {
|
|
70428
|
+
if (balanceResult && res) {
|
|
70429
|
+
await executeActions("this.showBalanceSymbol='true'", checkButton);
|
|
70430
|
+
checkButton.removeEventListener('click', onClick);
|
|
70431
|
+
}
|
|
70432
|
+
});
|
|
70433
|
+
checkButton.setAttribute('data-balance-listener', 'true');
|
|
70434
|
+
}
|
|
70435
|
+
}
|
|
69784
70436
|
}
|
|
69785
70437
|
else {
|
|
69786
70438
|
validateObjectiveStatus();
|
|
69787
70439
|
}
|
|
69788
70440
|
};
|
|
69789
|
-
|
|
70441
|
+
let res;
|
|
69790
70442
|
const validateObjectiveStatus = async () => {
|
|
69791
|
-
var _a;
|
|
70443
|
+
var _a, _b;
|
|
69792
70444
|
const container = document.getElementById(LidoContainer);
|
|
69793
70445
|
if (!container)
|
|
69794
70446
|
return;
|
|
69795
70447
|
const objectiveString = container['objective'];
|
|
70448
|
+
const additionalCheck = container.getAttribute('equationCheck');
|
|
70449
|
+
console.log('🚀 ~ validateObjectiveStatus ~ additionalCheck:', additionalCheck);
|
|
70450
|
+
let equationGiven = false;
|
|
69796
70451
|
if (objectiveString == null || objectiveString.length === 0) {
|
|
69797
|
-
|
|
69798
|
-
|
|
69799
|
-
|
|
69800
|
-
|
|
70452
|
+
if (additionalCheck) {
|
|
70453
|
+
equationGiven = true;
|
|
70454
|
+
}
|
|
70455
|
+
if (!equationGiven) {
|
|
70456
|
+
const onCorrect = container.getAttribute('onCorrect');
|
|
70457
|
+
if (onCorrect) {
|
|
70458
|
+
await executeActions(onCorrect, container);
|
|
70459
|
+
}
|
|
70460
|
+
storeActivityScore(100);
|
|
70461
|
+
storingEachActivityScore(true);
|
|
70462
|
+
triggerNextContainer();
|
|
70463
|
+
return;
|
|
69801
70464
|
}
|
|
69802
|
-
storeActivityScore(100);
|
|
69803
|
-
storingEachActivityScore(true);
|
|
69804
|
-
triggerNextContainer();
|
|
69805
|
-
return;
|
|
69806
70465
|
}
|
|
69807
|
-
|
|
69808
|
-
|
|
69809
|
-
|
|
69810
|
-
|
|
69811
|
-
if (!!additionalCheck) {
|
|
70466
|
+
const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
|
|
70467
|
+
if (!!additionalCheck) {
|
|
70468
|
+
const balanceEl = document.querySelector('lido-balance');
|
|
70469
|
+
if (!balanceEl) {
|
|
69812
70470
|
res = equationCheck(additionalCheck);
|
|
69813
|
-
console.log('🚀 ~ handleShowCheck ~ res:', res);
|
|
69814
70471
|
}
|
|
69815
70472
|
else {
|
|
69816
|
-
res =
|
|
70473
|
+
res = balanceResult(container, objectiveString);
|
|
69817
70474
|
}
|
|
69818
|
-
|
|
69819
|
-
|
|
69820
|
-
|
|
69821
|
-
|
|
69822
|
-
|
|
69823
|
-
|
|
69824
|
-
|
|
69825
|
-
|
|
69826
|
-
|
|
69827
|
-
|
|
69828
|
-
|
|
69829
|
-
setTimeout(() => {
|
|
69830
|
-
triggerNextContainer();
|
|
69831
|
-
}, 2000);
|
|
70475
|
+
console.log('🚀 ~ handleShowCheck ~ res:', res);
|
|
70476
|
+
}
|
|
70477
|
+
else {
|
|
70478
|
+
res = matchStringPattern(objectiveString, objectiveArray);
|
|
70479
|
+
}
|
|
70480
|
+
if (res) {
|
|
70481
|
+
const attach = container.getAttribute('appendToDropOnCompletion');
|
|
70482
|
+
const onCorrect = container.getAttribute('onCorrect');
|
|
70483
|
+
if (onCorrect) {
|
|
70484
|
+
if (attach === 'true') {
|
|
70485
|
+
appendingDragElementsInDrop();
|
|
69832
70486
|
}
|
|
69833
|
-
|
|
70487
|
+
await executeActions(onCorrect, container);
|
|
70488
|
+
}
|
|
70489
|
+
if (container.getAttribute('dropAttr') === 'EnableAnimation') {
|
|
70490
|
+
setTimeout(() => {
|
|
69834
70491
|
triggerNextContainer();
|
|
69835
|
-
}
|
|
69836
|
-
await calculateScore();
|
|
70492
|
+
}, 2000);
|
|
69837
70493
|
}
|
|
69838
70494
|
else {
|
|
69839
|
-
|
|
69840
|
-
|
|
69841
|
-
|
|
69842
|
-
|
|
69843
|
-
|
|
69844
|
-
|
|
69845
|
-
|
|
70495
|
+
triggerNextContainer();
|
|
70496
|
+
}
|
|
70497
|
+
await calculateScore();
|
|
70498
|
+
}
|
|
70499
|
+
else {
|
|
70500
|
+
const onInCorrect = container.getAttribute('onInCorrect');
|
|
70501
|
+
await executeActions(onInCorrect, container);
|
|
70502
|
+
const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
|
|
70503
|
+
if (!isContinueOnCorrect) {
|
|
70504
|
+
triggerNextContainer();
|
|
70505
|
+
await calculateScore();
|
|
69846
70506
|
}
|
|
69847
70507
|
}
|
|
69848
70508
|
};
|
|
@@ -69861,16 +70521,16 @@ const triggerPrevcontainer = () => {
|
|
|
69861
70521
|
function convertUrlToRelative(url) {
|
|
69862
70522
|
const container = document.getElementById(LidoContainer);
|
|
69863
70523
|
const baseUrl = container.getAttribute('baseUrl');
|
|
69864
|
-
if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))
|
|
70524
|
+
if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))) {
|
|
69865
70525
|
return url;
|
|
69866
70526
|
}
|
|
69867
|
-
if (baseUrl) {
|
|
69868
|
-
const newUrl = url.startsWith('/') ? url.
|
|
69869
|
-
|
|
69870
|
-
|
|
69871
|
-
|
|
70527
|
+
else if (baseUrl) {
|
|
70528
|
+
const newUrl = !url.startsWith('/') ? url : url.substring(1);
|
|
70529
|
+
return baseUrl + (baseUrl.endsWith('/') ? newUrl : '/' + newUrl);
|
|
70530
|
+
}
|
|
70531
|
+
else {
|
|
70532
|
+
return getAssetPath(url);
|
|
69872
70533
|
}
|
|
69873
|
-
return getAssetPath(url);
|
|
69874
70534
|
}
|
|
69875
70535
|
/**
|
|
69876
70536
|
* Asynchronously speaks the given text using the browser's text-to-speech API.
|
|
@@ -70059,7 +70719,10 @@ const equationCheck = (additionalCheck) => {
|
|
|
70059
70719
|
});
|
|
70060
70720
|
// 3. Join the modified parts back into one string
|
|
70061
70721
|
const resultString = modifiedParts.join('');
|
|
70722
|
+
console.log('🚀 ~ equationCheck ~ resultString:', resultString);
|
|
70723
|
+
// 4. Evaluate the final string as a mathematical expression
|
|
70062
70724
|
const finalRes = evaluate(resultString);
|
|
70725
|
+
console.log('🚀 ~ equationCheck ~ finalRes:', finalRes);
|
|
70063
70726
|
return finalRes;
|
|
70064
70727
|
};
|
|
70065
70728
|
const getElementsForQueries = (query) => {
|
|
@@ -70127,13 +70790,6 @@ const attachSpeakIcon = async (element) => {
|
|
|
70127
70790
|
}
|
|
70128
70791
|
element.appendChild(speakIconElement);
|
|
70129
70792
|
};
|
|
70130
|
-
const clearLocalStorage = () => {
|
|
70131
|
-
localStorage.removeItem(DragSelectedMapKey);
|
|
70132
|
-
localStorage.removeItem(DragMapKey);
|
|
70133
|
-
localStorage.removeItem(SelectedValuesKey);
|
|
70134
|
-
localStorage.removeItem(DropHasDrag);
|
|
70135
|
-
localStorage.removeItem(DropLength);
|
|
70136
|
-
};
|
|
70137
70793
|
/**
|
|
70138
70794
|
* Applies a delay to the element's visibility based on `delayVisible`.
|
|
70139
70795
|
*/
|
|
@@ -70219,5 +70875,229 @@ function generateUUIDFallback() {
|
|
|
70219
70875
|
return v.toString(16);
|
|
70220
70876
|
});
|
|
70221
70877
|
}
|
|
70878
|
+
const revealImageValue = (imageEl) => {
|
|
70879
|
+
if (!imageEl)
|
|
70880
|
+
return;
|
|
70881
|
+
const value = imageEl.getAttribute('value');
|
|
70882
|
+
if (!value)
|
|
70883
|
+
return;
|
|
70884
|
+
let valueElement = imageEl.querySelector('.lido-display-hiddenvalue');
|
|
70885
|
+
if (!valueElement) {
|
|
70886
|
+
valueElement = document.createElement('div');
|
|
70887
|
+
valueElement.classList.add('lido-display-hiddenvalue');
|
|
70888
|
+
imageEl.style.position = 'relative';
|
|
70889
|
+
imageEl.appendChild(valueElement);
|
|
70890
|
+
}
|
|
70891
|
+
valueElement.innerText = value;
|
|
70892
|
+
};
|
|
70893
|
+
const setImageBackground = (el, color) => {
|
|
70894
|
+
if (!el)
|
|
70895
|
+
return;
|
|
70896
|
+
el.classList.add('lido-image-colorize');
|
|
70897
|
+
const img = el.querySelector('img');
|
|
70898
|
+
if (img) {
|
|
70899
|
+
// use same image as mask
|
|
70900
|
+
el.style.setProperty('--mask-url', `url(${img.src})`);
|
|
70901
|
+
}
|
|
70902
|
+
if (color === 'red') {
|
|
70903
|
+
el.style.setProperty('--tint-color', '#ff0000');
|
|
70904
|
+
}
|
|
70905
|
+
else if (color === 'green') {
|
|
70906
|
+
el.style.setProperty('--tint-color', '#00c853');
|
|
70907
|
+
}
|
|
70908
|
+
else {
|
|
70909
|
+
el.style.removeProperty('--tint-color');
|
|
70910
|
+
el.style.removeProperty('--mask-url');
|
|
70911
|
+
}
|
|
70912
|
+
};
|
|
70913
|
+
const HighlightStarsOneByOne = async (element, value) => {
|
|
70914
|
+
if (!element)
|
|
70915
|
+
return;
|
|
70916
|
+
if (!value)
|
|
70917
|
+
return;
|
|
70918
|
+
// Dynamically find the parent row of stars
|
|
70919
|
+
const stars = Array.from(element.children);
|
|
70920
|
+
console.log('starRow', stars);
|
|
70921
|
+
for (const star of stars) {
|
|
70922
|
+
// Highlight the star
|
|
70923
|
+
star.classList.add('lido-glow');
|
|
70924
|
+
// Play star sound
|
|
70925
|
+
await AudioPlayer.getI().play(star);
|
|
70926
|
+
// Fade out the star (disappear)
|
|
70927
|
+
star.style.opacity = '0';
|
|
70928
|
+
star.style.visibility = 'hidden';
|
|
70929
|
+
await new Promise(resolve => setTimeout(resolve, 300)); // Wait for fade-out to complete
|
|
70930
|
+
// Remove the highlight
|
|
70931
|
+
star.classList.remove('lido-glow');
|
|
70932
|
+
}
|
|
70933
|
+
};
|
|
70934
|
+
const animateBoxCells = async (element, value) => {
|
|
70935
|
+
if (!element)
|
|
70936
|
+
return;
|
|
70937
|
+
if (!value)
|
|
70938
|
+
return;
|
|
70939
|
+
// Select all cells with the attribute type="box"
|
|
70940
|
+
const boxCells = Array.from(element.children);
|
|
70941
|
+
console.log('boxCells', boxCells);
|
|
70942
|
+
if (!boxCells)
|
|
70943
|
+
return;
|
|
70944
|
+
boxCells.forEach(cell => {
|
|
70945
|
+
// Reset any previous styles
|
|
70946
|
+
cell.style.visibility = 'hidden';
|
|
70947
|
+
});
|
|
70948
|
+
// Animate each cell one by one
|
|
70949
|
+
for (const cell of boxCells) {
|
|
70950
|
+
cell.style.visibility = 'visible';
|
|
70951
|
+
cell.style.opacity = '1';
|
|
70952
|
+
// Apply the "come from top" animation
|
|
70953
|
+
cell.classList.add('lido-box-highlight');
|
|
70954
|
+
// Delay for each cell to come one after another
|
|
70955
|
+
await new Promise(resolve => setTimeout(resolve, 600)); // Adjust delay as needed
|
|
70956
|
+
cell.classList.remove('lido-box-highlight');
|
|
70957
|
+
}
|
|
70958
|
+
// After all cells have come down, apply the bounce animation
|
|
70959
|
+
for (const cell of boxCells) {
|
|
70960
|
+
// play the text child inside cell
|
|
70961
|
+
await AudioPlayer.getI().play(cell);
|
|
70962
|
+
}
|
|
70963
|
+
};
|
|
70964
|
+
const questionBoxAnimation = async (element, value) => {
|
|
70965
|
+
if (!element)
|
|
70966
|
+
return;
|
|
70967
|
+
if (!value)
|
|
70968
|
+
return;
|
|
70969
|
+
// Select all drag elements and drop elements
|
|
70970
|
+
const dragElements = Array.from(element.querySelectorAll("[type='drag']"));
|
|
70971
|
+
// Ensure all drag childrens which is dropped disappear
|
|
70972
|
+
dragElements.forEach(dragElement => {
|
|
70973
|
+
if (dragElement.hasAttribute('drop-to')) {
|
|
70974
|
+
dragElement.style.transition = 'opacity 0.5s ease';
|
|
70975
|
+
dragElement.style.opacity = '0'; // Fade out
|
|
70976
|
+
setTimeout(() => {
|
|
70977
|
+
dragElement.remove(); // Remove from view after fade-out
|
|
70978
|
+
}, 500);
|
|
70979
|
+
}
|
|
70980
|
+
});
|
|
70981
|
+
// Reveal all drop childrens which is hidden
|
|
70982
|
+
const dropElements = Array.from(element.querySelectorAll("[type='drop']"));
|
|
70983
|
+
let check = false;
|
|
70984
|
+
dropElements.forEach(dropEl => {
|
|
70985
|
+
const dropVal = dropEl.getAttribute("value");
|
|
70986
|
+
if (dropVal && dropEl.innerText.trim() === "?") {
|
|
70987
|
+
dropEl.innerText = dropVal;
|
|
70988
|
+
if (dropElements.length > 1 && check == false) {
|
|
70989
|
+
if (window.innerWidth > window.innerHeight) {
|
|
70990
|
+
dropEl.style.marginRight = "-45px";
|
|
70991
|
+
}
|
|
70992
|
+
else {
|
|
70993
|
+
dropEl.style.marginRight = "-65px";
|
|
70994
|
+
}
|
|
70995
|
+
check = true;
|
|
70996
|
+
}
|
|
70997
|
+
}
|
|
70998
|
+
});
|
|
70999
|
+
};
|
|
71000
|
+
const SumTogetherAnimation = async (element, value) => {
|
|
71001
|
+
if (!element)
|
|
71002
|
+
return;
|
|
71003
|
+
if (!value)
|
|
71004
|
+
return;
|
|
71005
|
+
const container = document.getElementById(LidoContainer);
|
|
71006
|
+
if (!container)
|
|
71007
|
+
return;
|
|
71008
|
+
// Expecting structure: [_, TopRow, questionRow, optionRow, ...]
|
|
71009
|
+
const TopRow = Array.from(element.children)[1];
|
|
71010
|
+
const questionRow = Array.from(element.children)[2];
|
|
71011
|
+
const optionRow = Array.from(element.children)[3];
|
|
71012
|
+
if (!TopRow || !questionRow || !optionRow)
|
|
71013
|
+
return;
|
|
71014
|
+
const topRowChildren = Array.from(TopRow.children);
|
|
71015
|
+
const questionRowChildren = Array.from(questionRow.children);
|
|
71016
|
+
const firstNumberEl = questionRowChildren[0];
|
|
71017
|
+
const signElement = questionRowChildren[1];
|
|
71018
|
+
const secondNumberEl = questionRowChildren[2];
|
|
71019
|
+
const equalElement = questionRowChildren[3];
|
|
71020
|
+
const answerElement = questionRowChildren[4];
|
|
71021
|
+
// helper functions
|
|
71022
|
+
const showElement = (el) => {
|
|
71023
|
+
if (!el)
|
|
71024
|
+
return;
|
|
71025
|
+
el.style.visibility = 'visible';
|
|
71026
|
+
el.style.display = '';
|
|
71027
|
+
el.style.opacity = '1';
|
|
71028
|
+
};
|
|
71029
|
+
const readNumber = (el) => {
|
|
71030
|
+
if (!el)
|
|
71031
|
+
return 0;
|
|
71032
|
+
const v = (el.getAttribute && (el.getAttribute('value') || el.getAttribute('string'))) || el.textContent || '';
|
|
71033
|
+
return parseInt(String(v).trim(), 10) || 0;
|
|
71034
|
+
};
|
|
71035
|
+
const elementAppearance = async (flag) => {
|
|
71036
|
+
if (flag) {
|
|
71037
|
+
if (firstNumberEl) {
|
|
71038
|
+
await new Promise(r => setTimeout(r, 200));
|
|
71039
|
+
showElement(firstNumberEl);
|
|
71040
|
+
}
|
|
71041
|
+
if (signElement) {
|
|
71042
|
+
await new Promise(r => setTimeout(r, 200));
|
|
71043
|
+
showElement(signElement);
|
|
71044
|
+
}
|
|
71045
|
+
}
|
|
71046
|
+
else {
|
|
71047
|
+
if (secondNumberEl) {
|
|
71048
|
+
await new Promise(r => setTimeout(r, 200));
|
|
71049
|
+
showElement(secondNumberEl);
|
|
71050
|
+
}
|
|
71051
|
+
if (equalElement) {
|
|
71052
|
+
await new Promise(r => setTimeout(r, 300));
|
|
71053
|
+
showElement(equalElement);
|
|
71054
|
+
}
|
|
71055
|
+
if (optionRow) {
|
|
71056
|
+
await new Promise(r => setTimeout(r, 300));
|
|
71057
|
+
showElement(optionRow);
|
|
71058
|
+
}
|
|
71059
|
+
if (answerElement) {
|
|
71060
|
+
await new Promise(r => setTimeout(r, 200));
|
|
71061
|
+
showElement(answerElement);
|
|
71062
|
+
}
|
|
71063
|
+
}
|
|
71064
|
+
};
|
|
71065
|
+
const number1 = readNumber(firstNumberEl);
|
|
71066
|
+
const number2 = readNumber(secondNumberEl);
|
|
71067
|
+
const sign = ((signElement && ((signElement.getAttribute('string') || signElement.textContent) || '')).toString().trim() === '+') ? '+' : '-';
|
|
71068
|
+
if (sign === '-') {
|
|
71069
|
+
// '-' flow: reveal one by one then change bgColor of last B to red
|
|
71070
|
+
for (let i = 0; i < topRowChildren.length; i++) {
|
|
71071
|
+
await new Promise(resolve => setTimeout(resolve, 75));
|
|
71072
|
+
showElement(topRowChildren[i]);
|
|
71073
|
+
}
|
|
71074
|
+
elementAppearance(true);
|
|
71075
|
+
await new Promise(r => setTimeout(r, 500));
|
|
71076
|
+
for (let k = 0; k < Math.min(number2, topRowChildren.length); k++) {
|
|
71077
|
+
const idx = topRowChildren.length - 1 - k;
|
|
71078
|
+
setImageBackground(topRowChildren[idx], 'red');
|
|
71079
|
+
await new Promise(r => setTimeout(r, 200));
|
|
71080
|
+
}
|
|
71081
|
+
elementAppearance(false);
|
|
71082
|
+
}
|
|
71083
|
+
else {
|
|
71084
|
+
// '+' flow: hide all, then showElement first A, then showElement next B in green
|
|
71085
|
+
for (let i = 0; i < Math.min(number1, topRowChildren.length); i++) {
|
|
71086
|
+
await new Promise(resolve => setTimeout(resolve, 120));
|
|
71087
|
+
showElement(topRowChildren[i]);
|
|
71088
|
+
}
|
|
71089
|
+
elementAppearance(true);
|
|
71090
|
+
await new Promise(r => setTimeout(r, 500));
|
|
71091
|
+
for (let j = 0; j < Math.min(number2, Math.max(0, topRowChildren.length - number1)); j++) {
|
|
71092
|
+
const idx = number1 + j;
|
|
71093
|
+
if (topRowChildren[idx]) {
|
|
71094
|
+
showElement(topRowChildren[idx]);
|
|
71095
|
+
setImageBackground(topRowChildren[idx], 'green');
|
|
71096
|
+
}
|
|
71097
|
+
await new Promise(r => setTimeout(r, 80));
|
|
71098
|
+
}
|
|
71099
|
+
elementAppearance(false);
|
|
71100
|
+
}
|
|
71101
|
+
};
|
|
70222
71102
|
|
|
70223
|
-
export { ActivityScoreKey as A,
|
|
71103
|
+
export { ActivityScoreKey as A, generateUUIDFallback as B, exitUrl as C, prevUrl as D, nextUrl as E, speakUrl as F, getCancelBtnPopup as G, H, triggerPrevcontainer as I, setCancelBtnPopup as J, getDefaultExportFromCjs as K, LidoContainer as L, tinyColor as M, NextContainerKey as N, triggerNextContainer as O, PrevContainerKey as P, DropAction as Q, RiveService as R, SelectedValuesKey as S, validateObjectiveStatus as T, fraction as U, TraceMode as V, speakIcon as W, fingerUrl as X, setNonce as a, setPlatformOptions as b, commonjsGlobal as c, setVisibilityWithDelay as d, convertUrlToRelative as e, format as f, getAssetPath$1 as g, h, initEventsForElement as i, Host as j, parseProp as k, createEvent as l, equationCheck as m, storingEachActivityScore as n, executeActions as o, proxyCustomElement as p, handlingChildElements as q, attachSpeakIcon as r, setAssetPath as s, calculateScale as t, handleFloatElementPosition as u, handleElementClick as v, dispatchActivityChangeEvent as w, dispatchGameCompletedEvent as x, dispatchGameExitEvent as y, AudioPlayer as z };
|