-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
63 lines (59 loc) · 2.08 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Button Glow</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet">
</head>
<body>
<button id="ab" class="button glow-effect">
Hover Me!
<svg class="glow-container">
<rect pathLength="100" stroke-linecap="round" class="glow-blur"></rect>
<rect pathLength="100" stroke-linecap="round" class="glow-line"></rect>
</svg>
</button>
<button class="button glow-effect"
data-glow-animation="false"
>
Hover Me!
<svg class="glow-container">
<rect pathLength="100" stroke-linecap="round" class="glow-blur"></rect>
<rect pathLength="100" stroke-linecap="round" class="glow-line"></rect>
</svg>
</button>
</body>
</html>
<script>
// Client-side script to reload the page when connection
// with live-reload websocket is lost.
(() => {
const socketUrl = "ws://localhost:8765";
const socket = new WebSocket(socketUrl);
socket.addEventListener('close', () => {
const maxAttempts = 3;
let backoff = 2000;
let attempts = 0;
const tryReconnect = () => {
attempts++;
if (attempts > maxAttempts) {
console.error(
"Could not reconnect to live-reload socket."
+ " Check the server and refresh manually."
);
return;
}
const socket = new WebSocket(socketUrl);
socket.addEventListener('error', () => {
setTimeout(tryReconnect, backoff);
backoff *= 2;
});
socket.addEventListener('open', () => {
location.reload();
});
};
tryReconnect();
});
})();
</script>