如何在Anki卡片上只显示一个视频,而不是多个视频。

huangapple go评论95阅读模式
英文:

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 -->

// &quot;soundLink&quot;: Anki desktop | &quot;replaybutton&quot;: AnkiDroid
var buttons = document.querySelectorAll(&quot;.soundLink, .replaybutton&quot;);

if (buttons) {
  const randomIndex = Math.floor(Math.random() * buttons.length);
  buttons[randomIndex].classList.add(&quot;active&quot;);
}

CSS
<!-- language: lang-css -->

.soundLink,
.replaybutton {
  display: none;
}

.soundLink.active,
.replaybutton.active {
  display: inline-block;
}

huangapple
  • 本文由 发表于 2023年5月7日 01:54:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76190337.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定