Make number of voriables instant apply

This commit is contained in:
Arne Keller 2024-11-09 11:37:49 +01:00
parent 38a5d2d36d
commit 06a1d808de
2 changed files with 3 additions and 3 deletions

View File

@ -40,7 +40,7 @@
<div><h1>KV diagram calculator</h1><a href="https://gitlab.kit.edu/uskyk/kv">(source code)</a></div>
<div id="main">
<div id="settings">
<label>Number of variables: <input type="number" min="1" value="3" id="variables"></label><button id="apply-variables">Apply</button>
<label>Number of variables: <input type="number" min="1" value="3" id="variables"></label>
</div>
<p id="hints">
Change output specification by scrolling (up => 1, down => 0), typing (=> 1, 0) or deleting (=> -).

View File

@ -174,9 +174,9 @@ fn init_settings() {
let closure = Closure::wrap(Box::new(|| run()) as Box<dyn FnMut()>);
calculate.add_event_listener_with_callback("click", closure.as_ref().unchecked_ref()).unwrap();
closure.forget();
let apply_count = web!(document).get_element_by_id("apply-variables").unwrap().unchecked_into::<EventTarget>();
let count = web!(document).get_element_by_id("variables").unwrap().unchecked_into::<EventTarget>();
let closure = Closure::wrap(Box::new(|| update_input_grid(&grid(get_var_number()))) as Box<dyn FnMut()>);
apply_count.add_event_listener_with_callback("click", closure.as_ref().unchecked_ref()).unwrap();
count.add_event_listener_with_callback("change", closure.as_ref().unchecked_ref()).unwrap();
closure.forget();
}