Emoji-ify status messages.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3906 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-06-18 20:51:22 +00:00
parent b42b5d11fa
commit 3a40722c89
2 changed files with 14 additions and 13 deletions

View File

@ -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,13 +514,11 @@ 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);
}
}
if (message) {
node.appendChild(document.createTextNode(message));
node.setAttribute("style", "display: inline-block; vertical-align: top; white-space: pre; color: " + (color || kErrorColor));
@ -529,9 +527,11 @@ function setStatusMessage(message, color, keep) {
function send(value) {
try {
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);
}
}
}

View File

@ -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];