aboutsummaryrefslogtreecommitdiff
path: root/webAO/client.js
diff options
context:
space:
mode:
authorstonedDiscord <stoned@derpymail.org>2019-07-26 16:04:55 +0200
committerstonedDiscord <stoned@derpymail.org>2019-07-26 16:04:55 +0200
commitbc0592b4c5f1f5c130c19eb89d4061b7cd77cdba (patch)
tree3ce976c4d20d79954a1074651e997e2dc42c8167 /webAO/client.js
parent87a9c3992e1c3f52bb6320577a24790fcae8d6e0 (diff)
add setCookie and use web123 if the cookie is empty
Diffstat (limited to 'webAO/client.js')
-rw-r--r--webAO/client.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/webAO/client.js b/webAO/client.js
index e6647c1..90d9ba0 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -168,7 +168,7 @@ class Client extends EventEmitter {
* @param {string} message the message to send
*/
sendOOC(message) {
- document.cookie = "OOC_name=" + escapeChat(encodeChat(document.getElementById("OOC_name").value));
+ setCookie("OOC_name",escapeChat(encodeChat(document.getElementById("OOC_name").value)));
this.serv.send(`CT#${escapeChat(encodeChat(document.getElementById("OOC_name").value))}#${escapeChat(encodeChat(message))}#%`);
}
@@ -286,7 +286,7 @@ class Client extends EventEmitter {
loadResources() {
// Set to playerID to server chat name
// TODO: Make a text box for this!
- document.getElementById("OOC_name").value = getCookie("OOC_name");
+ document.getElementById("OOC_name").value = getCookie("OOC_name") !== "" ? "web" + this.playerID : getCookie("OOC_name");
// Load evidence array to select
const evidence_select = document.getElementById("evi_select");
@@ -1341,6 +1341,16 @@ function getCookie(cname) {
}
/**
+ * set a cookie
+ * the version from w3schools expects these to expire
+ * @param {String} cname The name of the cookie to return
+ * @param {String} value The value of that cookie option
+ */
+function setCookie(cname,value) {
+ document.cookie = cname + "=" + value;
+}
+
+/**
* Triggered when the Return key is pressed on the out-of-character chat input box.
* @param {KeyboardEvent} event
*/