英文:
How to show only one video from multiple videos on Anki Card
问题
我有一些卡片,其中背面附有多个带有视频文件的声音标签。我只想随机选择其中一个并显示在卡片上。不幸的是,我还没有能做到这一点。
英文:
I have cards where a back note has multiple sound tags with video files. I want only one of them to be randomly selected and appear on the card. Unfortunately, I haven't been able to do this.
答案1
得分: 0
这是翻译好的部分:
最终,我想出了这个解决方案:
前/后模板
// "soundLink": Anki desktop | "replaybutton": AnkiDroid
var buttons = document.querySelectorAll(".soundLink, .replaybutton");
if (buttons) {
const randomIndex = Math.floor(Math.random() * buttons.length);
buttons[randomIndex].classList.add("active");
}
CSS
.soundLink,
.replaybutton {
display: none;
}
.soundLink.active,
.replaybutton.active {
display: inline-block;
}
请注意,我已经移除了HTML注释<!-- language: lang-js -->
和<!-- language: lang-css -->
,因为这些注释不需要翻译。
英文:
Finally I came up with this solution:
Front / Back Template
<!-- language: lang-js -->
// "soundLink": Anki desktop | "replaybutton": AnkiDroid
var buttons = document.querySelectorAll(".soundLink, .replaybutton");
if (buttons) {
const randomIndex = Math.floor(Math.random() * buttons.length);
buttons[randomIndex].classList.add("active");
}
CSS
<!-- language: lang-css -->
.soundLink,
.replaybutton {
display: none;
}
.soundLink.active,
.replaybutton.active {
display: inline-block;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论