2 import { store } from "@/store";
3 // Component for moves list on the right
6 props: ["moves","cursor","score","message","firstNum"],
8 cursor: function(newCursor) {
9 if (window.innerWidth <= 767)
10 return; //moves list is below: scrolling would hide chessboard
11 // Count grouped moves until the cursor (if multi-moves):
13 let curCol = undefined;
14 for (let i=0; i<newCursor; i++)
16 const m = this.moves[i];
17 if (m.color != curCol)
23 // $nextTick to wait for table > tr to be rendered
24 this.$nextTick( () => {
25 let rows = document.querySelectorAll('#movesList tr');
28 rows[Math.floor(Math.max(groupsCount,0)/2)].scrollIntoView({
37 if (this.moves.length == 0)
39 let tableContent = [];
41 let tableRow = undefined;
42 let moveCells = undefined;
43 let curCellContent = "";
45 for (let i=0; i<this.moves.length; i++)
47 if (this.moves[i].color == "w")
49 if (i == 0 || i>0 && this.moves[i-1].color=="b")
53 tableRow.children = moveCells;
54 tableContent.push(tableRow);
59 { domProps: { innerHTML: (++moveCounter) + "." } }
70 // Next condition is fine because even if the first move is black,
71 // there will be the "..." which count as white move.
72 else if (this.moves[i].color == "b" && this.moves[i-1].color == "w")
74 curCellContent += this.moves[i].notation;
75 if (i < this.moves.length-1 && this.moves[i+1].color == this.moves[i].color)
76 curCellContent += ",";
83 domProps: { innerHTML: curCellContent },
84 on: { click: () => this.gotoMove(i) },
85 "class": { "highlight-lm":
86 this.cursor >= firstIndex && this.cursor <= i },
93 // Complete last row, which might not be full:
94 if (moveCells.length-1 == 1)
99 { domProps: { innerHTML: "" } }
103 tableRow.children = moveCells;
104 tableContent.push(tableRow);
105 let rootElements = [];
106 if (this.score != "*")
108 const scoreDiv = h("div",
112 display: this.score!="*" ? "block" : "none",
117 h("p", store.state.tr[this.message]),
120 rootElements.push(scoreDiv);
139 gotoMove: function(index) {
140 this.$emit("goto-move", index);
146 <style lang="sass" scoped>
149 @media screen and (max-width: 767px)
158 background-color: plum