Ajout des orateurices au clavier

master
Florent Becker 2020-10-08 00:27:30 +02:00
parent cdc350f260
commit 24d42c1401
3 changed files with 14 additions and 3 deletions

View File

@ -34,6 +34,7 @@ features = [
'HtmlCollection',
'HtmlInputElement',
'HtmlOListElement',
'KeyboardEvent',
'Node',
'NodeList',
'Window',

View File

@ -3,7 +3,7 @@
<meta charset="utf-8"/>
<title>Kikikoz</title>
<script type="module">
import {default as init, ajoute, next} from './pkg/kikikoz.js';
import {default as init, ajoute, ajoute_kp, next} from './pkg/kikikoz.js';
async function run() {
await init()
@ -11,6 +11,7 @@
run()
window.ajoute = ajoute;
window.ajoute_kp = ajoute_kp;
window.next = next;
</script>
<link rel="stylesheet" href="kikikoz.css"/>
@ -26,7 +27,8 @@
<ol>
</ol>
<p>Ajouter: <input type="text"/><button onclick='ajoute("queue_prio")'>x</button></p>
<p>Ajouter: <input type="text" onkeypress='ajoute_kp(event, "queue_prio")'/>
<button onclick='ajoute("queue_prio")'>x</button></p>
</section>
<section class="queue" id="queue_non_prio">
@ -34,7 +36,8 @@
<ol>
</ol>
<p>Ajouter: <input type="text"/><button onclick='ajoute("queue_non_prio")'>x</button></p>
<p>Ajouter: <input type="text" onkeypress='ajoute_kp(event, "queue_prio")'/>
<button onclick='ajoute("queue_non_prio")'>x</button></p>
</section>
</body>

View File

@ -45,6 +45,13 @@ pub fn next() {
}
}
#[wasm_bindgen]
pub fn ajoute_kp(ev: web_sys::KeyboardEvent, id: &str) {
if ev.key_code() == 13 {
ajoute(id)
}
}
#[wasm_bindgen]
pub fn ajoute(id: &str) {
let window = web_sys::window().expect("no global `window` exists");