RLG-Web client: improvements to UI messages.
Improve the appearance of the message area, make warnings a different color from other messages, and make some message texts more helpful.
This commit is contained in:
parent
16df3d2a7a
commit
3dc15a18e7
2 changed files with 23 additions and 9 deletions
26
rlgterm.js
26
rlgterm.js
|
|
@ -262,7 +262,7 @@ function postResponseHandler() {
|
|||
|
||||
function errHandler() {
|
||||
//debug(1, "Server unavailable?");
|
||||
message("Unable to connect to the server.");
|
||||
message("Unable to connect to the server.", "warn");
|
||||
}
|
||||
|
||||
function sendback(str) {
|
||||
|
|
@ -450,7 +450,14 @@ function formlogin(ev) {
|
|||
}
|
||||
else if (reply.t == 'E') {
|
||||
debug(0, "Could not log in: " + reply.s);
|
||||
message("Logging in failed: " + reply.s);
|
||||
var failmsg = "Logging in failed. ";
|
||||
if (reply.c == 2)
|
||||
failmsg += reply.s.match(/Invalid data: (.*)/)[1];
|
||||
else if (reply.c == 3)
|
||||
failmsg += "The username or password was incorrect.";
|
||||
else if (reply.c == 6)
|
||||
failmsg += "The server is shutting down.";
|
||||
message(failmsg, "warn");
|
||||
document.getElementById("input_name").value = "";
|
||||
document.getElementById("input_pw").value = "";
|
||||
}
|
||||
|
|
@ -630,18 +637,18 @@ function startgame(game) {
|
|||
debug(1, "Could not start game: " + reply.s);
|
||||
if (reply.c == 1) {
|
||||
logout();
|
||||
message("The server forgot about you, please log in again.");
|
||||
message("The server forgot about you, please log in again.", "warn");
|
||||
}
|
||||
else if (reply.c == 4) {
|
||||
message("You can't play that game because it is currently being " +
|
||||
"played over SSH.");
|
||||
"played over SSH.", "warn");
|
||||
}
|
||||
else if (reply.c == 7) {
|
||||
message("The game is being saved, try again in a few seconds.");
|
||||
}
|
||||
else {
|
||||
message("The server says it can't start your game because \"" +
|
||||
reply.s + "\". This is probably a bug.");
|
||||
reply.s + "\". This is probably a bug.", "warn");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -676,7 +683,7 @@ function startwatching(gamenumber) {
|
|||
}
|
||||
else if (reply.t == 'E') {
|
||||
debug(1, "Could not watch game " + gamenumber + ": " + reply.s);
|
||||
message("The game could not be watched: " + reply.s);
|
||||
message("The game could not be watched: " + reply.s, "warn");
|
||||
getcurrent();
|
||||
}
|
||||
};
|
||||
|
|
@ -736,7 +743,7 @@ function formreg(ev) {
|
|||
}
|
||||
else
|
||||
failmsg += " This is probably a bug.";
|
||||
message(failmsg);
|
||||
message(failmsg, "warn");
|
||||
document.getElementById("regin_name").value = "";
|
||||
document.getElementById("regin_pw").value = "";
|
||||
document.getElementById("regin_email").value = "";
|
||||
|
|
@ -848,10 +855,13 @@ function toggleBlock(id) {
|
|||
element.style.display = "none";
|
||||
}
|
||||
|
||||
function message(msg, type) {
|
||||
function message(msg, mtype) {
|
||||
var msgdiv = document.createElement("div");
|
||||
var msgtext = document.createTextNode(msg);
|
||||
msgdiv.appendChild(msgtext);
|
||||
if (mtype) {
|
||||
msgdiv.className = mtype;
|
||||
}
|
||||
var msgcontainer = document.getElementById("messages");
|
||||
msgcontainer.insertBefore(msgdiv, msgcontainer.firstChild);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ div#keys {
|
|||
div#messages {
|
||||
width: 100%;
|
||||
max-height: 10em;
|
||||
overflow: scroll;
|
||||
overflow-y: auto;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +97,10 @@ div#messages > div:first-child {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
div#messages > div.warn {
|
||||
background-color: #F0F0C0;
|
||||
}
|
||||
|
||||
div#debug {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue