aboutsummaryrefslogtreecommitdiff
path: root/webAO/client.js
diff options
context:
space:
mode:
authorstonedDiscord <stoned@derpymail.org>2019-07-26 13:24:25 +0200
committerstonedDiscord <stoned@derpymail.org>2019-07-26 13:24:25 +0200
commitc9759b9f1c3010ffdbe9a422cb9fb104349598cf (patch)
treef51ea59c5a5d4b0fefd4f8f2aea4446a0e275a70 /webAO/client.js
parent999d40256496dfe7beff3a8f422fa31f3fc3df92 (diff)
save ooc name to a cookie
Diffstat (limited to 'webAO/client.js')
-rw-r--r--webAO/client.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/webAO/client.js b/webAO/client.js
index 57b0d0c..9971d0e 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -35,9 +35,11 @@ if (/webOS|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|PlaySt
oldLoading = true;
}
+/** presettings */
let selectedEffect = 0;
let selectedMenu = 1;
let selectedShout = 0;
+document.getElementById("OOC_name").value = getCookie("OOC_name");
const fp = new Fingerprint({
canvas: true,
@@ -167,6 +169,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));
this.serv.send(`CT#${escapeChat(encodeChat(document.getElementById("OOC_name").value))}#${escapeChat(encodeChat(message))}#%`);
}
@@ -1067,7 +1070,7 @@ class Viewport {
duration += delay < 2 ? 10 : delay;
}
}
- return duration*10;
+ return duration * 10;
}
/**
@@ -1317,6 +1320,28 @@ class INI {
}
/**
+ * read a cookie from storage
+ * got this from w3schools
+ * https://www.w3schools.com/js/js_cookies.asp
+ * @param {String} cname The name of the cookie to return
+ */
+function getCookie(cname) {
+ var name = cname + "=";
+ var decodedCookie = decodeURIComponent(document.cookie);
+ var ca = decodedCookie.split(';');
+ for (var i = 0; i < ca.length; i++) {
+ var c = ca[i];
+ while (c.charAt(0) == ' ') {
+ c = c.substring(1);
+ }
+ if (c.indexOf(name) == 0) {
+ return c.substring(name.length, c.length);
+ }
+ }
+ return "";
+}
+
+/**
* Triggered when the Return key is pressed on the out-of-character chat input box.
* @param {KeyboardEvent} event
*/