2 import { store } from "@/store";
5 props: ["moves", "cursor", "score", "message", "firstNum"],
8 if (!!this.score && this.score != "*") {
14 display: this.score != "*" ? "block" : "none"
17 [h("p", this.score), h("p", store.state.tr[this.message])]
19 rootElements.push(scoreDiv);
21 if (this.moves.length > 0) {
22 let tableContent = [];
24 let tableRow = undefined;
25 let moveCells = undefined;
26 let curCellContent = "";
28 for (let i = 0; i < this.moves.length; i++) {
29 if (this.moves[i].color == "w") {
30 if (i == 0 || (i > 0 && this.moves[i - 1].color == "b")) {
32 tableRow.children = moveCells;
33 tableContent.push(tableRow);
40 domProps: { innerHTML: ++moveCounter + "." }
44 tableRow = h("div", {"class": {tr: true}});
49 // Next condition is fine because even if the first move is black,
50 // there will be the "..." which count as white move.
51 else if (this.moves[i].color == "b" && this.moves[i - 1].color == "w")
53 curCellContent += this.moves[i].notation;
55 i < this.moves.length - 1 &&
56 this.moves[i + 1].color == this.moves[i].color
58 curCellContent += ",";
67 "highlight-lm": this.cursor >= firstIndex && this.cursor <= i
69 domProps: { innerHTML: curCellContent },
70 on: { click: () => this.gotoMove(i) }
77 // Complete last row, which might not be full:
78 if (moveCells.length - 1 == 1) {
79 moveCells.push(h("div", {"class": {td: true}}));
81 tableRow.children = moveCells;
82 tableContent.push(tableRow);
95 return h("div", {}, rootElements);
98 cursor: function(newCursor) {
99 if (window.innerWidth <= 767) return; //scrolling would hide chessboard
100 // $nextTick to wait for table > tr to be rendered
101 this.$nextTick(() => {
102 let curMove = document.querySelector(".td.highlight-lm");
104 curMove.scrollIntoView({
113 gotoMove: function(index) {
114 this.$emit("goto-move", index);
120 <style lang="sass" scoped>
126 background-color: white
130 border-bottom: 1px solid lightgrey
140 @media screen and (max-width: 767px)
145 background-color: plum