-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.html
202 lines (184 loc) · 8.21 KB
/
demo.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 lang="en">
<head>
<title>Demo - gpu-loading-overlay</title>
<!-- specify utf-8 encoding -->
<meta charset="utf-8">
<style>
.clock-button {
background-color: blueviolet;
padding: 0.5em;
color: white;
}
.clock-placement {
position: fixed;
/* Fixed/sticky position */
top: 20px;
/* Place the button at the top of the page */
right: 30px;
/* Place the button 30px from the right */
z-index: 99;
/* Make sure it does not overlap */
}
</style>
</head>
<body>
<h1>gpu-loading-overlay demo</h1>
<div class="clock-button clock-placement" aria-hidden="true">
<svg width="1em" height="1em" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
<g><path fill="#FFFFFF" d="M500,986.9c-270.6,0-490-218-490-486.9C10,231.1,229.4,13.1,500,13.1c270.6,0,490,218,490,486.9C990,768.9,770.6,986.9,500,986.9z M500,104.4c-219.9,0-398.1,177.1-398.1,395.6c0,218.5,178.2,395.6,398.1,395.6S898.1,718.5,898.1,500C898.1,281.5,719.8,104.4,500,104.4z M699,545.7h-91.9h-61.2h-46l0,0c-25.4,0-45.9-20.4-45.9-45.7V226.1c0-25.2,20.5-45.7,45.9-45.7c25.4,0,46,20.4,46,45.7v228.3h61.2H699c25.4,0,45.9,20.4,45.9,45.6C745,525.2,724.4,545.7,699,545.7z"/></g>
</svg>
<span id="clock"></span>
</div>
<hr>
<div id="show-3-seconds">
<h3>Fixed time example</h3>
<p>
<button id="show-3-seconds-btn">Show for 3 Seconds</button>
</p>
</div>
<hr>
<div id="show-n-seconds">
<h3>Configurable time example</h3>
<form id="show-n-seconds-form">
<p>
<input required type="number" id="show-n-seconds-number" placeholder="number of seconds" min="1">
</p>
<p>
<button type="submit">Show for N Seconds</button>
</p>
</form>
</div>
<hr>
<div id="race-1">
<h3>Overlapping / Race example #1</h3>
<p>
<button id="race-1-btn">"loadingOverlay.activate()" twice: 3 sec & 5 sec</button>
</p>
<small>
<p>Invokes "activate()" function 2 times successively, tracking each "spinHandle" respectively. </p>
<p>The 1st invokation's spinHandle is cancelled after 3 seconds, the 2nd invokation's spinHandle is cancelled after 5 seconds. </p>
<p>Thus, the overlay should stay on for 5 seconds total.</p>
</small>
<p>
<div for="race-1-spin-handle-1"><label><small>spinHandle1 (3 seconds)</small></label></div>
<input readonly type="text" id="race-1-spin-handle-1" placeholder="spinHandle1" size="40">
</p>
<p>
<div for="race-1-spin-handle-2"><label><small>spinHandle2 (5 seconds)</small></label></div>
<input readonly type="text" id="race-1-spin-handle-2" placeholder="spinHandle2" size="40">
</p>
</div>
<hr>
<div id="race-2">
<h3>Overlapping / Race example #2</h3>
<p>
<button id="race-2-btn">"loadingOverlay.activate()" twice: 5 sec & 3 sec</button>
</p>
<small>
<p>Invokes "activate()" function 2 times successively, tracking each "spinHandle" respectively. </p>
<p>The 1st invokation's spinHandle is cancelled after 5 seconds, the 2nd invokation's spinHandle is cancelled after 3 seconds. </p>
<p>Thus, the overlay should stay on for 5 seconds total.</p>
</small>
<p>
<div for="race-2-spin-handle-1"><label><small>spinHandle1 (5 seconds)</small></label></div>
<input readonly type="text" id="race-2-spin-handle-1" placeholder="spinHandle1" size="40">
</p>
<p>
<div for="race-2-spin-handle-2"><label><small>spinHandle2 (3 seconds)</small></label></div>
<input readonly type="text" id="race-2-spin-handle-2" placeholder="spinHandle2" size="40">
</p>
</div>
<hr>
<small>
<p>© 2014-2017 Doug Bird - All Rights Reserved.</p>
<p>This demo and the gpu-loading-overlay module are distributed under the terms of the MIT license.</p>
<p>Clock icon © onlinewebfonts.com and distributed under terms of the Creative Commons 3.0 License.</p>
</small>
<hr>
<!-- display time for reference -->
<script>
/*
* Display a clock at the top of the page
*/
(function() {
var checkTime = function() {
var now = new Date();
var timeString = String(now.getHours()).padStart(2, "0") + ":" +
String(now.getMinutes()).padStart(2, "0") + ":" +
String(now.getSeconds()).padStart(2, "0");
if (document.getElementById('clock').innerHTML != timeString) {
document.getElementById('clock').innerHTML = timeString;
}
setTimeout(checkTime, 100);
}
checkTime();
})();
</script>
<!-- jQuery: Dependency of loadingOverlay.js -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha384-xBuQ/xzmlsLoJpyjoggmTEz8OWUFM0/RC5BsqQBDX2v5cMvDHcMakNTNrHIW2I5f" crossorigin="anonymous"></script>
<!-- loadingOverlay module -->
<script src="src/loadingOverlay.js"></script>
<script data-example="show-3-seconds">
(function() {
var show3SecondsBtn = document.getElementById('show-3-seconds-btn');
show3SecondsBtn.onclick = function() {
var spinHandle = loadingOverlay.activate();
setTimeout(function() {
loadingOverlay.cancel(spinHandle);
}, 3000);
return false;
};
})();
</script>
<script data-example="show-n-seconds">
(function() {
var showNSecondsForm = document.getElementById('show-n-seconds-form');
showNSecondsForm.onsubmit = function() {
var msTimeout = parseInt(document.getElementById('show-n-seconds-number').value) * 1000;
var spinHandle = loadingOverlay.activate();
setTimeout(function() {
loadingOverlay.cancel(spinHandle);
}, msTimeout);
return false;
};
})();
</script>
<script data-example="race-1">
(function() {
var race1Btn = document.getElementById('race-1-btn');
race1Btn.onclick = function() {
var spinHandle1 = loadingOverlay.activate();
var spinHandle2 = loadingOverlay.activate();
setTimeout(function() {
loadingOverlay.cancel(spinHandle1);
}, 3000);
setTimeout(function() {
loadingOverlay.cancel(spinHandle2);
}, 5000);
document.getElementById('race-1-spin-handle-1').value = spinHandle1;
document.getElementById('race-1-spin-handle-2').value = spinHandle2;
return false;
};
})();
</script>
<script data-example="race-2">
(function() {
var race2Btn = document.getElementById('race-2-btn');
race2Btn.onclick = function() {
var spinHandle1 = loadingOverlay.activate();
var spinHandle2 = loadingOverlay.activate();
setTimeout(function() {
loadingOverlay.cancel(spinHandle1);
}, 5000);
setTimeout(function() {
loadingOverlay.cancel(spinHandle2);
}, 3000);
document.getElementById('race-2-spin-handle-1').value = spinHandle1;
document.getElementById('race-2-spin-handle-2').value = spinHandle2;
return false;
};
})();
</script>
</body>
</html>