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) {
28 // $nextTick to wait for table > tr to be rendered
29 this.$nextTick( () => {
30 let rows = document.querySelectorAll('#movesList tr');
33 rows[Math.floor(newValue/2)].scrollIntoView({
42 evenNumbers: function() {
43 return [...Array(this.moves.length).keys()].filter(i => i%2==0);
47 gotoMove: function(index) {
48 this.$emit("goto-move", index);
54 <style lang="sass" scoped>
58 background-color: plum
61 <!-- Old render method:
63 if (this.moves.length == 0)
65 let tableContent = [];
67 let tableRow = undefined;
68 let moveCells = undefined;
69 let curCellContent = "";
70 for (let i=0; i<this.moves.length; i++)
72 if (this.moves[i].color == "w")
74 if (i == 0 || i>0 && this.moves[i-1].color=="b")
78 tableRow.children = moveCells;
79 tableContent.push(tableRow);
84 { domProps: { innerHTML: (++moveCounter) + "." } }
94 curCellContent += this.moves[i].notation;
95 if (i < this.moves.length-1 && this.moves[i+1].color == this.moves[i].color)
96 curCellContent += ",";
103 domProps: { innerHTML: curCellContent },
104 on: { click: () => this.gotoMove(i) },
105 "class": { "highlight-lm": this.cursor == i },
112 // Complete last row, which might not be full:
113 if (moveCells.length-1 == 1)
118 { domProps: { innerHTML: "" } }
122 tableRow.children = moveCells;
123 tableContent.push(tableRow);
124 const scoreDiv = h("div",
128 display: this.score!="*" ? "block" : "none",
133 h("p", this.message),
136 const movesTable = h(