+++ /dev/null
-PGN text is not selectable on desktop computer (understand why?!)
{
elementArray.push(
h('div',
- { },
+ { attrs: { id: "pgn-div" } },
[
+ h('a',
+ {
+ attrs: {
+ id: "download",
+ href: "#",
+ }
+ }
+ ),
h('p',
{
+ attrs: { id: "pgn-game" },
+ on: { click: this.download },
domProps: {
innerHTML: this.vr.getPGN(this.mycolor, this.score, this.fenStart, this.mode)
}
this.conn.onclose = socketCloseListener;
},
methods: {
+ download: function() {
+ let content = document.getElementById("pgn-game").innerHTML;
+ content = content.replace(/<br>/g, "\n");
+ // Prepare and trigger download link
+ let downloadAnchor = document.getElementById("download");
+ downloadAnchor.setAttribute("download", "game.pgn");
+ downloadAnchor.href = "data:text/plain;charset=utf-8," + encodeURIComponent(content);
+ downloadAnchor.click();
+ },
endGame: function(score) {
this.score = score;
let modalBox = document.getElementById("modal-eog");
let [sizeX,sizeY] = VariantRules.size;
let shift = (color == 'w' ? -1 : 1);
let startRank = (color == 'w' ? sizeY-2 : 1);
+ let firstRank = (color == 'w' ? sizeY-1 : 0);
let lastRank = (color == "w" ? 0 : sizeY-1);
if (x+shift >= 0 && x+shift < sizeX && x+shift != lastRank)
if (this.board[x+shift][y] == V.EMPTY)
{
moves.push(this.getBasicMove(x, y, x+shift, y));
- if (x==startRank && this.board[x+2*shift][y] == V.EMPTY)
+ if ([startRank,firstRank].includes(x) && this.board[x+2*shift][y] == V.EMPTY)
{
//two squares jump
moves.push(this.getBasicMove(x, y, x+2*shift, y));
margin-right: 0
padding: 0 3px
+#pgn-div > a
+ display: none
+
+#pgn-div > p
+ cursor: pointer
+
.warn
padding: 3px
color: red
// { "name" : "AntiKing", "description" : "Keep anti-king in check" },
// { "name" : "Magnetic", "description" : "Laws of attraction" },
// { "name" : "Alice", "description" : "Both sides of the mirror" },
-// { "name" : "Cylindric", "description" : "Sides comunicate" },
-// { "name" : "Moscow", "description" : "Custom pieces setup" },
// { "name" : "Grand", "description" : "Big board" },
// { "name" : "Wildebeest", "description" : "Balanced sliders & leapers" },
// { "name" : "Loser", "description" : "Lose all pieces" },
-// { "name" : "Shatranj", "description" : "Ancestral rules" },
+// { "name" : "Crazyhouse", "description" : "Captures reborn" },
// { "name" : "Switching", "description" : "Exchange pieces positions" },
// { "name" : "Absorption", "description" : "Capture enhance movements" },
// { "name" : "Dark", "description" : "In the fog" },
-// { "name" : "Kriegspiel", "description" : "Blind war" },
];