97 lines
2.1 KiB
HTML
97 lines
2.1 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<!-- meta name="color-scheme" content="dark light" /-->
|
||
|
<title>
|
||
|
Test Post | Criminally Cute
|
||
|
</title>
|
||
|
<link rel="icon" type="image/png" href="/favicon.png">
|
||
|
<link rel="stylesheet" href="/css/site.css">
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<header>
|
||
|
<nav>
|
||
|
<ul>
|
||
|
<li><a href="/">Home</a></li>
|
||
|
<li><a href="/about">About</a></li>
|
||
|
<li><a href="/blog">Blog</a></li>
|
||
|
<li><a href="/projects">Projects</a></li>
|
||
|
</ul>
|
||
|
</nav>
|
||
|
<div>
|
||
|
<h1>Test Post</h1>
|
||
|
</div>
|
||
|
</header>
|
||
|
|
||
|
<main>
|
||
|
<p>TEST POST PLEASE IGNORE</p>
|
||
|
|
||
|
</main>
|
||
|
|
||
|
<footer>
|
||
|
<ul>
|
||
|
<li>some link</li>
|
||
|
<li>some link 2</li>
|
||
|
</ul>
|
||
|
<div>
|
||
|
<p>© 2024 Criminally Cute</p>
|
||
|
<p><a class="underline" href="/feed.xml">RSS</a></p>
|
||
|
</div>
|
||
|
</footer>
|
||
|
</body>
|
||
|
</html>
|
||
|
|
||
|
|
||
|
<script>
|
||
|
function log(message) {
|
||
|
if (true) {
|
||
|
console.log(`[web_dev_utils] ${message}`)
|
||
|
}
|
||
|
}
|
||
|
function connect() {
|
||
|
try {
|
||
|
window.socket = new WebSocket('ws://' + location.host + '/ws');
|
||
|
|
||
|
window.socket.onmessage = function(e) {
|
||
|
if (e.data === "reload") {
|
||
|
log("reloading!");
|
||
|
location.reload();
|
||
|
} else if (e.data === "subscribed") {
|
||
|
log("connected and subscribed!");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
window.socket.onopen = () => {
|
||
|
waitForConnection(() => {
|
||
|
log("sending 'subscribe' message");
|
||
|
window.socket.send("subscribe")
|
||
|
}
|
||
|
, 300);
|
||
|
};
|
||
|
|
||
|
window.socket.onclose = () => {
|
||
|
setTimeout(() => connect(), 500);
|
||
|
};
|
||
|
|
||
|
function waitForConnection(callback, interval) {
|
||
|
log("waiting for connection!")
|
||
|
if (window.socket.readyState === 1) {
|
||
|
callback();
|
||
|
} else {
|
||
|
log("setting a timeout")
|
||
|
setTimeout(() => waitForConnection(callback, interval), interval);
|
||
|
}
|
||
|
}
|
||
|
} catch (e) {
|
||
|
log(e);
|
||
|
setTimeout(() => connect(), 500);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
log("about to connect");
|
||
|
connect();
|
||
|
</script>
|
||
|
|