- postNewProblem: function() {
- const fen = document.getElementById("newpbFen").value;
- const instructions = document.getElementById("newpbInstructions").value;
- const solution = document.getElementById("newpbSolution").value;
-
+ previewNewProblem: function() {
+ if (!V.IsGoodFen(this.newProblem.fen))
+ return alert("Bad FEN string");
+ if (this.newProblem.instructions.length == 0)
+ return alert("Empty instructions");
+ if (this.newProblem.solution.length == 0)
+ return alert("Empty solution");
+ this.newProblem.stage = "preview";
+ },
+ sendNewProblem: function() {
+ // Send it to the server and close modal
+ ajax("/problems/" + variant, "POST", {
+ fen: this.newProblem.fen,
+ instructions: this.newProblem.instructions,
+ solution: this.newProblem.solution,
+ }, response => {
+ this.newProblem.added = Date.now();
+ this.problems.push(JSON.parse(JSON.stringify(this.newProblem)));
+ document.getElementById("modal-newproblem").checked = false;
+ this.newProblem.stage = "nothing";
+ });