-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
129 lines (116 loc) · 3.81 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
<!DOCTYPE html>
<html>
<head>
<script>
let name1 = 'Julie';
let name2 = 'Benoît';
let durations = ['1 soirée', '3 jours', '2 semaines', '1 mois', '4 mois', '6 mois', '1 an', '3 ans', '5 ans', '10 ans', '15 ans', '20 ans'];
let events = ["il a rencontré quelqu'un d'autre au travail", "elle aime dormir avec ses chaussettes", "il voudrait faire le tour du monde"];
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
function getRandomFromArray(array) {
return array.splice(getRandomInt(array.length),1);
}
function randomizerDuration() {
return getRandomFromArray(durations);
}
function randomizerEvent() {
return getRandomFromArray(events);
}
function setClass(id, className) {
var e = document.getElementById(id);
e.className = className;
}
function addClass(id, className) {
var e = document.getElementById(id);
e.classList.add(className);
}
function removeClass(id, className) {
var e = document.getElementById(id);
e.classList.remove(className);
}
function setContent(id, content) {
var e = document.getElementById(id);
e.innerHTML = content;
}
function resetAll() {
setContent('duration', '');
setContent('event', '');
setClass('clock', 'spinOff');
}
function clockTimer() {
console.log('done');
addClass('clock', 'spinOff');
setContent('duration', randomizerDuration());
}
function spinClock(duration) {
setContent('duration', '');
removeClass('clock', 'spinOff');
setTimeout(clockTimer, duration);
}
function timerEvent() {
removeClass('event', 'lds-hourglass');
setContent('event', randomizerEvent());
}
function spinEvent(duration) {
setContent('event', '');
addClass('event', 'lds-hourglass');
setTimeout(timerEvent, duration);
}
function throwTheDices() {
spinClock(5000);
spinEvent(7500);
}
function fade(out) {
document.body.className = out ? 'fadeout' : '';
}
let actionStep = 2;
function action() {
switch (actionStep % 3) {
case 0: throwTheDices(); break;
case 1: fade(true); break;
case 2: resetAll(); fade(false); break;
}
++actionStep;
}
function load() {
setContent('name1', name1);
setContent('name2', name2);
resetAll();
}
</script>
<Link rel="StyleSheet" href="reset.css" type="text/css" />
<Link rel="StyleSheet" href="global.css" type="text/css" />
<Link rel="StyleSheet" href="spin.css" type="text/css" />
</head>
<body onload="load()" onclick="action()" class="fadeout">
<div class="fullHeight">
<div class="names">
<span id="name1"></span>
<span id="name2"></span>
</div>
<div class="center">
<svg id="svg" width="500" height="500" xmlns="http://www.w3.org/2000/svg">
<circle cx="50%" cy="50%" r="245" stroke="white" stroke-width="5" fill="none" />
<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" fill="white" id="duration"></text>
<g id="clock" class="spinOff">
<line x1="50%" y1="50%" x2="50%" y2="5%" stroke="white" stroke-width="5">
<animateTransform attributeName="transform" type="rotate" dur="0.75s" values="0 250 250;360 250 250"
repeatCount="indefinite" />
</line>
<line x1="50%" y1="50%" x2="50%" y2="15%" stroke="white" stroke-width="5">
<animateTransform attributeName="transform" type="rotate" dur="9s" values="0 250 250;360 250 250"
repeatCount="indefinite" />
</line>
</g>
</svg>
</div>
<div class="center">
<div id="event">
</div>
</div>
</div>
</body>
</html>
<!-- https://github.com/n3r4zzurr0/svg-spinners -->