Experimental game upload added
[vchess.git] / client / src / components / MoveList.vue
index eb47dc9..4c351dd 100644 (file)
@@ -27,6 +27,12 @@ div
       :aria-label="st.tr['Resize board']"
     )
       img.inline(src="/images/icons/resize.svg")
+    button.tooltip(
+      v-if="canAnalyze"
+      @click="$emit('analyze')"
+      :aria-label="st.tr['Analyse']"
+    )
+      img.inline(src="/images/icons/analyse.svg")
     #downloadDiv(v-if="canDownload")
       a#download(href="#")
       button.tooltip(
@@ -34,12 +40,6 @@ div
         :aria-label="st.tr['Download'] + ' PGN'"
       )
         img.inline(src="/images/icons/download.svg")
-    button.tooltip(
-      v-if="canAnalyze"
-      @click="$emit('analyze')"
-      :aria-label="st.tr['Analyse']"
-    )
-      img.inline(src="/images/icons/analyse.svg")
   #scoreInfo(v-if="score!='*'")
     span.score {{ score }}
     span.score-msg {{ st.tr[message] }}
@@ -53,7 +53,7 @@ div
         | {{ notation(moves[moveIdx]) }}
       .td(
         v-if="moveIdx < moves.length-1"
-        :class="{'highlight-lm': cursor == moveIdx+1}"
+        :class="{'highlight-lm': highlightBlackmove(moveIdx+1)}"
         @click="() => gotoMove(moveIdx+1)"
       )
         | {{ notation(moves[moveIdx+1]) }}
@@ -74,9 +74,8 @@ export default {
     };
   },
   mounted: function() {
-    document.getElementById("adjuster").addEventListener(
-      "click",
-      processModalClick);
+    document.getElementById("adjuster")
+      .addEventListener("click", processModalClick);
     if ("ontouchstart" in window) {
       // Disable tooltips on smartphones:
       document.querySelectorAll("#aboveMoves .tooltip").forEach(elt => {
@@ -102,10 +101,8 @@ export default {
     window.addEventListener("resize", () => {
       if (!timeoutLaunched) {
         timeoutLaunched = true;
-        setTimeout(() => {
-          this.adjustBoard();
-          timeoutLaunched = false;
-        }, 500);
+        this.adjustBoard();
+        setTimeout(() => { timeoutLaunched = false; }, 500);
       }
     });
   },
@@ -115,9 +112,11 @@ export default {
       // $nextTick to wait for table > tr to be rendered
       this.$nextTick(() => {
         let curMove = document.querySelector(".td.highlight-lm");
-        if (!curMove && this.moves.length > 0)
+        if (!curMove && this.moves.length > 0) {
           // Cursor is before game beginning, and some moves were made:
-          curMove = document.querySelector(".moves-list > .tr:first-child > .td");
+          curMove =
+            document.querySelector(".moves-list > .tr:first-child > .td");
+        }
         if (!!curMove) {
           curMove.scrollIntoView({
             behavior: "auto",
@@ -136,12 +135,21 @@ export default {
     notation: function(move) {
       return getFullNotation(move);
     },
+    highlightBlackmove: function(moveIdx) {
+      return (
+        this.cursor == moveIdx ||
+        (this.show == "byrow" && this.cursor == moveIdx + 1)
+      );
+    },
     gotoMove: function(index) {
       this.$emit("goto-move", index);
     },
     adjustBoard: function() {
       const boardContainer = document.getElementById("boardContainer");
       if (!boardContainer) return; //no board on page
+      let arrows = document.getElementById("arrowCanvas");
+      // TODO: arrows on board don't scale
+      if (!!arrows) this.$emit("reset-arrows");
       const k = document.getElementById("boardSize").value;
       const movesWidth = window.innerWidth >= 768 ? 280 : 0;
       const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...
@@ -194,7 +202,7 @@ export default {
   padding: 5px
 
 img.inline
-  height: 24px
+  height: 22px
   @media screen and (max-width: 767px)
     height: 18px
 
@@ -226,6 +234,6 @@ span#rulesBtn
 button
   margin: 0
 
-button.tooltip
+#aboveMoves button
   padding-bottom: 5px
 </style>