- delete localStorage["variant"];
- delete localStorage["myid"];
- delete localStorage["mycolor"];
- delete localStorage["oppid"];
- delete localStorage["fenStart"];
- delete localStorage["fen"];
- delete localStorage["moves"];
- },
- clickGameSeek: function() {
+ if (["human","chat"].includes(this.mode))
+ {
+ delete localStorage["myid"];
+ delete localStorage["oppid"];
+ delete localStorage["gameId"];
+ }
+ const prefix = (this.mode=="computer" ? "comp-" : "");
+ delete localStorage[prefix+"variant"];
+ delete localStorage[prefix+"mycolor"];
+ delete localStorage[prefix+"fenStart"];
+ delete localStorage[prefix+"moves"];
+ delete localStorage[prefix+"fen"];
+ delete localStorage[prefix+"score"];
+ },
+ // HACK because mini-css tooltips are persistent after click...
+ getRidOfTooltip: function(elt) {
+ elt.style.visibility = "hidden";
+ setTimeout(() => { elt.style.visibility="visible"; }, 100);
+ },
+ startChat: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ document.getElementById("modal-chat").checked = true;
+ },
+ clearComputerGame: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ this.clearStorage(); //this.mode=="computer" (already checked)
+ location.reload(); //to see clearing effects
+ },
+ showSettings: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ document.getElementById("modal-settings").checked = true;
+ },
+ toggleHints: function() {
+ this.hints = !this.hints;
+ localStorage["hints"] = (this.hints ? "1" : "0");
+ },
+ setColor: function(e) {
+ this.color = e.target.options[e.target.selectedIndex].value;
+ localStorage["color"] = this.color;
+ },
+ setSound: function(e) {
+ this.sound = parseInt(e.target.options[e.target.selectedIndex].value);
+ localStorage["sound"] = this.sound;
+ },
+ clickGameSeek: function(e) {
+ this.getRidOfTooltip(e.currentTarget);