From 1c46a4c775872321271d9d11577503737ef14279 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 15:32:25 +0100 Subject: add showname ui --- webAO/client.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index ed28819..5702e13 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -838,6 +838,9 @@ class Client extends EventEmitter { handleFL(args) { console.info("Server-supported features:"); console.info(args); + if (args.contains("cccc_ic_support")) { + document.getElementById("cccc").style.display = ""; + } } /** -- cgit From 92d5ac9974f288deb6e08836b42fe271df846627 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 16:41:36 +0100 Subject: add shownames and prepare for cccc features --- webAO/client.js | 64 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 15 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 5702e13..4446d96 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -70,6 +70,7 @@ class Client extends EventEmitter { this.on("message", this.onMessage.bind(this)); this.on("error", this.onError.bind(this)); // Preset some of the variables + this.extrafeatures = []; this.flip = false; this.presentable = false; @@ -184,25 +185,34 @@ class Client extends EventEmitter { /** * Sends an in-character chat message. + * @param {string} deskmod currently unused * @param {string} speaking who is speaking * @param {string} name the name of the current character * @param {string} silent whether or not it's silent * @param {string} message the message to be sent * @param {string} side the name of the side in the background - * @param {string} ssfxname the name of the sound effect - * @param {string} zoom whether or not to zoom - * @param {number} ssfxdelay the delay (in milliseconds) to play the sound effect - * @param {string} objection the number of the shout to play + * @param {string} sfx_name the name of the sound effect + * @param {string} emote_modifier whether or not to zoom + * @param {number} sfx_delay the delay (in milliseconds) to play the sound effect + * @param {string} objection_modifier the number of the shout to play * @param {string} evidence the filename of evidence to show * @param {number} flip change to 1 to reverse sprite for position changes - * @param {string} flash screen flash effect - * @param {string} color text color + * @param {string} realization screen flash effect + * @param {string} text_color text color + * @param {string} showname custom name to be displayed (optional) + * @param {string} other_charid paired character (optional) + * @param {string} self_offset offset to paired character (optional) + * @param {string} noninterrupting_preanim play the full preanim (optional) */ - sendIC(speaking, name, silent, message, side, ssfxname, zoom, ssfxdelay, objection, evidence, flip, flash, color) { + sendIC(deskmod, speaking, name, silent, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim) { + let extra_cccc = ``; + if (this.extrafeatures.includes("cccc_ic_support")) { + extra_cccc = `${showname}#${other_charid}#${self_offset}#${noninterrupting_preanim}#`; + } this.serv.send( - `MS#chat#${speaking}#${name}#${silent}` + - `#${escapeChat(encodeChat(message))}#${side}#${ssfxname}#${zoom}` + - `#${this.charID}#${ssfxdelay}#${selectedShout}#${evidence}#${flip}#${flash}#${color}#%` + `MS#${deskmod}#${speaking}#${name}#${silent}` + + `#${escapeChat(encodeChat(message))}#${side}#${sfx_name}#${emote_modifier}` + + `#${this.charID}#${sfx_delay}#${objection_modifier}#${evidence}#${flip}#${realization}#${text_color}#${extra_cccc}%` ); } @@ -427,7 +437,8 @@ class Client extends EventEmitter { //we already set defaults } - const chatmsg = { + let chatmsg = { + deskmod: escape(args[1]), preanim: escape(args[2]).toLowerCase(), // get preanim nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed name: args[3].toLowerCase(), @@ -448,10 +459,27 @@ class Client extends EventEmitter { isnew: true, }; + if (this.extrafeatures.includes("cccc_ic_support")) { + const extra_options = { + showname: escape(args[16]), + other_charid: args[17], + other_name: args[18], + other_emote: args[19], + self_offset: args[20], + other_offset: args[21], + other_flip: args[22], + noninterrupting_preanim: args[23] + }; + chatmsg = Object.assign(extra_options, chatmsg); + if (chatmsg.showname && document.getElementById("showname").checked) { + chatmsg.nameplate = chatmsg.showname; + } + } + if (chatmsg.charid === this.charID) { resetICParams(); } - + console.log(chatmsg); viewport.say(chatmsg); // no await } } @@ -811,13 +839,17 @@ class Client extends EventEmitter { } /** - * Handles the issuance of a player ID by the server. + * Identifies the server and issues a playerID * @param {Array} args packet arguments */ handleID(args) { this.playerID = args[1]; } + /** + * Indicates how many users are on this server + * @param {Array} args packet arguments + */ handlePN(_args) { this.serv.send("askchaa#%"); } @@ -838,7 +870,8 @@ class Client extends EventEmitter { handleFL(args) { console.info("Server-supported features:"); console.info(args); - if (args.contains("cccc_ic_support")) { + this.extrafeatures = args; + if (args.includes("cccc_ic_support")) { document.getElementById("cccc").style.display = ""; } } @@ -1427,6 +1460,7 @@ export function onEnter(event) { const myevi = client.evidence; const myflip = ((client.flip) ? 1 : 0); const mycolor = document.getElementById("textcolor").value; + const showname = document.getElementById("ic_chat_name").value; let ssfxname = "0"; let ssfxdelay = "0"; if (document.getElementById("sendsfx").checked) { @@ -1437,7 +1471,7 @@ export function onEnter(event) { client.sendIC(myemo.speaking, mychar.name, myemo.silent, document.getElementById("client_inputbox").value, mychar.side, ssfxname, myemo.zoom, ssfxdelay, selectedShout, myevi, myflip, - selectedEffect, mycolor); + selectedEffect, mycolor, showname); } } window.onEnter = onEnter; -- cgit From 0f09863265a922bdabd65f912e782da69fab06d0 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 16:52:53 +0100 Subject: adjust colors to match the client --- webAO/client.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 4446d96..a477474 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1308,15 +1308,16 @@ class Viewport { chatBox.style.display = "block"; chatBox.style.fontSize = (chatBox.offsetHeight * 0.25) + "px"; - // TODO: add missing colors - const colors = { - "0": "#ffffff", - "1": "#00ff00", - "2": "#ff0000", - "3": "#ffaa00", - "4": "#0000ff", - "5": "#ffff00", - "6": "#aa00aa" + let colors = { + "0": "#ffffff", // white + "1": "#00ff00", // green + "2": "#ff0000", // red + "3": "#ffa500", // orange + "4": "#4596ff", // blue + "5": "#ffff00", // yellow + "6": "#fedcba", // 6 is rainbow. + "7": "#aac0cb", // pink + "8": "#00ffff" // cyan }; chatBoxInner.style.color = colors[this.chatmsg.color] || "#ffffff"; this.chatmsg.startspeaking = false; -- cgit From d76123f3745fafad75450eea84b37fa4d3697312 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 17:56:12 +0100 Subject: handle colors like client --- webAO/client.js | 53 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index a477474..9fc169a 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -197,18 +197,27 @@ class Client extends EventEmitter { * @param {string} objection_modifier the number of the shout to play * @param {string} evidence the filename of evidence to show * @param {number} flip change to 1 to reverse sprite for position changes - * @param {string} realization screen flash effect - * @param {string} text_color text color + * @param {number} realization screen flash effect + * @param {number} text_color text color * @param {string} showname custom name to be displayed (optional) - * @param {string} other_charid paired character (optional) - * @param {string} self_offset offset to paired character (optional) - * @param {string} noninterrupting_preanim play the full preanim (optional) + * @param {number} other_charid paired character (optional) + * @param {string} other_name offset to paired character (optional) + * @param {string} other_emote offset to paired character (optional) + * @param {number} self_offset offset to paired character (optional) + * @param {number} other_offset offset to paired character (optional) + * @param {number} other_flip offset to paired character (optional) + * @param {number} noninterrupting_preanim play the full preanim (optional) */ - sendIC(deskmod, speaking, name, silent, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim) { + sendIC(deskmod, speaking, name, silent, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, other_name, other_emote, self_offset, other_offset, other_flip, noninterrupting_preanim) { let extra_cccc = ``; - if (this.extrafeatures.includes("cccc_ic_support")) { + if (this.extrafeatures.includes("cccc_ic_support") ) { extra_cccc = `${showname}#${other_charid}#${self_offset}#${noninterrupting_preanim}#`; } + console.log( + `MS#${deskmod}#${speaking}#${name}#${silent}` + + `#${escapeChat(encodeChat(message))}#${side}#${sfx_name}#${emote_modifier}` + + `#${this.charID}#${sfx_delay}#${objection_modifier}#${evidence}#${flip}#${realization}#${text_color}#${extra_cccc}%` + ); this.serv.send( `MS#${deskmod}#${speaking}#${name}#${silent}` + `#${escapeChat(encodeChat(message))}#${side}#${sfx_name}#${emote_modifier}` + @@ -479,7 +488,7 @@ class Client extends EventEmitter { if (chatmsg.charid === this.charID) { resetICParams(); } - console.log(chatmsg); + viewport.say(chatmsg); // no await } } @@ -859,7 +868,7 @@ class Client extends EventEmitter { * webAO doesn't have this feature yet, but i want the warning to go away. * @param {Array} args packet arguments */ - handleARUP(args) { + handleARUP(_args) { // TODO: webAO doesn't have this feature yet } @@ -871,6 +880,15 @@ class Client extends EventEmitter { console.info("Server-supported features:"); console.info(args); this.extrafeatures = args; + + if (args.includes("yellowtext")) { + let colorselect = document.getElementById("textcolor"); + + colorselect.options[colorselect.options.length] = new Option("Yellow", 5); + colorselect.options[colorselect.options.length] = new Option("Pink", 7); + colorselect.options[colorselect.options.length] = new Option("Cyan", 8); + } + if (args.includes("cccc_ic_support")) { document.getElementById("cccc").style.display = ""; } @@ -1462,17 +1480,18 @@ export function onEnter(event) { const myflip = ((client.flip) ? 1 : 0); const mycolor = document.getElementById("textcolor").value; const showname = document.getElementById("ic_chat_name").value; - let ssfxname = "0"; - let ssfxdelay = "0"; + const mytext = document.getElementById("client_inputbox").value; + let sfxname = "0"; + let sfxdelay = "0"; if (document.getElementById("sendsfx").checked) { - ssfxname = myemo.sfx; - ssfxdelay = myemo.sfxdelay; + sfxname = myemo.sfx; + sfxdelay = myemo.sfxdelay; } - client.sendIC(myemo.speaking, mychar.name, myemo.silent, - document.getElementById("client_inputbox").value, mychar.side, - ssfxname, myemo.zoom, ssfxdelay, selectedShout, myevi, myflip, - selectedEffect, mycolor, showname); + client.sendIC("chat", myemo.speaking, mychar.name, myemo.silent, + mytext, mychar.side, + sfxname, myemo.zoom, sfxdelay, selectedShout, myevi, myflip, + selectedEffect, mycolor, showname, -1, "", "", 0, 0, 0, 0); } } window.onEnter = onEnter; -- cgit From 0db57eb3e94aa77b45e957516770cd00115b84b4 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 18:04:28 +0100 Subject: add pairing ui --- webAO/client.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9fc169a..6437df7 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -562,6 +562,11 @@ class Client extends EventEmitter { // If it does, give the user a visual indication that the character is unusable } + const mute_select = document.getElementById("mute_select"); + mute_select.add(new Option(escape(chargs[0]), charid)); + const pair_select = document.getElementById("pair_select"); + pair_select.add(new Option(escape(chargs[0]), charid)); + // sometimes ini files lack important settings const default_options = { name: chargs[0], @@ -891,6 +896,7 @@ class Client extends EventEmitter { if (args.includes("cccc_ic_support")) { document.getElementById("cccc").style.display = ""; + document.getElementById("pairing").style.display = ""; } } -- cgit From 772e8eb4f5869b47f2000285ecf85a0cdc06b485 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 18:16:21 +0100 Subject: correct mute ui, add pairing send to code --- webAO/client.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 6437df7..8d2bb27 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -201,14 +201,10 @@ class Client extends EventEmitter { * @param {number} text_color text color * @param {string} showname custom name to be displayed (optional) * @param {number} other_charid paired character (optional) - * @param {string} other_name offset to paired character (optional) - * @param {string} other_emote offset to paired character (optional) * @param {number} self_offset offset to paired character (optional) - * @param {number} other_offset offset to paired character (optional) - * @param {number} other_flip offset to paired character (optional) * @param {number} noninterrupting_preanim play the full preanim (optional) */ - sendIC(deskmod, speaking, name, silent, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, other_name, other_emote, self_offset, other_offset, other_flip, noninterrupting_preanim) { + sendIC(deskmod, speaking, name, silent, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim) { let extra_cccc = ``; if (this.extrafeatures.includes("cccc_ic_support") ) { extra_cccc = `${showname}#${other_charid}#${self_offset}#${noninterrupting_preanim}#`; @@ -1487,6 +1483,8 @@ export function onEnter(event) { const mycolor = document.getElementById("textcolor").value; const showname = document.getElementById("ic_chat_name").value; const mytext = document.getElementById("client_inputbox").value; + const pairchar = document.getElementById("pair_select").value; + const pairoffset = document.getElementById("pair_offset").value; let sfxname = "0"; let sfxdelay = "0"; if (document.getElementById("sendsfx").checked) { @@ -1497,7 +1495,7 @@ export function onEnter(event) { client.sendIC("chat", myemo.speaking, mychar.name, myemo.silent, mytext, mychar.side, sfxname, myemo.zoom, sfxdelay, selectedShout, myevi, myflip, - selectedEffect, mycolor, showname, -1, "", "", 0, 0, 0, 0); + selectedEffect, mycolor, showname, pairchar, pairoffset, 0); } } window.onEnter = onEnter; @@ -1536,6 +1534,17 @@ export function musiclist_click(_event) { } window.musiclist_click = musiclist_click; +/** + * Triggered when a character in the mute list is clicked + * @param {MouseEvent} event + */ +export function mutelist_click(_event) { + const select_character = document.getElementById("mute_select").value; + + // TODO: i don't feel like writing this rn +} +window.musiclist_click = mutelist_click; + /** * Triggered when an item on the area list is clicked. * @param {MouseEvent} event -- cgit From e5ba4be22c3e77d120c8aaf17d19e6b439ea180b Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 18:41:42 +0100 Subject: basic pairing --- webAO/client.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 8d2bb27..512dc22 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -43,6 +43,8 @@ let selectedEffect = 0; let selectedMenu = 1; let selectedShout = 0; +let extrafeatures = []; + const fp = new Fingerprint({ canvas: true, ie_activex: true, @@ -69,8 +71,9 @@ class Client extends EventEmitter { this.on("close", this.onClose.bind(this)); this.on("message", this.onMessage.bind(this)); this.on("error", this.onError.bind(this)); + // Preset some of the variables - this.extrafeatures = []; + this.flip = false; this.presentable = false; @@ -206,7 +209,7 @@ class Client extends EventEmitter { */ sendIC(deskmod, speaking, name, silent, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim) { let extra_cccc = ``; - if (this.extrafeatures.includes("cccc_ic_support") ) { + if (extrafeatures.includes("cccc_ic_support") ) { extra_cccc = `${showname}#${other_charid}#${self_offset}#${noninterrupting_preanim}#`; } console.log( @@ -464,7 +467,7 @@ class Client extends EventEmitter { isnew: true, }; - if (this.extrafeatures.includes("cccc_ic_support")) { + if (extrafeatures.includes("cccc_ic_support")) { const extra_options = { showname: escape(args[16]), other_charid: args[17], @@ -880,7 +883,7 @@ class Client extends EventEmitter { handleFL(args) { console.info("Server-supported features:"); console.info(args); - this.extrafeatures = args; + extrafeatures = args; if (args.includes("yellowtext")) { let colorselect = document.getElementById("textcolor"); @@ -1217,6 +1220,7 @@ class Viewport { const nameBox = document.getElementById("client_name"); const chatBox = document.getElementById("client_chat"); const charSprite = document.getElementById("client_char"); + const pairSprite = document.getElementById("client_pair_char"); const eviBox = document.getElementById("client_evi"); const background = document.getElementById("client_background"); const shoutSprite = document.getElementById("client_shout"); @@ -1229,6 +1233,15 @@ class Viewport { charSprite.style.transform = "scaleX(1)"; } + if (extrafeatures.includes("cccc_ic_support")) { + // Flip the pair character + if (this.chatmsg.other_flip === "1") { + pairSprite.style.transform = "scaleX(-1)"; + } else { + pairSprite.style.transform = "scaleX(1)"; + } + } + if (this._animating) { this.updater = setTimeout(() => this.tick(), UPDATE_INTERVAL); } @@ -1291,6 +1304,17 @@ class Viewport { charSprite.src = `${AO_HOST}characters/${charName}/${preanim}.gif`; } + if (extrafeatures.includes("cccc_ic_support")) { + if (this.chatmsg.other_name) { + const pairName = this.chatmsg.other_name.toLowerCase(); + const pairEmote = this.chatmsg.other_emote.toLowerCase(); + pairSprite.style.display = ""; + pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; + } else { + pairSprite.style.display = "none"; + } + } + this.chatmsg.startpreanim = false; this.chatmsg.startspeaking = true; } else if (this.textTimer >= this.shoutTimer + this.chatmsg.preanimdelay && !this.chatmsg.startpreanim) { -- cgit From 14a820df051d53e9a3254b819c1b63c84c549b14 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 18:47:12 +0100 Subject: fix offset --- webAO/client.js | 1 + 1 file changed, 1 insertion(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 512dc22..cccf2c8 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1309,6 +1309,7 @@ class Viewport { const pairName = this.chatmsg.other_name.toLowerCase(); const pairEmote = this.chatmsg.other_emote.toLowerCase(); pairSprite.style.display = ""; + pairSprite.style.left = this.chatmsg.other_offset+"%"; pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; } else { pairSprite.style.display = "none"; -- cgit From be568feef204eeb07ded55cb51c1e4ba8f2e9c92 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 19:00:25 +0100 Subject: self offset --- webAO/client.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index cccf2c8..c5ff1b2 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1259,6 +1259,9 @@ class Viewport { "2": "objection", "3": "takethat" }; + // Hide old characters + charSprite.style.display = "none"; + pairSprite.style.display = "none"; // gets which shout shall played const shout = shouts[this.chatmsg.objection]; @@ -1302,15 +1305,17 @@ class Viewport { const charName = this.chatmsg.name.toLowerCase(); const preanim = this.chatmsg.preanim.toLowerCase(); charSprite.src = `${AO_HOST}characters/${charName}/${preanim}.gif`; + charSprite.style.display = ""; } if (extrafeatures.includes("cccc_ic_support")) { if (this.chatmsg.other_name) { const pairName = this.chatmsg.other_name.toLowerCase(); const pairEmote = this.chatmsg.other_emote.toLowerCase(); - pairSprite.style.display = ""; pairSprite.style.left = this.chatmsg.other_offset+"%"; + charSprite.style.left = this.chatmsg.self_offset+"%"; pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; + pairSprite.style.display = ""; } else { pairSprite.style.display = "none"; } @@ -1372,10 +1377,25 @@ class Viewport { changeBackground(this.chatmsg.side); } + if (extrafeatures.includes("cccc_ic_support")) { + if (this.chatmsg.other_name) { + const pairName = this.chatmsg.other_name.toLowerCase(); + const pairEmote = this.chatmsg.other_emote.toLowerCase(); + pairSprite.style.left = this.chatmsg.other_offset+"%"; + charSprite.style.left = this.chatmsg.self_offset+"%"; + pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; + pairSprite.style.display = ""; + } else { + pairSprite.style.display = "none"; + } + } + charSprite.src = AO_HOST + "characters/" + this.chatmsg.name.toLowerCase() + "/" + this.chatmsg.speaking.toLowerCase() + ".gif"; + charSprite.style.display = ""; if (this.textnow === this.chatmsg.content) { charSprite.src = AO_HOST + "characters/" + this.chatmsg.name.toLowerCase() + "/" + this.chatmsg.silent.toLowerCase() + ".gif"; + charSprite.style.display = ""; this._animating = false; clearTimeout(this.updater); } @@ -1397,6 +1417,7 @@ class Viewport { this.textTimer = 0; this._animating = false; charSprite.src = AO_HOST + "characters/" + this.chatmsg.name.toLowerCase() + "/" + this.chatmsg.silent.toLowerCase() + ".gif"; + charSprite.style.display = ""; clearTimeout(this.updater); } } -- cgit From 50718dfeb5ecc0010e247e67b4a52777a4da033c Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 19:08:50 +0100 Subject: store showname in cookie --- webAO/client.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index c5ff1b2..f6917b8 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -317,6 +317,7 @@ class Client extends EventEmitter { if (document.getElementById("OOC_name").value==="") { document.getElementById("OOC_name").value = "web"+this.playerID; } + document.getElementById("client_mvolume").value = getCookie("musicVolume"); changeMusicVolume(); document.getElementById("client_svolume").value = getCookie("sfxVolume"); @@ -324,6 +325,9 @@ class Client extends EventEmitter { document.getElementById("client_bvolume").value = getCookie("blipVolume"); changeBlipVolume(); + document.getElementById("ic_chat_name").value = getCookie("ic_chat_name"); + document.getElementById("showname").value = getCookie("showname"); + // Load evidence array to select const evidence_select = document.getElementById("evi_select"); evidence_select.add(new Option("Custom", 0)); @@ -1318,6 +1322,7 @@ class Viewport { pairSprite.style.display = ""; } else { pairSprite.style.display = "none"; + charSprite.style.left = 0; } } @@ -1591,6 +1596,16 @@ export function mutelist_click(_event) { } window.musiclist_click = mutelist_click; +/** + * Triggered when the showname checkboc is clicked + * @param {MouseEvent} event + */ +export function showname_click(_event) { + setCookie("showname", document.getElementById("showname").value); + setCookie("ic_chat_name", document.getElementById("ic_chat_name").value); +} +window.showname_click = showname_click; + /** * Triggered when an item on the area list is clicked. * @param {MouseEvent} event -- cgit From f91da83cd23cfe7885c263b731e5730075f03551 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 19:31:16 +0100 Subject: fix checkbox cookie, replace escape method --- webAO/client.js | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index f6917b8..c29d6c6 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -51,6 +51,10 @@ const fp = new Fingerprint({ screen_resolution: true }); +function safe_tags(str) { + return str.replace(/&/g,'&').replace(//g,'>') ; +} + // An emulated, semi-unique HDID that is generally safe for HDID bans. const hdid = fp.get(); console.info(`Your emulated HDID is ${hdid}`); @@ -326,7 +330,7 @@ class Client extends EventEmitter { changeBlipVolume(); document.getElementById("ic_chat_name").value = getCookie("ic_chat_name"); - document.getElementById("showname").value = getCookie("showname"); + document.getElementById("showname").checked = getCookie("showname"); // Load evidence array to select const evidence_select = document.getElementById("evi_select"); @@ -450,15 +454,15 @@ class Client extends EventEmitter { } let chatmsg = { - deskmod: escape(args[1]), - preanim: escape(args[2]).toLowerCase(), // get preanim + deskmod: safe_tags(args[1]), + preanim: safe_tags(args[2]).toLowerCase(), // get preanim nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed name: args[3].toLowerCase(), - speaking: "(b)" + escape(args[4]).toLowerCase(), - silent: "(a)" + escape(args[4]).toLowerCase(), + speaking: "(b)" + safe_tags(args[4]).toLowerCase(), + silent: "(a)" + safe_tags(args[4]).toLowerCase(), content: this.prepChat(args[5]), // Escape HTML tags side: args[6].toLowerCase(), - sound: escape(args[7]).toLowerCase(), + sound: safe_tags(args[7]).toLowerCase(), blips: msg_blips, type: args[8], charid: args[9], @@ -473,7 +477,7 @@ class Client extends EventEmitter { if (extrafeatures.includes("cccc_ic_support")) { const extra_options = { - showname: escape(args[16]), + showname: safe_tags(args[16]), other_charid: args[17], other_name: args[18], other_emote: args[19], @@ -550,14 +554,14 @@ class Client extends EventEmitter { */ async handleCharacterInfo(chargs, charid) { let cini = {}; - let icon = AO_HOST + "characters/" + escape(chargs[0]).toLowerCase() + "/char_icon.png"; + let icon = AO_HOST + "characters/" + safe_tags(chargs[0]).toLowerCase() + "/char_icon.png"; let img = document.getElementById(`demo_${charid}`); img.alt = chargs[0]; img.src = icon; // seems like a good time to load the icon // If the ini doesn't exist on the server this will throw an error try { - const cinidata = await request(AO_HOST + "characters/" + escape(chargs[0]).toLowerCase() + "/char.ini"); + const cinidata = await request(AO_HOST + "characters/" + safe_tags(chargs[0]).toLowerCase() + "/char.ini"); cini = INI.parse(cinidata); } catch(err) { cini = {}; @@ -566,9 +570,9 @@ class Client extends EventEmitter { } const mute_select = document.getElementById("mute_select"); - mute_select.add(new Option(escape(chargs[0]), charid)); + mute_select.add(new Option(safe_tags(chargs[0]), charid)); const pair_select = document.getElementById("pair_select"); - pair_select.add(new Option(escape(chargs[0]), charid)); + pair_select.add(new Option(safe_tags(chargs[0]), charid)); // sometimes ini files lack important settings const default_options = { @@ -580,10 +584,10 @@ class Client extends EventEmitter { cini.options = Object.assign(default_options, cini.options); this.chars[charid] = { - name: escape(chargs[0]), - showname: escape(cini.options.showname), - desc: escape(chargs[1]), - gender: escape(cini.options.gender).toLowerCase(), + name: safe_tags(chargs[0]), + showname: safe_tags(cini.options.showname), + desc: safe_tags(chargs[1]), + gender: safe_tags(cini.options.gender).toLowerCase(), evidence: chargs[3], icon: icon, inifile: cini @@ -652,8 +656,8 @@ class Client extends EventEmitter { this.evidences[i - 1] = { name: decodeChat(unescapeChat(arg[0])), desc: decodeChat(unescapeChat(arg[1])), - filename: escape(arg[2]), - icon: AO_HOST + "evidence/" + escape(arg[2].toLowerCase()) + filename: safe_tags(arg[2]), + icon: AO_HOST + "evidence/" + safe_tags(arg[2].toLowerCase()) }; } @@ -748,7 +752,7 @@ class Client extends EventEmitter { */ handleKK(args) { document.getElementById("client_loading").style.display = "flex"; - document.getElementById("client_loadingtext").innerHTML = "Kicked: " + escape(args[1]); + document.getElementById("client_loadingtext").innerHTML = "Kicked: " + safe_tags(args[1]); } /** @@ -758,7 +762,7 @@ class Client extends EventEmitter { */ handleKB(args) { document.getElementById("client_loading").style.display = "flex"; - document.getElementById("client_loadingtext").innerHTML = "You got banned: " + escape(args[1]); + document.getElementById("client_loadingtext").innerHTML = "You got banned: " + safe_tags(args[1]); } /** @@ -768,7 +772,7 @@ class Client extends EventEmitter { */ handleBD(args) { document.getElementById("client_loading").style.display = "flex"; - document.getElementById("client_loadingtext").innerHTML = "Banned: " + escape(args[1]); + document.getElementById("client_loadingtext").innerHTML = "Banned: " + safe_tags(args[1]); } /** @@ -791,14 +795,14 @@ class Client extends EventEmitter { * @param {Array} args packet arguments */ handleBN(args) { - viewport.bgname = escape(args[1]); - const bg_index = getIndexFromSelect("bg_select", escape(args[1])); + viewport.bgname = safe_tags(args[1]); + const bg_index = getIndexFromSelect("bg_select", safe_tags(args[1])); document.getElementById("bg_select").selectedIndex = bg_index; updateBackgroundPreview(); if (bg_index === 0) { document.getElementById("bg_filename").value = args[1]; } - document.getElementById("bg_preview").src = AO_HOST + "background/" + escape(args[1].toLowerCase()) + "/defenseempty.png"; + document.getElementById("bg_preview").src = AO_HOST + "background/" + safe_tags(args[1].toLowerCase()) + "/defenseempty.png"; if (this.charID === -1) { changeBackground("jud"); } else { @@ -1433,7 +1437,7 @@ class Viewport { this.sfxaudio.pause(); this.sfxplayed = 1; if (this.chatmsg.sound !== "0" && this.chatmsg.sound !== "1") { - this.sfxaudio.src = AO_HOST + "sounds/general/" + escape(this.chatmsg.sound.toLowerCase()) + ".wav"; + this.sfxaudio.src = AO_HOST + "sounds/general/" + safe_tags(this.chatmsg.sound.toLowerCase()) + ".wav"; this.sfxaudio.play(); } } @@ -1601,7 +1605,7 @@ window.musiclist_click = mutelist_click; * @param {MouseEvent} event */ export function showname_click(_event) { - setCookie("showname", document.getElementById("showname").value); + setCookie("showname", document.getElementById("showname").checked); setCookie("ic_chat_name", document.getElementById("ic_chat_name").value); } window.showname_click = showname_click; -- cgit From 9c73a040c53835e200f28db1d0730084c95f5d7c Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 19:53:30 +0100 Subject: Revert "fix checkbox cookie, replace escape method" This reverts commit f91da83cd23cfe7885c263b731e5730075f03551. --- webAO/client.js | 54 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index c29d6c6..f6917b8 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -51,10 +51,6 @@ const fp = new Fingerprint({ screen_resolution: true }); -function safe_tags(str) { - return str.replace(/&/g,'&').replace(//g,'>') ; -} - // An emulated, semi-unique HDID that is generally safe for HDID bans. const hdid = fp.get(); console.info(`Your emulated HDID is ${hdid}`); @@ -330,7 +326,7 @@ class Client extends EventEmitter { changeBlipVolume(); document.getElementById("ic_chat_name").value = getCookie("ic_chat_name"); - document.getElementById("showname").checked = getCookie("showname"); + document.getElementById("showname").value = getCookie("showname"); // Load evidence array to select const evidence_select = document.getElementById("evi_select"); @@ -454,15 +450,15 @@ class Client extends EventEmitter { } let chatmsg = { - deskmod: safe_tags(args[1]), - preanim: safe_tags(args[2]).toLowerCase(), // get preanim + deskmod: escape(args[1]), + preanim: escape(args[2]).toLowerCase(), // get preanim nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed name: args[3].toLowerCase(), - speaking: "(b)" + safe_tags(args[4]).toLowerCase(), - silent: "(a)" + safe_tags(args[4]).toLowerCase(), + speaking: "(b)" + escape(args[4]).toLowerCase(), + silent: "(a)" + escape(args[4]).toLowerCase(), content: this.prepChat(args[5]), // Escape HTML tags side: args[6].toLowerCase(), - sound: safe_tags(args[7]).toLowerCase(), + sound: escape(args[7]).toLowerCase(), blips: msg_blips, type: args[8], charid: args[9], @@ -477,7 +473,7 @@ class Client extends EventEmitter { if (extrafeatures.includes("cccc_ic_support")) { const extra_options = { - showname: safe_tags(args[16]), + showname: escape(args[16]), other_charid: args[17], other_name: args[18], other_emote: args[19], @@ -554,14 +550,14 @@ class Client extends EventEmitter { */ async handleCharacterInfo(chargs, charid) { let cini = {}; - let icon = AO_HOST + "characters/" + safe_tags(chargs[0]).toLowerCase() + "/char_icon.png"; + let icon = AO_HOST + "characters/" + escape(chargs[0]).toLowerCase() + "/char_icon.png"; let img = document.getElementById(`demo_${charid}`); img.alt = chargs[0]; img.src = icon; // seems like a good time to load the icon // If the ini doesn't exist on the server this will throw an error try { - const cinidata = await request(AO_HOST + "characters/" + safe_tags(chargs[0]).toLowerCase() + "/char.ini"); + const cinidata = await request(AO_HOST + "characters/" + escape(chargs[0]).toLowerCase() + "/char.ini"); cini = INI.parse(cinidata); } catch(err) { cini = {}; @@ -570,9 +566,9 @@ class Client extends EventEmitter { } const mute_select = document.getElementById("mute_select"); - mute_select.add(new Option(safe_tags(chargs[0]), charid)); + mute_select.add(new Option(escape(chargs[0]), charid)); const pair_select = document.getElementById("pair_select"); - pair_select.add(new Option(safe_tags(chargs[0]), charid)); + pair_select.add(new Option(escape(chargs[0]), charid)); // sometimes ini files lack important settings const default_options = { @@ -584,10 +580,10 @@ class Client extends EventEmitter { cini.options = Object.assign(default_options, cini.options); this.chars[charid] = { - name: safe_tags(chargs[0]), - showname: safe_tags(cini.options.showname), - desc: safe_tags(chargs[1]), - gender: safe_tags(cini.options.gender).toLowerCase(), + name: escape(chargs[0]), + showname: escape(cini.options.showname), + desc: escape(chargs[1]), + gender: escape(cini.options.gender).toLowerCase(), evidence: chargs[3], icon: icon, inifile: cini @@ -656,8 +652,8 @@ class Client extends EventEmitter { this.evidences[i - 1] = { name: decodeChat(unescapeChat(arg[0])), desc: decodeChat(unescapeChat(arg[1])), - filename: safe_tags(arg[2]), - icon: AO_HOST + "evidence/" + safe_tags(arg[2].toLowerCase()) + filename: escape(arg[2]), + icon: AO_HOST + "evidence/" + escape(arg[2].toLowerCase()) }; } @@ -752,7 +748,7 @@ class Client extends EventEmitter { */ handleKK(args) { document.getElementById("client_loading").style.display = "flex"; - document.getElementById("client_loadingtext").innerHTML = "Kicked: " + safe_tags(args[1]); + document.getElementById("client_loadingtext").innerHTML = "Kicked: " + escape(args[1]); } /** @@ -762,7 +758,7 @@ class Client extends EventEmitter { */ handleKB(args) { document.getElementById("client_loading").style.display = "flex"; - document.getElementById("client_loadingtext").innerHTML = "You got banned: " + safe_tags(args[1]); + document.getElementById("client_loadingtext").innerHTML = "You got banned: " + escape(args[1]); } /** @@ -772,7 +768,7 @@ class Client extends EventEmitter { */ handleBD(args) { document.getElementById("client_loading").style.display = "flex"; - document.getElementById("client_loadingtext").innerHTML = "Banned: " + safe_tags(args[1]); + document.getElementById("client_loadingtext").innerHTML = "Banned: " + escape(args[1]); } /** @@ -795,14 +791,14 @@ class Client extends EventEmitter { * @param {Array} args packet arguments */ handleBN(args) { - viewport.bgname = safe_tags(args[1]); - const bg_index = getIndexFromSelect("bg_select", safe_tags(args[1])); + viewport.bgname = escape(args[1]); + const bg_index = getIndexFromSelect("bg_select", escape(args[1])); document.getElementById("bg_select").selectedIndex = bg_index; updateBackgroundPreview(); if (bg_index === 0) { document.getElementById("bg_filename").value = args[1]; } - document.getElementById("bg_preview").src = AO_HOST + "background/" + safe_tags(args[1].toLowerCase()) + "/defenseempty.png"; + document.getElementById("bg_preview").src = AO_HOST + "background/" + escape(args[1].toLowerCase()) + "/defenseempty.png"; if (this.charID === -1) { changeBackground("jud"); } else { @@ -1437,7 +1433,7 @@ class Viewport { this.sfxaudio.pause(); this.sfxplayed = 1; if (this.chatmsg.sound !== "0" && this.chatmsg.sound !== "1") { - this.sfxaudio.src = AO_HOST + "sounds/general/" + safe_tags(this.chatmsg.sound.toLowerCase()) + ".wav"; + this.sfxaudio.src = AO_HOST + "sounds/general/" + escape(this.chatmsg.sound.toLowerCase()) + ".wav"; this.sfxaudio.play(); } } @@ -1605,7 +1601,7 @@ window.musiclist_click = mutelist_click; * @param {MouseEvent} event */ export function showname_click(_event) { - setCookie("showname", document.getElementById("showname").checked); + setCookie("showname", document.getElementById("showname").value); setCookie("ic_chat_name", document.getElementById("ic_chat_name").value); } window.showname_click = showname_click; -- cgit From f06a61c201ebf9f7fb74192fa43cf7319da11cab Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Dec 2019 19:54:20 +0100 Subject: showname cookie checked --- webAO/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index f6917b8..36610b8 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -326,7 +326,7 @@ class Client extends EventEmitter { changeBlipVolume(); document.getElementById("ic_chat_name").value = getCookie("ic_chat_name"); - document.getElementById("showname").value = getCookie("showname"); + document.getElementById("showname").checked = getCookie("showname"); // Load evidence array to select const evidence_select = document.getElementById("evi_select"); @@ -1601,7 +1601,7 @@ window.musiclist_click = mutelist_click; * @param {MouseEvent} event */ export function showname_click(_event) { - setCookie("showname", document.getElementById("showname").value); + setCookie("showname", document.getElementById("showname").checked); setCookie("ic_chat_name", document.getElementById("ic_chat_name").value); } window.showname_click = showname_click; -- cgit