3 input#modalSettings.modal(type="checkbox")
4 div(role="dialog" data-checkbox="modalSettings"
5 aria-labelledby="settingsTitle")
6 .card.smallpad(@change="updateSettings")
7 label.modal-close(for="modalSettings")
8 h3#settingsTitle.section {{ st.tr["Preferences"] }}
10 label(for="setSqSize")
11 | {{ st.tr["Square size (in pixels). 0 for 'adaptative'"] }}
12 input#setSqSize(type="number" v-model="st.settings.sqSize")
14 label(for="selectHints") {{ st.tr["Show move hints?"] }}
15 select#setHints(v-model="st.settings.hints")
16 option(value="0") {{ st.tr["None"] }}
17 option(value="1") {{ st.tr["Moves from a square"] }}
18 option(value="2") {{ st.tr["Pieces which can move"] }}
20 label(for="setHighlight")
21 | {{ st.tr["Highlight squares? (Last move & checks)"] }}
22 input#setHighlight(type="checkbox" v-model="st.settings.highlight")
24 label(for="setCoords") {{ st.tr["Show board coordinates?"] }}
25 input#setCoords(type="checkbox" v-model="st.settings.coords")
27 label(for="selectColor") {{ st.tr["Board colors"] }}
28 select#setBcolor(v-model="st.settings.bcolor")
29 option(value="lichess") {{ st.tr["brown"] }}
30 option(value="chesscom") {{ st.tr["green"] }}
31 option(value="chesstempo") {{ st.tr["blue"] }}
33 label(for="selectSound") {{ st.tr["Play sounds?"] }}
34 select#setSound(v-model="st.settings.sound")
35 option(value="0") {{ st.tr["None"] }}
36 option(value="1") {{ st.tr["New game"] }}
37 option(value="2") {{ st.tr["All"] }}
40 input#myRange.slider(type="range" min="0" max="100" value="50"
45 import { store } from "@/store.js";
54 const boardSize = localStorage.getItem("boardSize");
56 document.getElementById("myRange").value = Math.floor(boardSize / 10);
57 // timeout to avoid calling too many time the adjust method
58 let timeoutLaunched = false;
59 window.addEventListener("resize", (e) => {
62 timeoutLaunched = true;
65 timeoutLaunched = false;
71 updateSettings: function(event) {
73 event.target.id.substr(3).replace(/^\w/, c => c.toLowerCase())
74 localStorage[propName] = ["highlight","coords"].includes(propName)
75 ? event.target.checked
78 adjustBoard: function() {
79 const boardContainer = document.getElementById("boardContainer");
81 return; //no board on page
82 const k = document.getElementById("myRange").value;
83 const movesWidth = (window.innerWidth >= 768 ? 280 : 0);
84 const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...
85 // Value of 0 is board min size; 100 is window.width [- movesWidth]
86 const boardSize = minBoardWidth +
87 k * (window.innerWidth - (movesWidth+minBoardWidth)) / 100;
88 localStorage.setItem("boardSize", boardSize);
89 boardContainer.style.width = boardSize + "px";
90 document.getElementById("gameContainer").style.width =
91 (boardSize + movesWidth) + "px";