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 // Take full width on small screens:
81 let boardSize = parseInt(localStorage.getItem("boardSize"));
84 window.innerWidth >= 768
85 ? 0.75 * Math.min(window.innerWidth, window.innerHeight)
88 const movesWidth = window.innerWidth >= 768 ? 280 : 0;
89 document.getElementById("boardContainer").style.width = boardSize + "px";
90 let gameContainer = document.getElementById("gameContainer");
91 gameContainer.style.width = boardSize + movesWidth + "px";
92 document.getElementById("boardSize").value =
93 (boardSize * 100) / (window.innerWidth - movesWidth);
94 // timeout to avoid calling too many time the adjust method
95 let timeoutLaunched = false;
96 window.addEventListener("resize", () => {
97 if (!timeoutLaunched) {
98 timeoutLaunched = true;
101 timeoutLaunched = false;
107 cursor: function(newCursor) {
108 if (window.innerWidth <= 767) return; //scrolling would hide chessboard
109 // $nextTick to wait for table > tr to be rendered
110 this.$nextTick(() => {
111 let curLine = document.querySelector(".td.highlight-lm");
112 if (!!curLine) curLine = curLine.parentNode;
113 if (!curLine && this.moves.length > 0)
114 // Cursor is before game beginning, and some moves were made:
115 curLine = document.querySelector(".moves-list .tr:first-child")
117 curLine.scrollIntoView({
126 evenNumbers: function() {
127 return [...Array(this.moves.length).keys()].filter(i => i%2==0);
131 notation: function(move) {
132 return getFullNotation(move);
134 gotoMove: function(index) {
135 this.$emit("goto-move", index);
137 adjustBoard: function() {
138 const boardContainer = document.getElementById("boardContainer");
139 if (!boardContainer) return; //no board on page
140 const k = document.getElementById("boardSize").value;
141 const movesWidth = window.innerWidth >= 768 ? 280 : 0;
142 const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...
143 // Value of 0 is board min size; 100 is window.width [- movesWidth]
146 (k * (window.innerWidth - (movesWidth + minBoardWidth))) / 100;
147 localStorage.setItem("boardSize", boardSize);
148 boardContainer.style.width = boardSize + "px";
149 document.getElementById("gameContainer").style.width =
150 boardSize + movesWidth + "px";
156 <style lang="sass" scoped>
162 background-color: white
166 border-bottom: 1px solid lightgrey
176 @media screen and (max-width: 767px)
181 background-color: plum
183 #boardSizeBtnContainer
187 [type="checkbox"]#modalAdjust+div .card
192 @media screen and (max-width: 767px)
197 @media screen and (max-width: 767px)
201 display: inline-block
206 display: inline-block
211 display: inline-block
216 display: inline-block