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 curMove = document.querySelector(".td.highlight-lm");
113 curMove.scrollIntoView({
122 evenNumbers: function() {
123 return [...Array(this.moves.length).keys()].filter(i => i%2==0);
127 notation: function(move) {
128 return getFullNotation(move);
130 gotoMove: function(index) {
131 this.$emit("goto-move", index);
133 adjustBoard: function() {
134 const boardContainer = document.getElementById("boardContainer");
135 if (!boardContainer) return; //no board on page
136 const k = document.getElementById("boardSize").value;
137 const movesWidth = window.innerWidth >= 768 ? 280 : 0;
138 const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...
139 // Value of 0 is board min size; 100 is window.width [- movesWidth]
142 (k * (window.innerWidth - (movesWidth + minBoardWidth))) / 100;
143 localStorage.setItem("boardSize", boardSize);
144 boardContainer.style.width = boardSize + "px";
145 document.getElementById("gameContainer").style.width =
146 boardSize + movesWidth + "px";
152 <style lang="sass" scoped>
158 background-color: white
162 border-bottom: 1px solid lightgrey
172 @media screen and (max-width: 767px)
177 background-color: plum
179 #boardSizeBtnContainer
183 [type="checkbox"]#modalAdjust+div .card
188 @media screen and (max-width: 767px)
193 @media screen and (max-width: 767px)
197 display: inline-block
202 display: inline-block
207 display: inline-block
212 display: inline-block