From: Scott Worley Date: Mon, 30 Jul 2012 04:07:45 +0000 (-0700) Subject: Status bar indicators X-Git-Url: http://git.scottworley.com/reliable-chat/commitdiff_plain/24923aff2cc8021178c7e2acafce2b834c6bc2bc?ds=sidebyside Status bar indicators --- diff --git a/webclient/rc.js b/webclient/rc.js index 6dc527e..a5b8736 100644 --- a/webclient/rc.js +++ b/webclient/rc.js @@ -12,6 +12,16 @@ function rcserverbase(server) { } } +function rcchangeserverstatus(server, new_status) { + var statusbar = document.getElementById("status"); + var spans = statusbar.getElementsByTagName("span"); + for (i in spans) { + if (spans[i].firstChild && 'data' in spans[i].firstChild && spans[i].firstChild.data == server) { + spans[i].setAttribute("class", new_status); + } + } +} + function rcaddmessagetohistory(message) { var d = document.createElement("div"); d.appendChild(document.createTextNode(message)); @@ -30,7 +40,11 @@ function receiveMessage(server, time, id, text) { if (!(seen_key in seen)) { seen[seen_key] = true; rcaddmessagetohistory(text); + for (i in servers) { + rcchangeserverstatus(servers[i], "sad"); + } } + rcchangeserverstatus(server, "happy"); } function receiveMessageEvent(event) @@ -56,6 +70,11 @@ function rcconnect() { var iframe = document.createElement("iframe"); iframe.setAttribute("src", rcserverbase(servers[i]) + "/frame"); document.body.insertBefore(iframe, document.body.firstChild); + // Status bar entry + var status_indicator = document.createElement("span"); + status_indicator.appendChild(document.createTextNode(servers[i])); + status_indicator.setAttribute("class", "sad"); + document.getElementById("status").appendChild(status_indicator); } }