From 6684f3fce6e90fd0574d7bab63b629554ab03ef6 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 20 Nov 2024 13:31:50 +0000 Subject: Prettified Code! --- webAO/dom/addEvidence.ts | 24 ++--- webAO/dom/addHPD.ts | 4 +- webAO/dom/addHPP.ts | 4 +- webAO/dom/areaClick.ts | 22 ++--- webAO/dom/banPlayer.ts | 20 ++-- webAO/dom/callMod.ts | 20 ++-- webAO/dom/cancelEvidence.ts | 52 +++++----- webAO/dom/changeBackgroundOOC.ts | 38 ++++---- webAO/dom/changeBlipVolume.ts | 18 ++-- webAO/dom/changeCallwords.ts | 14 +-- webAO/dom/changeCharacter.ts | 9 +- webAO/dom/changeMusicVolume.ts | 22 ++--- webAO/dom/changeRoleOOC.ts | 14 +-- webAO/dom/charError.ts | 8 +- webAO/dom/charTableFilter.ts | 26 ++--- webAO/dom/deleteEvidence.ts | 8 +- webAO/dom/editEvidence.ts | 32 +++---- webAO/dom/getIndexFromSelect.ts | 16 ++-- webAO/dom/guilty.ts | 4 +- webAO/dom/imgError.ts | 8 +- webAO/dom/iniEdit.ts | 15 +-- webAO/dom/initCE.ts | 4 +- webAO/dom/initWT.ts | 4 +- webAO/dom/modCallTest.ts | 4 +- webAO/dom/musicListClick.ts | 24 ++--- webAO/dom/musicListFilter.ts | 22 ++--- webAO/dom/muteListClick.ts | 22 ++--- webAO/dom/notGuilty.ts | 4 +- webAO/dom/onEnter.ts | 178 +++++++++++++++++------------------ webAO/dom/onOOCEnter.ts | 14 +-- webAO/dom/onReplayGo.ts | 4 +- webAO/dom/opusCheck.ts | 30 +++--- webAO/dom/pickChar.ts | 14 +-- webAO/dom/pickEmotion.ts | 32 +++---- webAO/dom/pickEvidence.ts | 81 ++++++++-------- webAO/dom/randomCharacterOOC.ts | 6 +- webAO/dom/reconnectButton.ts | 12 +-- webAO/dom/redHPD.ts | 4 +- webAO/dom/redHPP.ts | 4 +- webAO/dom/reloadTheme.ts | 20 ++-- webAO/dom/resetOffset.ts | 7 +- webAO/dom/resizeChatbox.ts | 95 ++++++++++++------- webAO/dom/setChatbox.ts | 34 +++---- webAO/dom/showNameClick.ts | 29 +++--- webAO/dom/switchAspectRatio.ts | 28 +++--- webAO/dom/switchChatOffset.ts | 24 ++--- webAO/dom/switchPanTilt.ts | 18 ++-- webAO/dom/toggleMenu.ts | 18 ++-- webAO/dom/toggleShout.ts | 21 +++-- webAO/dom/twofactor.ts | 8 +- webAO/dom/updateActionCommands.ts | 39 ++++---- webAO/dom/updateBackgroundPreview.ts | 42 +++++---- webAO/dom/updateEvidenceIcon.ts | 40 ++++---- webAO/dom/updateIniswap.ts | 20 ++-- webAO/dom/updatePlayerAreas.ts | 30 +++--- webAO/dom/window.ts | 116 +++++++++++------------ 56 files changed, 732 insertions(+), 698 deletions(-) (limited to 'webAO/dom') diff --git a/webAO/dom/addEvidence.ts b/webAO/dom/addEvidence.ts index 84c7fae..f9207bb 100644 --- a/webAO/dom/addEvidence.ts +++ b/webAO/dom/addEvidence.ts @@ -5,16 +5,16 @@ import { cancelEvidence } from "./cancelEvidence"; * Add evidence. */ export function addEvidence() { - const evidence_select = ( - document.getElementById("evi_select") - ); - client.sender.sendPE( - (document.getElementById("evi_name")).value, - (document.getElementById("evi_desc")).value, - evidence_select.selectedIndex === 0 - ? (document.getElementById("evi_filename")).value - : evidence_select.options[evidence_select.selectedIndex].text - ); - cancelEvidence(); + const evidence_select = ( + document.getElementById("evi_select") + ); + client.sender.sendPE( + (document.getElementById("evi_name")).value, + (document.getElementById("evi_desc")).value, + evidence_select.selectedIndex === 0 + ? (document.getElementById("evi_filename")).value + : evidence_select.options[evidence_select.selectedIndex].text, + ); + cancelEvidence(); } -window.addEvidence = addEvidence; \ No newline at end of file +window.addEvidence = addEvidence; diff --git a/webAO/dom/addHPD.ts b/webAO/dom/addHPD.ts index 8f7e1f7..3a7a853 100644 --- a/webAO/dom/addHPD.ts +++ b/webAO/dom/addHPD.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Increment defense health point. */ export function addHPD() { - client.sender.sendHP(1, client.hp[0] + 1); + client.sender.sendHP(1, client.hp[0] + 1); } -window.addHPD = addHPD; \ No newline at end of file +window.addHPD = addHPD; diff --git a/webAO/dom/addHPP.ts b/webAO/dom/addHPP.ts index 1379f7c..2329f7e 100644 --- a/webAO/dom/addHPP.ts +++ b/webAO/dom/addHPP.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Increment prosecution health point. */ export function addHPP() { - client.sender.sendHP(2, client.hp[1] + 1); + client.sender.sendHP(2, client.hp[1] + 1); } -window.addHPP = addHPP; \ No newline at end of file +window.addHPP = addHPP; diff --git a/webAO/dom/areaClick.ts b/webAO/dom/areaClick.ts index e217c2c..1e41f4b 100644 --- a/webAO/dom/areaClick.ts +++ b/webAO/dom/areaClick.ts @@ -1,18 +1,18 @@ -import { client } from '../client' -import { updatePlayerAreas } from './updatePlayerAreas' +import { client } from "../client"; +import { updatePlayerAreas } from "./updatePlayerAreas"; /** * Triggered when an item on the area list is clicked. * @param {HTMLElement} el */ export function area_click(el: HTMLElement) { - const area = client.areas[el.id.substring(4)].name; - client.sender.sendMusicChange(area); + const area = client.areas[el.id.substring(4)].name; + client.sender.sendMusicChange(area); - const areaHr = document.createElement("div"); - areaHr.className = "hrtext"; - areaHr.textContent = `switched to ${el.textContent}`; - document.getElementById("client_log")!.appendChild(areaHr); - client.area = Number(el.id.substring(4)); - updatePlayerAreas(client.area); + const areaHr = document.createElement("div"); + areaHr.className = "hrtext"; + areaHr.textContent = `switched to ${el.textContent}`; + document.getElementById("client_log")!.appendChild(areaHr); + client.area = Number(el.id.substring(4)); + updatePlayerAreas(client.area); } -window.area_click = area_click; \ No newline at end of file +window.area_click = area_click; diff --git a/webAO/dom/banPlayer.ts b/webAO/dom/banPlayer.ts index f122a1b..bf8622b 100644 --- a/webAO/dom/banPlayer.ts +++ b/webAO/dom/banPlayer.ts @@ -1,16 +1,16 @@ -import { client } from '../client' +import { client } from "../client"; /** * Tries to ban a player from the playerlist * @param {Number} id the players id */ export function banPlayer(id: number) { - let reason; - let length; - reason = prompt("Please enter the reason", "Being annoying"); - length = Number(prompt("Please enter the ban length in minutes", "60")); + let reason; + let length; + reason = prompt("Please enter the reason", "Being annoying"); + length = Number(prompt("Please enter the ban length in minutes", "60")); - client.sender.sendMA(id, length, reason); + client.sender.sendMA(id, length, reason); } window.banPlayer = banPlayer; @@ -19,9 +19,9 @@ window.banPlayer = banPlayer; * @param {Number} id the players id */ export function kickPlayer(id: number) { - let reason; - reason = prompt("Please enter the reason", "Being annoying"); + let reason; + reason = prompt("Please enter the reason", "Being annoying"); - client.sender.sendMA(id, 0, reason); + client.sender.sendMA(id, 0, reason); } -window.kickPlayer = kickPlayer; \ No newline at end of file +window.kickPlayer = kickPlayer; diff --git a/webAO/dom/callMod.ts b/webAO/dom/callMod.ts index a2e2685..8d4c80d 100644 --- a/webAO/dom/callMod.ts +++ b/webAO/dom/callMod.ts @@ -3,14 +3,14 @@ import { client, extrafeatures } from "../client"; * Call mod. */ export function callMod() { - let modcall; - if (extrafeatures.includes("modcall_reason")) { - modcall = prompt("Please enter the reason for the modcall", ""); - } - if (modcall == null || modcall === "") { - // cancel - } else { - client.sender.sendZZ(modcall); - } + let modcall; + if (extrafeatures.includes("modcall_reason")) { + modcall = prompt("Please enter the reason for the modcall", ""); + } + if (modcall == null || modcall === "") { + // cancel + } else { + client.sender.sendZZ(modcall); + } } -window.callMod = callMod; \ No newline at end of file +window.callMod = callMod; diff --git a/webAO/dom/cancelEvidence.ts b/webAO/dom/cancelEvidence.ts index 05910f8..2ebcd9c 100644 --- a/webAO/dom/cancelEvidence.ts +++ b/webAO/dom/cancelEvidence.ts @@ -1,36 +1,34 @@ -import { client, } from "../client"; -import { updateEvidenceIcon } from './updateEvidenceIcon' +import { client } from "../client"; +import { updateEvidenceIcon } from "./updateEvidenceIcon"; import { AO_HOST } from "../client/aoHost"; - /** * Cancel evidence selection. */ export function cancelEvidence() { - // Clear evidence data - if (client.selectedEvidence >= 0) { - document.getElementById(`evi_${client.selectedEvidence}`)!.className = - "evi_icon"; - } - client.selectedEvidence = -1; + // Clear evidence data + if (client.selectedEvidence >= 0) { + document.getElementById(`evi_${client.selectedEvidence}`)!.className = + "evi_icon"; + } + client.selectedEvidence = -1; - // Clear evidence on information window - (document.getElementById("evi_select")).selectedIndex = 0; - updateEvidenceIcon(); // Update icon widget - (document.getElementById("evi_filename")).value = ""; - (document.getElementById("evi_name")).value = ""; - (document.getElementById("evi_desc")).value = ""; - (( - document.getElementById("evi_preview") - )).src = `${AO_HOST}misc/empty.png`; // Clear icon + // Clear evidence on information window + (document.getElementById("evi_select")).selectedIndex = 0; + updateEvidenceIcon(); // Update icon widget + (document.getElementById("evi_filename")).value = ""; + (document.getElementById("evi_name")).value = ""; + (document.getElementById("evi_desc")).value = ""; + (document.getElementById("evi_preview")).src = + `${AO_HOST}misc/empty.png`; // Clear icon - // Update button - document.getElementById("evi_add")!.className = "client_button hover_button"; - document.getElementById("evi_edit")!.className = - "client_button hover_button inactive"; - document.getElementById("evi_cancel")!.className = - "client_button hover_button inactive"; - document.getElementById("evi_del")!.className = - "client_button hover_button inactive"; + // Update button + document.getElementById("evi_add")!.className = "client_button hover_button"; + document.getElementById("evi_edit")!.className = + "client_button hover_button inactive"; + document.getElementById("evi_cancel")!.className = + "client_button hover_button inactive"; + document.getElementById("evi_del")!.className = + "client_button hover_button inactive"; } -window.cancelEvidence = cancelEvidence; \ No newline at end of file +window.cancelEvidence = cancelEvidence; diff --git a/webAO/dom/changeBackgroundOOC.ts b/webAO/dom/changeBackgroundOOC.ts index 55ce238..c90ecba 100644 --- a/webAO/dom/changeBackgroundOOC.ts +++ b/webAO/dom/changeBackgroundOOC.ts @@ -1,28 +1,26 @@ - -import queryParser from '../utils/queryParser' -import { client } from '../client' -const { mode } = queryParser() +import queryParser from "../utils/queryParser"; +import { client } from "../client"; +const { mode } = queryParser(); /** * Change background via OOC. */ export function changeBackgroundOOC() { - const selectedBG = document.getElementById("bg_select"); - const changeBGCommand = "bg $1"; - const bgFilename = document.getElementById("bg_filename"); - - let filename = ""; - if (selectedBG.selectedIndex === 0) { - filename = bgFilename.value; - } else { - filename = selectedBG.value; - } + const selectedBG = document.getElementById("bg_select"); + const changeBGCommand = "bg $1"; + const bgFilename = document.getElementById("bg_filename"); + let filename = ""; + if (selectedBG.selectedIndex === 0) { + filename = bgFilename.value; + } else { + filename = selectedBG.value; + } - if (mode === "join") { - client.sender.sendOOC(`/${changeBGCommand.replace("$1", filename)}`); - } else if (mode === "replay") { - client.sender.sendSelf(`BN#${filename}#%`); - } + if (mode === "join") { + client.sender.sendOOC(`/${changeBGCommand.replace("$1", filename)}`); + } else if (mode === "replay") { + client.sender.sendSelf(`BN#${filename}#%`); + } } -window.changeBackgroundOOC = changeBackgroundOOC; \ No newline at end of file +window.changeBackgroundOOC = changeBackgroundOOC; diff --git a/webAO/dom/changeBlipVolume.ts b/webAO/dom/changeBlipVolume.ts index 572f389..2e77403 100644 --- a/webAO/dom/changeBlipVolume.ts +++ b/webAO/dom/changeBlipVolume.ts @@ -1,15 +1,15 @@ import setCookie from "../utils/setCookie"; -import { client } from '../client' +import { client } from "../client"; /** * Triggered by the blip volume slider. */ export const changeBlipVolume = () => { - const blipVolume = (( - document.getElementById("client_bvolume") - )).value; - client.viewport.blipChannels.forEach( - (channel: HTMLAudioElement) => (channel.volume = Number(blipVolume)) - ); - setCookie("blipVolume", blipVolume); -} + const blipVolume = (( + document.getElementById("client_bvolume") + )).value; + client.viewport.blipChannels.forEach( + (channel: HTMLAudioElement) => (channel.volume = Number(blipVolume)), + ); + setCookie("blipVolume", blipVolume); +}; window.changeBlipVolume = changeBlipVolume; diff --git a/webAO/dom/changeCallwords.ts b/webAO/dom/changeCallwords.ts index 28be674..e125817 100644 --- a/webAO/dom/changeCallwords.ts +++ b/webAO/dom/changeCallwords.ts @@ -1,13 +1,13 @@ -import { client } from '../client' -import setCookie from '../utils/setCookie'; +import { client } from "../client"; +import setCookie from "../utils/setCookie"; /** * Triggered by a changed callword list */ export function changeCallwords() { - client.callwords = (( - document.getElementById("client_callwords") - )).value.split("\n"); - setCookie("callwords", client.callwords.join("\n")); + client.callwords = (( + document.getElementById("client_callwords") + )).value.split("\n"); + setCookie("callwords", client.callwords.join("\n")); } -window.changeCallwords = changeCallwords; \ No newline at end of file +window.changeCallwords = changeCallwords; diff --git a/webAO/dom/changeCharacter.ts b/webAO/dom/changeCharacter.ts index 7ecefe5..abf6f71 100644 --- a/webAO/dom/changeCharacter.ts +++ b/webAO/dom/changeCharacter.ts @@ -1,11 +1,10 @@ - /** * Triggered when a character icon is clicked in the character selection menu. * @param {MouseEvent} event */ export function changeCharacter(_event: Event) { - document.getElementById("client_waiting")!.style.display = "block"; - document.getElementById("client_charselect")!.style.display = "block"; - document.getElementById("client_emo")!.innerHTML = ""; + document.getElementById("client_waiting")!.style.display = "block"; + document.getElementById("client_charselect")!.style.display = "block"; + document.getElementById("client_emo")!.innerHTML = ""; } -window.changeCharacter = changeCharacter; \ No newline at end of file +window.changeCharacter = changeCharacter; diff --git a/webAO/dom/changeMusicVolume.ts b/webAO/dom/changeMusicVolume.ts index b54661b..df0a656 100644 --- a/webAO/dom/changeMusicVolume.ts +++ b/webAO/dom/changeMusicVolume.ts @@ -1,14 +1,14 @@ -import { client } from '../client' -import setCookie from '../utils/setCookie'; +import { client } from "../client"; +import setCookie from "../utils/setCookie"; export const changeMusicVolume = (volume: number = -1) => { - const clientVolume = Number( - (document.getElementById("client_mvolume")).value - ); - const musicVolume = volume === -1 ? clientVolume : volume; - client.viewport.music.forEach( - (channel: HTMLAudioElement) => (channel.volume = musicVolume) - ); - setCookie("musicVolume", String(musicVolume)); + const clientVolume = Number( + (document.getElementById("client_mvolume")).value, + ); + const musicVolume = volume === -1 ? clientVolume : volume; + client.viewport.music.forEach( + (channel: HTMLAudioElement) => (channel.volume = musicVolume), + ); + setCookie("musicVolume", String(musicVolume)); }; -window.changeMusicVolume = changeMusicVolume; \ No newline at end of file +window.changeMusicVolume = changeMusicVolume; diff --git a/webAO/dom/changeRoleOOC.ts b/webAO/dom/changeRoleOOC.ts index 7d89bee..1d79c2a 100644 --- a/webAO/dom/changeRoleOOC.ts +++ b/webAO/dom/changeRoleOOC.ts @@ -1,13 +1,13 @@ -import { updateActionCommands } from './updateActionCommands' -import { client } from '../client' +import { updateActionCommands } from "./updateActionCommands"; +import { client } from "../client"; /** * Change role via OOC. */ export function changeRoleOOC() { - const roleselect = document.getElementById("role_select"); + const roleselect = document.getElementById("role_select"); - client.sender.sendOOC(`/pos ${roleselect.value}`); - client.sender.sendServer(`SP#${roleselect.value}#%`); - updateActionCommands(roleselect.value); + client.sender.sendOOC(`/pos ${roleselect.value}`); + client.sender.sendServer(`SP#${roleselect.value}#%`); + updateActionCommands(roleselect.value); } -window.changeRoleOOC = changeRoleOOC; \ No newline at end of file +window.changeRoleOOC = changeRoleOOC; diff --git a/webAO/dom/charError.ts b/webAO/dom/charError.ts index 8cb672a..dfc054a 100644 --- a/webAO/dom/charError.ts +++ b/webAO/dom/charError.ts @@ -5,8 +5,8 @@ import transparentPng from "../constants/transparentPng"; * @param {HTMLImageElement} image the element containing the missing image */ export function charError(image: HTMLImageElement) { - console.warn(`${image.src} is missing from webAO`); - image.src = transparentPng; - return true; + console.warn(`${image.src} is missing from webAO`); + image.src = transparentPng; + return true; } -window.charError = charError; \ No newline at end of file +window.charError = charError; diff --git a/webAO/dom/charTableFilter.ts b/webAO/dom/charTableFilter.ts index d81fb88..a093ee2 100644 --- a/webAO/dom/charTableFilter.ts +++ b/webAO/dom/charTableFilter.ts @@ -1,20 +1,20 @@ -import { client } from '../client' +import { client } from "../client"; /** * Triggered when the music search bar is changed * @param {MouseEvent} event */ export function chartable_filter(_event: Event) { - const searchname = (( - document.getElementById("client_charactersearch") - )).value; + const searchname = (( + document.getElementById("client_charactersearch") + )).value; - client.chars.forEach((character: any, charid: number) => { - const demothing = document.getElementById(`demo_${charid}`)!; - if (character.name.toLowerCase().indexOf(searchname.toLowerCase()) === -1) { - demothing.style.display = "none"; - } else { - demothing.style.display = "inline-block"; - } - }); + client.chars.forEach((character: any, charid: number) => { + const demothing = document.getElementById(`demo_${charid}`)!; + if (character.name.toLowerCase().indexOf(searchname.toLowerCase()) === -1) { + demothing.style.display = "none"; + } else { + demothing.style.display = "inline-block"; + } + }); } -window.chartable_filter = chartable_filter; \ No newline at end of file +window.chartable_filter = chartable_filter; diff --git a/webAO/dom/deleteEvidence.ts b/webAO/dom/deleteEvidence.ts index 764b9e5..0b5228e 100644 --- a/webAO/dom/deleteEvidence.ts +++ b/webAO/dom/deleteEvidence.ts @@ -5,8 +5,8 @@ import { cancelEvidence } from "./cancelEvidence"; * Delete selected evidence. */ export function deleteEvidence() { - const id = client.selectedEvidence; - client.sender.sendDE(id); - cancelEvidence(); + const id = client.selectedEvidence; + client.sender.sendDE(id); + cancelEvidence(); } -window.deleteEvidence = deleteEvidence; \ No newline at end of file +window.deleteEvidence = deleteEvidence; diff --git a/webAO/dom/editEvidence.ts b/webAO/dom/editEvidence.ts index 80ce350..bb4ab23 100644 --- a/webAO/dom/editEvidence.ts +++ b/webAO/dom/editEvidence.ts @@ -1,22 +1,22 @@ -import { client } from '../client' -import { cancelEvidence } from './cancelEvidence'; +import { client } from "../client"; +import { cancelEvidence } from "./cancelEvidence"; /** * Edit selected evidence. */ export function editEvidence() { - const evidence_select = ( - document.getElementById("evi_select") - ); - const id = client.selectedEvidence; - client.sender.sendEE( - id, - (document.getElementById("evi_name")).value, - (document.getElementById("evi_desc")).value, - evidence_select.selectedIndex === 0 - ? (document.getElementById("evi_filename")).value - : evidence_select.options[evidence_select.selectedIndex].text - ); - cancelEvidence(); + const evidence_select = ( + document.getElementById("evi_select") + ); + const id = client.selectedEvidence; + client.sender.sendEE( + id, + (document.getElementById("evi_name")).value, + (document.getElementById("evi_desc")).value, + evidence_select.selectedIndex === 0 + ? (document.getElementById("evi_filename")).value + : evidence_select.options[evidence_select.selectedIndex].text, + ); + cancelEvidence(); } -window.editEvidence = editEvidence; \ No newline at end of file +window.editEvidence = editEvidence; diff --git a/webAO/dom/getIndexFromSelect.ts b/webAO/dom/getIndexFromSelect.ts index 2f21653..dbbdd2b 100644 --- a/webAO/dom/getIndexFromSelect.ts +++ b/webAO/dom/getIndexFromSelect.ts @@ -4,13 +4,13 @@ * @param {string} value the value that need to be compared */ export function getIndexFromSelect(select_box: string, value: string) { - // Find if icon alraedy existed in select box - const select_element = document.getElementById(select_box); - for (let i = 1; i < select_element.length; ++i) { - if (select_element.options[i].value === value) { - return i; - } + // Find if icon alraedy existed in select box + const select_element = document.getElementById(select_box); + for (let i = 1; i < select_element.length; ++i) { + if (select_element.options[i].value === value) { + return i; } - return 0; + } + return 0; } -window.getIndexFromSelect = getIndexFromSelect; \ No newline at end of file +window.getIndexFromSelect = getIndexFromSelect; diff --git a/webAO/dom/guilty.ts b/webAO/dom/guilty.ts index f008065..075dc00 100644 --- a/webAO/dom/guilty.ts +++ b/webAO/dom/guilty.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Declare the defendant not guilty */ export function guilty() { - client.sender.sendRT("judgeruling#1"); + client.sender.sendRT("judgeruling#1"); } -window.guilty = guilty; \ No newline at end of file +window.guilty = guilty; diff --git a/webAO/dom/imgError.ts b/webAO/dom/imgError.ts index fdb6122..dfc6c92 100644 --- a/webAO/dom/imgError.ts +++ b/webAO/dom/imgError.ts @@ -3,8 +3,8 @@ * @param {HTMLImageElement} image the element containing the missing image */ export function imgError(image: HTMLImageElement) { - image.onerror = null; - image.src = ""; // unload so the old sprite doesn't persist - return true; + image.onerror = null; + image.src = ""; // unload so the old sprite doesn't persist + return true; } -window.imgError = imgError; \ No newline at end of file +window.imgError = imgError; diff --git a/webAO/dom/iniEdit.ts b/webAO/dom/iniEdit.ts index b26c179..245eedc 100644 --- a/webAO/dom/iniEdit.ts +++ b/webAO/dom/iniEdit.ts @@ -6,13 +6,16 @@ import { packetHandler } from "../packets/packetHandler"; * Triggered by the ini button. */ export async function iniedit() { - const iniselect = (document.getElementById("client_iniselect")) - const ininame = (document.getElementById("client_ininame")); - const inicharID = client.charID; + const iniselect = ( + document.getElementById("client_iniselect") + ); + const ininame = document.getElementById("client_ininame"); + const inicharID = client.charID; - const newname = iniselect.selectedIndex === 0 ? ininame.value : iniselect.value; + const newname = + iniselect.selectedIndex === 0 ? ininame.value : iniselect.value; - await handleCharacterInfo(newname.split("&"), inicharID); - packetHandler.get("PV")!(`PV#0#CID#${inicharID}`.split("#")); + await handleCharacterInfo(newname.split("&"), inicharID); + packetHandler.get("PV")!(`PV#0#CID#${inicharID}`.split("#")); } window.iniedit = iniedit; diff --git a/webAO/dom/initCE.ts b/webAO/dom/initCE.ts index fd57d74..8c92481 100644 --- a/webAO/dom/initCE.ts +++ b/webAO/dom/initCE.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Declare cross examination. */ export function initCE() { - client.sender.sendRT("testimony2"); + client.sender.sendRT("testimony2"); } -window.initCE = initCE; \ No newline at end of file +window.initCE = initCE; diff --git a/webAO/dom/initWT.ts b/webAO/dom/initWT.ts index d99fc3e..5b679cf 100644 --- a/webAO/dom/initWT.ts +++ b/webAO/dom/initWT.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Declare witness testimony. */ export function initWT() { - client.sender.sendRT("testimony1"); + client.sender.sendRT("testimony1"); } -window.initWT = initWT; \ No newline at end of file +window.initWT = initWT; diff --git a/webAO/dom/modCallTest.ts b/webAO/dom/modCallTest.ts index 7058caf..d6fa246 100644 --- a/webAO/dom/modCallTest.ts +++ b/webAO/dom/modCallTest.ts @@ -3,6 +3,6 @@ import { packetHandler } from "../packets/packetHandler"; * Triggered by the modcall sfx dropdown */ export function modcall_test() { - packetHandler.get("ZZ")!("test#test".split("#")); + packetHandler.get("ZZ")!("test#test".split("#")); } -window.modcall_test = modcall_test; \ No newline at end of file +window.modcall_test = modcall_test; diff --git a/webAO/dom/musicListClick.ts b/webAO/dom/musicListClick.ts index 2243553..5a29dc4 100644 --- a/webAO/dom/musicListClick.ts +++ b/webAO/dom/musicListClick.ts @@ -4,18 +4,18 @@ import { client } from "../client"; * @param {MouseEvent} event */ export function musiclist_click(_event: Event) { - const playtrack = (( - document.getElementById("client_musiclist") - )).value; - client.sender.sendMusicChange(playtrack); + const playtrack = (( + document.getElementById("client_musiclist") + )).value; + client.sender.sendMusicChange(playtrack); - // This is here so you can't actually select multiple tracks, - // even though the select tag has the multiple option to render differently - const musiclist_elements = (( - document.getElementById("client_musiclist") - )).selectedOptions; - for (let i = 0; i < musiclist_elements.length; i++) { - musiclist_elements[i].selected = false; - } + // This is here so you can't actually select multiple tracks, + // even though the select tag has the multiple option to render differently + const musiclist_elements = (( + document.getElementById("client_musiclist") + )).selectedOptions; + for (let i = 0; i < musiclist_elements.length; i++) { + musiclist_elements[i].selected = false; + } } window.musiclist_click = musiclist_click; diff --git a/webAO/dom/musicListFilter.ts b/webAO/dom/musicListFilter.ts index b5284a2..b0a8c3b 100644 --- a/webAO/dom/musicListFilter.ts +++ b/webAO/dom/musicListFilter.ts @@ -1,24 +1,24 @@ -import { client } from '../client' +import { client } from "../client"; /** * Triggered when the music search bar is changed * @param {MouseEvent} event */ export function musiclist_filter(_event: Event) { - const musiclist_element = ( + const musiclist_element = ( document.getElementById("client_musiclist") ); - const searchname = (( + const searchname = (( document.getElementById("client_musicsearch") )).value; - musiclist_element.innerHTML = ""; + musiclist_element.innerHTML = ""; - for (const trackname of client.musics) { - if (trackname.toLowerCase().indexOf(searchname.toLowerCase()) !== -1) { - const newentry = document.createElement("OPTION"); - newentry.text = trackname; - musiclist_element.options.add(newentry); - } + for (const trackname of client.musics) { + if (trackname.toLowerCase().indexOf(searchname.toLowerCase()) !== -1) { + const newentry = document.createElement("OPTION"); + newentry.text = trackname; + musiclist_element.options.add(newentry); } + } } -window.musiclist_filter = musiclist_filter; \ No newline at end of file +window.musiclist_filter = musiclist_filter; diff --git a/webAO/dom/muteListClick.ts b/webAO/dom/muteListClick.ts index 51bdd3d..2aca500 100644 --- a/webAO/dom/muteListClick.ts +++ b/webAO/dom/muteListClick.ts @@ -4,16 +4,16 @@ import { client } from "../client"; * @param {MouseEvent} event */ export function mutelist_click(_event: Event) { - const mutelist = (document.getElementById('mute_select')); - const selected_character = mutelist.options[mutelist.selectedIndex]; + const mutelist = document.getElementById("mute_select"); + const selected_character = mutelist.options[mutelist.selectedIndex]; - if (client.chars[selected_character.value].muted === false) { - client.chars[selected_character.value].muted = true; - selected_character.text = `${client.chars[selected_character.value].name} (muted)`; - console.info(`muted ${client.chars[selected_character.value].name}`); - } else { - client.chars[selected_character.value].muted = false; - selected_character.text = client.chars[selected_character.value].name; - } + if (client.chars[selected_character.value].muted === false) { + client.chars[selected_character.value].muted = true; + selected_character.text = `${client.chars[selected_character.value].name} (muted)`; + console.info(`muted ${client.chars[selected_character.value].name}`); + } else { + client.chars[selected_character.value].muted = false; + selected_character.text = client.chars[selected_character.value].name; + } } -window.mutelist_click = mutelist_click; \ No newline at end of file +window.mutelist_click = mutelist_click; diff --git a/webAO/dom/notGuilty.ts b/webAO/dom/notGuilty.ts index 95b830b..52d3462 100644 --- a/webAO/dom/notGuilty.ts +++ b/webAO/dom/notGuilty.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Declare the defendant not guilty */ export function notguilty() { - client.sender.sendRT("judgeruling#0"); + client.sender.sendRT("judgeruling#0"); } -window.notguilty = notguilty; \ No newline at end of file +window.notguilty = notguilty; diff --git a/webAO/dom/onEnter.ts b/webAO/dom/onEnter.ts index 65bfa37..6c8cbe7 100644 --- a/webAO/dom/onEnter.ts +++ b/webAO/dom/onEnter.ts @@ -6,97 +6,97 @@ import { escapeChat } from "../encoding"; * @param {KeyboardEvent} event */ export function onEnter(event: KeyboardEvent) { - if (event.keyCode === 13) { - const mychar = client.character; - const myemo = client.emote; - const evi = client.evidence + 1; - const flip = Boolean( - document.getElementById("button_flip")!.classList.contains("dark") - ); - const flash = Boolean( - document.getElementById("button_flash")!.classList.contains("dark") - ); - const screenshake = Boolean( - document.getElementById("button_shake")!.classList.contains("dark") - ); - const noninterrupting_preanim = Boolean( - (document.getElementById("check_nonint")).checked - ); - const looping_sfx = Boolean( - (document.getElementById("check_loopsfx")).checked - ); - const color = Number( - (document.getElementById("textcolor")).value - ); - const showname = escapeChat( - (document.getElementById("ic_chat_name")).value - ); - const text = (document.getElementById("client_inputbox")) - .value; - const pairchar = (document.getElementById("pair_select")) - .value; - const pairoffset = Number( - (document.getElementById("pair_offset")).value - ); - const pairyoffset = Number( - (document.getElementById("pair_y_offset")).value - ); - const myrole = (document.getElementById("role_select")) - .value - ? (document.getElementById("role_select")).value - : mychar.side; - const additive = Boolean( - (document.getElementById("check_additive")).checked - ); - const effect = (document.getElementById("effect_select")) - .value; + if (event.keyCode === 13) { + const mychar = client.character; + const myemo = client.emote; + const evi = client.evidence + 1; + const flip = Boolean( + document.getElementById("button_flip")!.classList.contains("dark"), + ); + const flash = Boolean( + document.getElementById("button_flash")!.classList.contains("dark"), + ); + const screenshake = Boolean( + document.getElementById("button_shake")!.classList.contains("dark"), + ); + const noninterrupting_preanim = Boolean( + (document.getElementById("check_nonint")).checked, + ); + const looping_sfx = Boolean( + (document.getElementById("check_loopsfx")).checked, + ); + const color = Number( + (document.getElementById("textcolor")).value, + ); + const showname = escapeChat( + (document.getElementById("ic_chat_name")).value, + ); + const text = (document.getElementById("client_inputbox")) + .value; + const pairchar = (document.getElementById("pair_select")) + .value; + const pairoffset = Number( + (document.getElementById("pair_offset")).value, + ); + const pairyoffset = Number( + (document.getElementById("pair_y_offset")).value, + ); + const myrole = (document.getElementById("role_select")) + .value + ? (document.getElementById("role_select")).value + : mychar.side; + const additive = Boolean( + (document.getElementById("check_additive")).checked, + ); + const effect = (document.getElementById("effect_select")) + .value; - let sfxname = "0"; - let sfxdelay = 0; - let emote_mod = myemo.zoom; - if ((document.getElementById("sendsfx")).checked) { - sfxname = myemo.sfx; - sfxdelay = myemo.sfxdelay; - } - - // not to overwrite a 5 from the ini or anything else - if ((document.getElementById("sendpreanim")).checked) { - if (emote_mod === 0) { - emote_mod = 1; - } - } else if (emote_mod === 1) { - emote_mod = 0; - } + let sfxname = "0"; + let sfxdelay = 0; + let emote_mod = myemo.zoom; + if ((document.getElementById("sendsfx")).checked) { + sfxname = myemo.sfx; + sfxdelay = myemo.sfxdelay; + } - client.sender.sendIC( - myemo.deskmod, - myemo.preanim, - mychar.name, - myemo.emote, - text, - myrole, - sfxname, - emote_mod, - sfxdelay, - selectedShout, - evi, - flip, - flash, - color, - showname, - pairchar, - pairoffset, - pairyoffset, - noninterrupting_preanim, - looping_sfx, - screenshake, - "-", - "-", - "-", - additive, - effect - ); + // not to overwrite a 5 from the ini or anything else + if ((document.getElementById("sendpreanim")).checked) { + if (emote_mod === 0) { + emote_mod = 1; + } + } else if (emote_mod === 1) { + emote_mod = 0; } - return false; + + client.sender.sendIC( + myemo.deskmod, + myemo.preanim, + mychar.name, + myemo.emote, + text, + myrole, + sfxname, + emote_mod, + sfxdelay, + selectedShout, + evi, + flip, + flash, + color, + showname, + pairchar, + pairoffset, + pairyoffset, + noninterrupting_preanim, + looping_sfx, + screenshake, + "-", + "-", + "-", + additive, + effect, + ); + } + return false; } window.onEnter = onEnter; diff --git a/webAO/dom/onOOCEnter.ts b/webAO/dom/onOOCEnter.ts index d7ec21b..e4e0971 100644 --- a/webAO/dom/onOOCEnter.ts +++ b/webAO/dom/onOOCEnter.ts @@ -4,12 +4,12 @@ import { client } from "../client"; * @param {KeyboardEvent} event */ export function onOOCEnter(event: KeyboardEvent) { - if (event.keyCode === 13) { - client.sender.sendOOC( - (document.getElementById("client_oocinputbox")).value - ); - (document.getElementById("client_oocinputbox")).value = - ""; - } + if (event.keyCode === 13) { + client.sender.sendOOC( + (document.getElementById("client_oocinputbox")).value, + ); + (document.getElementById("client_oocinputbox")).value = + ""; + } } window.onOOCEnter = onOOCEnter; diff --git a/webAO/dom/onReplayGo.ts b/webAO/dom/onReplayGo.ts index 82a6f2f..4475778 100644 --- a/webAO/dom/onReplayGo.ts +++ b/webAO/dom/onReplayGo.ts @@ -5,6 +5,6 @@ import { client } from "../client"; * @param {KeyboardEvent} event */ export function onReplayGo(_event: Event) { - client.handleReplay(); + client.handleReplay(); } -window.onReplayGo = onReplayGo; \ No newline at end of file +window.onReplayGo = onReplayGo; diff --git a/webAO/dom/opusCheck.ts b/webAO/dom/opusCheck.ts index 608a30a..90f5bb6 100644 --- a/webAO/dom/opusCheck.ts +++ b/webAO/dom/opusCheck.ts @@ -3,20 +3,20 @@ * @param {HTMLAudioElement} image the element containing the missing sound */ export function opusCheck( - channel: HTMLAudioElement + channel: HTMLAudioElement, ): OnErrorEventHandlerNonNull { - const audio = channel.src; - if (audio === "") { - return; - } - console.warn(`failed to load sound ${channel.src}`); - let oldsrc = ""; - let newsrc = ""; - oldsrc = channel.src; - if (!oldsrc.endsWith(".opus")) { - newsrc = oldsrc.replace(".mp3", ".opus"); - newsrc = newsrc.replace(".wav", ".opus"); - channel.src = newsrc; // unload so the old sprite doesn't persist - } + const audio = channel.src; + if (audio === "") { + return; + } + console.warn(`failed to load sound ${channel.src}`); + let oldsrc = ""; + let newsrc = ""; + oldsrc = channel.src; + if (!oldsrc.endsWith(".opus")) { + newsrc = oldsrc.replace(".mp3", ".opus"); + newsrc = newsrc.replace(".wav", ".opus"); + channel.src = newsrc; // unload so the old sprite doesn't persist + } } -window.opusCheck = opusCheck; \ No newline at end of file +window.opusCheck = opusCheck; diff --git a/webAO/dom/pickChar.ts b/webAO/dom/pickChar.ts index 82fb6af..05f1c70 100644 --- a/webAO/dom/pickChar.ts +++ b/webAO/dom/pickChar.ts @@ -6,11 +6,11 @@ import { client } from "../client"; * then spectator is chosen instead. */ export function pickChar(ccharacter: number) { - if (ccharacter === -1) { - // Spectator - document.getElementById("client_waiting")!.style.display = "none"; - document.getElementById("client_charselect")!.style.display = "none"; - } - client.sender.sendCharacter(ccharacter); + if (ccharacter === -1) { + // Spectator + document.getElementById("client_waiting")!.style.display = "none"; + document.getElementById("client_charselect")!.style.display = "none"; + } + client.sender.sendCharacter(ccharacter); } -window.pickChar = pickChar; \ No newline at end of file +window.pickChar = pickChar; diff --git a/webAO/dom/pickEmotion.ts b/webAO/dom/pickEmotion.ts index 619d0ab..15169c3 100644 --- a/webAO/dom/pickEmotion.ts +++ b/webAO/dom/pickEmotion.ts @@ -1,26 +1,26 @@ -import { client } from '../client' +import { client } from "../client"; /** * Highlights and selects an emotion for in-character chat. * @param {string} emo the new emotion to be selected */ export function pickEmotion(emo: number) { - try { - if (client.selectedEmote !== -1) { - document.getElementById(`emo_${client.selectedEmote}`)!.className = - "emote_button"; - } - } catch (err) { - // do nothing + try { + if (client.selectedEmote !== -1) { + document.getElementById(`emo_${client.selectedEmote}`)!.className = + "emote_button"; } - client.selectedEmote = emo; - document.getElementById(`emo_${emo}`)!.className = "emote_button dark"; + } catch (err) { + // do nothing + } + client.selectedEmote = emo; + document.getElementById(`emo_${emo}`)!.className = "emote_button dark"; - (document.getElementById("sendsfx")).checked = - client.emote.sfx.length > 1; + (document.getElementById("sendsfx")).checked = + client.emote.sfx.length > 1; - (document.getElementById("sendpreanim")).checked = - client.emote.zoom == 1; + (document.getElementById("sendpreanim")).checked = + client.emote.zoom == 1; - (document.getElementById("client_inputbox")).focus(); + (document.getElementById("client_inputbox")).focus(); } -window.pickEmotion = pickEmotion; \ No newline at end of file +window.pickEmotion = pickEmotion; diff --git a/webAO/dom/pickEvidence.ts b/webAO/dom/pickEvidence.ts index e4c86fa..eef92ec 100644 --- a/webAO/dom/pickEvidence.ts +++ b/webAO/dom/pickEvidence.ts @@ -1,51 +1,52 @@ -import { client } from '../client' -import { cancelEvidence } from './cancelEvidence'; -import { updateEvidenceIcon } from './updateEvidenceIcon' -import { getIndexFromSelect } from './getIndexFromSelect' +import { client } from "../client"; +import { cancelEvidence } from "./cancelEvidence"; +import { updateEvidenceIcon } from "./updateEvidenceIcon"; +import { getIndexFromSelect } from "./getIndexFromSelect"; /** * Highlights and selects an evidence for in-character chat. * @param {string} evidence the evidence to be presented */ export function pickEvidence(evidence: number) { - if (client.selectedEvidence !== evidence) { - // Update selected evidence - if (client.selectedEvidence >= 0) { - document.getElementById(`evi_${client.selectedEvidence}`)!.className = - "evi_icon"; - } - document.getElementById(`evi_${evidence}`)!.className = "evi_icon dark"; - client.selectedEvidence = evidence; - - // Show evidence on information window - (document.getElementById("evi_name")).value = - client.evidences[evidence].name; - (document.getElementById("evi_desc")).value = - client.evidences[evidence].desc; + if (client.selectedEvidence !== evidence) { + // Update selected evidence + if (client.selectedEvidence >= 0) { + document.getElementById(`evi_${client.selectedEvidence}`)!.className = + "evi_icon"; + } + document.getElementById(`evi_${evidence}`)!.className = "evi_icon dark"; + client.selectedEvidence = evidence; - // Update icon - const icon_id = getIndexFromSelect( - "evi_select", - client.evidences[evidence].filename - ); - (document.getElementById("evi_select")).selectedIndex = - icon_id; - if (icon_id === 0) { - (document.getElementById("evi_filename")).value = - client.evidences[evidence].filename; - } - updateEvidenceIcon(); + // Show evidence on information window + (document.getElementById("evi_name")).value = + client.evidences[evidence].name; + (document.getElementById("evi_desc")).value = + client.evidences[evidence].desc; - // Update button - document.getElementById("evi_add")!.className = - "client_button hover_button inactive"; - document.getElementById("evi_edit")!.className = - "client_button hover_button"; - document.getElementById("evi_cancel")!.className = - "client_button hover_button"; - document.getElementById("evi_del")!.className = "client_button hover_button"; - } else { - cancelEvidence(); + // Update icon + const icon_id = getIndexFromSelect( + "evi_select", + client.evidences[evidence].filename, + ); + (document.getElementById("evi_select")).selectedIndex = + icon_id; + if (icon_id === 0) { + (document.getElementById("evi_filename")).value = + client.evidences[evidence].filename; } + updateEvidenceIcon(); + + // Update button + document.getElementById("evi_add")!.className = + "client_button hover_button inactive"; + document.getElementById("evi_edit")!.className = + "client_button hover_button"; + document.getElementById("evi_cancel")!.className = + "client_button hover_button"; + document.getElementById("evi_del")!.className = + "client_button hover_button"; + } else { + cancelEvidence(); + } } window.pickEvidence = pickEvidence; diff --git a/webAO/dom/randomCharacterOOC.ts b/webAO/dom/randomCharacterOOC.ts index 657a474..c701f62 100644 --- a/webAO/dom/randomCharacterOOC.ts +++ b/webAO/dom/randomCharacterOOC.ts @@ -1,8 +1,8 @@ -import { client } from '../client' +import { client } from "../client"; /** * Random character via OOC. */ export function randomCharacterOOC() { - client.sender.sendOOC(`/randomchar`); + client.sender.sendOOC(`/randomchar`); } -window.randomCharacterOOC = randomCharacterOOC; \ No newline at end of file +window.randomCharacterOOC = randomCharacterOOC; diff --git a/webAO/dom/reconnectButton.ts b/webAO/dom/reconnectButton.ts index 76a6b51..079e7fc 100644 --- a/webAO/dom/reconnectButton.ts +++ b/webAO/dom/reconnectButton.ts @@ -6,11 +6,11 @@ const { ip: serverIP } = queryParser(); * Triggered when the reconnect button is pushed. */ export function ReconnectButton() { - client.cleanup(); - setClient(new Client(serverIP)); + client.cleanup(); + setClient(new Client(serverIP)); - if (client) { - document.getElementById("client_error")!.style.display = "none"; - } + if (client) { + document.getElementById("client_error")!.style.display = "none"; + } } -window.ReconnectButton = ReconnectButton; \ No newline at end of file +window.ReconnectButton = ReconnectButton; diff --git a/webAO/dom/redHPD.ts b/webAO/dom/redHPD.ts index e228d21..d2e7b3a 100644 --- a/webAO/dom/redHPD.ts +++ b/webAO/dom/redHPD.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Decrement defense health point. */ export function redHPD() { - client.sender.sendHP(1, client.hp[0] - 1); + client.sender.sendHP(1, client.hp[0] - 1); } -window.redHPD = redHPD; \ No newline at end of file +window.redHPD = redHPD; diff --git a/webAO/dom/redHPP.ts b/webAO/dom/redHPP.ts index efde941..c7adbbf 100644 --- a/webAO/dom/redHPP.ts +++ b/webAO/dom/redHPP.ts @@ -4,6 +4,6 @@ import { client } from "../client"; * Decrement prosecution health point. */ export function redHPP() { - client.sender.sendHP(2, client.hp[1] - 1); + client.sender.sendHP(2, client.hp[1] - 1); } -window.redHPP = redHPP; \ No newline at end of file +window.redHPP = redHPP; diff --git a/webAO/dom/reloadTheme.ts b/webAO/dom/reloadTheme.ts index bfa46b6..c65ac6d 100644 --- a/webAO/dom/reloadTheme.ts +++ b/webAO/dom/reloadTheme.ts @@ -1,16 +1,16 @@ -import { client } from '../client' -import setCookie from '../utils/setCookie'; +import { client } from "../client"; +import setCookie from "../utils/setCookie"; /** * Triggered by the theme selector. */ export const reloadTheme = () => { - client.viewport.setTheme((document.getElementById("client_themeselect")) - .value); + client.viewport.setTheme( + (document.getElementById("client_themeselect")).value, + ); - setCookie("theme", client.viewport.getTheme()); - (( - document.getElementById("client_theme") - )).href = `styles/${client.viewport.getTheme()}.css`; -} -window.reloadTheme = reloadTheme; \ No newline at end of file + setCookie("theme", client.viewport.getTheme()); + (document.getElementById("client_theme")).href = + `styles/${client.viewport.getTheme()}.css`; +}; +window.reloadTheme = reloadTheme; diff --git a/webAO/dom/resetOffset.ts b/webAO/dom/resetOffset.ts index 8b1a2fd..aaf8c48 100644 --- a/webAO/dom/resetOffset.ts +++ b/webAO/dom/resetOffset.ts @@ -1,6 +1,5 @@ - export function resetOffset(_event: Event) { - (document.getElementById("pair_offset")).value = "0"; - (document.getElementById("pair_y_offset")).value = "0"; + (document.getElementById("pair_offset")).value = "0"; + (document.getElementById("pair_y_offset")).value = "0"; } -window.resetOffset = resetOffset; \ No newline at end of file +window.resetOffset = resetOffset; diff --git a/webAO/dom/resizeChatbox.ts b/webAO/dom/resizeChatbox.ts index a60dbff..35b1e51 100644 --- a/webAO/dom/resizeChatbox.ts +++ b/webAO/dom/resizeChatbox.ts @@ -3,42 +3,71 @@ import { CHATBOX } from "../client"; * Set the font size for the chatbox */ export function resizeChatbox() { - const chatContainerBox = document.getElementById("client_chatcontainer"); - const clockBox = document.getElementById("client_clock"); - const trackstatusBox = document.getElementById("client_trackstatus"); + const chatContainerBox = document.getElementById("client_chatcontainer"); + const clockBox = document.getElementById("client_clock"); + const trackstatusBox = document.getElementById("client_trackstatus"); - const gameHeight = document.getElementById("client_background")!.offsetHeight; + const gameHeight = document.getElementById("client_background")!.offsetHeight; - chatContainerBox.style.fontSize = `${(gameHeight * 0.0521).toFixed(1)}px`; - clockBox.style.fontSize = `${(gameHeight * 0.0521).toFixed(1)}px`; - trackstatusBox.style.fontSize = `${(gameHeight * 0.0521).toFixed(1)}px`; + chatContainerBox.style.fontSize = `${(gameHeight * 0.0521).toFixed(1)}px`; + clockBox.style.fontSize = `${(gameHeight * 0.0521).toFixed(1)}px`; + trackstatusBox.style.fontSize = `${(gameHeight * 0.0521).toFixed(1)}px`; - const trackstatus = (document.getElementById("client_trackstatustext")); - trackstatus.style.width = (trackstatus.offsetWidth - 1) + "px"; + const trackstatus = ( + document.getElementById("client_trackstatustext") + ); + trackstatus.style.width = trackstatus.offsetWidth - 1 + "px"; - //name spacing - const namePlate = document.getElementById("client_name"); - if (CHATBOX == "aa" && namePlate.innerText.length<5) { - namePlate.style.letterSpacing = "0.2em"; - }else{ - namePlate.style.letterSpacing = "normal"; - } - - //clock - const now = new Date(); - let weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; - const month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; - document.getElementById("client_clock_month")!.innerText = month[now.getMonth()]; - if (CHATBOX == "acww") { - weekday = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; - document.getElementById("client_clock_weekday")!.innerText = weekday[now.getDay()]; - document.getElementById("client_clock_date")!.innerText = now.getDay() + "/" + now.getMonth(); - document.getElementById("client_clock_time")!.innerText = now.getHours() + ":" + now.getMinutes(); - } else if (CHATBOX == "key") { - weekday = ["Sun.", "Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sat."]; - document.getElementById("client_clock_weekday")!.innerText = weekday[now.getDay()]; - document.getElementById("client_clock_date")!.innerText = String(now.getDate()); - } + //name spacing + const namePlate = document.getElementById("client_name"); + if (CHATBOX == "aa" && namePlate.innerText.length < 5) { + namePlate.style.letterSpacing = "0.2em"; + } else { + namePlate.style.letterSpacing = "normal"; + } + //clock + const now = new Date(); + let weekday = [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + ]; + const month = [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + ]; + document.getElementById("client_clock_month")!.innerText = + month[now.getMonth()]; + if (CHATBOX == "acww") { + weekday = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; + document.getElementById("client_clock_weekday")!.innerText = + weekday[now.getDay()]; + document.getElementById("client_clock_date")!.innerText = + now.getDay() + "/" + now.getMonth(); + document.getElementById("client_clock_time")!.innerText = + now.getHours() + ":" + now.getMinutes(); + } else if (CHATBOX == "key") { + weekday = ["Sun.", "Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sat."]; + document.getElementById("client_clock_weekday")!.innerText = + weekday[now.getDay()]; + document.getElementById("client_clock_date")!.innerText = String( + now.getDate(), + ); + } } -window.resizeChatbox = resizeChatbox; \ No newline at end of file +window.resizeChatbox = resizeChatbox; diff --git a/webAO/dom/setChatbox.ts b/webAO/dom/setChatbox.ts index 095ead3..c75559d 100644 --- a/webAO/dom/setChatbox.ts +++ b/webAO/dom/setChatbox.ts @@ -6,24 +6,24 @@ import setCookie from "../utils/setCookie"; * Set the style of the chatbox */ export function setChatbox(setstyle: string) { - const chatbox_theme = ( - document.getElementById("chatbox_theme") - ); - const themeselect = ( - document.getElementById("client_chatboxselect") - ); - setCHATBOX(themeselect.value); + const chatbox_theme = ( + document.getElementById("chatbox_theme") + ); + const themeselect = ( + document.getElementById("client_chatboxselect") + ); + setCHATBOX(themeselect.value); - setCookie("chatbox", CHATBOX); - if (CHATBOX === "dynamic") { - const style = setstyle.replace("chat",""); - if (chatbox_arr.includes(style)) { - chatbox_theme.href = `styles/chatbox/${style}.css`; - } else { - chatbox_theme.href = "styles/chatbox/aa.css"; - } + setCookie("chatbox", CHATBOX); + if (CHATBOX === "dynamic") { + const style = setstyle.replace("chat", ""); + if (chatbox_arr.includes(style)) { + chatbox_theme.href = `styles/chatbox/${style}.css`; } else { - chatbox_theme.href = `styles/chatbox/${CHATBOX}.css`; + chatbox_theme.href = "styles/chatbox/aa.css"; } + } else { + chatbox_theme.href = `styles/chatbox/${CHATBOX}.css`; + } } -window.setChatbox = setChatbox; \ No newline at end of file +window.setChatbox = setChatbox; diff --git a/webAO/dom/showNameClick.ts b/webAO/dom/showNameClick.ts index 3e48b70..005bfd5 100644 --- a/webAO/dom/showNameClick.ts +++ b/webAO/dom/showNameClick.ts @@ -1,26 +1,25 @@ import setCookie from "../utils/setCookie"; - /** * Triggered when the showname checkboc is clicked * @param {MouseEvent} event */ export function showname_click(_event: Event | null) { - setCookie( - "showname", - String((document.getElementById("showname")).checked) - ); - setCookie( - "ic_chat_name", - (document.getElementById("ic_chat_name")).value - ); + setCookie( + "showname", + String((document.getElementById("showname")).checked), + ); + setCookie( + "ic_chat_name", + (document.getElementById("ic_chat_name")).value, + ); - const css_s = document.getElementById("nameplate_setting"); + const css_s = document.getElementById("nameplate_setting"); - if ((document.getElementById("showname")).checked) { - css_s.href = "styles/shownames.css"; - } else { - css_s.href = "styles/nameplates.css"; - } + if ((document.getElementById("showname")).checked) { + css_s.href = "styles/shownames.css"; + } else { + css_s.href = "styles/nameplates.css"; + } } window.showname_click = showname_click; diff --git a/webAO/dom/switchAspectRatio.ts b/webAO/dom/switchAspectRatio.ts index 79d4110..db55cb0 100644 --- a/webAO/dom/switchAspectRatio.ts +++ b/webAO/dom/switchAspectRatio.ts @@ -2,18 +2,18 @@ * Triggered by the change aspect ratio checkbox */ export async function switchAspectRatio() { - const background = document.getElementById("client_gamewindow")!; - const offsetCheck = ( - document.getElementById("client_hdviewport_offset") - ); - if ( - (document.getElementById("client_hdviewport")).checked - ) { - background.style.paddingBottom = "56.25%"; - offsetCheck.disabled = false; - } else { - background.style.paddingBottom = "75%"; - offsetCheck.disabled = true; - } + const background = document.getElementById("client_gamewindow")!; + const offsetCheck = ( + document.getElementById("client_hdviewport_offset") + ); + if ( + (document.getElementById("client_hdviewport")).checked + ) { + background.style.paddingBottom = "56.25%"; + offsetCheck.disabled = false; + } else { + background.style.paddingBottom = "75%"; + offsetCheck.disabled = true; + } } -window.switchAspectRatio = switchAspectRatio; \ No newline at end of file +window.switchAspectRatio = switchAspectRatio; diff --git a/webAO/dom/switchChatOffset.ts b/webAO/dom/switchChatOffset.ts index 6552cbd..257d1ca 100644 --- a/webAO/dom/switchChatOffset.ts +++ b/webAO/dom/switchChatOffset.ts @@ -2,16 +2,16 @@ * Triggered by the change aspect ratio checkbox */ export async function switchChatOffset() { - const container = document.getElementById("client_chatcontainer")!; - if ( - (document.getElementById("client_hdviewport_offset")) - .checked - ) { - container.style.width = "80%"; - container.style.left = "10%"; - } else { - container.style.width = "100%"; - container.style.left = "0"; - } + const container = document.getElementById("client_chatcontainer")!; + if ( + (document.getElementById("client_hdviewport_offset")) + .checked + ) { + container.style.width = "80%"; + container.style.left = "10%"; + } else { + container.style.width = "100%"; + container.style.left = "0"; + } } -window.switchChatOffset = switchChatOffset; \ No newline at end of file +window.switchChatOffset = switchChatOffset; diff --git a/webAO/dom/switchPanTilt.ts b/webAO/dom/switchPanTilt.ts index 7ceea06..9422eff 100644 --- a/webAO/dom/switchPanTilt.ts +++ b/webAO/dom/switchPanTilt.ts @@ -2,15 +2,15 @@ * Triggered by the pantilt checkbox */ export async function switchPanTilt() { - const fullview = document.getElementById("client_fullview")!; - const checkbox = document.getElementById("client_pantilt"); + const fullview = document.getElementById("client_fullview")!; + const checkbox = document.getElementById("client_pantilt"); - if (checkbox.checked) { - fullview.style.transition = "0.5s ease-in-out"; - } else { - fullview.style.transition = "none"; - } + if (checkbox.checked) { + fullview.style.transition = "0.5s ease-in-out"; + } else { + fullview.style.transition = "none"; + } - return; + return; } -window.switchPanTilt = switchPanTilt; \ No newline at end of file +window.switchPanTilt = switchPanTilt; diff --git a/webAO/dom/toggleMenu.ts b/webAO/dom/toggleMenu.ts index 6d5e1fc..0e00941 100644 --- a/webAO/dom/toggleMenu.ts +++ b/webAO/dom/toggleMenu.ts @@ -5,14 +5,14 @@ import { selectedMenu, setSelectedMenu } from "../client"; * @param {number} menu the menu to be selected */ export function toggleMenu(menu: number) { - if (menu !== selectedMenu) { - document.getElementById(`menu_${menu}`)!.className = "menu_button active"; - document.getElementById(`content_${menu}`)!.className = - "menu_content active"; - document.getElementById(`menu_${selectedMenu}`)!.className = "menu_button"; - document.getElementById(`content_${selectedMenu}`)!.className = - "menu_content"; - setSelectedMenu(menu); - } + if (menu !== selectedMenu) { + document.getElementById(`menu_${menu}`)!.className = "menu_button active"; + document.getElementById(`content_${menu}`)!.className = + "menu_content active"; + document.getElementById(`menu_${selectedMenu}`)!.className = "menu_button"; + document.getElementById(`content_${selectedMenu}`)!.className = + "menu_content"; + setSelectedMenu(menu); + } } window.toggleMenu = toggleMenu; diff --git a/webAO/dom/toggleShout.ts b/webAO/dom/toggleShout.ts index cb12f49..dcfccba 100644 --- a/webAO/dom/toggleShout.ts +++ b/webAO/dom/toggleShout.ts @@ -6,16 +6,17 @@ import { selectedShout, setSelectedShout } from "../client"; * @param {number} shout the new shout to be selected */ export function toggleShout(shout: number) { - if (shout === selectedShout) { - document.getElementById(`button_${shout}`)!.className = "client_button"; - setSelectedShout(0); - } else { - document.getElementById(`button_${shout}`)!.className = "client_button dark"; - if (selectedShout) { - document.getElementById(`button_${selectedShout}`)!.className = - "client_button"; - } - setSelectedShout(shout); + if (shout === selectedShout) { + document.getElementById(`button_${shout}`)!.className = "client_button"; + setSelectedShout(0); + } else { + document.getElementById(`button_${shout}`)!.className = + "client_button dark"; + if (selectedShout) { + document.getElementById(`button_${selectedShout}`)!.className = + "client_button"; } + setSelectedShout(shout); + } } window.toggleShout = toggleShout; diff --git a/webAO/dom/twofactor.ts b/webAO/dom/twofactor.ts index b53f4cf..58bbc4c 100644 --- a/webAO/dom/twofactor.ts +++ b/webAO/dom/twofactor.ts @@ -2,9 +2,9 @@ import { client } from "../client"; import setCookie from "../utils/setCookie"; export function hcallback(hcaptcharesponse: string) { - setCookie('hdid', client.hdid); - client.sender.sendServer(`2T#${hcaptcharesponse}#%`); - location.reload(); + setCookie("hdid", client.hdid); + client.sender.sendServer(`2T#${hcaptcharesponse}#%`); + location.reload(); } -window.hcallback = hcallback; \ No newline at end of file +window.hcallback = hcallback; diff --git a/webAO/dom/updateActionCommands.ts b/webAO/dom/updateActionCommands.ts index ca8ca60..536292b 100644 --- a/webAO/dom/updateActionCommands.ts +++ b/webAO/dom/updateActionCommands.ts @@ -1,27 +1,26 @@ - /** * Update evidence icon. */ export function updateActionCommands(side: string) { - if (side === "jud") { - document.getElementById("judge_action")!.style.display = "inline-table"; - document.getElementById("no_action")!.style.display = "none"; - } else { - document.getElementById("judge_action")!.style.display = "none"; - document.getElementById("no_action")!.style.display = "inline-table"; - } + if (side === "jud") { + document.getElementById("judge_action")!.style.display = "inline-table"; + document.getElementById("no_action")!.style.display = "none"; + } else { + document.getElementById("judge_action")!.style.display = "none"; + document.getElementById("no_action")!.style.display = "inline-table"; + } - // Update role selector - for ( - let i = 0, - role_select = document.getElementById("role_select"); - i < role_select.options.length; - i++ - ) { - if (side === role_select.options[i].value) { - role_select.options.selectedIndex = i; - return; - } + // Update role selector + for ( + let i = 0, + role_select = document.getElementById("role_select"); + i < role_select.options.length; + i++ + ) { + if (side === role_select.options[i].value) { + role_select.options.selectedIndex = i; + return; } + } } -window.updateActionCommands = updateActionCommands; \ No newline at end of file +window.updateActionCommands = updateActionCommands; diff --git a/webAO/dom/updateBackgroundPreview.ts b/webAO/dom/updateBackgroundPreview.ts index 659d4cb..61eec58 100644 --- a/webAO/dom/updateBackgroundPreview.ts +++ b/webAO/dom/updateBackgroundPreview.ts @@ -1,29 +1,31 @@ -import { AO_HOST } from '../client/aoHost'; +import { AO_HOST } from "../client/aoHost"; import tryUrls from "../utils/tryUrls"; /** * Update background preview. */ export function updateBackgroundPreview() { - const background_select = ( - document.getElementById("bg_select") - ); - const background_filename = ( - document.getElementById("bg_filename") - ); - const background_preview = ( - document.getElementById("bg_preview") - ); + const background_select = ( + document.getElementById("bg_select") + ); + const background_filename = ( + document.getElementById("bg_filename") + ); + const background_preview = ( + document.getElementById("bg_preview") + ); - if (background_select.selectedIndex === 0) { - background_filename.style.display = "initial"; - } else { - background_filename.style.display = "none"; - } - tryUrls(`${AO_HOST}background/${encodeURI( - background_select.value.toLowerCase() - )}/defenseempty`).then((resp) => { - background_preview.src = resp; - }); + if (background_select.selectedIndex === 0) { + background_filename.style.display = "initial"; + } else { + background_filename.style.display = "none"; + } + tryUrls( + `${AO_HOST}background/${encodeURI( + background_select.value.toLowerCase(), + )}/defenseempty`, + ).then((resp) => { + background_preview.src = resp; + }); } window.updateBackgroundPreview = updateBackgroundPreview; diff --git a/webAO/dom/updateEvidenceIcon.ts b/webAO/dom/updateEvidenceIcon.ts index bff0475..dbda07c 100644 --- a/webAO/dom/updateEvidenceIcon.ts +++ b/webAO/dom/updateEvidenceIcon.ts @@ -3,26 +3,26 @@ import { AO_HOST } from "../client/aoHost"; * Update evidence icon. */ export function updateEvidenceIcon() { - const evidence_select = ( - document.getElementById("evi_select") - ); - const evidence_filename = ( - document.getElementById("evi_filename") - ); - const evidence_iconbox = ( - document.getElementById("evi_preview") - ); + const evidence_select = ( + document.getElementById("evi_select") + ); + const evidence_filename = ( + document.getElementById("evi_filename") + ); + const evidence_iconbox = ( + document.getElementById("evi_preview") + ); - if (evidence_select.selectedIndex === 0) { - evidence_filename.style.display = "initial"; - evidence_iconbox.src = `${AO_HOST}evidence/${encodeURI( - evidence_filename.value.toLowerCase() - )}`; - } else { - evidence_filename.style.display = "none"; - evidence_iconbox.src = `${AO_HOST}evidence/${encodeURI( - evidence_select.value.toLowerCase() - )}`; - } + if (evidence_select.selectedIndex === 0) { + evidence_filename.style.display = "initial"; + evidence_iconbox.src = `${AO_HOST}evidence/${encodeURI( + evidence_filename.value.toLowerCase(), + )}`; + } else { + evidence_filename.style.display = "none"; + evidence_iconbox.src = `${AO_HOST}evidence/${encodeURI( + evidence_select.value.toLowerCase(), + )}`; + } } window.updateEvidenceIcon = updateEvidenceIcon; diff --git a/webAO/dom/updateIniswap.ts b/webAO/dom/updateIniswap.ts index 5bea0f5..929d4a0 100644 --- a/webAO/dom/updateIniswap.ts +++ b/webAO/dom/updateIniswap.ts @@ -2,17 +2,15 @@ * Update iniswap drowdown */ export function updateIniswap() { - const ini_select = ( - document.getElementById("client_iniselect") - ); - const ini_name = ( - document.getElementById("client_ininame") - ); + const ini_select = ( + document.getElementById("client_iniselect") + ); + const ini_name = document.getElementById("client_ininame"); - if (ini_select.selectedIndex === 0) { - ini_name.style.display = "initial"; - } else { - ini_name.style.display = "none"; - } + if (ini_select.selectedIndex === 0) { + ini_name.style.display = "initial"; + } else { + ini_name.style.display = "none"; + } } window.updateIniswap = updateIniswap; diff --git a/webAO/dom/updatePlayerAreas.ts b/webAO/dom/updatePlayerAreas.ts index d2ec076..99eccf1 100644 --- a/webAO/dom/updatePlayerAreas.ts +++ b/webAO/dom/updatePlayerAreas.ts @@ -1,16 +1,24 @@ -import { client } from '../client' -import { area_click } from './areaClick'; +import { client } from "../client"; +import { area_click } from "./areaClick"; /** * Triggered when someone switches areas * @param {Number} ownarea */ export function updatePlayerAreas(ownarea: number) { - for (let i=0; i < client.areas.length; i++) { - if (i===ownarea) - for (let classelement of Array.from(document.getElementsByClassName(`area${i}`) as HTMLCollectionOf)) - classelement.style.display = ""; - else - for (let classelement of Array.from(document.getElementsByClassName(`area${i}`) as HTMLCollectionOf)) - classelement.style.display = "none"; - } -} \ No newline at end of file + for (let i = 0; i < client.areas.length; i++) { + if (i === ownarea) + for (let classelement of Array.from( + document.getElementsByClassName( + `area${i}`, + ) as HTMLCollectionOf, + )) + classelement.style.display = ""; + else + for (let classelement of Array.from( + document.getElementsByClassName( + `area${i}`, + ) as HTMLCollectionOf, + )) + classelement.style.display = "none"; + } +} diff --git a/webAO/dom/window.ts b/webAO/dom/window.ts index 59ad575..ee1b121 100644 --- a/webAO/dom/window.ts +++ b/webAO/dom/window.ts @@ -1,60 +1,60 @@ declare global { - interface Window { - toggleShout: (shout: number) => void; - toggleMenu: (menu: number) => void; - updateBackgroundPreview: () => void; - redHPP: () => void; - addHPP: () => void; - redHPD: () => void; - addHPD: () => void; - guilty: () => void; - notguilty: () => void; - initCE: () => void; - initWT: () => void; - callMod: () => void; - randomCharacterOOC: () => void; - changeRoleOOC: () => void; - changeBackgroundOOC: () => void; - updateActionCommands: (side: string) => void; - updateEvidenceIcon: () => void; - updateIniswap: () => void; - resizeChatbox: () => void; - setChatbox: (style: string) => void; - getIndexFromSelect: (select_box: string, value: string) => number; - cancelEvidence: () => void; - deleteEvidence: () => void; - editEvidence: () => void; - addEvidence: () => void; - pickEvidence: (evidence: any) => void; - pickEmotion: (emo: number) => void; - pickChar: (ccharacter: any) => void; - chartable_filter: (_event: any) => void; - ReconnectButton: (_event: any) => void; - opusCheck: (channel: HTMLAudioElement) => OnErrorEventHandlerNonNull; - imgError: (image: any) => void; - charError: (image: any) => void; - changeCharacter: (_event: any) => void; - switchChatOffset: () => void; - switchAspectRatio: () => void; - switchPanTilt: (addcheck: number) => void; - iniedit: () => void; - modcall_test: () => void; - reloadTheme: () => void; - changeCallwords: () => void; - changeBlipVolume: () => void; - changeMusicVolume: () => void; - area_click: (el: any) => void; - showname_click: (_event: any) => void; - mutelist_click: (_event: any) => void; - musiclist_click: (_event: any) => void; - musiclist_filter: (_event: any) => void; - resetOffset: (_event: any) => void; - onEnter: (event: any) => void; - onReplayGo: (_event: any) => void; - onOOCEnter: (_event: any) => void; - kickPlayer: (id: number) => void; - banPlayer: (id: number) => void; - hcallback: (_event: any) => void; - } + interface Window { + toggleShout: (shout: number) => void; + toggleMenu: (menu: number) => void; + updateBackgroundPreview: () => void; + redHPP: () => void; + addHPP: () => void; + redHPD: () => void; + addHPD: () => void; + guilty: () => void; + notguilty: () => void; + initCE: () => void; + initWT: () => void; + callMod: () => void; + randomCharacterOOC: () => void; + changeRoleOOC: () => void; + changeBackgroundOOC: () => void; + updateActionCommands: (side: string) => void; + updateEvidenceIcon: () => void; + updateIniswap: () => void; + resizeChatbox: () => void; + setChatbox: (style: string) => void; + getIndexFromSelect: (select_box: string, value: string) => number; + cancelEvidence: () => void; + deleteEvidence: () => void; + editEvidence: () => void; + addEvidence: () => void; + pickEvidence: (evidence: any) => void; + pickEmotion: (emo: number) => void; + pickChar: (ccharacter: any) => void; + chartable_filter: (_event: any) => void; + ReconnectButton: (_event: any) => void; + opusCheck: (channel: HTMLAudioElement) => OnErrorEventHandlerNonNull; + imgError: (image: any) => void; + charError: (image: any) => void; + changeCharacter: (_event: any) => void; + switchChatOffset: () => void; + switchAspectRatio: () => void; + switchPanTilt: (addcheck: number) => void; + iniedit: () => void; + modcall_test: () => void; + reloadTheme: () => void; + changeCallwords: () => void; + changeBlipVolume: () => void; + changeMusicVolume: () => void; + area_click: (el: any) => void; + showname_click: (_event: any) => void; + mutelist_click: (_event: any) => void; + musiclist_click: (_event: any) => void; + musiclist_filter: (_event: any) => void; + resetOffset: (_event: any) => void; + onEnter: (event: any) => void; + onReplayGo: (_event: any) => void; + onOOCEnter: (_event: any) => void; + kickPlayer: (id: number) => void; + banPlayer: (id: number) => void; + hcallback: (_event: any) => void; + } } -export { } \ No newline at end of file +export {}; -- cgit