Fix. TODO: Vue reactivity on game.score and game. ...
[vchess.git] / client / src / components / MoveList.vue
index fa01cf1..6e2ef66 100644 (file)
@@ -2,22 +2,10 @@
 // Component for moves list on the right
 export default {
   name: 'my-move-list',
-       props: ["moves","cursor"], //TODO: other props for e.g. players names + connected indicator
-       // --> we could also add turn indicator here
-       data: function() {
-               return {
-                       something: "", //TODO?
-               };
-       },
-       // TODO: extend rendering for more than 2 colors: would be a parameter
-       // in that case some moves for some colors could be just skipped (if a player lost)
+       props: ["moves","cursor"],
        render(h) {
                if (this.moves.length == 0)
                        return;
-               const nbColors = 2;
-               // TODO: name colors "white", "black", "red", "yellow" ?
-               if (this.moves[0].color == "b")
-                       this.moves.unshift({color: "w", notation: "..."});
                let tableContent = [];
                let moveCounter = 0;
                let tableRow = undefined;
@@ -66,26 +54,26 @@ export default {
                        }
                }
                // Complete last row, which might not be full:
-               if (moveCells.length-1 < nbColors)
+               if (moveCells.length-1 == 1)
                {
-                       const delta = nbColors - (moveCells.length-1);
-                       for (let i=0; i<delta; i++)
-                       {
-                               moveCells.push(
-                                       h(
-                                               "td",
-                                               { domProps: { innerHTML: "" } }
-                                       )
-                               );
-                       }
+      moveCells.push(
+        h(
+          "td",
+          { domProps: { innerHTML: "" } }
+        )
+      );
                }
                tableRow.children = moveCells;
                tableContent.push(tableRow);
                const movesTable = h(
-                       "table",
-                       { },
-                       tableContent
-               );
+      "div",
+      { },
+      [h(
+                         "table",
+                         { },
+                         tableContent
+                 )]
+    );
                return movesTable;
        },
        methods: {