Fix '3 knights' bug + tiny advance on problems tab
authorBenjamin Auder <benjamin.auder@somewhere>
Fri, 14 Dec 2018 23:58:04 +0000 (00:58 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Fri, 14 Dec 2018 23:58:04 +0000 (00:58 +0100)
public/javascripts/components/game.js
public/javascripts/components/problems.js
public/javascripts/variant.js
public/stylesheets/variant.sass
views/variant.pug

index 63bf675..533bc0e 100644 (file)
@@ -1083,7 +1083,10 @@ Vue.component('my-game', {
                        const compMove = this.vr.getComputerMove();
                        // (first move) HACK: avoid selecting elements before they appear on page:
                        const delay = Math.max(500-(Date.now()-timeStart), 0);
-                       setTimeout(() => this.play(compMove, "animate"), delay);
+                       setTimeout(() => {
+                               if (this.mode == "computer") //Warning: mode could have changed!
+                                       this.play(compMove, "animate")
+                       }, delay);
                },
                // Get the identifier of a HTML table cell from its numeric coordinates o.x,o.y.
                getSquareId: function(o) {
index 54b36ab..dc32052 100644 (file)
 //
 // click on problem ==> masque problems, affiche game tab, launch new game Friend with
 //   FEN + turn + flags + rappel instructions / solution on click sous l'échiquier
+
+Vue.component('my-problems', {
+       //props: ['vobj'],
+       template: `
+               <div class="variant col-sm-12">
+                       <p>Hello</p>
+               </div>
+       `,
+})
index f9d23d8..2174c50 100644 (file)
@@ -4,4 +4,12 @@ new Vue({
        // TODO: listen event "show problem", avec le probleme stringifié en arg
        // Alors: display=game, mode=friend, newGame(fen, turn, ...),
        //   et set Instructions+Soluce
+       methods: {
+               toggleDisplay: function(elt) {
+                       if (this.display == elt)
+                               this.display = ""; //hide
+                       else
+                               this.display = elt; //show
+               },
+       },
 });
index 40bf212..f5bffc3 100644 (file)
@@ -221,10 +221,10 @@ ul:not(.browser-default)
 ul:not(.browser-default) > li
   list-style-type: disc
 
-.rulesTitle
+.variantpage-title
   font-weight: bold
   cursor: pointer
-  padding: 3px;
+  padding: 3px
   background-color: lightgrey
 
 #fen-string
index e744962..a613a0b 100644 (file)
@@ -8,17 +8,17 @@ block content
        .container#variantPage
                .row
                        .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
-                               h4.rulesTitle.text-center(v-on:click="display='rules'")
+                               h4.variantpage-title.text-center(v-on:click="toggleDisplay('rules')")
                                        | #{variant} Rules
                                my-rules(v-show="display=='rules'")
                        .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
-                               h4.rulesTitle.text-center(v-on:click="display='game'")
+                               h4.variantpage-title.text-center(v-on:click="toggleDisplay('game')")
                                        | #{variant} Game
                                my-game(v-show="display=='game'")
                        .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
-                               h4.rulesTitle.text-center(v-on:click="display='problems'")
+                               h4.variantpage-title.text-center(v-on:click="toggleDisplay('problems')")
                                        | #{variant} Problems
-                               my-game(v-show="display=='problems'")
+                               my-problems(v-show="display=='problems'")
 
 block javascripts
        script(src="/javascripts/utils/misc.js")
@@ -34,3 +34,4 @@ block javascripts
        script(src="/javascripts/components/rules.js")
        script(src="/javascripts/components/game.js")
        script(src="/javascripts/components/problems.js")
+       script(src="/javascripts/variant.js")