diff rlgterm.js @ 90:6c6a6e4f1e5b

RLG-Web client: distinguish playing and watching in UI. Don't show the keyboard when watching games, and display appropriate messages when playing or watching.
author John "Elwin" Edwards <elwin@sdf.org>
date Tue, 10 Jul 2012 13:53:38 -0700
parents 6145e1ea7ace
children e07f98799120
line wrap: on
line diff
--- a/rlgterm.js	Tue Jul 10 08:08:54 2012 -0700
+++ b/rlgterm.js	Tue Jul 10 13:53:38 2012 -0700
@@ -662,7 +662,7 @@
       setTitle("Watching");
       debug(1, "Watching with id " + session.id);
       message("You are now watching.");
-      setmode("play");
+      setmode("watch");
       getData();
     }
     else if (reply.t == 'E') {
@@ -725,6 +725,10 @@
   if (session.id == null)
     return;
   /* TODO IFACE2 If the end was unexpected, tell player the game was saved. */
+  if (session.playing)
+    message("Finished playing.");
+  else
+    message("Finished watching.");
   session.id = null;
   session.playing = false;
   ajaxstate.clear();
@@ -767,13 +771,23 @@
     ev.preventDefault();
   if (mode == "play") {
     document.getElementById("keyboard").style.display = "block";
+    document.getElementById("playctl").style.display = "block";
     document.getElementById("startgame").style.display = "none";
     document.getElementById("login").style.display = "none";
     document.getElementById("register").style.display = "none";
     document.getElementById("current").style.display = "none";
   }
-  if (mode == "choose") {
+  else if (mode == "watch") {
     document.getElementById("keyboard").style.display = "none";
+    document.getElementById("playctl").style.display = "block";
+    document.getElementById("startgame").style.display = "none";
+    document.getElementById("login").style.display = "none";
+    document.getElementById("register").style.display = "none";
+    document.getElementById("current").style.display = "none";
+  }
+  else if (mode == "choose") {
+    document.getElementById("keyboard").style.display = "none";
+    document.getElementById("playctl").style.display = "none";
     document.getElementById("startgame").style.display = "block";
     document.getElementById("login").style.display = "none";
     document.getElementById("register").style.display = "none";
@@ -782,6 +796,7 @@
   }
   else if (mode == "login") {
     document.getElementById("keyboard").style.display = "none";
+    document.getElementById("playctl").style.display = "none";
     document.getElementById("startgame").style.display = "none";
     document.getElementById("login").style.display = "block";
     document.getElementById("register").style.display = "none";
@@ -790,6 +805,7 @@
   }
   else if (mode == "register") {
     document.getElementById("keyboard").style.display = "none";
+    document.getElementById("playctl").style.display = "none";
     document.getElementById("startgame").style.display = "none";
     document.getElementById("login").style.display = "none";
     document.getElementById("register").style.display = "block";