# HG changeset patch # User John "Elwin" Edwards # Date 1342030250 25200 # Node ID 7bb634f6995c353f6d7fe09e3f9c110fa41279da # Parent e84a99712c62df54d011e336ffcb3c23a5ab86e0 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. diff -r e84a99712c62 -r 7bb634f6995c rlgterm.js --- a/rlgterm.js Wed Jul 11 10:43:40 2012 -0700 +++ b/rlgterm.js Wed Jul 11 11:10:50 2012 -0700 @@ -262,7 +262,7 @@ 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 @@ } 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 @@ 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 @@ } 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 @@ } 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 @@ 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); } diff -r e84a99712c62 -r 7bb634f6995c style-rlg.css --- a/style-rlg.css Wed Jul 11 10:43:40 2012 -0700 +++ b/style-rlg.css Wed Jul 11 11:10:50 2012 -0700 @@ -83,7 +83,7 @@ div#messages { width: 100%; max-height: 10em; - overflow: scroll; + overflow-y: auto; clear: both; } @@ -97,6 +97,10 @@ font-weight: bold; } +div#messages > div.warn { + background-color: #F0F0C0; +} + div#debug { display: none; }