Mercurial > hg > rlgwebd
comparison rlgterm.js @ 176:bf518a00190b
Add client-side support for watching dgamelaunch games.
author | John "Elwin" Edwards |
---|---|
date | Wed, 14 Jan 2015 07:44:22 -0500 |
parents | 0f6da35b27a0 |
children | 674e8899703b |
comparison
equal
deleted
inserted
replaced
175:4dd87508fc96 | 176:bf518a00190b |
---|---|
335 var row = document.createElement("div"); | 335 var row = document.createElement("div"); |
336 var cell1 = document.createElement("div"); | 336 var cell1 = document.createElement("div"); |
337 var cell2 = document.createElement("div"); | 337 var cell2 = document.createElement("div"); |
338 var cell3 = document.createElement("div"); | 338 var cell3 = document.createElement("div"); |
339 var cell4 = document.createElement("div"); | 339 var cell4 = document.createElement("div"); |
340 var cell5 = document.createElement("div"); | |
340 cell1.appendChild(document.createTextNode(gamelist[i].p)); | 341 cell1.appendChild(document.createTextNode(gamelist[i].p)); |
341 var uname = gamelist[i].g; | 342 var uname = gamelist[i].g; |
342 if (uname in games) | 343 if (uname in games) |
343 cell2.appendChild(document.createTextNode(games[uname].name)); | 344 cell2.appendChild(document.createTextNode(games[uname].name)); |
344 else { | 345 else { |
345 continue; | 346 continue; |
346 } | 347 } |
347 cell3.appendChild(document.createTextNode(idlestr(gamelist[i].i))); | 348 var srcstr = "VR"; |
349 if (gamelist[i].c == "rlg") | |
350 srcstr = "Web"; | |
351 else if (gamelist[i].c == "dgl") | |
352 srcstr = "SSH"; | |
353 cell3.appendChild(document.createTextNode(srcstr)); | |
354 cell4.appendChild(document.createTextNode(idlestr(gamelist[i].i))); | |
348 var button = document.createElement("span"); | 355 var button = document.createElement("span"); |
349 button.appendChild(document.createTextNode("Watch")); | 356 button.appendChild(document.createTextNode("Watch")); |
350 button.onclick = makeWatcher(uname + "/" + gamelist[i].p); | 357 button.onclick = makeWatcher(uname + "/" + gamelist[i].p); |
351 button.className = "ibutton"; | 358 button.className = "ibutton"; |
352 cell4.appendChild(button); | 359 cell5.appendChild(button); |
353 row.appendChild(cell1); | 360 row.appendChild(cell1); |
354 row.appendChild(cell2); | 361 row.appendChild(cell2); |
355 row.appendChild(cell3); | 362 row.appendChild(cell3); |
356 row.appendChild(cell4); | 363 row.appendChild(cell4); |
364 row.appendChild(cell5); | |
357 gamediv.appendChild(row); | 365 gamediv.appendChild(row); |
358 } | 366 } |
359 } | 367 } |
360 | 368 |
361 /* Handles the status socket, opening and closing it when necessary. */ | 369 /* Handles the status socket, opening and closing it when necessary. */ |
411 } | 419 } |
412 else if (msg.t == "b") { | 420 else if (msg.t == "b") { |
413 var justbegun = {}; | 421 var justbegun = {}; |
414 justbegun.g = msg.g; | 422 justbegun.g = msg.g; |
415 justbegun.p = msg.p; | 423 justbegun.p = msg.p; |
424 justbegun.c = msg.c; | |
416 justbegun.i = 0; | 425 justbegun.i = 0; |
417 currentList.push(justbegun); | 426 currentList.push(justbegun); |
418 tableCurrent(currentList); | 427 tableCurrent(currentList); |
419 if (msg.p == sessionStorage.getItem("lname")) { | 428 if (msg.p == sessionStorage.getItem("lname")) { |
420 getchoices(); | 429 getchoices(); |
871 debug(1, "Changing font size to " + nsize.toString()); | 880 debug(1, "Changing font size to " + nsize.toString()); |
872 return nsize; | 881 return nsize; |
873 } | 882 } |
874 | 883 |
875 function idlestr(ms) { | 884 function idlestr(ms) { |
885 /* Minute accuracy is good enough. */ | |
876 if (typeof(ms) != "number") | 886 if (typeof(ms) != "number") |
877 return "?"; | 887 return "?"; |
878 var seconds = Math.round(ms / 1000); | 888 var minutes = Math.round(ms / 60000); |
879 var ss = String(seconds % 60); | 889 if (minutes < 60) |
880 if (ss.length < 2) | 890 return String(minutes) + " min"; |
881 ss = "0" + ss; | 891 var hours = Math.floor(minutes / 60); |
882 var mm = String(Math.floor((seconds % 3600) / 60)); | 892 if (hours < 24) |
883 if (mm.length < 2) | 893 return String(hours) + " hr " + String(minutes % 60) + " min"; |
884 mm = "0" + mm; | 894 var days = Math.floor(days / 24); |
885 var hh = String(Math.floor(seconds / 3600)); | 895 if (days == 1) |
886 if (hh.length < 2) | 896 return "1 day " + String(hours % 24) + " hr"; |
887 hh = "0" + hh; | 897 else |
888 return hh + ":" + mm + ":" + ss; | 898 return String(days) + " days " + String(hours % 24) + " hr"; |
889 } | 899 } |
890 | 900 |
891 function bell(on) { | 901 function bell(on) { |
892 var imgnode = document.getElementById("bell"); | 902 var imgnode = document.getElementById("bell"); |
893 if (on) { | 903 if (on) { |