From f5d3e4f539355d166baf38bab97480582e90e4af Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 15 Dec 2018 00:20:15 +0100
Subject: [PATCH] On the road to problems to complete website :)

---
 public/javascripts/components/problems.js | 14 ++++++++++++++
 public/javascripts/variant.js             |  7 +++++++
 views/index.pug                           | 11 +----------
 views/variant.pug                         | 18 ++++++++++--------
 4 files changed, 32 insertions(+), 18 deletions(-)
 create mode 100644 public/javascripts/components/problems.js
 create mode 100644 public/javascripts/variant.js

diff --git a/public/javascripts/components/problems.js b/public/javascripts/components/problems.js
new file mode 100644
index 00000000..54b36ab7
--- /dev/null
+++ b/public/javascripts/components/problems.js
@@ -0,0 +1,14 @@
+//TODO: list problems as FEN (quickly rendered), by date, with possible filtering per variant(?)
+//click on a problem ==> land on variant page with mode==friend, FEN prefilled... ok
+
+// get 10 first problems, and buttons next<>previous send date + "before" or "after"
+// need database: sqlite !
+
+// form "new problem" fen(position/turn/flags[guess]), instructions, solution (mandatory)
+// ==> upload on server in sandbox
+//
+// Atomic rules, atomic game, atomic problems(list drawn position
+//   + summary(first chars of instructions) + timedate)... one big Vue ? with components
+//
+// click on problem ==> masque problems, affiche game tab, launch new game Friend with
+//   FEN + turn + flags + rappel instructions / solution on click sous l'échiquier
diff --git a/public/javascripts/variant.js b/public/javascripts/variant.js
new file mode 100644
index 00000000..f9d23d8b
--- /dev/null
+++ b/public/javascripts/variant.js
@@ -0,0 +1,7 @@
+new Vue({
+	el: "#variantPage",
+	data: { display: "" }, //do not show anything...
+	// TODO: listen event "show problem", avec le probleme stringifié en arg
+	// Alors: display=game, mode=friend, newGame(fen, turn, ...),
+	//   et set Instructions+Soluce
+});
diff --git a/views/index.pug b/views/index.pug
index 188ec9ca..521c1258 100644
--- a/views/index.pug
+++ b/views/index.pug
@@ -16,16 +16,7 @@ block content
 				div(role="dialog")
 					#help.card
 						label.modal-close(for="modal-help")
-						h3.blue.section Tips
-						p.section
-							span.conditional-jump
-								| On a variant page, read the rules by clicking on the title
-								| "&lt;Variant&gt; rules". 
-							span.conditional-jump
-								| Try playing against a human: click the leftmost "new game" button. 
-							| ...Then, while waiting you can play against a (rather weak) bot
-							| or a friend.
-						// TODO? On the index page, try typing the first letters of a variant.
+						p.section First: watch #[a(href="/demo.webm") demo video] :)
 						h3.blue.section Comments
 						p.section.
 							All games start with a random assymetric position. #[br]
diff --git a/views/variant.pug b/views/variant.pug
index a44a3741..e7449621 100644
--- a/views/variant.pug
+++ b/views/variant.pug
@@ -8,11 +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="displayRules=!displayRules")
+				h4.rulesTitle.text-center(v-on:click="display='rules'")
 					| #{variant} Rules
-				my-rules(v-show="displayRules")
+				my-rules(v-show="display=='rules'")
 			.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
-				my-game
+				h4.rulesTitle.text-center(v-on:click="display='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'")
+					| #{variant} Problems
+				my-game(v-show="display=='problems'")
 
 block javascripts
 	script(src="/javascripts/utils/misc.js")
@@ -27,8 +33,4 @@ block javascripts
 		const variant = "#{variant}";
 	script(src="/javascripts/components/rules.js")
 	script(src="/javascripts/components/game.js")
-	script.
-		new Vue({
-			el: "#variantPage",
-			data: { displayRules: false },
-		});
+	script(src="/javascripts/components/problems.js")
-- 
2.44.0