3 input#modalAdjust.modal(type="checkbox")
6 data-checkbox="modalAdjust"
9 label.modal-close(for="modalAdjust")
10 label(for="boardSize") {{ st.tr["Board size"] }}
11 input#boardSize.slider(
16 @input="adjustBoard()"
19 // NOTE: variants pages already have a "Rules" link on top
21 v-if="!$route.path.match('/variants/')"
22 @click="$emit('showrules')"
24 | {{ st.tr["Rules"] }}
26 onClick="window.doClick('modalAdjust')"
27 :aria-label="st.tr['Resize board']"
29 img.inline(src="/images/icons/resize.svg")
30 #downloadDiv(v-if="canDownload")
33 @click="$emit('download')"
34 :aria-label="st.tr['Download'] + ' PGN'"
36 img.inline(src="/images/icons/download.svg")
39 @click="$emit('analyze')"
40 :aria-label="st.tr['Analyse']"
42 img.inline(src="/images/icons/analyse.svg")
43 #scoreInfo(v-if="score!='*'")
44 span.score {{ score }}
45 span.score-msg {{ st.tr[message] }}
46 .moves-list(v-if="!['none','highlight'].includes(show)")
47 .tr(v-for="moveIdx in evenNumbers")
48 .td {{ firstNum + moveIdx / 2 + 1 }}
49 .td(v-if="moveIdx < moves.length-1 || show == 'all'"
50 :class="{'highlight-lm': cursor == moveIdx}"
51 @click="() => gotoMove(moveIdx)"
53 | {{ notation(moves[moveIdx]) }}
55 v-if="moveIdx < moves.length-1"
56 :class="{'highlight-lm': cursor == moveIdx+1}"
57 @click="() => gotoMove(moveIdx+1)"
59 | {{ notation(moves[moveIdx+1]) }}
63 import { store } from "@/store";
64 import { getFullNotation } from "@/utils/notation";
65 import { processModalClick } from "@/utils/modalClick";
69 "moves", "show", "canAnalyze", "canDownload",
70 "cursor", "score", "message", "firstNum"],
77 document.getElementById("adjuster").addEventListener(
80 if ("ontouchstart" in window) {
81 // Disable tooltips on smartphones:
82 document.querySelectorAll("#aboveMoves .tooltip").forEach(elt => {
83 elt.classList.remove("tooltip");
86 // Take full width on small screens:
87 let boardSize = parseInt(localStorage.getItem("boardSize"));
90 window.innerWidth >= 768
91 ? 0.75 * Math.min(window.innerWidth, window.innerHeight)
94 const movesWidth = window.innerWidth >= 768 ? 280 : 0;
95 document.getElementById("boardContainer").style.width = boardSize + "px";
96 let gameContainer = document.getElementById("gameContainer");
97 gameContainer.style.width = boardSize + movesWidth + "px";
98 document.getElementById("boardSize").value =
99 (boardSize * 100) / (window.innerWidth - movesWidth);
100 // timeout to avoid calling too many time the adjust method
101 let timeoutLaunched = false;
102 window.addEventListener("resize", () => {
103 if (!timeoutLaunched) {
104 timeoutLaunched = true;
107 timeoutLaunched = false;
113 cursor: function(newCursor) {
114 if (window.innerWidth <= 767) return; //scrolling would hide chessboard
115 // $nextTick to wait for table > tr to be rendered
116 this.$nextTick(() => {
117 let curMove = document.querySelector(".td.highlight-lm");
118 if (!curMove && this.moves.length > 0)
119 // Cursor is before game beginning, and some moves were made:
120 curMove = document.querySelector(".moves-list > .tr:first-child > .td");
122 curMove.scrollIntoView({
131 evenNumbers: function() {
132 return [...Array(this.moves.length).keys()].filter(i => i%2==0);
136 notation: function(move) {
137 return getFullNotation(move);
139 gotoMove: function(index) {
140 this.$emit("goto-move", index);
142 adjustBoard: function() {
143 const boardContainer = document.getElementById("boardContainer");
144 if (!boardContainer) return; //no board on page
145 const k = document.getElementById("boardSize").value;
146 const movesWidth = window.innerWidth >= 768 ? 280 : 0;
147 const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...
148 // Value of 0 is board min size; 100 is window.width [- movesWidth]
151 (k * (window.innerWidth - (movesWidth + minBoardWidth))) / 100;
152 localStorage.setItem("boardSize", boardSize);
153 boardContainer.style.width = boardSize + "px";
154 document.getElementById("gameContainer").style.width =
155 boardSize + movesWidth + "px";
161 <style lang="sass" scoped>
167 background-color: white
171 border-bottom: 1px solid lightgrey
181 @media screen and (max-width: 767px)
186 background-color: plum
188 #boardSizeBtnContainer
192 [type="checkbox"]#modalAdjust+div .card
197 @media screen and (max-width: 767px)
202 @media screen and (max-width: 767px)
206 display: inline-block
211 display: inline-block
216 display: inline-block
221 display: inline-block