aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--webAO/client.js38
1 files changed, 36 insertions, 2 deletions
diff --git a/webAO/client.js b/webAO/client.js
index 9817390..de22a0e 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -250,12 +250,21 @@ class Client extends EventEmitter {
* Hook for sending messages to the client
* @param {string} message the message to send
*/
- sendSelf(message) {
- document.getElementById("client_ooclog").value += message + "\r\n";
+ handleSelf(message) {
const message_event = new MessageEvent('websocket', { data: message });
setTimeout(() => this.onMessage(message_event), 1);
+ }
+
+ /**
+ * Hook for sending messages to the client
+ * @param {string} message the message to send
+ */
+ sendSelf(message) {
+ document.getElementById("client_ooclog").value += message + "\r\n";
+ this.handleSelf(message);
}
+
/**
* Sends an out-of-character chat message.
* @param {string} message the message to send
@@ -543,6 +552,22 @@ class Client extends EventEmitter {
}
/**
+ * Parse the lines in the OOC and play them
+ * @param {*} args packet arguments
+ */
+ handleReplay() {
+ const ooclog = document.getElementById("client_ooclog");
+ const rtime = document.getElementById("client_replaytimer").value;
+
+ const clines = ooclog.value.split(/\r?\n/);
+ if (clines[0]) {
+ this.handleSelf(clines[0]);
+ ooclog.value = clines.slice(1).join("\r\n");
+ setTimeout(() => onReplayGo(""), rtime);
+ }
+ }
+
+ /**
* Handles an in-character chat message.
* @param {*} args packet arguments
*/
@@ -2160,6 +2185,15 @@ export function onOOCEnter(event) {
window.onOOCEnter = onOOCEnter;
/**
+ * Triggered when the user click replay GOOOOO
+ * @param {KeyboardEvent} event
+ */
+export function onReplayGo(_event) {
+ client.handleReplay();
+}
+window.onReplayGo = onReplayGo;
+
+/**
* Triggered when the Return key is pressed on the in-character chat input box.
* @param {KeyboardEvent} event
*/