Display idle time of games in progress.
statusmsg() now includes games' idle times, and the client displays them using getcurrent().
This commit is contained in:
parent
f750d9eb34
commit
2d9c8bd011
3 changed files with 59 additions and 7 deletions
21
rlgterm.js
21
rlgterm.js
|
|
@ -453,6 +453,7 @@ function getcurrent() {
|
|||
var cell1 = document.createElement("div");
|
||||
var cell2 = document.createElement("div");
|
||||
var cell3 = document.createElement("div");
|
||||
var cell4 = document.createElement("div");
|
||||
cell1.appendChild(document.createTextNode(reply.g[i].p));
|
||||
var uname = reply.g[i].g;
|
||||
if (uname in games)
|
||||
|
|
@ -461,14 +462,16 @@ function getcurrent() {
|
|||
debug(1, "Unrecognized game: " + uname);
|
||||
continue;
|
||||
}
|
||||
cell3.appendChild(document.createTextNode(idlestr(reply.g[i].i)));
|
||||
var button = document.createElement("span");
|
||||
button.appendChild(document.createTextNode("Watch"));
|
||||
button.onclick = makeWatcher(reply.g[i].n);
|
||||
button.className = "ibutton";
|
||||
cell3.appendChild(button);
|
||||
cell4.appendChild(button);
|
||||
row.appendChild(cell1);
|
||||
row.appendChild(cell2);
|
||||
row.appendChild(cell3);
|
||||
row.appendChild(cell4);
|
||||
gamediv.appendChild(row);
|
||||
}
|
||||
};
|
||||
|
|
@ -779,6 +782,22 @@ function textsize(larger) {
|
|||
return;
|
||||
}
|
||||
|
||||
function idlestr(ms) {
|
||||
if (typeof(ms) != "number")
|
||||
return "?";
|
||||
var seconds = Math.round(ms / 1000);
|
||||
var ss = String(seconds % 60);
|
||||
if (ss.length < 2)
|
||||
ss = "0" + ss;
|
||||
var mm = String(Math.floor((seconds % 3600) / 60));
|
||||
if (mm.length < 2)
|
||||
mm = "0" + mm;
|
||||
var hh = String(Math.floor(seconds / 3600));
|
||||
if (hh.length < 2)
|
||||
hh = "0" + hh;
|
||||
return hh + ":" + mm + ":" + ss;
|
||||
}
|
||||
|
||||
function bell(on) {
|
||||
var imgnode = document.getElementById("bell");
|
||||
if (on) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue