Browse Source

On start or server select open new websocket rather than reloading

master
Jimmy 4 months ago
parent
commit
905cb9412c
  1. 21
      frontend/src/main.js

21
frontend/src/main.js

@ -62,8 +62,17 @@ function main() {
serverselect.addEventListener("click", (event) => {
console.log(serverselect.value);
window.location.hash = serverselect.value;
server = serverselect.value;
socket.close();
location.reload();
try {
socket = new WebSocket(`wss://${host}/server/${server}/logs?token=${token}`);
const attachAddon = new AttachAddon(socket);
term.loadAddon(attachAddon);
} catch(err) {
alert("You are not allowed to use this server");
return;
}
//location.reload();
})
window.onbeforeunload = function() {
@ -90,7 +99,15 @@ function main() {
return
}
socket.close();
location.reload();
try {
socket = new WebSocket(`wss://${host}/server/${server}/logs?token=${token}`);
const attachAddon = new AttachAddon(socket);
term.loadAddon(attachAddon);
} catch(err) {
alert("You are not allowed to use this server");
return;
}
//location.reload();
} catch(err) {
console.error(`Error: ${err}`);
}

Loading…
Cancel
Save