From 6684f3fce6e90fd0574d7bab63b629554ab03ef6 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 20 Nov 2024 13:31:50 +0000 Subject: Prettified Code! --- webAO/client/addTrack.ts | 19 ++-- webAO/client/aoHost.ts | 20 ++-- webAO/client/appendICLog.ts | 93 +++++++++---------- webAO/client/checkCallword.ts | 16 ++-- webAO/client/createArea.ts | 46 +++++----- webAO/client/fetchLists.ts | 110 +++++++++++----------- webAO/client/fixLastArea.ts | 15 ++- webAO/client/handleBans.ts | 16 ++-- webAO/client/handleCharacterInfo.ts | 162 ++++++++++++++++----------------- webAO/client/isAudio.ts | 10 +- webAO/client/isCategory.ts | 10 +- webAO/client/isLowMemory.ts | 18 ++-- webAO/client/loadResources.ts | 129 +++++++++++++------------- webAO/client/resetICParams.ts | 22 ++--- webAO/client/saveChatLogHandle.ts | 40 ++++---- webAO/client/sender/index.ts | 136 +++++++++++++-------------- webAO/client/sender/sendCharacter.ts | 8 +- webAO/client/sender/sendCheck.ts | 4 +- webAO/client/sender/sendDE.ts | 4 +- webAO/client/sender/sendEE.ts | 9 +- webAO/client/sender/sendHP.ts | 4 +- webAO/client/sender/sendIC.ts | 148 +++++++++++++++--------------- webAO/client/sender/sendMA.ts | 4 +- webAO/client/sender/sendMusicChange.ts | 5 +- webAO/client/sender/sendOOC.ts | 50 +++++----- webAO/client/sender/sendPE.ts | 8 +- webAO/client/sender/sendRT.ts | 4 +- webAO/client/sender/sendSelf.ts | 10 +- webAO/client/sender/sendServer.ts | 10 +- webAO/client/sender/sendZZ.ts | 12 +-- webAO/client/setEmote.ts | 78 ++++++++-------- 31 files changed, 607 insertions(+), 613 deletions(-) (limited to 'webAO/client') diff --git a/webAO/client/addTrack.ts b/webAO/client/addTrack.ts index d6b1519..09ca049 100644 --- a/webAO/client/addTrack.ts +++ b/webAO/client/addTrack.ts @@ -2,14 +2,13 @@ import { client } from "../client"; import { unescapeChat, safeTags } from "../encoding"; import { getFilenameFromPath } from "../utils/paths"; - export const addTrack = (trackname: string) => { - const newentry = document.createElement("OPTION"); - const songName = getFilenameFromPath(trackname); - newentry.text = safeTags(unescapeChat(songName)); - newentry.value = trackname; - (( - document.getElementById("client_musiclist") - )).options.add(newentry); - client.musics.push(trackname); -} \ No newline at end of file + const newentry = document.createElement("OPTION"); + const songName = getFilenameFromPath(trackname); + newentry.text = safeTags(unescapeChat(songName)); + newentry.value = trackname; + (document.getElementById("client_musiclist")).options.add( + newentry, + ); + client.musics.push(trackname); +}; diff --git a/webAO/client/aoHost.ts b/webAO/client/aoHost.ts index 33e010d..906d4a6 100644 --- a/webAO/client/aoHost.ts +++ b/webAO/client/aoHost.ts @@ -1,16 +1,16 @@ -import queryParser from '../utils/queryParser' +import queryParser from "../utils/queryParser"; const { asset } = queryParser(); export let AO_HOST = asset; export const setAOhost = (val: string) => { - const currentProtocol = window.location.protocol; - const assetProtocol = val.split(':')[0] + ':'; + const currentProtocol = window.location.protocol; + const assetProtocol = val.split(":")[0] + ":"; - if (currentProtocol === 'https:' && assetProtocol === 'http:') { - // In this specific case, we need to request assets over HTTPS - console.log('Upgrading asset link to https'); - val = val.replace('http:', 'https:'); - } + if (currentProtocol === "https:" && assetProtocol === "http:") { + // In this specific case, we need to request assets over HTTPS + console.log("Upgrading asset link to https"); + val = val.replace("http:", "https:"); + } - AO_HOST = val; -} + AO_HOST = val; +}; diff --git a/webAO/client/appendICLog.ts b/webAO/client/appendICLog.ts index 2d3564c..181f982 100644 --- a/webAO/client/appendICLog.ts +++ b/webAO/client/appendICLog.ts @@ -1,55 +1,56 @@ import { lastICMessageTime, setLastICMessageTime } from "../client"; - - /** * Appends a message to the in-character chat log. * @param {string} msg the string to be added * @param {string} name the name of the sender */ export function appendICLog( - msg: string, - showname = "", - nameplate = "", - time = new Date() + msg: string, + showname = "", + nameplate = "", + time = new Date(), ) { - const entry = document.createElement("p"); - const shownameField = document.createElement("span"); - const nameplateField = document.createElement("span"); - const textField = document.createElement("span"); - nameplateField.className = "iclog_name iclog_nameplate"; - nameplateField.appendChild(document.createTextNode(nameplate)); - - shownameField.className = "iclog_name iclog_showname"; - if (showname === "" || !showname) { - shownameField.appendChild(document.createTextNode(nameplate)); - } else { - shownameField.appendChild(document.createTextNode(showname)); - } - - textField.className = "iclog_text"; - textField.appendChild(document.createTextNode(msg)); - - entry.appendChild(shownameField); - entry.appendChild(nameplateField); - entry.appendChild(textField); - - // Only put a timestamp if the minute has changed. - if (lastICMessageTime.getMinutes() !== time.getMinutes()) { - const timeStamp = document.createElement("span"); - timeStamp.className = "iclog_time"; - timeStamp.innerText = time.toLocaleTimeString(undefined, { - hour: "numeric", - minute: "2-digit", - }); - entry.appendChild(timeStamp); - } - - const clientLog = document.getElementById("client_log")!; - clientLog.appendChild(entry); - - if (clientLog.scrollTop+clientLog.offsetHeight+120>clientLog.scrollHeight) - clientLog.scrollTo(0, clientLog.scrollHeight); - - setLastICMessageTime(new Date()); -} \ No newline at end of file + const entry = document.createElement("p"); + const shownameField = document.createElement("span"); + const nameplateField = document.createElement("span"); + const textField = document.createElement("span"); + nameplateField.className = "iclog_name iclog_nameplate"; + nameplateField.appendChild(document.createTextNode(nameplate)); + + shownameField.className = "iclog_name iclog_showname"; + if (showname === "" || !showname) { + shownameField.appendChild(document.createTextNode(nameplate)); + } else { + shownameField.appendChild(document.createTextNode(showname)); + } + + textField.className = "iclog_text"; + textField.appendChild(document.createTextNode(msg)); + + entry.appendChild(shownameField); + entry.appendChild(nameplateField); + entry.appendChild(textField); + + // Only put a timestamp if the minute has changed. + if (lastICMessageTime.getMinutes() !== time.getMinutes()) { + const timeStamp = document.createElement("span"); + timeStamp.className = "iclog_time"; + timeStamp.innerText = time.toLocaleTimeString(undefined, { + hour: "numeric", + minute: "2-digit", + }); + entry.appendChild(timeStamp); + } + + const clientLog = document.getElementById("client_log")!; + clientLog.appendChild(entry); + + if ( + clientLog.scrollTop + clientLog.offsetHeight + 120 > + clientLog.scrollHeight + ) + clientLog.scrollTo(0, clientLog.scrollHeight); + + setLastICMessageTime(new Date()); +} diff --git a/webAO/client/checkCallword.ts b/webAO/client/checkCallword.ts index f6cffbc..b7413f7 100644 --- a/webAO/client/checkCallword.ts +++ b/webAO/client/checkCallword.ts @@ -6,12 +6,12 @@ import { AO_HOST } from "./aoHost"; * @param {string} message */ export function checkCallword(message: string, sfxAudio: HTMLAudioElement) { - client.callwords.forEach(testCallword); - function testCallword(item: string) { - if (item !== "" && message.toLowerCase().includes(item.toLowerCase())) { - sfxAudio.pause(); - sfxAudio.src = `${AO_HOST}sounds/general/sfx-gallery.opus`; - sfxAudio.play(); - } + client.callwords.forEach(testCallword); + function testCallword(item: string) { + if (item !== "" && message.toLowerCase().includes(item.toLowerCase())) { + sfxAudio.pause(); + sfxAudio.src = `${AO_HOST}sounds/general/sfx-gallery.opus`; + sfxAudio.play(); } -} \ No newline at end of file + } +} diff --git a/webAO/client/createArea.ts b/webAO/client/createArea.ts index 63af644..68406d9 100644 --- a/webAO/client/createArea.ts +++ b/webAO/client/createArea.ts @@ -2,29 +2,29 @@ import { client } from "../client"; import { area_click } from "../dom/areaClick"; export const createArea = (id: number, name: string) => { - const thisarea = { - name, - players: 0, - status: "IDLE", - cm: "", - locked: "FREE", - }; + const thisarea = { + name, + players: 0, + status: "IDLE", + cm: "", + locked: "FREE", + }; - client.areas.push(thisarea); + client.areas.push(thisarea); - // Create area button - const newarea = document.createElement("SPAN"); - newarea.className = "area-button area-default"; - newarea.id = `area${id}`; - newarea.innerText = thisarea.name; - newarea.title = - `Players: ${thisarea.players}\n` + - `Status: ${thisarea.status}\n` + - `CM: ${thisarea.cm}\n` + - `Area lock: ${thisarea.locked}`; - newarea.onclick = function () { - area_click(newarea); - }; + // Create area button + const newarea = document.createElement("SPAN"); + newarea.className = "area-button area-default"; + newarea.id = `area${id}`; + newarea.innerText = thisarea.name; + newarea.title = + `Players: ${thisarea.players}\n` + + `Status: ${thisarea.status}\n` + + `CM: ${thisarea.cm}\n` + + `Area lock: ${thisarea.locked}`; + newarea.onclick = function () { + area_click(newarea); + }; - document.getElementById("areas")!.appendChild(newarea); -} \ No newline at end of file + document.getElementById("areas")!.appendChild(newarea); +}; diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index 9efd181..2489c97 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -3,75 +3,69 @@ import { AO_HOST } from "./aoHost"; import { request } from "../services/request.js"; export const fetchBackgroundList = async () => { - try { - const bgdata = await request(`${AO_HOST}backgrounds.json`); - const bg_array = JSON.parse(bgdata); - // the try catch will fail before here when there is no file + try { + const bgdata = await request(`${AO_HOST}backgrounds.json`); + const bg_array = JSON.parse(bgdata); + // the try catch will fail before here when there is no file - const bg_select = document.getElementById("bg_select"); - bg_select.innerHTML = ""; + const bg_select = document.getElementById("bg_select"); + bg_select.innerHTML = ""; - bg_select.add(new Option("Custom", "0")); - bg_array.forEach((background: string) => { - bg_select.add(new Option(background)); - }); - } catch (err) { - console.warn("there was no backgrounds.json file"); - } -} + bg_select.add(new Option("Custom", "0")); + bg_array.forEach((background: string) => { + bg_select.add(new Option(background)); + }); + } catch (err) { + console.warn("there was no backgrounds.json file"); + } +}; export const fetchCharacterList = async () => { - const char_select = ( - document.getElementById("client_iniselect") - ); - char_select.innerHTML = ""; + const char_select = ( + document.getElementById("client_iniselect") + ); + char_select.innerHTML = ""; - char_select.add(new Option("Custom", "0")); - - try { - const chardata = await request(`${AO_HOST}characters.json`); - const char_array = JSON.parse(chardata); - // the try catch will fail before here when there is no file + char_select.add(new Option("Custom", "0")); - char_array.forEach((character: string) => { - char_select.add(new Option(character)); - }); - } catch (err) { - console.warn("there was no characters.json file"); - } -} + try { + const chardata = await request(`${AO_HOST}characters.json`); + const char_array = JSON.parse(chardata); + // the try catch will fail before here when there is no file + char_array.forEach((character: string) => { + char_select.add(new Option(character)); + }); + } catch (err) { + console.warn("there was no characters.json file"); + } +}; export const fetchEvidenceList = async () => { - const evi_select = ( - document.getElementById("evi_select") - ); - evi_select.innerHTML = ""; + const evi_select = document.getElementById("evi_select"); + evi_select.innerHTML = ""; - evi_select.add(new Option("Custom", "0")); + evi_select.add(new Option("Custom", "0")); - try { - const evidata = await request(`${AO_HOST}evidence.json`); - const evi_array = JSON.parse(evidata); - // the try catch will fail before here when there is no file - - evi_array.forEach((evi: string) => { - evi_select.add(new Option(evi)); - }); - - } catch (err) { - console.warn("there was no evidence.json file"); - } -} + try { + const evidata = await request(`${AO_HOST}evidence.json`); + const evi_array = JSON.parse(evidata); + // the try catch will fail before here when there is no file + evi_array.forEach((evi: string) => { + evi_select.add(new Option(evi)); + }); + } catch (err) { + console.warn("there was no evidence.json file"); + } +}; export const fetchManifest = async () => { - try { - const manifestdata = await request(`${AO_HOST}manifest.txt`); - client.manifest = manifestdata.split(/\r\n|\n\r|\n|\r/); - // the try catch will fail before here when there is no file - - } catch (err) { - console.warn("there was no manifest.txt file"); - } -} \ No newline at end of file + try { + const manifestdata = await request(`${AO_HOST}manifest.txt`); + client.manifest = manifestdata.split(/\r\n|\n\r|\n|\r/); + // the try catch will fail before here when there is no file + } catch (err) { + console.warn("there was no manifest.txt file"); + } +}; diff --git a/webAO/client/fixLastArea.ts b/webAO/client/fixLastArea.ts index f1aa99f..a9979da 100644 --- a/webAO/client/fixLastArea.ts +++ b/webAO/client/fixLastArea.ts @@ -1,15 +1,14 @@ import { client } from "../client"; import { addTrack } from "./addTrack"; - /** * Area list fuckery */ export const fix_last_area = () => { - if (client.areas.length > 0) { - const malplaced = client.areas.pop().name; - const areas = document.getElementById("areas")!; - areas.removeChild(areas.lastChild); - addTrack(malplaced); - } -} \ No newline at end of file + if (client.areas.length > 0) { + const malplaced = client.areas.pop().name; + const areas = document.getElementById("areas")!; + areas.removeChild(areas.lastChild); + addTrack(malplaced); + } +}; diff --git a/webAO/client/handleBans.ts b/webAO/client/handleBans.ts index 298b27f..a2e56f4 100644 --- a/webAO/client/handleBans.ts +++ b/webAO/client/handleBans.ts @@ -4,12 +4,10 @@ * @param {string} reason why */ export const handleBans = (type: string, reason: string) => { - document.getElementById("client_error")!.style.display = "flex"; - document.getElementById( - "client_errortext" - )!.innerHTML = `${type}:
${reason.replace(/\n/g, "
")}`; - (( - document.getElementById("client_reconnect") - )).style.display = "none"; - alert(type+":\r"+reason) -} \ No newline at end of file + document.getElementById("client_error")!.style.display = "flex"; + document.getElementById("client_errortext")!.innerHTML = + `${type}:
${reason.replace(/\n/g, "
")}`; + (document.getElementById("client_reconnect")).style.display = + "none"; + alert(type + ":\r" + reason); +}; diff --git a/webAO/client/handleCharacterInfo.ts b/webAO/client/handleCharacterInfo.ts index cd024b5..3f81e57 100644 --- a/webAO/client/handleCharacterInfo.ts +++ b/webAO/client/handleCharacterInfo.ts @@ -5,23 +5,22 @@ import request from "../services/request"; import fileExists from "../utils/fileExists"; import { AO_HOST } from "./aoHost"; - export const getCharIcon = async (img: HTMLImageElement, charname: string) => { - const extensions = [".png", ".webp"]; - img.alt = charname; - const charIconBaseUrl = `${AO_HOST}characters/${encodeURI( - charname.toLowerCase() - )}/char_icon`; - for (let i = 0; i < extensions.length; i++) { - const fileUrl = charIconBaseUrl + extensions[i]; - const exists = await fileExists(fileUrl); - if (exists) { - img.alt = charname; - img.title = charname; - img.src = fileUrl; - return; - } + const extensions = [".png", ".webp"]; + img.alt = charname; + const charIconBaseUrl = `${AO_HOST}characters/${encodeURI( + charname.toLowerCase(), + )}/char_icon`; + for (let i = 0; i < extensions.length; i++) { + const fileUrl = charIconBaseUrl + extensions[i]; + const exists = await fileExists(fileUrl); + if (exists) { + img.alt = charname; + img.title = charname; + img.src = fileUrl; + return; } + } }; /** @@ -30,78 +29,77 @@ export const getCharIcon = async (img: HTMLImageElement, charname: string) => { * @param {Number} charid character ID */ export const handleCharacterInfo = async (chargs: string[], charid: number) => { - const img = document.getElementById(`demo_${charid}`); - if (chargs[0]) { - let cini: any = {}; - - getCharIcon(img, chargs[0]); + const img = document.getElementById(`demo_${charid}`); + if (chargs[0]) { + let cini: any = {}; - // If the ini doesn't exist on the server this will throw an error - try { - const cinidata = await request( - `${AO_HOST}characters/${encodeURI(chargs[0].toLowerCase())}/char.ini` - ); - cini = iniParse(cinidata); - } catch (err) { - cini = {}; - img.classList.add("noini"); - console.warn(`character ${chargs[0]} is missing from webAO`); - // If it does, give the user a visual indication that the character is unusable - } + getCharIcon(img, chargs[0]); - const mute_select = ( - document.getElementById("mute_select") - ); - mute_select.add(new Option(safeTags(chargs[0]), String(charid))); - const pair_select = ( - document.getElementById("pair_select") - ); - pair_select.add(new Option(safeTags(chargs[0]), String(charid))); + // If the ini doesn't exist on the server this will throw an error + try { + const cinidata = await request( + `${AO_HOST}characters/${encodeURI(chargs[0].toLowerCase())}/char.ini`, + ); + cini = iniParse(cinidata); + } catch (err) { + cini = {}; + img.classList.add("noini"); + console.warn(`character ${chargs[0]} is missing from webAO`); + // If it does, give the user a visual indication that the character is unusable + } - // sometimes ini files lack important settings - const default_options = { - name: chargs[0], - showname: chargs[0], - side: "def", - blips: "male", - chat: "", - category: "", - }; - cini.options = Object.assign(default_options, cini.options); + const mute_select = ( + document.getElementById("mute_select") + ); + mute_select.add(new Option(safeTags(chargs[0]), String(charid))); + const pair_select = ( + document.getElementById("pair_select") + ); + pair_select.add(new Option(safeTags(chargs[0]), String(charid))); - // sometimes ini files lack important settings - const default_emotions = { - number: 0, - }; - cini.emotions = Object.assign(default_emotions, cini.emotions); + // sometimes ini files lack important settings + const default_options = { + name: chargs[0], + showname: chargs[0], + side: "def", + blips: "male", + chat: "", + category: "", + }; + cini.options = Object.assign(default_options, cini.options); - client.chars[charid] = { - name: safeTags(chargs[0]), - showname: safeTags(cini.options.showname), - desc: safeTags(chargs[1]), - blips: safeTags(cini.options.blips).toLowerCase(), - gender: safeTags(cini.options.gender).toLowerCase(), - side: safeTags(cini.options.side).toLowerCase(), - chat: - cini.options.chat === "" - ? safeTags(cini.options.category).toLowerCase() - : safeTags(cini.options.chat).toLowerCase(), - evidence: chargs[3], - icon: img.src, - inifile: cini, - muted: false, - }; + // sometimes ini files lack important settings + const default_emotions = { + number: 0, + }; + cini.emotions = Object.assign(default_emotions, cini.emotions); - if ( - client.chars[charid].blips === "male" && - client.chars[charid].gender !== "male" && - client.chars[charid].gender !== "" - ) { - client.chars[charid].blips = client.chars[charid].gender; - } + client.chars[charid] = { + name: safeTags(chargs[0]), + showname: safeTags(cini.options.showname), + desc: safeTags(chargs[1]), + blips: safeTags(cini.options.blips).toLowerCase(), + gender: safeTags(cini.options.gender).toLowerCase(), + side: safeTags(cini.options.side).toLowerCase(), + chat: + cini.options.chat === "" + ? safeTags(cini.options.category).toLowerCase() + : safeTags(cini.options.chat).toLowerCase(), + evidence: chargs[3], + icon: img.src, + inifile: cini, + muted: false, + }; - } else { - console.warn(`missing charid ${charid}`); - img.style.display = "none"; + if ( + client.chars[charid].blips === "male" && + client.chars[charid].gender !== "male" && + client.chars[charid].gender !== "" + ) { + client.chars[charid].blips = client.chars[charid].gender; } -} \ No newline at end of file + } else { + console.warn(`missing charid ${charid}`); + img.style.display = "none"; + } +}; diff --git a/webAO/client/isAudio.ts b/webAO/client/isAudio.ts index 430f543..52e53a1 100644 --- a/webAO/client/isAudio.ts +++ b/webAO/client/isAudio.ts @@ -1,6 +1,6 @@ export const isAudio = (trackname: string) => { - const audioEndings = [".wav", ".mp3", ".ogg", ".opus"]; - return ( - audioEndings.filter((ending) => trackname.endsWith(ending)).length === 1 - ); -} \ No newline at end of file + const audioEndings = [".wav", ".mp3", ".ogg", ".opus"]; + return ( + audioEndings.filter((ending) => trackname.endsWith(ending)).length === 1 + ); +}; diff --git a/webAO/client/isCategory.ts b/webAO/client/isCategory.ts index 0d2b8df..3f3dfd5 100644 --- a/webAO/client/isCategory.ts +++ b/webAO/client/isCategory.ts @@ -1,6 +1,6 @@ export const isCategory = (trackname: string) => { - const audioEndings = ["==", "--"]; - return ( - audioEndings.filter((ending) => trackname.startsWith(ending)).length === 1 - ); -} \ No newline at end of file + const audioEndings = ["==", "--"]; + return ( + audioEndings.filter((ending) => trackname.startsWith(ending)).length === 1 + ); +}; diff --git a/webAO/client/isLowMemory.ts b/webAO/client/isLowMemory.ts index caa6784..8a8bd48 100644 --- a/webAO/client/isLowMemory.ts +++ b/webAO/client/isLowMemory.ts @@ -1,10 +1,10 @@ -import { setOldLoading } from '../client' +import { setOldLoading } from "../client"; export const isLowMemory = () => { - if ( - /webOS|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|PlayStation|Nintendo|Opera Mini/i.test( - navigator.userAgent - ) - ) { - setOldLoading(true); - } -} + if ( + /webOS|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|PlayStation|Nintendo|Opera Mini/i.test( + navigator.userAgent, + ) + ) { + setOldLoading(true); + } +}; diff --git a/webAO/client/loadResources.ts b/webAO/client/loadResources.ts index 4954966..2608ace 100644 --- a/webAO/client/loadResources.ts +++ b/webAO/client/loadResources.ts @@ -1,81 +1,84 @@ import getCookie from "../utils/getCookie"; import vanilla_evidence_arr from "../constants/evidence.js"; import vanilla_background_arr from "../constants/backgrounds.js"; -import { changeMusicVolume } from '../dom/changeMusicVolume' +import { changeMusicVolume } from "../dom/changeMusicVolume"; import { setChatbox } from "../dom/setChatbox"; -import { changeSFXVolume, changeShoutVolume, changeTestimonyVolume } from "../dom/changeVolume"; +import { + changeSFXVolume, + changeShoutVolume, + changeTestimonyVolume, +} from "../dom/changeVolume"; import { showname_click } from "../dom/showNameClick"; -import { changeBlipVolume } from '../dom/changeBlipVolume' -import { reloadTheme } from '../dom/reloadTheme' +import { changeBlipVolume } from "../dom/changeBlipVolume"; +import { reloadTheme } from "../dom/reloadTheme"; const version = process.env.npm_package_version; /** - * Load game resources and stored settings. - */ + * Load game resources and stored settings. + */ export const loadResources = () => { - document.getElementById("client_version")!.innerText = `version ${version}`; - // Load background array to select - const background_select = ( - document.getElementById("bg_select") - ); - background_select.add(new Option("Custom", "0")); - vanilla_background_arr.forEach((background) => { - background_select.add(new Option(background)); - }); + document.getElementById("client_version")!.innerText = `version ${version}`; + // Load background array to select + const background_select = ( + document.getElementById("bg_select") + ); + background_select.add(new Option("Custom", "0")); + vanilla_background_arr.forEach((background) => { + background_select.add(new Option(background)); + }); - // Load evidence array to select - const evidence_select = ( - document.getElementById("evi_select") - ); - evidence_select.add(new Option("Custom", "0")); - vanilla_evidence_arr.forEach((evidence) => { - evidence_select.add(new Option(evidence)); - }); + // Load evidence array to select + const evidence_select = ( + document.getElementById("evi_select") + ); + evidence_select.add(new Option("Custom", "0")); + vanilla_evidence_arr.forEach((evidence) => { + evidence_select.add(new Option(evidence)); + }); - // Read cookies and set the UI to its values - (document.getElementById("OOC_name")).value = - getCookie("OOC_name") || - `web${String(Math.round(Math.random() * 100 + 10))}`; + // Read cookies and set the UI to its values + (document.getElementById("OOC_name")).value = + getCookie("OOC_name") || + `web${String(Math.round(Math.random() * 100 + 10))}`; - // Read cookies and set the UI to its values - const cookietheme = getCookie("theme") || "default"; + // Read cookies and set the UI to its values + const cookietheme = getCookie("theme") || "default"; - (( - document.querySelector(`#client_themeselect [value="${cookietheme}"]`) - )).selected = true; - reloadTheme(); + (( + document.querySelector(`#client_themeselect [value="${cookietheme}"]`) + )).selected = true; + reloadTheme(); - const cookiechatbox = getCookie("chatbox") || "dynamic"; + const cookiechatbox = getCookie("chatbox") || "dynamic"; - (( - document.querySelector(`#client_chatboxselect [value="${cookiechatbox}"]`) - )).selected = true; - setChatbox(cookiechatbox); + (( + document.querySelector(`#client_chatboxselect [value="${cookiechatbox}"]`) + )).selected = true; + setChatbox(cookiechatbox); - (document.getElementById("client_mvolume")).value = - getCookie("musicVolume") || "1"; - changeMusicVolume(); - (document.getElementById("client_sfxaudio")).volume = - Number(getCookie("sfxVolume")) || 1; - changeSFXVolume(); - (document.getElementById("client_shoutaudio")).volume = - Number(getCookie("shoutVolume")) || 1; - changeShoutVolume(); - (( - document.getElementById("client_testimonyaudio") - )).volume = Number(getCookie("testimonyVolume")) || 1; - changeTestimonyVolume(); - (document.getElementById("client_bvolume")).value = - getCookie("blipVolume") || "1"; - changeBlipVolume(); + (document.getElementById("client_mvolume")).value = + getCookie("musicVolume") || "1"; + changeMusicVolume(); + (document.getElementById("client_sfxaudio")).volume = + Number(getCookie("sfxVolume")) || 1; + changeSFXVolume(); + (document.getElementById("client_shoutaudio")).volume = + Number(getCookie("shoutVolume")) || 1; + changeShoutVolume(); + (document.getElementById("client_testimonyaudio")).volume = + Number(getCookie("testimonyVolume")) || 1; + changeTestimonyVolume(); + (document.getElementById("client_bvolume")).value = + getCookie("blipVolume") || "1"; + changeBlipVolume(); - (document.getElementById("ic_chat_name")).value = - getCookie("ic_chat_name"); - (document.getElementById("showname")).checked = Boolean( - getCookie("showname") - ); - showname_click(null); + (document.getElementById("ic_chat_name")).value = + getCookie("ic_chat_name"); + (document.getElementById("showname")).checked = Boolean( + getCookie("showname"), + ); + showname_click(null); - (document.getElementById("client_callwords")).value = - getCookie("callwords"); -} \ No newline at end of file + (document.getElementById("client_callwords")).value = + getCookie("callwords"); +}; diff --git a/webAO/client/resetICParams.ts b/webAO/client/resetICParams.ts index 414da27..e67cf22 100644 --- a/webAO/client/resetICParams.ts +++ b/webAO/client/resetICParams.ts @@ -6,16 +6,16 @@ import { selectedShout, setSelectedShout } from "../client"; * was successfully sent/presented. */ export function resetICParams() { - (document.getElementById("client_inputbox")).value = ""; - document.getElementById("button_flash")!.className = "client_button"; - document.getElementById("button_shake")!.className = "client_button"; + (document.getElementById("client_inputbox")).value = ""; + document.getElementById("button_flash")!.className = "client_button"; + document.getElementById("button_shake")!.className = "client_button"; - (document.getElementById("sendpreanim")).checked = false; - (document.getElementById("sendsfx")).checked = false; + (document.getElementById("sendpreanim")).checked = false; + (document.getElementById("sendsfx")).checked = false; - if (selectedShout) { - document.getElementById(`button_${selectedShout}`)!.className = - "client_button"; - setSelectedShout(0); - } -} \ No newline at end of file + if (selectedShout) { + document.getElementById(`button_${selectedShout}`)!.className = + "client_button"; + setSelectedShout(0); + } +} diff --git a/webAO/client/saveChatLogHandle.ts b/webAO/client/saveChatLogHandle.ts index 497dd50..e083f2f 100644 --- a/webAO/client/saveChatLogHandle.ts +++ b/webAO/client/saveChatLogHandle.ts @@ -1,26 +1,26 @@ import downloadFile from "../services/downloadFile"; export const saveChatlogHandle = async () => { - const clientLog = document.getElementById("client_log")!; - const icMessageLogs = clientLog.getElementsByTagName("p"); - const messages: string[] = []; + const clientLog = document.getElementById("client_log")!; + const icMessageLogs = clientLog.getElementsByTagName("p"); + const messages: string[] = []; - for (let i = 0; i < icMessageLogs.length; i++) { - const SHOWNAME_POSITION = 0; - const TEXT_POSITION = 2; - const showname = icMessageLogs[i].children[SHOWNAME_POSITION].innerHTML; - const text = icMessageLogs[i].children[TEXT_POSITION].innerHTML; - const message = `${showname}: ${text}`; - messages.push(message); - } - const d = new Date(); - const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d); - const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d); - const da = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(d); + for (let i = 0; i < icMessageLogs.length; i++) { + const SHOWNAME_POSITION = 0; + const TEXT_POSITION = 2; + const showname = icMessageLogs[i].children[SHOWNAME_POSITION].innerHTML; + const text = icMessageLogs[i].children[TEXT_POSITION].innerHTML; + const message = `${showname}: ${text}`; + messages.push(message); + } + const d = new Date(); + const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d); + const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d); + const da = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(d); - const filename = `chatlog-${da}-${mo}-${ye}`.toLowerCase(); - downloadFile(messages.join("\n"), filename); + const filename = `chatlog-${da}-${mo}-${ye}`.toLowerCase(); + downloadFile(messages.join("\n"), filename); - // Reset Chatbox to Empty - (document.getElementById("client_inputbox")).value = ""; -}; \ No newline at end of file + // Reset Chatbox to Empty + (document.getElementById("client_inputbox")).value = ""; +}; diff --git a/webAO/client/sender/index.ts b/webAO/client/sender/index.ts index 4781ec1..a50fce3 100644 --- a/webAO/client/sender/index.ts +++ b/webAO/client/sender/index.ts @@ -1,71 +1,73 @@ import { sendIC } from "./sendIC"; -import { sendSelf } from './sendSelf' -import { sendServer } from './sendServer' -import { sendCheck } from './sendCheck' -import {sendHP} from './sendHP' -import {sendOOC} from './sendOOC' -import {sendCharacter} from './sendCharacter' -import {sendRT} from './sendRT' -import {sendMusicChange} from './sendMusicChange' -import {sendZZ} from './sendZZ' -import {sendEE} from './sendEE' -import {sendDE} from './sendDE' -import {sendPE} from './sendPE' -import {sendMA} from './sendMA' +import { sendSelf } from "./sendSelf"; +import { sendServer } from "./sendServer"; +import { sendCheck } from "./sendCheck"; +import { sendHP } from "./sendHP"; +import { sendOOC } from "./sendOOC"; +import { sendCharacter } from "./sendCharacter"; +import { sendRT } from "./sendRT"; +import { sendMusicChange } from "./sendMusicChange"; +import { sendZZ } from "./sendZZ"; +import { sendEE } from "./sendEE"; +import { sendDE } from "./sendDE"; +import { sendPE } from "./sendPE"; +import { sendMA } from "./sendMA"; export interface ISender { - sendIC: (deskmod: number, - preanim: string, - name: string, - emote: string, - message: string, - side: string, - sfx_name: string, - emote_modifier: number, - sfx_delay: number, - objection_modifier: number, - evidence: number, - flip: boolean, - realization: boolean, - text_color: number, - showname: string, - other_charid: string, - self_hoffset: number, - self_yoffset: number, - noninterrupting_preanim: boolean, - looping_sfx: boolean, - screenshake: boolean, - frame_screenshake: string, - frame_realization: string, - frame_sfx: string, - additive: boolean, - effect: string) => void - sendSelf: (message: string) => void - sendServer: (message: string) => void - sendCheck: () => void - sendHP: (side: number, hp: number) => void - sendOOC: (message: string) => void - sendCharacter: (character: number) => void - sendRT: (testimony: string) => void - sendMusicChange: (track: string) => void - sendZZ: (msg: string) => void - sendEE: (id: number, name: string, desc: string, img: string) => void - sendDE: (id: number) => void - sendPE: (name: string, desc: string, img: string) => void - sendMA: (id: number, length: number, reason: string) => void + sendIC: ( + deskmod: number, + preanim: string, + name: string, + emote: string, + message: string, + side: string, + sfx_name: string, + emote_modifier: number, + sfx_delay: number, + objection_modifier: number, + evidence: number, + flip: boolean, + realization: boolean, + text_color: number, + showname: string, + other_charid: string, + self_hoffset: number, + self_yoffset: number, + noninterrupting_preanim: boolean, + looping_sfx: boolean, + screenshake: boolean, + frame_screenshake: string, + frame_realization: string, + frame_sfx: string, + additive: boolean, + effect: string, + ) => void; + sendSelf: (message: string) => void; + sendServer: (message: string) => void; + sendCheck: () => void; + sendHP: (side: number, hp: number) => void; + sendOOC: (message: string) => void; + sendCharacter: (character: number) => void; + sendRT: (testimony: string) => void; + sendMusicChange: (track: string) => void; + sendZZ: (msg: string) => void; + sendEE: (id: number, name: string, desc: string, img: string) => void; + sendDE: (id: number) => void; + sendPE: (name: string, desc: string, img: string) => void; + sendMA: (id: number, length: number, reason: string) => void; } export const sender = { - sendIC, - sendSelf, - sendServer, - sendCheck, - sendHP, - sendOOC, - sendCharacter, - sendRT, - sendMusicChange, - sendZZ, - sendEE, - sendDE, - sendPE, - sendMA -} \ No newline at end of file + sendIC, + sendSelf, + sendServer, + sendCheck, + sendHP, + sendOOC, + sendCharacter, + sendRT, + sendMusicChange, + sendZZ, + sendEE, + sendDE, + sendPE, + sendMA, +}; diff --git a/webAO/client/sender/sendCharacter.ts b/webAO/client/sender/sendCharacter.ts index 5e81727..2db4dcd 100644 --- a/webAO/client/sender/sendCharacter.ts +++ b/webAO/client/sender/sendCharacter.ts @@ -5,7 +5,7 @@ import { client } from "../../client"; * @param {number} character the character ID */ export const sendCharacter = (character: number) => { - if (character === -1 || client.chars[character].name) { - client.sender.sendServer(`CC#${client.playerID}#${character}#web#%`); - } -} \ No newline at end of file + if (character === -1 || client.chars[character].name) { + client.sender.sendServer(`CC#${client.playerID}#${character}#web#%`); + } +}; diff --git a/webAO/client/sender/sendCheck.ts b/webAO/client/sender/sendCheck.ts index 91b3a02..7eb4751 100644 --- a/webAO/client/sender/sendCheck.ts +++ b/webAO/client/sender/sendCheck.ts @@ -4,5 +4,5 @@ import { client } from "../../client"; * Sends a keepalive packet. */ export const sendCheck = () => { - client.sender.sendServer(`CH#${client.charID}#%`); -} + client.sender.sendServer(`CH#${client.charID}#%`); +}; diff --git a/webAO/client/sender/sendDE.ts b/webAO/client/sender/sendDE.ts index 4d94d65..cf8fa5a 100644 --- a/webAO/client/sender/sendDE.ts +++ b/webAO/client/sender/sendDE.ts @@ -5,5 +5,5 @@ import { client } from "../../client"; * @param {number} evidence id */ export const sendDE = (id: number) => { - client.sender.sendServer(`DE#${id}#%`); -} \ No newline at end of file + client.sender.sendServer(`DE#${id}#%`); +}; diff --git a/webAO/client/sender/sendEE.ts b/webAO/client/sender/sendEE.ts index 7c5bfe3..2aac2a6 100644 --- a/webAO/client/sender/sendEE.ts +++ b/webAO/client/sender/sendEE.ts @@ -1,7 +1,6 @@ import { client } from "../../client"; import { escapeChat } from "../../encoding"; - /** * Sends edit evidence command. * @param {number} evidence id @@ -10,7 +9,7 @@ import { escapeChat } from "../../encoding"; * @param {string} evidence image filename */ export const sendEE = (id: number, name: string, desc: string, img: string) => { - client.sender.sendServer( - `EE#${id}#${escapeChat(name)}#${escapeChat(desc)}#${escapeChat(img)}#%` - ); -} \ No newline at end of file + client.sender.sendServer( + `EE#${id}#${escapeChat(name)}#${escapeChat(desc)}#${escapeChat(img)}#%`, + ); +}; diff --git a/webAO/client/sender/sendHP.ts b/webAO/client/sender/sendHP.ts index d007094..bd44163 100644 --- a/webAO/client/sender/sendHP.ts +++ b/webAO/client/sender/sendHP.ts @@ -6,5 +6,5 @@ import { client } from "../../client"; * @param {number} hp the health point */ export const sendHP = (side: number, hp: number) => { - client.sender.sendServer(`HP#${side}#${hp}#%`); -} \ No newline at end of file + client.sender.sendServer(`HP#${side}#${hp}#%`); +}; diff --git a/webAO/client/sender/sendIC.ts b/webAO/client/sender/sendIC.ts index ca8984f..d23a113 100644 --- a/webAO/client/sender/sendIC.ts +++ b/webAO/client/sender/sendIC.ts @@ -1,8 +1,8 @@ import { extrafeatures } from "../../client"; import { escapeChat } from "../../encoding"; -import {client} from '../../client' +import { client } from "../../client"; import queryParser from "../../utils/queryParser"; -const {mode} = queryParser() +const { mode } = queryParser(); /** * Sends an in-character chat message. @@ -26,81 +26,81 @@ const {mode} = queryParser() * @param {number} noninterrupting_preanim play the full preanim (optional) */ export const sendIC = ( - deskmod: number, - preanim: string, - name: string, - emote: string, - message: string, - side: string, - sfx_name: string, - emote_modifier: number, - sfx_delay: number, - objection_modifier: number, - evidence: number, - flip: boolean, - realization: boolean, - text_color: number, - showname: string, - other_charid: string, - self_hoffset: number, - self_yoffset: number, - noninterrupting_preanim: boolean, - looping_sfx: boolean, - screenshake: boolean, - frame_screenshake: string, - frame_realization: string, - frame_sfx: string, - additive: boolean, - effect: string + deskmod: number, + preanim: string, + name: string, + emote: string, + message: string, + side: string, + sfx_name: string, + emote_modifier: number, + sfx_delay: number, + objection_modifier: number, + evidence: number, + flip: boolean, + realization: boolean, + text_color: number, + showname: string, + other_charid: string, + self_hoffset: number, + self_yoffset: number, + noninterrupting_preanim: boolean, + looping_sfx: boolean, + screenshake: boolean, + frame_screenshake: string, + frame_realization: string, + frame_sfx: string, + additive: boolean, + effect: string, ) => { - let extra_cccc = ""; - let other_emote = ""; - let other_offset = ""; - let extra_27 = ""; - let extra_28 = ""; + let extra_cccc = ""; + let other_emote = ""; + let other_offset = ""; + let extra_27 = ""; + let extra_28 = ""; - if (extrafeatures.includes("cccc_ic_support")) { - const self_offset = extrafeatures.includes("y_offset") - ? `${self_hoffset}${self_yoffset}` - : self_hoffset; // HACK: this should be an & but client fucked it up and all the servers adopted it - if (mode === "replay") { - other_emote = "##"; - other_offset = "#0#0"; - } - extra_cccc = `${escapeChat( - showname - )}#${other_charid}${other_emote}#${self_offset}${other_offset}#${Number( - noninterrupting_preanim - )}#`; + if (extrafeatures.includes("cccc_ic_support")) { + const self_offset = extrafeatures.includes("y_offset") + ? `${self_hoffset}${self_yoffset}` + : self_hoffset; // HACK: this should be an & but client fucked it up and all the servers adopted it + if (mode === "replay") { + other_emote = "##"; + other_offset = "#0#0"; + } + extra_cccc = `${escapeChat( + showname, + )}#${other_charid}${other_emote}#${self_offset}${other_offset}#${Number( + noninterrupting_preanim, + )}#`; - if (extrafeatures.includes("looping_sfx")) { - extra_27 = `${Number(looping_sfx)}#${Number( - screenshake - )}#${frame_screenshake}#${frame_realization}#${frame_sfx}#`; - if (extrafeatures.includes("effects")) { - extra_28 = `${Number(additive)}#${escapeChat(effect)}#`; - } - } + if (extrafeatures.includes("looping_sfx")) { + extra_27 = `${Number(looping_sfx)}#${Number( + screenshake, + )}#${frame_screenshake}#${frame_realization}#${frame_sfx}#`; + if (extrafeatures.includes("effects")) { + extra_28 = `${Number(additive)}#${escapeChat(effect)}#`; + } } + } - const serverMessage = - `MS#${deskmod}#${escapeChat(preanim)}#${escapeChat(name)}#${escapeChat( - emote - )}` + - `#${escapeChat(message)}#${escapeChat(side)}#${escapeChat( - sfx_name - )}#${emote_modifier}` + - `#${client.charID}#${sfx_delay}#${Number(objection_modifier)}#${Number( - evidence - )}#${Number(flip)}#${Number( - realization - )}#${text_color}#${extra_cccc}${extra_27}${extra_28}%`; + const serverMessage = + `MS#${deskmod}#${escapeChat(preanim)}#${escapeChat(name)}#${escapeChat( + emote, + )}` + + `#${escapeChat(message)}#${escapeChat(side)}#${escapeChat( + sfx_name, + )}#${emote_modifier}` + + `#${client.charID}#${sfx_delay}#${Number(objection_modifier)}#${Number( + evidence, + )}#${Number(flip)}#${Number( + realization, + )}#${text_color}#${extra_cccc}${extra_27}${extra_28}%`; - client.sender.sendServer(serverMessage); - if (mode === "replay") { - (( - document.getElementById("client_ooclog") - )).value += `wait#${(document.getElementById("client_replaytimer")).value - }#%\r\n`; - } -} \ No newline at end of file + client.sender.sendServer(serverMessage); + if (mode === "replay") { + (document.getElementById("client_ooclog")).value += + `wait#${ + (document.getElementById("client_replaytimer")).value + }#%\r\n`; + } +}; diff --git a/webAO/client/sender/sendMA.ts b/webAO/client/sender/sendMA.ts index 5ba4e4b..6260da1 100644 --- a/webAO/client/sender/sendMA.ts +++ b/webAO/client/sender/sendMA.ts @@ -7,5 +7,5 @@ import { client } from "../../client"; * @param {string} reason player message */ export const sendMA = (id: number, length: number, reason: string) => { - client.sender.sendServer(`MA#${id}#${length}#${reason}#%`); -} \ No newline at end of file + client.sender.sendServer(`MA#${id}#${length}#${reason}#%`); +}; diff --git a/webAO/client/sender/sendMusicChange.ts b/webAO/client/sender/sendMusicChange.ts index 50c6306..69cba58 100644 --- a/webAO/client/sender/sendMusicChange.ts +++ b/webAO/client/sender/sendMusicChange.ts @@ -1,10 +1,9 @@ import { client } from "../../client"; - /** * Requests to change the music to the specified track. * @param {string} track the track ID */ export const sendMusicChange = (track: string) => { - client.sender.sendServer(`MC#${track}#${client.charID}#%`); -} + client.sender.sendServer(`MC#${track}#${client.charID}#%`); +}; diff --git a/webAO/client/sender/sendOOC.ts b/webAO/client/sender/sendOOC.ts index 9674ad9..43c3773 100644 --- a/webAO/client/sender/sendOOC.ts +++ b/webAO/client/sender/sendOOC.ts @@ -1,33 +1,33 @@ -import { client } from '../../client' -import { escapeChat } from '../../encoding'; -import setCookie from '../../utils/setCookie'; -import { saveChatlogHandle } from '../../client/saveChatLogHandle' +import { client } from "../../client"; +import { escapeChat } from "../../encoding"; +import setCookie from "../../utils/setCookie"; +import { saveChatlogHandle } from "../../client/saveChatLogHandle"; /** * Sends an out-of-character chat message. * @param {string} message the message to send */ export const sendOOC = (message: string) => { - setCookie( - "OOC_name", - (document.getElementById("OOC_name")).value - ); - const oocName = `${escapeChat( - (document.getElementById("OOC_name")).value - )}`; - const oocMessage = `${escapeChat(message)}`; + setCookie( + "OOC_name", + (document.getElementById("OOC_name")).value, + ); + const oocName = `${escapeChat( + (document.getElementById("OOC_name")).value, + )}`; + const oocMessage = `${escapeChat(message)}`; - const commands = { - "/save_chatlog": saveChatlogHandle, - }; - const commandsMap = new Map(Object.entries(commands)); + const commands = { + "/save_chatlog": saveChatlogHandle, + }; + const commandsMap = new Map(Object.entries(commands)); - if (oocMessage && commandsMap.has(oocMessage.toLowerCase())) { - try { - commandsMap.get(oocMessage.toLowerCase())(); - } catch (e) { - // Command Not Recognized - } - } else { - client.sender.sendServer(`CT#${oocName}#${oocMessage}#%`); + if (oocMessage && commandsMap.has(oocMessage.toLowerCase())) { + try { + commandsMap.get(oocMessage.toLowerCase())(); + } catch (e) { + // Command Not Recognized } -} \ No newline at end of file + } else { + client.sender.sendServer(`CT#${oocName}#${oocMessage}#%`); + } +}; diff --git a/webAO/client/sender/sendPE.ts b/webAO/client/sender/sendPE.ts index 984fc4d..609a4df 100644 --- a/webAO/client/sender/sendPE.ts +++ b/webAO/client/sender/sendPE.ts @@ -8,7 +8,7 @@ import { escapeChat } from "../../encoding"; * @param {string} evidence image filename */ export const sendPE = (name: string, desc: string, img: string) => { - client.sender.sendServer( - `PE#${escapeChat(name)}#${escapeChat(desc)}#${escapeChat(img)}#%` - ); -} \ No newline at end of file + client.sender.sendServer( + `PE#${escapeChat(name)}#${escapeChat(desc)}#${escapeChat(img)}#%`, + ); +}; diff --git a/webAO/client/sender/sendRT.ts b/webAO/client/sender/sendRT.ts index 2d6c60a..6953870 100644 --- a/webAO/client/sender/sendRT.ts +++ b/webAO/client/sender/sendRT.ts @@ -5,5 +5,5 @@ import { client } from "../../client"; * @param {string} testimony type */ export const sendRT = (testimony: string) => { - client.sender.sendServer(`RT#${testimony}#%`); -} \ No newline at end of file + client.sender.sendServer(`RT#${testimony}#%`); +}; diff --git a/webAO/client/sender/sendSelf.ts b/webAO/client/sender/sendSelf.ts index 66c35fa..15665a7 100644 --- a/webAO/client/sender/sendSelf.ts +++ b/webAO/client/sender/sendSelf.ts @@ -1,13 +1,11 @@ import { client } from "../../client"; - /** * Hook for sending messages to the client * @param {string} message the message to send */ export const sendSelf = (message: string) => { - (( - document.getElementById("client_ooclog") - )).value += `${message}\r\n`; - client.handleSelf(message); -} \ No newline at end of file + (document.getElementById("client_ooclog")).value += + `${message}\r\n`; + client.handleSelf(message); +}; diff --git a/webAO/client/sender/sendServer.ts b/webAO/client/sender/sendServer.ts index ae95480..d48cc85 100644 --- a/webAO/client/sender/sendServer.ts +++ b/webAO/client/sender/sendServer.ts @@ -1,11 +1,13 @@ import { client } from "../../client"; import queryParser from "../../utils/queryParser"; -const { mode } = queryParser() +const { mode } = queryParser(); /** * Hook for sending messages to the server * @param {string} message the message to send */ export const sendServer = (message: string) => { - console.debug("C: "+message) - mode === "replay" ? client.sender.sendSelf(message) : client.serv.send(message); -} \ No newline at end of file + console.debug("C: " + message); + mode === "replay" + ? client.sender.sendSelf(message) + : client.serv.send(message); +}; diff --git a/webAO/client/sender/sendZZ.ts b/webAO/client/sender/sendZZ.ts index 237ab37..e9bd443 100644 --- a/webAO/client/sender/sendZZ.ts +++ b/webAO/client/sender/sendZZ.ts @@ -5,9 +5,9 @@ import { client, extrafeatures } from "../../client"; * @param {string} message to mod */ export const sendZZ = (msg: string) => { - if (extrafeatures.includes("modcall_reason")) { - client.sender.sendServer(`ZZ#${msg}#%`); - } else { - client.sender.sendServer("ZZ#%"); - } -} \ No newline at end of file + if (extrafeatures.includes("modcall_reason")) { + client.sender.sendServer(`ZZ#${msg}#%`); + } else { + client.sender.sendServer("ZZ#%"); + } +}; diff --git a/webAO/client/setEmote.ts b/webAO/client/setEmote.ts index 2b5a614..70f23ac 100644 --- a/webAO/client/setEmote.ts +++ b/webAO/client/setEmote.ts @@ -8,48 +8,50 @@ import fileExists from "../utils/fileExists"; */ const setEmote = async ( - AO_HOST: string, - client: Client, - charactername: string, - emotename: string, - prefix: string, - pair: boolean, - side: string + AO_HOST: string, + client: Client, + charactername: string, + emotename: string, + prefix: string, + pair: boolean, + side: string, ) => { - const pairID = pair ? "pair" : "char"; - const characterFolder = `${AO_HOST}characters/`; - const acceptedPositions = ["def", "pro", "wit"]; - const position = acceptedPositions.includes(side) ? `${side}_` : ""; - const emoteSelector = document.getElementById( - `client_${position}${pairID}_img` - ) as HTMLImageElement; - const extensionsMap = [".gif", ".png", ".apng", ".webp", ".webp.static"]; + const pairID = pair ? "pair" : "char"; + const characterFolder = `${AO_HOST}characters/`; + const acceptedPositions = ["def", "pro", "wit"]; + const position = acceptedPositions.includes(side) ? `${side}_` : ""; + const emoteSelector = document.getElementById( + `client_${position}${pairID}_img`, + ) as HTMLImageElement; + const extensionsMap = [".gif", ".png", ".apng", ".webp", ".webp.static"]; - for (const extension of extensionsMap) { + for (const extension of extensionsMap) { // Hides all sprites before creating a new sprite - if (client.viewport.getLastCharacter() !== client.viewport.getChatmsg().name) { - emoteSelector.src = transparentPng; - } - let url; - if (extension === ".png") { - url = `${characterFolder}${encodeURI(charactername)}/${encodeURI( - emotename - )}${extension}`; - } else if (extension === ".webp.static") { - url = `${characterFolder}${encodeURI(charactername)}/${encodeURI( - emotename - )}.webp`; - } else { - url = `${characterFolder}${encodeURI(charactername)}/${encodeURI( - prefix - )}${encodeURI(emotename)}${extension}`; - } - const exists = await fileExists(url); - if (exists) { - emoteSelector.src = url; - break; - } + if ( + client.viewport.getLastCharacter() !== client.viewport.getChatmsg().name + ) { + emoteSelector.src = transparentPng; } + let url; + if (extension === ".png") { + url = `${characterFolder}${encodeURI(charactername)}/${encodeURI( + emotename, + )}${extension}`; + } else if (extension === ".webp.static") { + url = `${characterFolder}${encodeURI(charactername)}/${encodeURI( + emotename, + )}.webp`; + } else { + url = `${characterFolder}${encodeURI(charactername)}/${encodeURI( + prefix, + )}${encodeURI(emotename)}${extension}`; + } + const exists = await fileExists(url); + if (exists) { + emoteSelector.src = url; + break; + } + } }; export default setEmote; -- cgit