Fixed the login/out link in the corner. Filled in obvious gaps in error reporting.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3199 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2016-04-11 00:28:42 +00:00
parent 6fbd00bddf
commit 577606a0f9
2 changed files with 18 additions and 14 deletions

View File

@ -1,6 +1,5 @@
"use strict";
var gHaveIndex = -1;
var gSessionId;
var gCredentials;
var gErrorCount = 0;
@ -122,8 +121,8 @@ function receive(data) {
if (line && line.action == "ping") {
gSocket.send(JSON.stringify({action: "pong"}));
} else if (line && line.action == "session") {
gSessionId = line.session.sessionId;
gCredentials = line.session.credentials;
gSessionId = line.sessionId;
gCredentials = line.credentials;
updateLogin();
} else if (line && line[0] && line[0].action == "ready") {
if (window.location.hash) {
@ -157,9 +156,6 @@ function receive(data) {
print(document.getElementById(target), line);
}
}
if ("index" in data) {
gHaveIndex = data.index;
}
}
function autoNewLine(terminal) {
@ -249,6 +245,15 @@ function autoScroll(terminal) {
terminal.scrollTop = terminal.scrollHeight - terminal.clientHeight;
}
function setErrorMessage(message) {
var node = document.getElementById("status");
while (node.firstChild) {
node.removeChild(node.firstChild);
}
node.appendChild(document.createTextNode(message));
node.setAttribute("style", "display: inline; color: #dc322f");
}
function send(command) {
var value = command;
if (!command) {
@ -260,12 +265,7 @@ function send(command) {
try {
gSocket.send(JSON.stringify({action: "command", command: value}));
} catch (error) {
var node = document.getElementById("status");
while (node.firstChild) {
node.removeChild(node.firstChild);
}
node.appendChild(document.createTextNode("Send failed: " + error));
node.setAttribute("style", "display: inline; color: #dc322f");
setErrorMessage("Send failed: " + error.toString());
}
}
@ -437,4 +437,7 @@ $(document).ready(function() {
gSocket.onmessage = function(event) {
receive(JSON.parse(event.data));
}
gSocket.onclose = function(event) {
setErrorMessage("Connection closed with code " + event.code);
}
});

View File

@ -174,9 +174,10 @@ function socket(request, response, client) {
packageOwner = match[1];
packageName = match[2];
}
response.send(JSON.stringify({action: "hello"}), 0x1);
var sessionId = makeSessionId();
response.send(JSON.stringify({lines: [{action: "session", sessionId: sessionId, credentials: credentials}]}), 0x1);
process = getSessionProcess(packageOwner, packageName, makeSessionId(), options);
process = getSessionProcess(packageOwner, packageName, sessionId, options);
process.terminal.readOutput(function(message) {
response.send(JSON.stringify(message), 0x1);
});