Spaces:
Sleeping
Sleeping
Commit
·
ce68975
1
Parent(s):
7502e91
Initial version
Browse files- Dockerfile +11 -0
- index.html +142 -0
Dockerfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Nginx image as the base
|
| 2 |
+
FROM nginx:alpine
|
| 3 |
+
|
| 4 |
+
# Copy the HTML file to the Nginx default directory
|
| 5 |
+
COPY index.html /usr/share/nginx/html
|
| 6 |
+
|
| 7 |
+
# Expose port 80 to allow external access
|
| 8 |
+
EXPOSE 80
|
| 9 |
+
|
| 10 |
+
# Start Nginx when the container launches
|
| 11 |
+
CMD ["nginx", "-g", "daemon off;"]
|
index.html
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Randomizer</title>
|
| 7 |
+
<style>
|
| 8 |
+
body, html {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
height: 100%;
|
| 12 |
+
width: 100%;
|
| 13 |
+
overflow: hidden;
|
| 14 |
+
display: flex;
|
| 15 |
+
justify-content: center;
|
| 16 |
+
align-items: center;
|
| 17 |
+
background-color: lightblue;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
#canvas {
|
| 21 |
+
width: 100%;
|
| 22 |
+
height: 100%;
|
| 23 |
+
display: flex;
|
| 24 |
+
flex-direction: column;
|
| 25 |
+
justify-content: center;
|
| 26 |
+
align-items: center;
|
| 27 |
+
position: relative;
|
| 28 |
+
background-color: lightblue;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
h1, p {
|
| 32 |
+
color: white;
|
| 33 |
+
text-align: center;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.circle {
|
| 37 |
+
position: absolute;
|
| 38 |
+
width: 50px;
|
| 39 |
+
height: 50px;
|
| 40 |
+
background-color: white;
|
| 41 |
+
border-radius: 50%;
|
| 42 |
+
transform: translate(-50%, -50%);
|
| 43 |
+
pointer-events: none;
|
| 44 |
+
}
|
| 45 |
+
</style>
|
| 46 |
+
</head>
|
| 47 |
+
<body>
|
| 48 |
+
<div id="canvas">
|
| 49 |
+
<h1>Randomizer</h1>
|
| 50 |
+
<p>put your finger to decide</p>
|
| 51 |
+
</div>
|
| 52 |
+
<script>
|
| 53 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 54 |
+
const canvas = document.getElementById('canvas');
|
| 55 |
+
let circles = [];
|
| 56 |
+
let timer = null;
|
| 57 |
+
|
| 58 |
+
function resetTimer() {
|
| 59 |
+
if (timer) {
|
| 60 |
+
clearTimeout(timer);
|
| 61 |
+
}
|
| 62 |
+
timer = setTimeout(decideWinner, 5000);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
function decideWinner() {
|
| 66 |
+
if (circles.length === 0) return;
|
| 67 |
+
|
| 68 |
+
const winnerIndex = Math.floor(Math.random() * circles.length);
|
| 69 |
+
const winnerCircle = circles[winnerIndex];
|
| 70 |
+
|
| 71 |
+
// Remove all circles
|
| 72 |
+
circles.forEach(circle => {
|
| 73 |
+
if (circle.element && circle.element.parentNode) {
|
| 74 |
+
circle.element.parentNode.removeChild(circle.element);
|
| 75 |
+
}
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
// Change the winner's circle to green
|
| 79 |
+
if (winnerCircle.element) {
|
| 80 |
+
winnerCircle.element.style.backgroundColor = 'green';
|
| 81 |
+
canvas.appendChild(winnerCircle.element);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
circles = [winnerCircle];
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
function createCircle(x, y, id) {
|
| 88 |
+
const circle = document.createElement('div');
|
| 89 |
+
circle.className = 'circle';
|
| 90 |
+
circle.style.left = `${x}px`;
|
| 91 |
+
circle.style.top = `${y}px`;
|
| 92 |
+
circle.id = `circle-${id}`;
|
| 93 |
+
canvas.appendChild(circle);
|
| 94 |
+
|
| 95 |
+
return circle;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
canvas.addEventListener('touchstart', (event) => {
|
| 99 |
+
event.preventDefault();
|
| 100 |
+
const touches = event.touches;
|
| 101 |
+
for (let i = 0; i < touches.length; i++) {
|
| 102 |
+
const touch = touches[i];
|
| 103 |
+
const circle = createCircle(touch.clientX, touch.clientY, touch.identifier);
|
| 104 |
+
circles.push({ id: touch.identifier, element: circle, x: touch.clientX, y: touch.clientY });
|
| 105 |
+
}
|
| 106 |
+
resetTimer();
|
| 107 |
+
});
|
| 108 |
+
|
| 109 |
+
canvas.addEventListener('touchmove', (event) => {
|
| 110 |
+
event.preventDefault();
|
| 111 |
+
const touches = event.touches;
|
| 112 |
+
for (let i = 0; i < touches.length; i++) {
|
| 113 |
+
const touch = touches[i];
|
| 114 |
+
const circleIndex = circles.findIndex(c => c.id === touch.identifier);
|
| 115 |
+
if (circleIndex !== -1) {
|
| 116 |
+
circles[circleIndex].x = touch.clientX;
|
| 117 |
+
circles[circleIndex].y = touch.clientY;
|
| 118 |
+
circles[circleIndex].element.style.left = `${touch.clientX}px`;
|
| 119 |
+
circles[circleIndex].element.style.top = `${touch.clientY}px`;
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
});
|
| 123 |
+
|
| 124 |
+
canvas.addEventListener('touchend', (event) => {
|
| 125 |
+
event.preventDefault();
|
| 126 |
+
const touches = event.changedTouches;
|
| 127 |
+
for (let i = 0; i < touches.length; i++) {
|
| 128 |
+
const touch = touches[i];
|
| 129 |
+
const circleIndex = circles.findIndex(c => c.id === touch.identifier);
|
| 130 |
+
if (circleIndex !== -1) {
|
| 131 |
+
if (circles[circleIndex].element && circles[circleIndex].element.parentNode) {
|
| 132 |
+
circles[circleIndex].element.parentNode.removeChild(circles[circleIndex].element);
|
| 133 |
+
}
|
| 134 |
+
circles.splice(circleIndex, 1);
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
resetTimer();
|
| 138 |
+
});
|
| 139 |
+
});
|
| 140 |
+
</script>
|
| 141 |
+
</body>
|
| 142 |
+
</html>
|