X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=app.js;h=4c0b5e4e239b1a4129d118e82cd6aa79d568f98d;hp=bb1653789337d5e8f4cb8a2e280eea2b71d3d6e7;hb=4cec374b0172e0888aa2fa33283ad72210be6e56;hpb=8f228ec8d91d528be3c72200f5f674058abce31e diff --git a/app.js b/app.js index bb16537..4c0b5e4 100644 --- a/app.js +++ b/app.js @@ -191,7 +191,9 @@ function getGameLink() { const vname = $.getElementById("selectVariant").value; const color = $.getElementById("selectColor").value; for (const select of $.querySelectorAll("#gameOptions select")) { - const value = parseInt(select.value, 10) || select.value; + let value = parseInt(select.value, 10); + if (isNaN(value)) //not an integer + value = select.value; options[ select.id.split("_")[1] ] = value; } for (const input of $.querySelectorAll("#gameOptions input")) { @@ -229,7 +231,7 @@ function fillGameInfos(gameInfos, oppIndex) { if (j == options.length) break; const opt = options[j]; - if (!opt[1]) + if (!opt[1]) //includes 0 and false (lighter display) continue; htmlContent += '' + @@ -543,8 +545,9 @@ function initializeGame(obj) { break; } } - fillGameInfos(obj, playerColor == "w" ? 1 : 0); - if (obj.randvar) + const playerIndex = (playerColor == "w" ? 0 : 1); + fillGameInfos(obj, 1 - playerIndex); + if (obj.players[playerIndex].randvar) toggleVisible("gameInfos"); else toggleVisible("boardContainer");