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', 'HtmlCollection',
'HtmlInputElement', 'HtmlInputElement',
'HtmlOListElement', 'HtmlOListElement',
'KeyboardEvent',
'Node', 'Node',
'NodeList', 'NodeList',
'Window', 'Window',

View File

@ -3,7 +3,7 @@
<meta charset="utf-8"/> <meta charset="utf-8"/>
<title>Kikikoz</title> <title>Kikikoz</title>
<script type="module"> <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() { async function run() {
await init() await init()
@ -11,6 +11,7 @@
run() run()
window.ajoute = ajoute; window.ajoute = ajoute;
window.ajoute_kp = ajoute_kp;
window.next = next; window.next = next;
</script> </script>
<link rel="stylesheet" href="kikikoz.css"/> <link rel="stylesheet" href="kikikoz.css"/>
@ -26,7 +27,8 @@
<ol> <ol>
</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>
<section class="queue" id="queue_non_prio"> <section class="queue" id="queue_non_prio">
@ -34,7 +36,8 @@
<ol> <ol>
</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> </section>
</body> </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] #[wasm_bindgen]
pub fn ajoute(id: &str) { pub fn ajoute(id: &str) {
let window = web_sys::window().expect("no global `window` exists"); let window = web_sys::window().expect("no global `window` exists");