Include next mora in greeting event
This commit is contained in:
parent
53fb1f3c4e
commit
f157c847bb
2 changed files with 14 additions and 5 deletions
|
@ -19,18 +19,25 @@ function displayWord(_word, end, delay) {
|
|||
div.scrollTop = div.offsetHeight;
|
||||
}
|
||||
|
||||
function updateInput(data) {
|
||||
if (data.next_mora !== null) {
|
||||
let waiting = data.author === id;
|
||||
input.placeholder = waiting ? "Waiting for other players..." : `${data.next_mora}…`;
|
||||
input.disabled = waiting;
|
||||
if (!waiting) input.focus();
|
||||
}
|
||||
}
|
||||
|
||||
ws.onmessage = e => {
|
||||
const { event, data } = JSON.parse(e.data);
|
||||
switch (event) {
|
||||
case "greeting":
|
||||
id = data.id;
|
||||
updateInput(data);
|
||||
break;
|
||||
case "word":
|
||||
let waiting = data.author === id;
|
||||
displayWord(data.word, true, 0);
|
||||
input.placeholder = waiting ? "Waiting for other players..." : `${data.next_mora}…`;
|
||||
input.disabled = waiting;
|
||||
if (!waiting) input.focus();
|
||||
updateInput(data);
|
||||
break;
|
||||
case "history":
|
||||
console.log(data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue