Change the wss if https
This commit is contained in:
parent
c7712982f3
commit
99f75f1cd1
@ -218,13 +218,22 @@
|
||||
}
|
||||
|
||||
const consoleDiv = document.getElementById('console');
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws?filename=${filename}`);
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const ws = new WebSocket(`${protocol}//${window.location.host}/ws?filename=${filename}`);
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
consoleDiv.textContent += event.data;
|
||||
consoleDiv.scrollTop = consoleDiv.scrollHeight;
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
console.log('WebSocket connection closed');
|
||||
};
|
||||
|
||||
ws.onerror = function(error) {
|
||||
console.error('WebSocket error:', error);
|
||||
};
|
||||
|
||||
document.getElementById('toggle-console').onclick = function() {
|
||||
if (consoleDiv.style.display === "none") {
|
||||
consoleDiv.style.display = "block";
|
||||
|
Loading…
Reference in New Issue
Block a user