diff --git a/src/templates/progress b/src/templates/progress index 7b6162c..02934bd 100644 --- a/src/templates/progress +++ b/src/templates/progress @@ -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";