-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
202 lines (175 loc) · 5.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html>
<head>
<title>The Useless Machine</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@700&display=swap" rel="stylesheet">
<style>
#container {
display: flex;
justify-content: center;
}
.bulb-container {
display: flex;
flex-direction: column;
align-items: center;
margin: 10px;
text-align: center;
}
.bulb-image {
width: 20px;
}
.bulb-btn {
margin-top: 10px;
}
h1 {
color: #ffffff;
text-align: center;
font-family: 'Comfortaa', cursive;
}
.hand-animation {
position: absolute;
width: 20px;
height: 20px;
background-image: url('https://img-s1.onedio.com/id-6283f409f2d042004140e5fe/rev-0/w-1200/h-1594/f-jpg/s-93c222b019f2b26ec5431bb571479da90ae4019e.jpg');
background-size: cover;
animation-name: clickAnimation;
animation-duration: 0.5s;
animation-fill-mode: forwards;
opacity: 1;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
}
@keyframes clickAnimation {
0% {
opacity: 0;
transform: translate(-50%, -50%) scale(0.2);
}
100% {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
}
.achievement-container {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
animation-name: slideIn;
animation-duration: 2s;
animation-fill-mode: forwards;
opacity: 0;
z-index: 9999;
}
@keyframes slideIn {
0% {
opacity: 0;
transform: translate(-50%, -200%);
}
100% {
opacity: 1;
transform: translate(-50%, -50%);
}
}
.achievement-image {
width: 300px;
height: 80px;
background-image: url('https://minecraftpanda.com/tools/achievement-generator/output?icon=14&title=Achievement%20Get%21&text=Power%20Waster%21');
background-size: contain;
background-repeat: no-repeat;
}
</style>
<script>
function getElementCoordinates(elementId) {
var element = document.getElementById(elementId);
var rect = element.getBoundingClientRect();
var coordinates = {
top: rect.top + rect.height / 2 + window.pageYOffset,
left: rect.left + rect.width / 2 + window.pageXOffset
};
return coordinates;
}
window.addEventListener('DOMContentLoaded', function() {
var container = document.getElementById('container');
for (var i = 0; i < 12; i++) {
// Create the bulb container div
var bulbContainer = document.createElement('div');
bulbContainer.className = 'bulb-container';
// Create the image element
var image = document.createElement('img');
image.alt = "bulb";
image.src = 'https://i.postimg.cc/KjK1wL3c/bulb-off.png';
var uniqueImageId = 'bulb-' + i;
image.id = uniqueImageId;
image.className = 'bulb-image';
bulbContainer.appendChild(image);
// Create the button element
var button = document.createElement('button');
button.textContent = 'On';
var uniqueButtonId = 'on-' + i;
button.id = uniqueButtonId;
button.type = "button";
button.style.backgroundColor = "#212121";
button.style.color = "#ffffff";
button.className = 'bulb-btn';
button.setAttribute('onclick', 'bulb_on("' + uniqueImageId + '","' + uniqueButtonId + '")');
bulbContainer.appendChild(button);
container.appendChild(bulbContainer);
}
});
function bulb_off(imageId) {
document.getElementById(imageId).src = 'https://i.postimg.cc/KjK1wL3c/bulb-off.png';
}
function bulb_on(imageId, buttonId) {
// Implement the functionality to turn on the bulb here
var image = document.getElementById(imageId);
image.src = 'https://i.postimg.cc/6QyTynzr/bulb-on.png';
// Check if all bulbs are on
var allBulbsOn = true;
var bulbImages = document.getElementsByClassName('bulb-image');
for (var i = 0; i < bulbImages.length; i++) {
if (bulbImages[i].src.indexOf('bulb-off') !== -1) {
allBulbsOn = false;
break;
}
}
if (allBulbsOn) {
// Create the achievement container
var achievementContainer = document.createElement('div');
achievementContainer.className = 'achievement-container';
// Create the achievement image
var achievementImage = document.createElement('div');
achievementImage.className = 'achievement-image';
achievementContainer.appendChild(achievementImage);
document.body.appendChild(achievementContainer);
// Set a timeout to remove the achievement container
setTimeout(function() {
document.body.removeChild(achievementContainer);
}, 3000); // 3 seconds
// Log the achievement to the console
console.log('Achievement: Power Waster');
}
// Get button coordinates
var buttonCoordinates = getElementCoordinates(buttonId);
// Trigger the hand animation
var handAnimation = document.createElement('div');
handAnimation.className = 'hand-animation';
handAnimation.style.top = buttonCoordinates.top + 'px';
handAnimation.style.left = buttonCoordinates.left + 'px';
document.body.appendChild(handAnimation);
setTimeout(function() {
bulb_off(imageId);
setTimeout(function() {
document.body.removeChild(handAnimation);
}, 500);
}, 1200); // 0.3 seconds before the light turns off (3 seconds total) Ammended to 1.5s because someone wanted a challenge
}
</script>
</head>
<body style="background-color:#212121;">
<h1>The Useless Machine</h1>
<div id="container"></div>
</body>
</html>