rlgterm.js: make the options table functional.
Enable launching games from the options table, and replace the old select dialog.
This commit is contained in:
parent
d3abfbcea9
commit
aba0a4b7da
2 changed files with 20 additions and 19 deletions
|
|
@ -86,22 +86,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal" id="startgame">
|
<div class="modal" id="startgame">
|
||||||
<form id="startform" action="/play" method="post">
|
<div id="opttable"><div><div>Game</div><div>Actions</div></div></div>
|
||||||
<div>
|
|
||||||
Choose game: <select name="game" id="input_game">
|
|
||||||
<option label="Rogue V3" value="rogue3">Rogue V3</option>
|
|
||||||
<option label="Rogue V4" value="rogue4">Rogue V4</option>
|
|
||||||
<option label="Rogue V5" value="rogue5">Rogue V5</option>
|
|
||||||
<option label="Super-Rogue" value="srogue">Super-Rogue</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="submit" value="Play" onclick="startgame(event)">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div id="opttable">
|
|
||||||
<div><div>Game</div><div>Actions</div></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal" id="login">
|
<div class="modal" id="login">
|
||||||
<form id="loginform" action="/login" method="post">
|
<form id="loginform" action="/login" method="post">
|
||||||
|
|
|
||||||
22
rlgterm.js
22
rlgterm.js
|
|
@ -440,6 +440,9 @@ function getchoices() {
|
||||||
var button = document.createElement("span");
|
var button = document.createElement("span");
|
||||||
button.appendChild(document.createTextNode(acttext));
|
button.appendChild(document.createTextNode(acttext));
|
||||||
button.className = "ibutton";
|
button.className = "ibutton";
|
||||||
|
if ("s0".indexOf(reply.stat[gname]) >= 0) {
|
||||||
|
button.onclick = makeStarter(gname);
|
||||||
|
}
|
||||||
var actdiv = document.createElement("div");
|
var actdiv = document.createElement("div");
|
||||||
actdiv.appendChild(button);
|
actdiv.appendChild(button);
|
||||||
var gamediv = document.createElement("div");
|
var gamediv = document.createElement("div");
|
||||||
|
|
@ -455,13 +458,26 @@ function getchoices() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startgame(ev) {
|
/* This can't be in the loop in getchoices(), or the closure's scope will
|
||||||
ev.preventDefault();
|
* get overwritten on the next iteration, and then all the games end up
|
||||||
|
* being Super-Rogue.
|
||||||
|
*/
|
||||||
|
function makeStarter(gname) {
|
||||||
|
if (!(gname in games))
|
||||||
|
return null;
|
||||||
|
var game = games[gname];
|
||||||
|
function starter(ev) {
|
||||||
|
startgame(game);
|
||||||
|
}
|
||||||
|
return starter;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startgame(game) {
|
||||||
if (termemu.sessid != null || !lcred)
|
if (termemu.sessid != null || !lcred)
|
||||||
return;
|
return;
|
||||||
var smsg = {};
|
var smsg = {};
|
||||||
smsg["key"] = lcred;
|
smsg["key"] = lcred;
|
||||||
smsg["game"] = document.getElementById("input_game").value;
|
smsg["game"] = game.uname;
|
||||||
smsg["h"] = 24;
|
smsg["h"] = 24;
|
||||||
smsg["w"] = 80;
|
smsg["w"] = 80;
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue