-Set problems style (maybe will fix strange flashing bug?)
global lang cookie, + display (remember in each variant what is shown...)
translations (how ? switch on index page only, then find ideas...)
-Improve style for various screen sizes
"code-point-at": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
"inherits": {
"version": "2.0.3",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
"version": "1.0.0",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
"version": "1.0.2",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
},
"dependencies": {
"readable-stream": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.0.6.tgz",
- "integrity": "sha512-9E1oLoOWfhSXHGv6QlwXJim7uNzd9EVlWK+21tCU9Ju/kR0/p2AZYPz4qSchgO8PlLIH4FpZYfzwS+rEksZjIg==",
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.1.0.tgz",
+ "integrity": "sha512-vpydAvIJvPODZNagCPuHG87O9JNPtvFEtjHHRVwNVsVVRBqemvPJkc2SYbxJsiZXawJdtZNmkmnsPuE3IgsG0A==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"dev": true
},
"postcss": {
- "version": "7.0.6",
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.6.tgz",
- "integrity": "sha512-Nq/rNjnHFcKgCDDZYO0lNsl6YWe6U7tTy+ESN+PnLxebL8uBtYX59HZqvrj7YLK5UCyll2hqDsJOo3ndzEW8Ug==",
+ "version": "7.0.7",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.7.tgz",
+ "integrity": "sha512-HThWSJEPkupqew2fnuQMEI2YcTj/8gMV3n80cMdJsKxfIh5tHf7nM5JigNX6LxVMqo6zkgQNAI88hyFvBk41Pg==",
"requires": {
"chalk": "^2.4.1",
"source-map": "^0.6.1",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sanitize-html": {
- "version": "1.19.3",
- "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.19.3.tgz",
- "integrity": "sha512-QpIjbF1rhUSQj9V7Wey/gv4DPqOso8KTebaI4rC97p0WCLnTpmhf7BJZUhS83MTtqRvUo8MuXH316CW2Nzd48w==",
+ "version": "1.20.0",
+ "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.20.0.tgz",
+ "integrity": "sha512-BpxXkBoAG+uKCHjoXFmox6kCSYpnulABoGcZ/R3QyY9ndXbIM5S94eOr1IqnzTG8TnbmXaxWoDDzKC5eJv7fEQ==",
"requires": {
"chalk": "^2.4.1",
"htmlparser2": "^3.10.0",
]
);
}
- if (this.mode == "friend")
+ if (["friend","problem"].includes(this.mode))
{
actionArray = actionArray.concat(
[
h('h3',
{
domProps: { innerHTML: "Show solution" },
- on: { click: "toggleShowSolution" }
+ on: { click: this.toggleShowSolution },
}
),
h('p',
methods: {
toggleShowSolution: function() {
let problemSolution = document.getElementById("problem-solution");
- problemSolution.style.display = problemSolution.style.display == "none"
- ? "block"
- : "none";
+ problemSolution.style.display =
+ !problemSolution.style.display || problemSolution.style.display == "none"
+ ? "block"
+ : "none";
},
download: function() {
let content = document.getElementById("pgn-game").innerHTML;
this.fenStart = localStorage.getItem(prefix+"fenStart");
}
else
- this.fenStart = fen;
+ this.fenStart = V.ParseFen(fen).position; //this is enough
if (mode=="human")
{
// Opponent found!
},
playComputerMove: function() {
const timeStart = Date.now();
+ // TODO: next call asynchronous (avoid freezing interface while computer "think").
+ // This would also allow to remove some artificial setTimeouts
const compMove = this.vr.getComputerMove();
// (first move) HACK: avoid selecting elements before they appear on page:
const delay = Math.max(250-(Date.now()-timeStart), 0);
undoInGame: function() {
const lm = this.vr.lastMove;
if (!!lm)
+ {
this.vr.undo(lm);
+ const lmBefore = this.vr.lastMove;
+ if (!!lmBefore)
+ {
+ this.vr.undo(lmBefore);
+ this.incheck = this.vr.getCheckSquares(lmBefore);
+ this.vr.play(lmBefore, "ingame");
+ }
+ else
+ this.incheck = [];
+ }
},
},
})
-// Show a problem summary on variant page
+// Show a problem summary on variant page or new problem preview
Vue.component('my-problem-summary', {
- props: ['prob'],
+ props: ['prob','preview'],
template: `
- <div class="problem col-sm-12" @click="showProblem()">
- <div class="diagram" v-html="getDiagram(prob.fen)"></div>
- <div class="problem-instructions" v-html="prob.instructions.substr(0,32)"></div>
- <div class="problem-time">{{ timestamp2date(prob.added) }}</div>
+ <div class="problem row" @click="showProblem()">
+ <div class="col-sm-12 col-md-6 col-lg-3 diagram"
+ v-html="getDiagram(prob.fen)">
+ </div>
+ <div class="col-sm-12 col-md-6 col-lg-9">
+ <p v-html="prob.instructions"></p>
+ <p v-if="preview" v-html="prob.solution"></p>
+ <p v-else class="problem-time">{{ timestamp2date(prob.added) }}</p>
+ </div>
</div>
`,
methods: {
getDiagram: function(fen) {
- const fenParts = fen.split(" ");
+ const fenParsed = V.ParseFen(fen);
return getDiagram({
- position: fenParts[0],
+ position: fenParsed.position,
+ turn: fenParsed.turn,
// No need for flags here
- turn: fenParts[2],
});
},
timestamp2date(ts) {
<button @click="fetchProblems('forward')">Next</button>
<button @click="showNewproblemModal">New</button>
<my-problem-summary v-on:show-problem="bubbleUp(p)"
- v-for="(p,idx) in sortedProblems" v-bind:prob="p" v-bind:key="idx">
+ v-for="(p,idx) in sortedProblems"
+ v-bind:prob="p" v-bind:preview="false" v-bind:key="idx">
</my-problem-summary>
<input type="checkbox" id="modal-newproblem" class="modal">
<div role="dialog" aria-labelledby="newProblemTxt">
<p class="emphasis">Safe HTML tags allowed</p>
<label for="newpbInstructions">Instructions</label>
<textarea id="newpbInstructions" v-model="newProblem.instructions"
- placeholder="Explain the problem here"/>
+ placeholder="Explain the problem here"></textarea>
<label for="newpbSolution">Solution</label>
<textarea id="newpbSolution" v-model="newProblem.solution"
- placeholder="How to solve the problem?"/>
+ placeholder="How to solve the problem?"></textarea>
<button class="center-btn">Preview</button>
</fieldset>
</form>
</div>
<div v-show="newProblem.stage=='preview'" class="card newproblem-preview">
- // TODO: we don't want exactly the same display (-date +solution)
- <my-problem-summary v-bind:prob="newProblem"></my-problem-summary>
- <button @click="sendNewProblem()" class="center-btn">Send</button>
+ <label for="modal-newproblem" class="modal-close"></label>
+ <my-problem-summary v-bind:prob="newProblem" v-bind:preview="true">
+ </my-problem-summary>
+ <div class="col-sm-12 col-md-6 col-lg-3 col-lg-offset-3 topspace">
+ <button @click="sendNewProblem()">Send</button>
+ <button @click="newProblem.stage='nothing'">Cancel</button>
+ </div>
</div>
</div>
</div>
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";
});
margin-left: 0
margin-right: 0
-.newproblem input, .newproblem textarea
+.newproblem-form input, .newproblem-form textarea
width: 100%
.emphasis
#problem-solution
display: none
+
+.topspace
+ margin-top: 15px
+
+.problem
+ cursor: pointer
+ margin-bottom: 15px
+
+#solution-div h3
+ cursor: pointer
const timestamp = Date.now();
// Sanitize them
const fen = req.body["fen"];
- if (!fen.match(/^[a-zA-Z0-9 /]*$/))
+ if (!fen.match(/^[a-zA-Z0-9, /-]*$/))
return res.json({errmsg: "Bad characters in FEN string"});
const instructions = sanitizeHtml(req.body["instructions"]);
const solution = sanitizeHtml(req.body["solution"]);
p.section.
All games start with a random assymetric position. #[br]
Games are untimed, and played anonymously. #[br]
- No chat, to rather focus on the moves :)
+ No chat while playing, to focus on the moves :)
h3.red.section Bug report
p.section
| If you find a bug in a game, please follow this procedure: #[br]