-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
91 lines (72 loc) · 3.21 KB
/
index.js
File metadata and controls
91 lines (72 loc) · 3.21 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
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
window.addEventListener('load', () => {
// const handleResult = (ev) => {
// console.log(ev);
// }
// const handleError = (ev) => {
// console.log(ev);
// }
const getRand = (max) => Math.floor(Math.random() * Math.floor(max));
const handleSubmit = (address) => {
// const req = new XMLHttpRequest();
// req.addEventListener('load', handleResult);
// req.addEventListener('error', handleError);
// req.open('GET', 'http://localhost:5000/bullshit?address=' + address);
// req.send();
let blurbCntr = 0;
const blurbs = [
'Starting up the blockchain',
'Training the models',
'Entangling qubits',
'Powering up IoT devices',
'Linking docker containers',
'Calculating buzzwords'
];
const outcomes = [
'Congratulations! Your project is grade A certified bullshit!',
'Seems legit',
'What even is this?',
'You forgot a ;',
'Excellent work from an excellent team',
'Meh',
'Did you just try to concatenate buzzwords?',
'Give these guys the medal',
'You have security issues',
'It was ok. I installed a bitcoin miner in your server, hope you don\'t mind :)',
'Please bring a front-end guy next time, your site is hideous',
]
document.querySelector('.submit').style['display'] = 'none';
document.querySelector('.loaderContainer').style['display'] = 'flex';
document.querySelector('.loaderText').innerHTML = blurbs[blurbCntr];
const loaderWidth = document.querySelector('.loader').offsetWidth;
const interval = setInterval(() => {
const width = getRand(20) + 10;
const currWidth = document.querySelector('.progress').offsetWidth;
document.querySelector('.progress').style['width'] = (width + currWidth) + "px";
if(width > 20 && blurbCntr < blurbs.length - 1){
document.querySelector('.loaderText').innerHTML = blurbs[++blurbCntr];
}
if(currWidth + width >= loaderWidth) {
clearInterval(interval);
document.querySelector('.loaderContainer').style['display'] = 'none';
document.querySelector('.result').innerHTML = outcomes[getRand(outcomes.length - 1)];
document.querySelector('.resultContainer').style['display'] = 'block';
}
}, 300);
}
document.querySelector('.submit').addEventListener('click', () => {
const address = document.querySelector('.input').value
handleSubmit(address);
});
document.querySelector('.reset').addEventListener('click', () => {
document.querySelector('.resultContainer').style['display'] = 'none';
document.querySelector('.submit').style['display'] = 'block';
blurbCntr = 0;
document.querySelector('.progress').style['width'] = '';
});
document.addEventListener('keypress', (ev) => {
if (ev.key === 'Enter') {
const address = document.querySelector('.input').value
handleSubmit(address);
}
});
});