1 // Component for moves list on the right
2 Vue
.component('my-move-list', {
3 props: ["moves","cursor"], //TODO: other props for e.g. players names + connected indicator
4 // --> we could also add turn indicator here
10 // TODO: extend rendering for more than 2 colors: would be a parameter
11 // in that case some moves for some colors could be just skipped (if a player lost)
13 if (this.moves
.length
== 0)
16 // TODO: name colors "white", "black", "red", "yellow" ?
17 if (this.moves
[0].color
== "b")
18 this.moves
.unshift({color: "w", notation: "..."});
19 let tableContent
= [];
21 let tableRow
= undefined;
22 let moveCells
= undefined;
23 let curCellContent
= "";
24 for (let i
=0; i
<this.moves
.length
; i
++)
26 if (this.moves
[i
].color
== "w")
28 if (i
== 0 || i
>0 && this.moves
[i
-1].color
=="b")
32 tableRow
.children
= moveCells
;
33 tableContent
.push(tableRow
);
38 { domProps: { innerHTML: (++moveCounter
) + "." } }
48 curCellContent
+= this.moves
[i
].notation
;
49 if (i
< this.moves
.length
-1 && this.moves
[i
+1].color
== this.moves
[i
].color
)
50 curCellContent
+= ",";
57 domProps: { innerHTML: curCellContent
},
58 on: { click: () => this.gotoMove(i
) },
59 "class": { "highlight-lm": this.cursor
== i
},
66 // Complete last row, which might not be full:
67 if (moveCells
.length
-1 < nbColors
)
69 const delta
= nbColors
- (moveCells
.length
-1);
70 for (let i
=0; i
<delta
; i
++)
75 { domProps: { innerHTML: "" } }
80 tableRow
.children
= moveCells
;
81 tableContent
.push(tableRow
);
90 gotoMove: function(index
) {
91 this.$emit("goto-move", index
);