tvl-depot/tvix/docs/mdbook-extra.js
toastal 8e31088a01 docs(tvix): introduction
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>
2024-07-04 14:18:09 +00:00

24 lines
773 B
JavaScript

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