diff options
author | toastal <toastal@posteo.net> | 2024-07-01T10·02+0700 |
---|---|---|
committer | toastal <toastal@posteo.net> | 2024-07-04T14·18+0000 |
commit | 8e31088a019c2c118e40323b1c7f9471805317c6 (patch) | |
tree | 8c0993fe4b21a14860041c488366fd95816a05d8 /tvix/docs/mdbook-extra.js | |
parent | 9ed967791c5f3c15f7b637efc5efa60044239721 (diff) |
docs(tvix): introduction r/8342
Includes hacky, but workable solution for the pronunciation ‘issue’ Karl comes from: http://ipa-reader.xyz/?text=tvɪks&voice=Karl Co-Authored-By: Florian Klink <flokli@flokli.de> Change-Id: Iad7788ec7295902fd2159766a664016c7b1e2ae9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11908 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/docs/mdbook-extra.js')
-rw-r--r-- | tvix/docs/mdbook-extra.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tvix/docs/mdbook-extra.js b/tvix/docs/mdbook-extra.js new file mode 100644 index 000000000000..bff412e69eb2 --- /dev/null +++ b/tvix/docs/mdbook-extra.js @@ -0,0 +1,24 @@ +"use strict" + +function main() { + document.removeEventListener("DOMContentLoaded", main, false) + + // NOTE: this is a hacky solution but should do the job for making a + // listenable audio link + function playAudio(evt) { + evt.preventDefault() + var audio = document.createElement("audio") + audio.addEventListener("ended", function() { audio.delete() }, false) + audio.addEventListener("loadeddata", function() { audio.play() }, false) + audio.src = evt.target.href + audio.load() + } + + var audios = document.querySelectorAll("a[href^=\"data:audio/\"]") + Array.prototype.forEach.call(audios, function setupAudio(elem) { + elem.setAttribute("role", "button") + elem.addEventListener("click", playAudio, false) + }) +} + +document.addEventListener("DOMContentLoaded", main, false) |