+ // TODO: in settings.js
+ setMyname: function(e) {
+ this.myname = e.target.value;
+ localStorage["username"] = this.myname;
+ },
+ 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");
+ },
+ setBoardColor: function(e) {
+ this.bcolor = e.target.options[e.target.selectedIndex].value;
+ localStorage["bcolor"] = this.bcolor;
+ },
+ setSound: function(e) {
+ this.sound = parseInt(e.target.options[e.target.selectedIndex].value);
+ localStorage["sound"] = this.sound;
+ },
+
+ // TODO: in another component
+ trySendChat: function(e) {
+ if (e.keyCode == 13) //'enter' key
+ this.sendChat();
+ },
+ sendChat: function() {
+ let chatInput = document.getElementById("input-chat");
+ const chatTxt = chatInput.value;
+ chatInput.value = "";
+ this.chats.push({msg:chatTxt, author:this.myid});
+ this.conn.send(JSON.stringify({
+ code:"newchat", oppid: this.oppid, msg: chatTxt}));
+ },
+ startChat: function(e) {
+ this.getRidOfTooltip(e.currentTarget);
+ document.getElementById("modal-chat").checked = true;
+ },
+
+ // TODO: in problems component
+ toggleShowSolution: function() {
+ let problemSolution = document.getElementById("problem-solution");
+ problemSolution.style.display =
+ !problemSolution.style.display || problemSolution.style.display == "none"
+ ? "block"
+ : "none";
+ },
+
+ download: function() {
+ // Variants may have special PGN structure (so next function isn't defined here)
+ const content = this.vr.getPGN(this.mycolor, this.score, this.fenStart, this.mode);
+ // Prepare and trigger download link
+ let downloadAnchor = document.getElementById("download");
+ downloadAnchor.setAttribute("download", "game.pgn");
+ downloadAnchor.href = "data:text/plain;charset=utf-8," + encodeURIComponent(content);
+ downloadAnchor.click();
+ },
+ showScoreMsg: function() {
+ let modalBox = document.getElementById("modal-eog");