-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJavascript.js
More file actions
60 lines (50 loc) · 1.97 KB
/
Javascript.js
File metadata and controls
60 lines (50 loc) · 1.97 KB
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
// [}EVSOC_ logo on index.html animation
const codeStrings = [
`[}EVSOC_`,
`Code`,
`Chat`,
`Game`,
]
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function initRotate(spanElement, period, strings = codeStrings) {
while(true) {
for (string of strings) {
let viewedStr = ""
// Repeatedly add a char onto the displayed string
for (char of string.split("")) {
viewedStr += char
spanElement.innerHTML = `<span class="wrap">${viewedStr}<span>`;
await sleep(200 - Math.random() * 100);
}
await sleep(period);
// Repeatedly "delete" the rightmost char
for (let i = string.length; i > 0; i--) {
spanElement.innerHTML = `<span class="wrap">${string.substring(0, i)}<span>`;
await sleep(100 - Math.random() * 50);
}
}
}
}
window.onload = function() {
for (element of document.getElementsByClassName('typewrite')) {
var period = element.getAttribute('data-period');
initRotate(element, period);
}
// INJECT CSS
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid #fff}";
document.body.appendChild(css);
};
// Warning for closed events
$('#warning').click(function (e) {
e.preventDefault()
$('#messageWarning').html('<div class="alert alert-danger fade-in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">×</button><strong>Alert:</strong> This event has ended. Try another one! :)</div>');
})
// Warning for pending events
$('#pending').click(function (e) {
e.preventDefault()
$('#messagePending').html('<div class="alert alert-success fade-in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">×</button><strong>Alert:</strong> Event details are pending. Try again later! :)</div>');
})