why doesn’t this code for backside of Anki card not work in newer Anki versions ? my old ubuntu machine has 25.09.2 anki version and when I synced to ankidroid it worked fine. But I’ve tried everything since then, copying the entire collection.media folder manually to new mac device, new windows vm and new ubuntu vm and the cards appear blank. The code is supposed to load an interactive chess board which makes opponent move automatically to memorize opening theory in the anki card by the means of .html and .js files. its working fine on the old ubuntu machine. Its still working great on ankidroid after one way sync from server, why it doesn’t work on newer machines, the cards simply appear blank. did I accidentally delete something ?
I suspect this is the culprit code block since the cards are blank, did something change in Anki ?
Back:
<iframe id="analysisBoard"></iframe>
<script>
var PGN = encodeURIComponent(`{{text:PGN}}`);
var FEN = encodeURIComponent(`{{text:FEN}}`);
document.getElementById("analysisBoard").src =`_ChessTempoViewerB.html?PGN=`+PGN+`&FEN=`+FEN+``;
</script>
The entire back side of the card :
<iframe id="analysisBoard"></iframe>
<button id="lichessBtn">Analyze on Lichess</button>
<script>
var PGN = encodeURIComponent(`{{text:PGN}}`);
var FEN = encodeURIComponent(`{{text:FEN}}`);
document.getElementById("analysisBoard").src =`_ChessTempoViewerB.html?PGN=`+PGN+`&FEN=`+FEN+``;
</script>
<script>
var PGN_raw = `{{text:PGN}}`;
var FEN_raw = `{{text:FEN}}`;
var PGN = encodeURIComponent(PGN_raw);
// convert FEN for lichess (spaces → underscores)
var FEN_lichess = FEN_raw.trim().replace(/\s+/g, "_");
// existing viewer
document.getElementById("analysisBoard").src =
`_ChessTempoViewerB.html?PGN=` + encodeURIComponent(PGN_raw) + `&FEN=` + encodeURIComponent(FEN_raw);
// lichess button
document.getElementById("lichessBtn").onclick = function() {
var url;
if (FEN_raw && FEN_raw.trim() !== "") {
url = "
" + FEN_lichess;
} else {
url = "
" + PGN;
}
window.open(url, "_blank");
};
</script>
Reading between the lines – are you using a different version of Anki on the newer machines? 25.09.3 and 25.09.4 were security patch releases, which could have impacted your card design.
Yup the latest 25.09.4. In the link you linked in the comment it does say “Importing untrusted decks (.apkg files) had the ability to read local files. This has now been fixed.” Maybe I will stick with the old versions. Weirdly enough I downloaded a old .dmg version on mac, and after installation if I go to Anki → About it still says versions 25.09.4, wonder whats up with that.However, I installed an older version on a ubuntu vm and seems to be the new anki version and security fixes. Working on the older versions!
Thank you! Looks like I’ll stick with the old version as long as possible.
Can you share an example of field contents for a note as well as the _ChessTempoViewerB.html file? There still might be a way of making it compatible with the newer Anki versions.
Keep in mind that the patches weren’t intended to break your cards – they were intended to give you security protections. If you decide to go without them (rather than fix your card templates), you’ll need to be vigilant.
Yup, have to be careful choosing shared .apkg decks.
I’m using a very old version of https://ankiweb.net/shared/info/1300975327. The html file is too long to post here but all the files should be here Releases · TowelSniffer/Anki-Chess-2.0 · GitHub , on page 9 from 2021. The Pgn notation is not standarazied and parsing gives a lot of headache, and sometimes works sometimes doesn’t and I stopping touching it once it started working well for all pgn chess notation. I checked out the new version of Anki-Chess and it works well card-template wise speaking but the pgn barely parses sometimes. To be honest I’m too afraid to touch it, I don’t even remember how it suddenly started working well. The old version can simply import a pgn chess file using this addon- https://ankiweb.net/shared/info/569467423 straight into an anki deck.
Field contents of a note: There is also sample apkg file on the github releases page 9.
[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "Mating Motifs 1"]
[Black "Arabian Mate 1-5"]
[Result "*"]
[FEN "6k1/5pp1/8/5P2/R6p/1P3N1P/3rnrPK/6R1 b - - 0 1"]
[SetUp "1"]
{ The Arabian Mate This is a very old motif in which rook and knight deliver the
mate. T. Casper â A. Yusupov, Bundesliga 1999 } 1... Rxf3 { This exchange
sacrifice prepares the discovered check. Nothing is achieved by 1...Nxg1 due to
2.Nxd2 And the "clever" 2.Ra8+! leading to mate, as pointed out by a helpful
reader.} 2. gxf3 Nd4+ 3. Kh1 { Or 3.Rg2 Nxf3+ 4.Kh1 Rd1+ 5.Rg1 Rxg1#} 3...
Nxf3 *
Well, considering there is an up-to-date version of the template that explicitly compatible with 25.09.4, I’d say that updating to it is the best option here. If PGN parsing is the only obstacle, then figuring it out instead of attempting making an obsolete template compatible, seems like the way to go. Original template author appears to be active too, so you can direct any parsing question to them (there’s a discord link on the ankiweb page as well as the issues category on the github). If you share an example of PGN contents that are parsed successfully by the old template but fail in the new one, I can have a look at it too.
You have to be much more careful than that. You need to not use Anki while browsing the internet: