diff --git a/typers/src/main.rs b/typers/src/main.rs index a8d98de..85055c8 100644 --- a/typers/src/main.rs +++ b/typers/src/main.rs @@ -1,7 +1,7 @@ mod interval; -use crate::interval::{set_interval, clear_interval}; -use sycamore::prelude::*; +use crate::interval::{clear_interval, set_interval}; +use sycamore::{prelude::*, rt::Event}; use wasm_bindgen::prelude::*; #[wasm_bindgen] @@ -10,6 +10,8 @@ extern "C" { fn process_text(value: String) -> usize; #[wasm_bindgen] fn reset(); + #[wasm_bindgen] + fn reload(event: Event); } fn main() { @@ -140,7 +142,7 @@ fn main() { div(class="text-align-center") { "Great job!" br - button { "Click to restart" } + button(on:click=reload) { "Click to restart" } } } }) diff --git a/typers/utils.js b/typers/utils.js index c98c61b..5aa2949 100644 --- a/typers/utils.js +++ b/typers/utils.js @@ -32,4 +32,8 @@ function reset() { char.classList.remove('correct'); char.classList.remove('incorrect'); }) +} + +function reload(event) { + window.location.reload(); } \ No newline at end of file