munchboka-edutools 0.1.13__py3-none-any.whl
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.
Potentially problematic release.
This version of munchboka-edutools might be problematic. Click here for more details.
- munchboka_edutools/__init__.py +184 -0
- munchboka_edutools/_plotmath_shim.py +126 -0
- munchboka_edutools/_version.py +2 -0
- munchboka_edutools/directives/__init__.py +1 -0
- munchboka_edutools/directives/admonitions.py +389 -0
- munchboka_edutools/directives/cas_popup.py +272 -0
- munchboka_edutools/directives/clear.py +103 -0
- munchboka_edutools/directives/dialogue.py +137 -0
- munchboka_edutools/directives/escape_room.py +296 -0
- munchboka_edutools/directives/factor_tree.py +549 -0
- munchboka_edutools/directives/ggb.py +209 -0
- munchboka_edutools/directives/ggb_icon.py +105 -0
- munchboka_edutools/directives/ggb_popup.py +165 -0
- munchboka_edutools/directives/horner.py +324 -0
- munchboka_edutools/directives/interactive_code.py +75 -0
- munchboka_edutools/directives/jeopardy.py +252 -0
- munchboka_edutools/directives/multi_plot.py +1126 -0
- munchboka_edutools/directives/pair_puzzle.py +191 -0
- munchboka_edutools/directives/parsons.py +109 -0
- munchboka_edutools/directives/plot.py +3105 -0
- munchboka_edutools/directives/poly_icon.py +111 -0
- munchboka_edutools/directives/polydiv.py +344 -0
- munchboka_edutools/directives/popup.py +245 -0
- munchboka_edutools/directives/quiz.py +291 -0
- munchboka_edutools/directives/signchart.py +516 -0
- munchboka_edutools/directives/timed_quiz.py +436 -0
- munchboka_edutools/directives/turtle.py +157 -0
- munchboka_edutools/static/css/admonitions.css +2012 -0
- munchboka_edutools/static/css/cas_popup.css +242 -0
- munchboka_edutools/static/css/code_mirror_themes/github_dark_cm.css +112 -0
- munchboka_edutools/static/css/code_mirror_themes/github_dark_default_cm.css +40 -0
- munchboka_edutools/static/css/code_mirror_themes/github_dark_high_contrast_cm.css +141 -0
- munchboka_edutools/static/css/code_mirror_themes/github_light_cm.css +120 -0
- munchboka_edutools/static/css/code_mirror_themes/github_light_default_cm.css +108 -0
- munchboka_edutools/static/css/code_mirror_themes/one_dark_cm.css +121 -0
- munchboka_edutools/static/css/dialogue.css +92 -0
- munchboka_edutools/static/css/escapeRoom/escape-room.css +223 -0
- munchboka_edutools/static/css/figures.css +274 -0
- munchboka_edutools/static/css/general_style.css +74 -0
- munchboka_edutools/static/css/github-dark-high-contrast.css +141 -0
- munchboka_edutools/static/css/github-dark.css +112 -0
- munchboka_edutools/static/css/github-light.css +120 -0
- munchboka_edutools/static/css/interactive_code/style.css +575 -0
- munchboka_edutools/static/css/interactive_code.css +582 -0
- munchboka_edutools/static/css/jeopardy.css +529 -0
- munchboka_edutools/static/css/pairPuzzle/style.css +177 -0
- munchboka_edutools/static/css/parsons/parsonsPuzzle.css +331 -0
- munchboka_edutools/static/css/popup.css +115 -0
- munchboka_edutools/static/css/quiz.css +312 -0
- munchboka_edutools/static/css/timedQuiz.css +375 -0
- munchboka_edutools/static/icons/ggb/mode_evaluate.svg +1 -0
- munchboka_edutools/static/icons/ggb/mode_extremum.svg +1 -0
- munchboka_edutools/static/icons/ggb/mode_intersect.svg +1 -0
- munchboka_edutools/static/icons/ggb/mode_nsolve.svg +1 -0
- munchboka_edutools/static/icons/ggb/mode_numeric.svg +1 -0
- munchboka_edutools/static/icons/ggb/mode_point.svg +1 -0
- munchboka_edutools/static/icons/ggb/mode_solve.svg +1 -0
- munchboka_edutools/static/icons/misc/windows-logo.svg +1 -0
- munchboka_edutools/static/icons/outline/dark_mode/academic.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/backward.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/book.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/chat_bubble.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/check.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/cmd_line.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/file.svg +1 -0
- munchboka_edutools/static/icons/outline/dark_mode/fire.svg +4 -0
- munchboka_edutools/static/icons/outline/dark_mode/key.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/magnifying.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/pencil_square.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/play.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/question.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/square_check.svg +1 -0
- munchboka_edutools/static/icons/outline/dark_mode/stop.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/summary.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/undo.svg +3 -0
- munchboka_edutools/static/icons/outline/dark_mode/unlock.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/academic.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/backward.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/book.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/chat_bubble.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/check.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/cmd_line.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/file.svg +1 -0
- munchboka_edutools/static/icons/outline/light_mode/fire.svg +4 -0
- munchboka_edutools/static/icons/outline/light_mode/key.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/magnifying.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/pencil_square.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/play.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/question.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/square_check.svg +1 -0
- munchboka_edutools/static/icons/outline/light_mode/stop.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/summary.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/undo.svg +3 -0
- munchboka_edutools/static/icons/outline/light_mode/unlock.svg +3 -0
- munchboka_edutools/static/icons/polyicons/cubicdown.svg +3 -0
- munchboka_edutools/static/icons/polyicons/cubicup.svg +3 -0
- munchboka_edutools/static/icons/polyicons/frown.svg +3 -0
- munchboka_edutools/static/icons/polyicons/smile.svg +3 -0
- munchboka_edutools/static/icons/solid/dark_mode/academic.svg +5 -0
- munchboka_edutools/static/icons/solid/dark_mode/backward.svg +3 -0
- munchboka_edutools/static/icons/solid/dark_mode/book.svg +3 -0
- munchboka_edutools/static/icons/solid/dark_mode/brain.svg +1 -0
- munchboka_edutools/static/icons/solid/dark_mode/file.svg +1 -0
- munchboka_edutools/static/icons/solid/dark_mode/fire.svg +3 -0
- munchboka_edutools/static/icons/solid/dark_mode/key.svg +3 -0
- munchboka_edutools/static/icons/solid/dark_mode/pencil_square.svg +4 -0
- munchboka_edutools/static/icons/solid/dark_mode/play.svg +3 -0
- munchboka_edutools/static/icons/solid/dark_mode/python.svg +1 -0
- munchboka_edutools/static/icons/solid/dark_mode/scroll.svg +1 -0
- munchboka_edutools/static/icons/solid/dark_mode/stop.svg +3 -0
- munchboka_edutools/static/icons/solid/light_mode/academic.svg +5 -0
- munchboka_edutools/static/icons/solid/light_mode/backward.svg +3 -0
- munchboka_edutools/static/icons/solid/light_mode/book.svg +3 -0
- munchboka_edutools/static/icons/solid/light_mode/brain.svg +1 -0
- munchboka_edutools/static/icons/solid/light_mode/file.svg +1 -0
- munchboka_edutools/static/icons/solid/light_mode/fire.svg +3 -0
- munchboka_edutools/static/icons/solid/light_mode/key.svg +3 -0
- munchboka_edutools/static/icons/solid/light_mode/pencil_square.svg +4 -0
- munchboka_edutools/static/icons/solid/light_mode/play.svg +3 -0
- munchboka_edutools/static/icons/solid/light_mode/python.svg +1 -0
- munchboka_edutools/static/icons/solid/light_mode/scroll.svg +1 -0
- munchboka_edutools/static/icons/solid/light_mode/stop.svg +3 -0
- munchboka_edutools/static/icons/stickers/edit.svg +1 -0
- munchboka_edutools/static/icons/stickers/pencil_square.svg +3 -0
- munchboka_edutools/static/js/casThemeManager.js +99 -0
- munchboka_edutools/static/js/escapeRoom/escape-room.js +219 -0
- munchboka_edutools/static/js/geogebra-setup.js +6 -0
- munchboka_edutools/static/js/highlight-init.js +6 -0
- munchboka_edutools/static/js/interactiveCode/codeEditor.js +632 -0
- munchboka_edutools/static/js/interactiveCode/interactiveCodeSetup.js +348 -0
- munchboka_edutools/static/js/interactiveCode/pythonRunner.js +336 -0
- munchboka_edutools/static/js/interactiveCode/turtleCode.js +203 -0
- munchboka_edutools/static/js/interactiveCode/workerManager.js +353 -0
- munchboka_edutools/static/js/jeopardy.js +523 -0
- munchboka_edutools/static/js/pairPuzzle/draggableItem.js +64 -0
- munchboka_edutools/static/js/pairPuzzle/dropZone.js +119 -0
- munchboka_edutools/static/js/pairPuzzle/game.js +160 -0
- munchboka_edutools/static/js/parsons/parsonsPuzzle.js +641 -0
- munchboka_edutools/static/js/popup.js +85 -0
- munchboka_edutools/static/js/quiz.js +422 -0
- munchboka_edutools/static/js/skulpt/skulpt.js +35721 -0
- munchboka_edutools/static/js/timedQuiz/multipleChoiceQuestion.js +184 -0
- munchboka_edutools/static/js/timedQuiz/timedMultipleChoiceQuiz.js +244 -0
- munchboka_edutools/static/js/timedQuiz/utils.js +6 -0
- munchboka_edutools/static/js/utils.js +3 -0
- munchboka_edutools-0.1.13.dist-info/METADATA +108 -0
- munchboka_edutools-0.1.13.dist-info/RECORD +149 -0
- munchboka_edutools-0.1.13.dist-info/WHEEL +4 -0
- munchboka_edutools-0.1.13.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
class DropZone {
|
|
2
|
+
constructor(id, uniqueId, gameInstance) {
|
|
3
|
+
this.id = id;
|
|
4
|
+
this.uniqueId = uniqueId;
|
|
5
|
+
this.items = [];
|
|
6
|
+
this.element = null;
|
|
7
|
+
this.placeholder = null;
|
|
8
|
+
this.game = gameInstance;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
createElement() {
|
|
12
|
+
const div = document.createElement('div');
|
|
13
|
+
div.classList.add('drop-zone');
|
|
14
|
+
div.dataset.id = this.id;
|
|
15
|
+
this.element = div;
|
|
16
|
+
|
|
17
|
+
// Create and add the placeholder element
|
|
18
|
+
this.placeholder = this.createPlaceholder();
|
|
19
|
+
div.appendChild(this.placeholder);
|
|
20
|
+
|
|
21
|
+
this.addDropEvents();
|
|
22
|
+
return div;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
createPlaceholder() {
|
|
26
|
+
const placeholder = document.createElement('div');
|
|
27
|
+
placeholder.classList.add('placeholder');
|
|
28
|
+
placeholder.textContent = 'Dra og dropp her'; // Customize your placeholder text here
|
|
29
|
+
return placeholder;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
addDropEvents() {
|
|
33
|
+
this.element.addEventListener('dragover', (e) => {
|
|
34
|
+
e.preventDefault(); // Necessary to allow dropping
|
|
35
|
+
this.element.classList.add('dropped');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this.element.addEventListener('dragleave', () => {
|
|
39
|
+
this.element.classList.remove('dropped');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
this.element.addEventListener('drop', (e) => {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
const itemId = e.dataTransfer.getData('text/plain');
|
|
45
|
+
const droppedItem = this.game.getItemById(itemId);
|
|
46
|
+
if (droppedItem) {
|
|
47
|
+
// If the item was previously in another drop zone or draggable container, remove it from there
|
|
48
|
+
const previousZone = this.game.getDropZoneContainingItem(droppedItem);
|
|
49
|
+
if (previousZone) {
|
|
50
|
+
previousZone.removeItem(droppedItem);
|
|
51
|
+
} else {
|
|
52
|
+
const draggableContainer = this.game.getDraggableContainer();
|
|
53
|
+
draggableContainer.removeChild(droppedItem.element);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.items.push(droppedItem);
|
|
57
|
+
droppedItem.element.style.opacity = '1'; // Ensure the item becomes visible after being dropped
|
|
58
|
+
this.element.insertBefore(droppedItem.element, this.placeholder); // Always append the item before the placeholder
|
|
59
|
+
|
|
60
|
+
// Re-render LaTeX in the drop zone
|
|
61
|
+
renderMathInElement(droppedItem.element, {
|
|
62
|
+
delimiters: [
|
|
63
|
+
{ left: "$$", right: "$$", display: true },
|
|
64
|
+
{ left: "$", right: "$", display: false },
|
|
65
|
+
{ left: "\\[", right: "\\]", display: true },
|
|
66
|
+
{ left: "\\(", right: "\\)", display: false }
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
this.element.classList.remove('dropped');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Update placeholder visibility
|
|
74
|
+
this.updatePlaceholderVisibility();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
updatePlaceholderVisibility() {
|
|
79
|
+
// Show the placeholder if there are less than two items
|
|
80
|
+
if (this.items.length < 2) {
|
|
81
|
+
this.placeholder.style.display = 'block';
|
|
82
|
+
this.element.appendChild(this.placeholder); // Ensure placeholder is always at the bottom
|
|
83
|
+
} else {
|
|
84
|
+
this.placeholder.style.display = 'none';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
removeItem(item) {
|
|
89
|
+
// Remove the item from the items array
|
|
90
|
+
this.items = this.items.filter(i => i.id !== item.id);
|
|
91
|
+
this.updatePlaceholderVisibility();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
clear() {
|
|
95
|
+
this.items = [];
|
|
96
|
+
this.element.innerHTML = ''; // Clear all children elements
|
|
97
|
+
this.element.appendChild(this.placeholder); // Re-add the placeholder
|
|
98
|
+
this.updatePlaceholderVisibility();
|
|
99
|
+
this.resetColor();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
isCorrect() {
|
|
103
|
+
if (this.items.length !== 2) return false;
|
|
104
|
+
return this.items[0].pairId === this.items[1].pairId;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Add color feedback to the drop zone
|
|
108
|
+
setCorrect() {
|
|
109
|
+
this.element.style.backgroundColor = 'rgba(0, 128, 0, 0.5)';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
setIncorrect() {
|
|
113
|
+
this.element.style.backgroundColor = 'rgba(255, 0, 0, 0.5)';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
resetColor() {
|
|
117
|
+
this.element.style.backgroundColor = '';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
function generateUUID() {
|
|
2
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
3
|
+
const r = Math.random() * 16 | 0,
|
|
4
|
+
v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
5
|
+
return v.toString(16);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Game {
|
|
11
|
+
constructor(containerId, pairs) {
|
|
12
|
+
this.containerId = containerId;
|
|
13
|
+
this.uniqueId = generateUUID();
|
|
14
|
+
this.container = document.getElementById(containerId);
|
|
15
|
+
this.pairs = pairs;
|
|
16
|
+
this.items = [];
|
|
17
|
+
this.dropZones = [];
|
|
18
|
+
this.init();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
init() {
|
|
22
|
+
this.generateHTML();
|
|
23
|
+
this.createItems();
|
|
24
|
+
this.createDropZones();
|
|
25
|
+
this.toast = this.createToast();
|
|
26
|
+
|
|
27
|
+
document.getElementById(`check-answer-${this.uniqueId}`).addEventListener('click', () => this.checkAnswer());
|
|
28
|
+
document.getElementById(`reset-puzzle-${this.uniqueId}`).addEventListener('click', () => this.resetPuzzle());
|
|
29
|
+
|
|
30
|
+
document.addEventListener('mousemove', (event) => {
|
|
31
|
+
this.cursorX = event.clientX;
|
|
32
|
+
this.cursorY = event.clientY;
|
|
33
|
+
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
generateHTML() {
|
|
38
|
+
if (!this.container) {
|
|
39
|
+
throw new Error('Container not found');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const uniqueId = this.uniqueId;
|
|
43
|
+
|
|
44
|
+
this.container.innerHTML = `
|
|
45
|
+
<div id="draggable-container-${uniqueId}" class="draggable-container"></div>
|
|
46
|
+
<div id="dropzone-container-${uniqueId}" class="drop-zone-container"></div>
|
|
47
|
+
<div class="button-container">
|
|
48
|
+
<button id="check-answer-${uniqueId}" class="button button-run">Sjekk svaret!</button>
|
|
49
|
+
<button id="reset-puzzle-${uniqueId}" class="button button-reset">Reset puslespill</button>
|
|
50
|
+
</div>
|
|
51
|
+
<!-- Toast Notification -->
|
|
52
|
+
<div id="toast-${uniqueId}" class="toast" style="display: none;">
|
|
53
|
+
<p>Riktig! Bra jobba 🔥</p>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
createItems() {
|
|
60
|
+
const itemsContainer = document.getElementById(`draggable-container-${this.uniqueId}`);
|
|
61
|
+
this.pairs.forEach((group, groupIndex) => {
|
|
62
|
+
group.forEach((item, itemIndex) => {
|
|
63
|
+
const draggableItem = new DraggableItem(`item-${groupIndex}-${itemIndex}`, item, groupIndex);
|
|
64
|
+
this.items.push(draggableItem);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Shuffle items before adding them to the container
|
|
69
|
+
this.items.sort(() => 0.5 - Math.random());
|
|
70
|
+
this.items.forEach((item) => itemsContainer.appendChild(item.createElement()));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
createDropZones() {
|
|
74
|
+
const dropzonesContainer = document.getElementById(`dropzone-container-${this.uniqueId}`);
|
|
75
|
+
this.pairs.forEach((_, index) => {
|
|
76
|
+
const dropZone = new DropZone(index, this.uniqueId, this);
|
|
77
|
+
this.dropZones.push(dropZone);
|
|
78
|
+
dropzonesContainer.appendChild(dropZone.createElement());
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getItemById(id) {
|
|
83
|
+
return this.items.find((item) => item.id === id);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getDropZoneContainingItem(item) {
|
|
87
|
+
return this.dropZones.find(zone => zone.items.includes(item));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getDraggableContainer() {
|
|
91
|
+
return document.getElementById(`draggable-container-${this.uniqueId}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
async checkAnswer() {
|
|
96
|
+
const results = await Promise.all(this.dropZones.map((zone) => zone.isCorrect()));
|
|
97
|
+
results.forEach((isCorrect, index) => {
|
|
98
|
+
const dropZone = this.dropZones[index];
|
|
99
|
+
if (isCorrect) {
|
|
100
|
+
dropZone.setCorrect(); // Set drop zone to green
|
|
101
|
+
} else {
|
|
102
|
+
dropZone.setIncorrect(); // Set drop zone to red
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const allCorrect = results.every(result => result);
|
|
107
|
+
if (allCorrect) {
|
|
108
|
+
this.showToast();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resetPuzzle() {
|
|
113
|
+
// Reset puzzle by returning all items back to the draggable container
|
|
114
|
+
const draggableContainer = this.getDraggableContainer();
|
|
115
|
+
this.items.forEach(item => {
|
|
116
|
+
draggableContainer.appendChild(item.element);
|
|
117
|
+
item.element.style.opacity = '1';
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Clear the drop zones
|
|
121
|
+
this.dropZones.forEach(zone => zone.clear());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
createToast() {
|
|
125
|
+
const toast = document.createElement('div');
|
|
126
|
+
toast.id = `toast-${this.uniqueId}`;
|
|
127
|
+
toast.className = 'toast';
|
|
128
|
+
toast.style.display = 'none';
|
|
129
|
+
toast.innerHTML = `
|
|
130
|
+
<p>Riktig! 🔥</p>
|
|
131
|
+
`;
|
|
132
|
+
|
|
133
|
+
document.body.appendChild(toast);
|
|
134
|
+
return toast;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
showToast() {
|
|
138
|
+
console.log("toast: ", this.toast);
|
|
139
|
+
|
|
140
|
+
console.log("X = ", this.cursorX);
|
|
141
|
+
console.log("Y = ", this.cursorY);
|
|
142
|
+
|
|
143
|
+
this.toast.style.top = `${this.cursorY - 150}px`;
|
|
144
|
+
this.toast.style.left = `${this.cursorX}px`;
|
|
145
|
+
|
|
146
|
+
this.toast.style.display = 'block';
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
this.toast.style.display = 'none';
|
|
152
|
+
}, 2500); // Display for 2.5 seconds (2000 ms)
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
function initGame(containerId, pairs) {
|
|
159
|
+
return new Game(containerId, pairs);
|
|
160
|
+
}
|