3 #scoreInfo(v-if="score!='*'")
8 tr(v-for="moveIdx in evenNumbers")
9 td {{ moveIdx / 2 + 1 }}
10 td(:class="{'highlight-lm': cursor == moveIdx}"
11 data-label="White move" @click="() => gotoMove(moveIdx)")
12 | {{ moves[moveIdx].notation }}
13 td(v-if="moveIdx < moves.length-1"
14 :class="{'highlight-lm': cursor == moveIdx+1}"
15 data-label="Black move" @click="() => gotoMove(moveIdx+1)")
16 | {{ moves[moveIdx+1].notation }}
17 // Else: just add an empty cell
22 // Component for moves list on the right
25 props: ["moves","cursor","score","message"],
27 cursor: function(newValue) {
29 newValue = 0; //avoid rows[-1] --> error
30 // $nextTick to wait for table > tr to be rendered
31 this.$nextTick( () => {
32 let rows = document.querySelectorAll('#movesList tr');
35 rows[Math.floor(newValue/2)].scrollIntoView({
44 evenNumbers: function() {
45 return [...Array(this.moves.length).keys()].filter(i => i%2==0);
49 gotoMove: function(index) {
50 this.$emit("goto-move", index);
56 <style lang="sass" scoped>
60 background-color: plum
63 <!-- Old render method:
65 if (this.moves.length == 0)
67 let tableContent = [];
69 let tableRow = undefined;
70 let moveCells = undefined;
71 let curCellContent = "";
72 for (let i=0; i<this.moves.length; i++)
74 if (this.moves[i].color == "w")
76 if (i == 0 || i>0 && this.moves[i-1].color=="b")
80 tableRow.children = moveCells;
81 tableContent.push(tableRow);
86 { domProps: { innerHTML: (++moveCounter) + "." } }
96 curCellContent += this.moves[i].notation;
97 if (i < this.moves.length-1 && this.moves[i+1].color == this.moves[i].color)
98 curCellContent += ",";
105 domProps: { innerHTML: curCellContent },
106 on: { click: () => this.gotoMove(i) },
107 "class": { "highlight-lm": this.cursor == i },
114 // Complete last row, which might not be full:
115 if (moveCells.length-1 == 1)
120 { domProps: { innerHTML: "" } }
124 tableRow.children = moveCells;
125 tableContent.push(tableRow);
126 const scoreDiv = h("div",
130 display: this.score!="*" ? "block" : "none",
135 h("p", this.message),
138 const movesTable = h(