mirror of
https://gitlab.kit.edu/uskyk/kv.git
synced 2024-11-22 00:45:03 +00:00
WASM: buttons to set entire input
This commit is contained in:
parent
b2eeecfae6
commit
1895421d68
@ -39,6 +39,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p id="examples">
|
<p id="examples">
|
||||||
Load <a href="#--111100">example 1</a>, <a href="#-1111000-1-01---">example 2</a>, <a href="#11101111111111111111101111111101">example 3</a>.
|
Load <a href="#--111100">example 1</a>, <a href="#-1111000-1-01---">example 2</a>, <a href="#11101111111111111111101111111101">example 3</a>.
|
||||||
|
Set all cells to <button id="set-0">0</button>, <button id="set-1">1</button> or <button id="set-any">-</button>.
|
||||||
</p>
|
</p>
|
||||||
<div id="input-container"></div>
|
<div id="input-container"></div>
|
||||||
<div><label>Generate: <select id="mode-select">
|
<div><label>Generate: <select id="mode-select">
|
||||||
|
@ -158,6 +158,18 @@ fn set_var_number(x: usize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init_settings() {
|
fn init_settings() {
|
||||||
|
let set0 = web!(document).get_element_by_id("set-0").unwrap().unchecked_into::<EventTarget>();
|
||||||
|
let closure = Closure::wrap(Box::new(|| set_input_function(&"0".repeat(2usize.pow(get_var_number() as u32)))) as Box<dyn FnMut()>);
|
||||||
|
set0.add_event_listener_with_callback("click", closure.as_ref().unchecked_ref()).unwrap();
|
||||||
|
closure.forget();
|
||||||
|
let set1 = web!(document).get_element_by_id("set-1").unwrap().unchecked_into::<EventTarget>();
|
||||||
|
let closure = Closure::wrap(Box::new(|| set_input_function(&"1".repeat(2usize.pow(get_var_number() as u32)))) as Box<dyn FnMut()>);
|
||||||
|
set1.add_event_listener_with_callback("click", closure.as_ref().unchecked_ref()).unwrap();
|
||||||
|
closure.forget();
|
||||||
|
let seta = web!(document).get_element_by_id("set-any").unwrap().unchecked_into::<EventTarget>();
|
||||||
|
let closure = Closure::wrap(Box::new(|| set_input_function(&"-".repeat(2usize.pow(get_var_number() as u32)))) as Box<dyn FnMut()>);
|
||||||
|
seta.add_event_listener_with_callback("click", closure.as_ref().unchecked_ref()).unwrap();
|
||||||
|
closure.forget();
|
||||||
let calculate = web!(document).get_element_by_id("calculate").unwrap().unchecked_into::<EventTarget>();
|
let calculate = web!(document).get_element_by_id("calculate").unwrap().unchecked_into::<EventTarget>();
|
||||||
let closure = Closure::wrap(Box::new(|| run()) as Box<dyn FnMut()>);
|
let closure = Closure::wrap(Box::new(|| run()) as Box<dyn FnMut()>);
|
||||||
calculate.add_event_listener_with_callback("click", closure.as_ref().unchecked_ref()).unwrap();
|
calculate.add_event_listener_with_callback("click", closure.as_ref().unchecked_ref()).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user