diff --git a/src/vn.rs b/src/vn.rs index b8ee83a..de0cb1a 100644 --- a/src/vn.rs +++ b/src/vn.rs @@ -68,7 +68,7 @@ fn render_dialog_block(block: &DialogBlock) -> Markup { convert(block.lines.iter().map(|l| l.text.as_ref()), &mut content); html! { - fieldset .visual-novel-box { + fieldset .visual-novel-box onclick="playCurrentAudio()" { @if !block.name.is_empty() { legend .character-name { (block.name) } } @@ -359,9 +359,9 @@ fn interactive_script(total_sections: usize, base_path: &str) -> Markup { let currentAudio = null; - function playSectionAudio(index) {{ + function playCurrentAudio() {{ const section = document.querySelector( - `.selection-section[data-section-index="${{index}}"]` + `.selection-section[data-section-index="${{currentScene}}"]` ); const audioElement = section?.querySelector('audio'); @@ -379,10 +379,10 @@ fn interactive_script(total_sections: usize, base_path: &str) -> Markup { }}); toggleText(true); - document.getElementById('section-counter').textContent = + document.getElementById('section-counter').textContent = `${{currentScene + 1}}/${{totalSections}}`; - if (currentScene + 1 < totalSections) playSectionAudio(currentScene); + if (currentScene + 1 < totalSections) playCurrentAudio(); }} function prev() {{