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 :class="btnTooltipClass()"
27 onClick="window.doClick('modalAdjust')"
28 :aria-label="st.tr['Resize board']"
30 img.inline(src="/images/icons/resize.svg")
33 :class="btnTooltipClass()"
34 @click="$emit('analyze')"
35 :aria-label="st.tr['Analyse']"
37 img.inline(src="/images/icons/analyse.svg")
38 #downloadDiv(v-if="canDownload")
41 :class="btnTooltipClass()"
42 @click="$emit('download')"
43 :aria-label="st.tr['Download'] + ' PGN'"
45 img.inline(src="/images/icons/download.svg")
46 #scoreInfo(v-if="score!='*'")
47 span.score {{ score }}
48 span.score-msg {{ st.tr[message] }}
50 .tr(v-for="moveIdx in evenNumbers")
51 .td {{ firstNum + moveIdx / 2 }}
53 :class="{'highlight-lm': cursor == moveIdx}"
54 @click="() => gotoMove(moveIdx)"
56 | {{ notation(moveIdx) }}
58 v-if="moveIdx < moves.length-1"
59 :class="{'highlight-lm': cursor == moveIdx+1}"
60 @click="() => gotoMove(moveIdx+1)"
62 | {{ notation(moveIdx + 1) }}
66 import { store } from "@/store";
67 import { getFullNotation } from "@/utils/notation";
68 import { processModalClick } from "@/utils/modalClick";
72 "moves", "show", "canAnalyze", "canDownload",
73 "cursor", "score", "message", "firstNum"],
80 document.getElementById("adjuster")
81 .addEventListener("click", processModalClick);
82 // Take full width on small screens:
83 let boardSize = parseInt(localStorage.getItem("boardSize"));
86 window.innerWidth >= 768
87 ? 0.75 * Math.min(window.innerWidth, window.innerHeight)
90 const movesWidth = window.innerWidth >= 768 ? 280 : 0;
91 document.getElementById("boardContainer").style.width = boardSize + "px";
92 let gameContainer = document.getElementById("gameContainer");
93 gameContainer.style.width = boardSize + movesWidth + "px";
94 document.getElementById("boardSize").value =
95 (boardSize * 100) / (window.innerWidth - movesWidth);
96 window.addEventListener("resize", this.adjustBoard);
98 beforeDestroy: function() {
99 window.removeEventListener("resize", this.adjustBoard);
102 cursor: function(newCursor) {
103 if (window.innerWidth <= 767) return; //scrolling would hide chessboard
104 // $nextTick to wait for table > tr to be rendered
105 this.$nextTick(() => {
106 let curMove = document.querySelector(".td.highlight-lm");
107 if (!curMove && this.moves.length > 0) {
108 // Cursor is before game beginning, and some moves were made:
110 document.querySelector(".moves-list > .tr:first-child > .td");
113 curMove.scrollIntoView({
122 evenNumbers: function() {
123 return [...Array(this.moves.length).keys()].filter(i => i%2==0);
127 notation: function(moveIdx) {
128 const move = this.moves[moveIdx];
129 if (this.score != "*") return getFullNotation(move);
131 ['none','highlight'].includes(this.show) ||
133 this.show == "byrow" &&
134 moveIdx == this.moves.length-1 &&
140 return getFullNotation(move);
142 btnTooltipClass: function() {
143 return { tooltip: !("ontouchstart" in window) };
145 gotoMove: function(index) {
146 // Goto move except if click on current move:
147 if (this.cursor != index) this.$emit("goto-move", index);
149 adjustBoard: function() {
150 const boardContainer = document.getElementById("boardContainer");
151 if (!boardContainer) return; //no board on page
152 const k = document.getElementById("boardSize").value;
153 const movesWidth = window.innerWidth >= 768 ? 280 : 0;
154 const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...
155 // Value of 0 is board min size; 100 is window.width [- movesWidth]
158 (k * (window.innerWidth - (movesWidth + minBoardWidth))) / 100;
159 localStorage.setItem("boardSize", boardSize);
160 boardContainer.style.width = boardSize + "px";
161 document.getElementById("gameContainer").style.width =
162 boardSize + movesWidth + "px";
163 this.$emit("redraw-board");
169 <style lang="sass" scoped>
176 background-color: white
180 border-bottom: 1px solid lightgrey
190 @media screen and (max-width: 767px)
195 background-color: plum
197 #boardSizeBtnContainer
201 [type="checkbox"]#modalAdjust+div .card
206 @media screen and (max-width: 767px)
211 @media screen and (max-width: 767px)
215 display: inline-block
220 display: inline-block
225 display: inline-block
230 display: inline-block
237 background-color: #48C9B0