projects
/
xogo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some improvements + simplify TODOs
[xogo.git]
/
app.js
diff --git
a/app.js
b/app.js
index
7f8dc27
..
676b895
100644
(file)
--- a/
app.js
+++ b/
app.js
@@
-86,8
+86,9
@@
function cancelSeek() {
if (send("cancelseek", {vname: seek_vname})) toggleVisible("newGame");
}
if (send("cancelseek", {vname: seek_vname})) toggleVisible("newGame");
}
-function sendRematch() {
- if (send("rematch", {gid: gid})) toggleVisible("pendingRematch");
+function sendRematch(random) {
+ if (send("rematch", {gid: gid, random: !!random}))
+ toggleVisible("pendingRematch");
}
function cancelRematch() {
if (send("norematch", {gid: gid})) toggleVisible("newGame");
}
function cancelRematch() {
if (send("norematch", {gid: gid})) toggleVisible("newGame");
@@
-103,6
+104,7
@@
function showNewGameForm() {
toggleVisible("newGameForm");
import(`/variants/${vname}/class.js`).then(module => {
window.V = module.default;
toggleVisible("newGameForm");
import(`/variants/${vname}/class.js`).then(module => {
window.V = module.default;
+ for (const [k, v] of Object.entries(V.Aliases)) window[k] = v;
prepareOptions();
});
}
prepareOptions();
});
}
@@
-206,6
+208,7
@@
function fillGameInfos(gameInfos, oppIndex) {
for (let j=i; j<i+4; j++) {
if (j == options.length) break;
const opt = options[j];
for (let j=i; j<i+4; j++) {
if (j == options.length) break;
const opt = options[j];
+ if (!opt[1]) continue;
htmlContent +=
'<span class="option">' +
(opt[1] === true ? opt[0] : `${opt[0]}:${opt[1]}`) + " " +
htmlContent +=
'<span class="option">' +
(opt[1] === true ? opt[0] : `${opt[0]}:${opt[1]}`) + " " +
@@
-395,7
+398,8
@@
connectToWSS();
// Playing
function toggleTurnIndicator(myTurn) {
// Playing
function toggleTurnIndicator(myTurn) {
- let indicator = $.getElementById("chessboard");
+ let indicator =
+ $.getElementById("boardContainer").querySelector(".chessboard");
if (myTurn) indicator.style.outline = "thick solid green";
else indicator.style.outline = "thick solid lightgrey";
}
if (myTurn) indicator.style.outline = "thick solid green";
else indicator.style.outline = "thick solid lightgrey";
}
@@
-428,12
+432,7
@@
const afterPlay = (move) => {
}
};
// Pack into one moves array, then send
}
};
// Pack into one moves array, then send
- curMoves.push({
- appear: move.appear,
- vanish: move.vanish,
- start: move.start,
- end: move.end
- });
+ curMoves.push(move);
if (vr.turn != playerColor) {
toggleTurnIndicator(false);
send("newmove",
if (vr.turn != playerColor) {
toggleTurnIndicator(false);
send("newmove",
@@
-451,6
+450,7
@@
function initializeGame(obj) {
const options = obj.options || {};
import(`/variants/${obj.vname}/class.js`).then(module => {
window.V = module.default;
const options = obj.options || {};
import(`/variants/${obj.vname}/class.js`).then(module => {
window.V = module.default;
+ for (const [k, v] of Object.entries(V.Aliases)) window[k] = v;
// Load CSS. Avoid loading twice the same stylesheet:
const allIds = [].slice.call($.styleSheets).map(s => s.id);
const newId = obj.vname + "_css";
// Load CSS. Avoid loading twice the same stylesheet:
const allIds = [].slice.call($.styleSheets).map(s => s.id);
const newId = obj.vname + "_css";
@@
-481,11
+481,11
@@
function initializeGame(obj) {
</g>
</svg>
</div>
</g>
</svg>
</div>
- <div class="resizeable
" id="
chessboard"></div>`;
+ <div class="resizeable
chessboard"></div>`;
vr = new V({
seed: obj.seed, //may be null if FEN already exists (running game)
fen: obj.fen,
vr = new V({
seed: obj.seed, //may be null if FEN already exists (running game)
fen: obj.fen,
- element: "
chessboard
",
+ element: "
boardContainer
",
color: playerColor,
afterPlay: afterPlay,
options: options
color: playerColor,
afterPlay: afterPlay,
options: options