Dictionary with Example(s)

I have a dictionary with fields structure like this:

  • {{Front}} = “impegno [sound: snd_f.mp3]” // Let say this is an example.

  • {{Back}} = “commitment, engagement, obligation, pledge, dedication. [sound: snd_b.mp3]”

  • {{Ex1}} = "Ho preso un impegno qua (I made a commitment here). [sound: snd_ex1.mp3]

  • {{Ex2}} = "Hai gia’ un impegno o roba simile? (You got a prior engagement or something?). [sound: snd_ex2.mp3]

  • {{ExN}} = "Spero che il tenente apprezzi il tuo impegno. (I hope the lieutenant appreciates your dedication. ). [sound: snd_exN.mp3]

Where N - is a defined number of examples, some examples can be empty, some just text, some text + mp3

And want to make a javascript which for back side displays answer and only fields with existing examples (Ex1, Ex2, …, ExN) and button to play sound manually, but not auto.

Took similar javascript from another example here

<hr id=answer>

<div id="word-audio" style="display: none;">{{Ex2}}</div>
<button onclick="play_example_audio()">&nbsp</button>&nbsp
<script>
    function play_example_audio(){
        var audioDiv = document.getElementById('word-audio');
        var audio = audioDiv.getElementsByTagName("*");
        audio[0].click();
    }
</script>
	
{{Back}}

but have no idea how to make variable list [0…N] of examples per each meaning without autoplay for those examples with bulleted play button. Especially want to avoid playing any/all of examples audio with autoplay option, but how ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.