+ // HACK because mini-css tooltips are persistent after click...
+ getRidOfTooltip: function(elt) {
+ elt.style.visibility = "hidden";
+ setTimeout(() => { elt.style.visibility="visible"; }, 100);
+ },
+ clickGameSeek: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ if (this.mode == "human")
+ return; //no newgame while playing
+ if (this.seek)
+ {
+ this.conn.send(JSON.stringify({code:"cancelnewgame"}));
+ delete localStorage["newgame"]; //cancel game seek
+ this.seek = false;
+ }
+ else
+ this.newGame("human");
+ },
+ clickComputerGame: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ if (this.mode == "human")
+ return; //no newgame while playing
+ this.newGame("computer");
+ },
+ clickFriendGame: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ document.getElementById("modal-fenedit").checked = true;
+ },
+ toggleExpertMode: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ this.expert = !this.expert;
+ setCookie("expert", this.expert ? "1" : "0");
+ },
+ resign: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ if (this.mode == "human" && this.oppConnected)
+ {
+ try {
+ this.conn.send(JSON.stringify({code: "resign", oppid: this.oppid}));
+ } catch (INVALID_STATE_ERR) {
+ return; //socket is not ready (and not yet reconnected)
+ }
+ }
+ this.endGame(this.mycolor=="w"?"0-1":"1-0");
+ },