forked from cory/tildefriends
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:
parent
b42b5d11fa
commit
3a40722c89
@ -386,7 +386,7 @@ function hash() {
|
|||||||
|
|
||||||
function receive(message) {
|
function receive(message) {
|
||||||
if (message && message.action == "session") {
|
if (message && message.action == "session") {
|
||||||
setStatusMessage("...Executing...", kStatusColor, true);
|
setStatusMessage("🟢 Executing...", kStatusColor);
|
||||||
gCredentials = message.credentials;
|
gCredentials = message.credentials;
|
||||||
gParentApp = message.parentApp;
|
gParentApp = message.parentApp;
|
||||||
updateLogin();
|
updateLogin();
|
||||||
@ -413,9 +413,9 @@ function receive(message) {
|
|||||||
} else if (message && message.action == "error") {
|
} else if (message && message.action == "error") {
|
||||||
if (message.error) {
|
if (message.error) {
|
||||||
if (typeof(message.error) == 'string') {
|
if (typeof(message.error) == 'string') {
|
||||||
setStatusMessage(message.error, '#f00', false);
|
setStatusMessage('⚠️ ' + message.error, '#f00');
|
||||||
} else {
|
} else {
|
||||||
setStatusMessage(message.error.message + '\n' + message.error.stack, '#f00', false);
|
setStatusMessage('⚠️ ' + mmessage.error.message + '\n' + message.error.stack, '#f00');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('error', message);
|
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");
|
var node = document.getElementById("status");
|
||||||
if (!keep) {
|
while (node.firstChild) {
|
||||||
while (node.firstChild) {
|
node.removeChild(node.firstChild);
|
||||||
node.removeChild(node.firstChild);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (message) {
|
if (message) {
|
||||||
node.appendChild(document.createTextNode(message));
|
node.appendChild(document.createTextNode(message));
|
||||||
@ -529,9 +527,11 @@ function setStatusMessage(message, color, keep) {
|
|||||||
|
|
||||||
function send(value) {
|
function send(value) {
|
||||||
try {
|
try {
|
||||||
gSocket.send(JSON.stringify(value));
|
if (gSocket && gSocket.readyState == gSocket.OPEN) {
|
||||||
|
gSocket.send(JSON.stringify(value));
|
||||||
|
}
|
||||||
} catch (error) {
|
} 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.onmessage = null;
|
||||||
gSocket.close();
|
gSocket.close();
|
||||||
}
|
}
|
||||||
setStatusMessage("Connecting...", kStatusColor, false);
|
setStatusMessage("⚪ Connecting...", kStatusColor);
|
||||||
gSocket = new WebSocket(
|
gSocket = new WebSocket(
|
||||||
(window.location.protocol == "https:" ? "wss://" : "ws://")
|
(window.location.protocol == "https:" ? "wss://" : "ws://")
|
||||||
+ window.location.hostname
|
+ window.location.hostname
|
||||||
+ (window.location.port.length ? ":" + window.location.port : "")
|
+ (window.location.port.length ? ":" + window.location.port : "")
|
||||||
+ "/app/socket");
|
+ "/app/socket");
|
||||||
gSocket.onopen = function() {
|
gSocket.onopen = function() {
|
||||||
setStatusMessage("...Authenticating...", kStatusColor, true);
|
setStatusMessage("🟡 Authenticating...", kStatusColor);
|
||||||
gSocket.send(JSON.stringify({
|
gSocket.send(JSON.stringify({
|
||||||
action: "hello",
|
action: "hello",
|
||||||
path: path,
|
path: path,
|
||||||
@ -749,7 +749,7 @@ function connectSocket(path) {
|
|||||||
1014: 'Bad gateway',
|
1014: 'Bad gateway',
|
||||||
1015: 'TLS handshake',
|
1015: 'TLS handshake',
|
||||||
};
|
};
|
||||||
setStatusMessage("Connection closed: " + (k_codes[event.code] || event.code), kErrorColor);
|
setStatusMessage("🔴 Closed: " + (k_codes[event.code] || event.code), kErrorColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,6 +375,7 @@ function guessType(path) {
|
|||||||
'css': 'text/css',
|
'css': 'text/css',
|
||||||
'html': 'text/html',
|
'html': 'text/html',
|
||||||
'js': 'text/javascript',
|
'js': 'text/javascript',
|
||||||
|
'svg': 'image/svg+xml',
|
||||||
};
|
};
|
||||||
var extension = path.split('.').pop();
|
var extension = path.split('.').pop();
|
||||||
return k_extension_to_type[extension];
|
return k_extension_to_type[extension];
|
||||||
|
Loading…
Reference in New Issue
Block a user