1 function fenToDiag(vname
) {
2 import(`/variants/${vname}/class.js`).then(module
=> {
3 window
.V
= module
.default;
4 for (const [k
, v
] of Object
.entries(V
.Aliases
))
10 // TODO: heuristic to improve for ratio != 1 (how?)
11 function getDiagSize(elt
) {
12 const baseWidth
= Math
.min(window
.innerWidth
, 800);
14 if (elt
.classList
.contains("left") || elt
.classList
.contains("right"))
16 else if (baseWidth
> 630)
20 return multFact
* baseWidth
;
24 function re_drawDiagrams() {
25 const diagrams
= document
.getElementsByClassName("diag");
26 if (diagrams
.length
== 0)
28 const redrawing
= !!vr
;
30 vr
= new Array(diagrams
.length
);
31 for (let i
=0; i
<diagrams
.length
; i
++) {
33 let chessboard
= document
.createElement("div");
34 chessboard
.classList
.add("chessboard");
35 diagrams
[i
].appendChild(chessboard
);
36 diagrams
[i
].id
= "diag_" + i
;
38 const diagSize
= getDiagSize(diagrams
[i
]);
39 diagrams
[i
].style
.width
= diagSize
+ "px";
40 diagrams
[i
].style
.height
= diagSize
+ "px";
44 fen: diagrams
[i
].dataset
.fen
,
45 marks: diagrams
[i
].dataset
.mks
46 ? JSON
.parse('[' + diagrams
[i
].dataset
.mks
+ ']')
48 color: diagrams
[i
].dataset
.col
|| 'w',
56 window
.onresize
= re_drawDiagrams
;