typing indicator
This commit is contained in:
@@ -86,6 +86,8 @@
|
||||
print(data.Text);
|
||||
} else if (data.QuietText) {
|
||||
print(data.QuietText);
|
||||
} else if (data.Typing) {
|
||||
print("(someone is typing...)")
|
||||
}
|
||||
}
|
||||
function ws_onerror(evt) {
|
||||
@@ -131,6 +133,21 @@
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var typing_clear_timeout = 0;
|
||||
input.onkeyup = function() {
|
||||
if (input.value) {
|
||||
if (!typing_clear_timeout) {
|
||||
ws.send(`{"Typing":true}`);
|
||||
} else {
|
||||
clearTimeout(typing_clear_timeout);
|
||||
}
|
||||
typing_clear_timeout = setTimeout(() => {
|
||||
ws.send(`{"Typing":false}`);
|
||||
typing_clear_timeout = 0;
|
||||
}, 3000);
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
||||
@@ -3,6 +3,7 @@ package server
|
||||
type message struct {
|
||||
Text string
|
||||
QuietText string
|
||||
Typing bool
|
||||
Pitch int
|
||||
Rate float64
|
||||
VoiceIdx int
|
||||
|
||||
Reference in New Issue
Block a user