Fixes
[vchess.git] / client / src / components / Settings.vue
index 318689c..4838297 100644 (file)
@@ -32,6 +32,10 @@ div
           option(value="0") {{ st.tr["None"] }}
           option(value="1") {{ st.tr["New game"] }}
           option(value="2") {{ st.tr["All"] }}
+      fieldset
+        .slidecontainer
+          input#myRange.slider(type="range" min="20" max="100" value="60"
+            @input="adjustBoard")
 </template>
 
 <script>
@@ -42,6 +46,11 @@ export default {
     return {
       st: store.state,
     };
+  },
+  mounted: function() {
+    const boardSize = localStorage.getItem("boardSize");
+    if (!!boardSize)
+      document.getElementById("myRange").value = Math.floor(boardSize / 10);
   },
        methods: {
     updateSettings: function(event) {
@@ -50,6 +59,15 @@ export default {
       localStorage[propName] = ["highlight","coords"].includes(propName)
         ? event.target.checked
         : event.target.value;
+    },
+    adjustBoard: function() {
+      const board = document.querySelector(".game");
+      if (!board)
+        return; //no board on page
+      const multiplier = document.getElementById("myRange").value;
+      const boardSize = 10 * multiplier;
+      localStorage.setItem("boardSize", boardSize);
+      board.style.width = boardSize + "px";
     },
        },
 };