sendXHR(cmds);
}
+ function sendBackTiles() {
+ const cmds = [];
+
+ for (let i = 0; i < playerLetters.length; i++) {
+ if (playerLetters[i].getElementsByClassName("tile")[0]) {
+ cmds.push({
+ cmd: "moveLetter",
+ from: "rack",
+ indexFrom: i,
+ to: "bag",
+ indexTo: -1
+ });
+ }
+ }
+
+ if (cmds.length) {
+ sendCmds(cmds);
+ }
+ setRack("");
+ }
+
function joinGame() {
checkGameInProgress(
function () {
if (isNaN(n)) {
myAlert(_("It seems your did not give a correct number, or you clicked on “Cancel”. As a result, the current game continues, if any. To join a game, click on “Join a game” again."));
} else {
+ sendBackTiles();
+ sendCmds([{cmd: "leaveGame"}]);
setSetting("GameNumber", n);
location.reload();
}
);
}
+ function leaveGame() {
+ myConfirm(
+ _("You are about to leave this game. Your letters will be put back in bag. Are you sure?"),
+ function () {
+ sendBackTiles();
+ sendCmds([{cmd: "leaveGame"}]);
+ setSetting("GameNumber", 0);
+ location.reload();
+ }
+ );
+ }
+
const specialTypesText = {
doubleLetter: "Double\nLetter",
doubleWord: "Double\nWord",
);
}
- function sendBackTiles() {
- const cmds = [];
-
- for (let i = 0; i < playerLetters.length; i++) {
- if (playerLetters[i].getElementsByClassName("tile")[0]) {
- cmds.push({
- cmd: "moveLetter",
- from: "rack",
- indexFrom: i,
- to: "bag",
- indexTo: -1
- });
- }
- }
-
- if (cmds.length) {
- sendCmds(cmds);
- }
- setRack("");
- }
-
- function leaveGame() {
- myConfirm(
- _("You are about to leave this game. Your letters will be put back in bag. Are you sure?"),
- function () {
- sendBackTiles();
- sendCmds([{cmd: "leaveGame"}]);
- setSetting("GameNumber", 0);
- location.reload();
- }
- );
- }
-
function clearRack() {
myConfirm(
_("Are you sure you want to put all your tiles back in the bag?"),