diff rlgterm.js @ 45:1bbd0e76ba92

RLG-Web: put the game options into a table. Create a nice table of options when the player logs in.
author John "Elwin" Edwards <elwin@sdf.org>
date Sat, 09 Jun 2012 15:22:56 -0700
parents b848cb50cd69
children 59ecd99845eb
line wrap: on
line diff
--- a/rlgterm.js	Sat Jun 09 14:13:07 2012 -0700
+++ b/rlgterm.js	Sat Jun 09 15:22:56 2012 -0700
@@ -421,28 +421,34 @@
     }
     if (!("name" in reply) || reply["name"] != lname || !("stat" in reply))
       return;
-    var statdiv = document.createElement("div");
+    var optdiv = document.getElementById("opttable");
+    /* Don't remove the first child, it's the header. */
+    while (optdiv.childNodes.length > 1)
+      optdiv.removeChild(optdiv.childNodes[1]);
     for (var gname in reply.stat) {
       if (!(gname in games))
         continue;
-      var stext;
+      var acttext;
       if (reply.stat[gname] == "s")
-        stext = games[gname].name + ": Resume your game";
+        acttext = "Resume your game";
       else if (reply.stat[gname] == "0")
-        stext = games[gname].name + ": Start a game";
+        acttext = "Start a game";
       else if (reply.stat[gname] == "p")
-        stext = games[gname].name + ": Game in progress";
+        acttext = "Game in progress";
       else
         continue;
-      var tnode = document.createTextNode(stext);
+      var button = document.createElement("span");
+      button.appendChild(document.createTextNode(acttext));
+      button.className = "ibutton";
+      var actdiv = document.createElement("div");
+      actdiv.appendChild(button);
       var gamediv = document.createElement("div");
-      gamediv.appendChild(tnode);
-      statdiv.appendChild(gamediv);
+      gamediv.appendChild(document.createTextNode(games[gname].name));
+      var rowdiv = document.createElement("div");
+      rowdiv.appendChild(gamediv);
+      rowdiv.appendChild(actdiv);
+      optdiv.appendChild(rowdiv);
     }
-    if (!statdiv.hasChildNodes()) {
-      statdiv.appendChild(document.createTextNode("No known games?"));
-    }
-    document.getElementById("startgame").appendChild(statdiv);
   };
   req.open('GET', '/pstatus/' + lname, true);
   req.send();