mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
This uses a browser skin element to spy on the command bar and report back to the server what verb is currently in it and how many characters it has. it skips reporting if the text hasn't changed since the last report. im intentionally not providing the full text in the command bar to the server, while designing the system so new verbs can be given typing indicators by editing DM code, not html code. The report rate is once a second but this could be lowered or tweaked. Both the tgui say window being open and this system being active because the command bar starts with `say "` is undefined behavior, mostly the first one to end the indicator will just freeze indicators for the other one until it too ends its current indicator session. The system waits until something besides the `"` is in the argument to say. It is enabled for verbs `say`, `me`, and `whisper`. I don't actually know if this is the case for tgui say. this is a one line tweak anyways so let me know if this should be changed. [(This pr closes a bounty)](https://tgstation13.org/phpBB/viewtopic.php?p=726634#p726634) 🆑 MrStonedOne & Lilah Novi add: Say commands typed in the command bar now trigger typing indicators /🆑 --------- Co-authored-by: san7890 <the@ san7890.com>
47 lines
1.1 KiB
HTML
47 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
</head>
|
|
<body>
|
|
<script>
|
|
lastseentypedtext = "";
|
|
function getoutput() {
|
|
setTimeout(getoutput, 1000);
|
|
window.location = "byond://winget?callback=checkoutput&id=:Input&property=text";
|
|
}
|
|
function checkoutput(props) {
|
|
if (typeof props !== 'object')
|
|
return;
|
|
|
|
if (typeof props.text !== 'string' && !(props.text instanceof String))
|
|
return;
|
|
|
|
var text = props.text;
|
|
|
|
if (text == lastseentypedtext)
|
|
return;
|
|
|
|
lastseentypedtext = text;
|
|
|
|
var words = text.split(" ");
|
|
var verb = words[0];
|
|
var argument = "";
|
|
var argument_length = -1;
|
|
|
|
if (words.length >= 2) {
|
|
words.splice(0, 1)
|
|
argument = words.join(" ");
|
|
argument_length = argument.length;
|
|
}
|
|
|
|
if (argument_length > 0 && argument[0] == "\"")
|
|
argument_length -= 1;
|
|
|
|
window.location = "byond://?commandbar_typing=1&verb="+encodeURIComponent(verb)+"&argument_length="+argument_length;
|
|
}
|
|
setTimeout(getoutput, 2000);
|
|
</script>
|
|
</body>
|
|
</html>
|