diff --git a/core/client.js b/core/client.js index 7364cab5..596f756f 100644 --- a/core/client.js +++ b/core/client.js @@ -386,7 +386,7 @@ function hash() { function receive(message) { if (message && message.action == "session") { - setStatusMessage("...Executing...", kStatusColor, true); + setStatusMessage("🟢 Executing...", kStatusColor); gCredentials = message.credentials; gParentApp = message.parentApp; updateLogin(); @@ -413,9 +413,9 @@ function receive(message) { } else if (message && message.action == "error") { if (message.error) { if (typeof(message.error) == 'string') { - setStatusMessage(message.error, '#f00', false); + setStatusMessage('⚠️ ' + message.error, '#f00'); } else { - setStatusMessage(message.error.message + '\n' + message.error.stack, '#f00', false); + setStatusMessage('⚠️ ' + mmessage.error.message + '\n' + message.error.stack, '#f00'); } } console.log('error', message); @@ -514,12 +514,10 @@ function keyEvent(event) { }); } -function setStatusMessage(message, color, keep) { +function setStatusMessage(message, color) { var node = document.getElementById("status"); - if (!keep) { - while (node.firstChild) { - node.removeChild(node.firstChild); - } + while (node.firstChild) { + node.removeChild(node.firstChild); } if (message) { node.appendChild(document.createTextNode(message)); @@ -529,9 +527,11 @@ function setStatusMessage(message, color, keep) { function send(value) { try { - gSocket.send(JSON.stringify(value)); + if (gSocket && gSocket.readyState == gSocket.OPEN) { + gSocket.send(JSON.stringify(value)); + } } catch (error) { - setStatusMessage("Send failed: " + error.toString(), kErrorColor); + setStatusMessage('🤷 Send failed: ' + error.toString(), kErrorColor); } } @@ -708,14 +708,14 @@ function connectSocket(path) { gSocket.onmessage = null; gSocket.close(); } - setStatusMessage("Connecting...", kStatusColor, false); + setStatusMessage("⚪ Connecting...", kStatusColor); gSocket = new WebSocket( (window.location.protocol == "https:" ? "wss://" : "ws://") + window.location.hostname + (window.location.port.length ? ":" + window.location.port : "") + "/app/socket"); gSocket.onopen = function() { - setStatusMessage("...Authenticating...", kStatusColor, true); + setStatusMessage("🟡 Authenticating...", kStatusColor); gSocket.send(JSON.stringify({ action: "hello", path: path, @@ -749,7 +749,7 @@ function connectSocket(path) { 1014: 'Bad gateway', 1015: 'TLS handshake', }; - setStatusMessage("Connection closed: " + (k_codes[event.code] || event.code), kErrorColor); + setStatusMessage("🔴 Closed: " + (k_codes[event.code] || event.code), kErrorColor); } } } diff --git a/core/core.js b/core/core.js index e26ad380..73cb3d77 100644 --- a/core/core.js +++ b/core/core.js @@ -375,6 +375,7 @@ function guessType(path) { 'css': 'text/css', 'html': 'text/html', 'js': 'text/javascript', + 'svg': 'image/svg+xml', }; var extension = path.split('.').pop(); return k_extension_to_type[extension];