Spaces:
Sleeping
Sleeping
Commit
·
1813729
1
Parent(s):
8dd2299
Add debug traces
Browse files- index.html +12 -1
index.html
CHANGED
|
@@ -43,13 +43,14 @@
|
|
| 43 |
<canvas id="drawing-canvas"></canvas>
|
| 44 |
<div id="text-container">
|
| 45 |
<h1>Randomizer</h1>
|
| 46 |
-
<p>put your finger to decide</p>
|
| 47 |
</div>
|
| 48 |
</div>
|
| 49 |
<script>
|
| 50 |
document.addEventListener('DOMContentLoaded', () => {
|
| 51 |
const canvas = document.getElementById('drawing-canvas');
|
| 52 |
const ctx = canvas.getContext('2d');
|
|
|
|
| 53 |
let circles = [];
|
| 54 |
let timer = null;
|
| 55 |
let animationId = null;
|
|
@@ -66,6 +67,7 @@
|
|
| 66 |
function resetTimer() {
|
| 67 |
clearTimeout(timer);
|
| 68 |
timer = setTimeout(decideWinner, 5000);
|
|
|
|
| 69 |
}
|
| 70 |
|
| 71 |
function decideWinner() {
|
|
@@ -77,6 +79,11 @@
|
|
| 77 |
// Clear all circles
|
| 78 |
circles = [winnerCircle];
|
| 79 |
winnerCircle.color = 'green';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
}
|
| 81 |
|
| 82 |
function draw() {
|
|
@@ -99,6 +106,7 @@
|
|
| 99 |
function addCircle(x, y, id) {
|
| 100 |
circles.push({ id, x, y, color: 'white' });
|
| 101 |
resetTimer();
|
|
|
|
| 102 |
}
|
| 103 |
|
| 104 |
function updateCircle(id, x, y) {
|
|
@@ -106,12 +114,14 @@
|
|
| 106 |
if (circle) {
|
| 107 |
circle.x = x;
|
| 108 |
circle.y = y;
|
|
|
|
| 109 |
}
|
| 110 |
}
|
| 111 |
|
| 112 |
function removeCircle(id) {
|
| 113 |
circles = circles.filter(c => c.id !== id);
|
| 114 |
resetTimer();
|
|
|
|
| 115 |
}
|
| 116 |
|
| 117 |
canvas.addEventListener('touchstart', (event) => {
|
|
@@ -143,6 +153,7 @@
|
|
| 143 |
|
| 144 |
// Start the drawing loop
|
| 145 |
draw();
|
|
|
|
| 146 |
});
|
| 147 |
</script>
|
| 148 |
</body>
|
|
|
|
| 43 |
<canvas id="drawing-canvas"></canvas>
|
| 44 |
<div id="text-container">
|
| 45 |
<h1>Randomizer</h1>
|
| 46 |
+
<p id="status-text">put your finger to decide</p>
|
| 47 |
</div>
|
| 48 |
</div>
|
| 49 |
<script>
|
| 50 |
document.addEventListener('DOMContentLoaded', () => {
|
| 51 |
const canvas = document.getElementById('drawing-canvas');
|
| 52 |
const ctx = canvas.getContext('2d');
|
| 53 |
+
const statusText = document.getElementById('status-text');
|
| 54 |
let circles = [];
|
| 55 |
let timer = null;
|
| 56 |
let animationId = null;
|
|
|
|
| 67 |
function resetTimer() {
|
| 68 |
clearTimeout(timer);
|
| 69 |
timer = setTimeout(decideWinner, 5000);
|
| 70 |
+
updateStatusText('Timer reset');
|
| 71 |
}
|
| 72 |
|
| 73 |
function decideWinner() {
|
|
|
|
| 79 |
// Clear all circles
|
| 80 |
circles = [winnerCircle];
|
| 81 |
winnerCircle.color = 'green';
|
| 82 |
+
updateStatusText(`Winner decided: Circle ${winnerCircle.id}`);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function updateStatusText(text) {
|
| 86 |
+
statusText.textContent = text;
|
| 87 |
}
|
| 88 |
|
| 89 |
function draw() {
|
|
|
|
| 106 |
function addCircle(x, y, id) {
|
| 107 |
circles.push({ id, x, y, color: 'white' });
|
| 108 |
resetTimer();
|
| 109 |
+
updateStatusText(`Circle added: ${id}`);
|
| 110 |
}
|
| 111 |
|
| 112 |
function updateCircle(id, x, y) {
|
|
|
|
| 114 |
if (circle) {
|
| 115 |
circle.x = x;
|
| 116 |
circle.y = y;
|
| 117 |
+
updateStatusText(`Circle updated: ${id}`);
|
| 118 |
}
|
| 119 |
}
|
| 120 |
|
| 121 |
function removeCircle(id) {
|
| 122 |
circles = circles.filter(c => c.id !== id);
|
| 123 |
resetTimer();
|
| 124 |
+
updateStatusText(`Circle removed: ${id}`);
|
| 125 |
}
|
| 126 |
|
| 127 |
canvas.addEventListener('touchstart', (event) => {
|
|
|
|
| 153 |
|
| 154 |
// Start the drawing loop
|
| 155 |
draw();
|
| 156 |
+
updateStatusText('Drawing loop started');
|
| 157 |
});
|
| 158 |
</script>
|
| 159 |
</body>
|