3 #scoreInfo(v-if="score!='*'")
8 tr(v-for="gmove,index in groupedMoves")
10 | {{ firstNum + index / 2 + 1 }}
11 td(:class="{'highlight-lm': cursor == moveIdx}"
12 @click="() => gotoMove(moveIdx)")
13 | {{ moves[moveIdx].notation }}
14 td(v-if="moveIdx < moves.length-1"
15 :class="{'highlight-lm': cursor == moveIdx+1}"
16 @click="() => gotoMove(moveIdx+1)")
17 | {{ moves[moveIdx+1].notation }}
18 // Else: just add an empty cell
23 // Component for moves list on the right
26 props: ["moves","cursor","score","message","firstNum"],
28 cursor: function(newValue) {
29 if (window.innerWidth <= 767)
30 return; //moves list is below: scrolling would hide chessboard
32 newValue = 0; //avoid rows[-1] --> error
33 // $nextTick to wait for table > tr to be rendered
34 this.$nextTick( () => {
35 let rows = document.querySelectorAll('#movesList tr');
38 rows[Math.floor(newValue/2)].scrollIntoView({
47 groupedMoves: function() {
49 let curCol = undefined;
50 for (let idx=0; idx < this.moves.length; idx++)
52 const m = this.moves[idx];
53 if (m.color == curCol)
55 const gidx = groups.length - 1;
56 groups[gidx].moves.push(m);
61 groups.push({moves: [m], idx: groups.length});
68 gotoMove: function(index) {
69 this.$emit("goto-move", index);
75 <style lang="sass" scoped>
78 @media screen and (max-width: 767px)
87 background-color: plum