build under prod env
This commit is contained in:
@@ -67,55 +67,4 @@
|
||||
</body>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user