This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ejs
247 lines (230 loc) · 5.32 KB
/
index.ejs
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
}
body {
background: linear-gradient(120deg, #324746, #45414E);
background-size: cover;
overflow: hidden;
font-family: sans-serif;
}
button {
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
}
.button-alt {
transform: translate(-50%, 70%) !important;
}
button {
background: none;
color: #ccc;
width: 220px;
height: 70px;
border: 1px solid <% if(isAlive) { %>#338033<% } else { %>#c2001a<% } %>;
font-size: 18px;
border-radius: 4px;
transition: .6s;
overflow: hidden;
}
button:focus {
outline: none;
}
button:before {
content: '';
display: block;
position: absolute;
background: rgba(255, 255, 255, .5);
width: 60px;
height: 100%;
left: 0;
top: 0;
opacity: .5s;
filter: blur(30px);
transform: translateX(-130px) skewX(-15deg);
}
button:after {
content: '';
display: block;
position: absolute;
background: rgba(255, 255, 255, .2);
width: 30px;
height: 100%;
left: 30px;
top: 0;
opacity: 0;
filter: blur(30px);
transform: translate(-100px) scaleX(-15deg);
}
button:hover {
background: <% if(isAlive) { %>#338033<% } else { %>#c2001a<% } %>;
cursor: pointer;
}
button:hover:before {
transform: translateX(300px) skewX(-15deg);
opacity: .6;
transition: .7s;
}
button:hover:after {
transform: translateX(300px) skewX(-15deg);
opacity: .6;
transition: .7s;
}
box-lol {
position: absolute;
top: 60%;
left: 50%;
background: none;
color: #ccc;
width: 220px;
height: 70px;
border: 1px solid <% if(isAlive) { %>#338033<% } else { %>#c2001a<% } %>;
font-size: 18px;
border-radius: 4px;
transition: .6s;
overflow: hidden;
}
.bar {
background-color: #338033;
width: <%=healthNumber %>px;
height: 20px;
border-radius: 5px;
margin-top: 3em;
margin-bottom: 1em;
transition: all 1s ease;
}
.bar-align {
margin-top: 10%;
display: flex;
justify-content: center;
align-items: center;
}
</style>
<title>The Button</title>
</head>
<body>
<div class="container-1">
<div class="container-bar">
<div class="bar-align">
<div class="bar" id="bar">
</div>
</div>
</div>
<div class="container-btn">
<div class="wrapper">
<div class="btn">
<form action="/" method="POST">
<%- captcha%>
<button type='submit' disabled id="submitButton">Click here to heal</button><br/>
</form>
<% if(userRank) { %>
<a href="<%=discordUrl %>"><button type='submit' class="button-alt" id="submitButton">Claim your <%=userRank %> rank on Discord.</button></a><br/>
<% } %>
</div>
</div>
</div>
</div>
</body>
<script>
const ranks = [
{
name: "A normal Vukky",
color: "#477891"
},
{
name: "Kind of a cool person",
color: "#363eca"
},
{
name: "Cool person",
color: "#2c04ca"
},
{
name: "Button Fanatic",
color: "#4e199b"
},
{
name: "Row-bot",
color: "#6f018a"
},
{
name: "niko",
color: "#db00ff"
},
{
name: "h",
color: "#ff23a7"
},
{
name: "no pls",
color: "#ff0061"
},
{
name: "touch grass",
color: "#00ff35"
},
{
name: "dead",
color: "#000000"
}
]
function roleNameToHex(roleName) {
return new Promise((resolve, reject) => {
ranks.forEach(rank => {
if (rank.name == roleName) {
resolve(rank.color)
}
})
});
}
function cb(token) {
/*
I would like to note that this isn't designed by me.
I took it off the example project of the node package, it seems a bit silly to me.
Surely there is a better way, but it works so I'll stick with it.
Ok I made some small edits to it, but it is still quite stupid.
- Skelly
*/
var input = document.createElement('input');
input.style.display = "none"
input.setAttribute('type', 'text');
input.setAttribute('name', 'g-recaptcha-response');
input.setAttribute('value', token);
document.getElementsByTagName('form')[0].appendChild(input);
document.getElementById("submitButton").disabled = <%=!isAlive %>;
roleNameToHex("<%=health %>").then(color => {
document.getElementById("bar").style.backgroundColor = color;
})
}
setInterval(() => {
console.log("getting new health");
fetch('/health')
.then(response => response.json())
.then(data => {
document.getElementById("submitButton").disabled = !data.isAlive;
if(document.getElementById("bar").style.width && document.getElementById("bar").style.width.split("px")[0] < data.health) new Audio("/resources/heal.wav").play();
document.getElementById("bar").style.width = `${data.health}px`;
roleNameToHex(data.healthLevel).then(color => {
document.getElementById("bar").style.backgroundColor = color;
})
if (!data.isAlive) {
location.reload()
}
console.log("new health is " + data.health)
});
}, 6000)
setTimeout(() => {
location.reload()
}, 120000)
</script>
</html>