comparison rlgterm.js @ 66:57bf0dcd080e

Display idle time of games in progress. statusmsg() now includes games' idle times, and the client displays them using getcurrent().
author John "Elwin" Edwards <elwin@sdf.org>
date Wed, 20 Jun 2012 11:37:05 -0700
parents e63c26dc0497
children b6a3b26fe0dc
comparison
equal deleted inserted replaced
65:e63c26dc0497 66:57bf0dcd080e
451 for (var i = 0; i < reply.g.length; i++) { 451 for (var i = 0; i < reply.g.length; i++) {
452 var row = document.createElement("div"); 452 var row = document.createElement("div");
453 var cell1 = document.createElement("div"); 453 var cell1 = document.createElement("div");
454 var cell2 = document.createElement("div"); 454 var cell2 = document.createElement("div");
455 var cell3 = document.createElement("div"); 455 var cell3 = document.createElement("div");
456 var cell4 = document.createElement("div");
456 cell1.appendChild(document.createTextNode(reply.g[i].p)); 457 cell1.appendChild(document.createTextNode(reply.g[i].p));
457 var uname = reply.g[i].g; 458 var uname = reply.g[i].g;
458 if (uname in games) 459 if (uname in games)
459 cell2.appendChild(document.createTextNode(games[uname].name)); 460 cell2.appendChild(document.createTextNode(games[uname].name));
460 else { 461 else {
461 debug(1, "Unrecognized game: " + uname); 462 debug(1, "Unrecognized game: " + uname);
462 continue; 463 continue;
463 } 464 }
465 cell3.appendChild(document.createTextNode(idlestr(reply.g[i].i)));
464 var button = document.createElement("span"); 466 var button = document.createElement("span");
465 button.appendChild(document.createTextNode("Watch")); 467 button.appendChild(document.createTextNode("Watch"));
466 button.onclick = makeWatcher(reply.g[i].n); 468 button.onclick = makeWatcher(reply.g[i].n);
467 button.className = "ibutton"; 469 button.className = "ibutton";
468 cell3.appendChild(button); 470 cell4.appendChild(button);
469 row.appendChild(cell1); 471 row.appendChild(cell1);
470 row.appendChild(cell2); 472 row.appendChild(cell2);
471 row.appendChild(cell3); 473 row.appendChild(cell3);
474 row.appendChild(cell4);
472 gamediv.appendChild(row); 475 gamediv.appendChild(row);
473 } 476 }
474 }; 477 };
475 req.open('GET', '/status', true); 478 req.open('GET', '/status', true);
476 req.send(); 479 req.send();
777 termemu.fixsize(); 780 termemu.fixsize();
778 debug(1, "Changing font size to " + nsize.toString()); 781 debug(1, "Changing font size to " + nsize.toString());
779 return; 782 return;
780 } 783 }
781 784
785 function idlestr(ms) {
786 if (typeof(ms) != "number")
787 return "?";
788 var seconds = Math.round(ms / 1000);
789 var ss = String(seconds % 60);
790 if (ss.length < 2)
791 ss = "0" + ss;
792 var mm = String(Math.floor((seconds % 3600) / 60));
793 if (mm.length < 2)
794 mm = "0" + mm;
795 var hh = String(Math.floor(seconds / 3600));
796 if (hh.length < 2)
797 hh = "0" + hh;
798 return hh + ":" + mm + ":" + ss;
799 }
800
782 function bell(on) { 801 function bell(on) {
783 var imgnode = document.getElementById("bell"); 802 var imgnode = document.getElementById("bell");
784 if (on) { 803 if (on) {
785 imgnode.style.visibility = "visible"; 804 imgnode.style.visibility = "visible";
786 window.setTimeout(bell, 1500, false); 805 window.setTimeout(bell, 1500, false);