Hello!
I’m trying to get cm-chessboard to run in Anki, a lightweight javascript chessboard. (There’s also the excellent Chessli deck, but it doesn’t quite do what I want.)
I can get it to work on the desktop version. But on mobile I’m just drawing a blank. Nothing.
Is there a way to get a debugging console on iPhone? I tried to load a javascript console, but again: no luck.
As for cm-chess, I’m suspecting, Anki on iPhone doesn’t find the javascript resources, but I can’t know. For what it’s worth, accessing cm-chessboard’s example page over the internet with Safari yields the expected and desired results.
The assets for cm-board in my current configuration reside in a directory cm
inside collection.media
. I’m trying the following code (in the card template):
<!-- <script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script> -->
<h2>{{Vorderseite}}</h2>
<div id="board"></div>
<script type="module">
import {COLOR, Chessboard, BORDER_TYPE} from "./cm/src/Chessboard.js"
new Chessboard(document.getElementById("board"), {
assetsUrl: "/cm/assets/",
assetsCache: false,
position: "rnbqkbnr/pp1p1ppp/4p3/2p5/4P3/2N3P1/PPPP1P1P/R1BQKBNR b KQkq - 0 3",
})
</script>
As I wrote, this works splendidly on the desktop, but on iPhone: nothing. For comparision, I successfully tried to load the older HtmlTTChess library as external resource file residing in collection.media
:
<!-- <script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script> -->
<h2>{{Vorderseite}}</h2>
<div id="board"></div>
<c:chess mode="bw" class="cdig">r1b1kb1r/1pqp1ppp/p1n1pn2/8/3NP3/2N1B3/PPP1BPPP/R2Q1RK1</c:chess>
<script type="module">
import parseChess from "./_html_tt_chess.js"
parseChess()
</script>
This works both on desktop and on iPhone. Assuming that there are no javascript incompabilities with the iPhone, the only difference that I can see is that HtmlTTChess is a single file.
Any help getting this to run or at least understanding the problem would be much appreciated.
I’m aware of this guide for loading external files on these forums. I’m extremely grateful for it, but unfortunately it doesn’t cover this problem.