aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-09-04 22:30:31 +0200
committerstonedDiscord <Tukz@gmx.de>2022-09-04 22:30:31 +0200
commit1e3fde25b9f6d8adbdf087a51a34dc35cc1907d8 (patch)
tree6b0c33270bc7ec96ab7dbe3381870babeb60a179
parent975fb353dd7f5bec7bcb836f4ceb86fae9b70340 (diff)
undo dom stuff
-rw-r--r--webAO/client.ts141
-rw-r--r--webAO/dom/changeBackgroundOOC.ts27
-rw-r--r--webAO/dom/musicListClick.ts21
-rw-r--r--webAO/dom/musicListFilter.ts24
-rw-r--r--webAO/dom/muteListClick.ts20
-rw-r--r--webAO/dom/onOOCEnter.ts16
-rw-r--r--webAO/dom/onReplayGo.ts9
-rw-r--r--webAO/dom/updateBackgroundPreview.ts29
-rw-r--r--webAO/packets/handlers/handleBN.ts3
-rw-r--r--webAO/viewport.ts3
10 files changed, 141 insertions, 152 deletions
diff --git a/webAO/client.ts b/webAO/client.ts
index 806c0a5..33f1802 100644
--- a/webAO/client.ts
+++ b/webAO/client.ts
@@ -36,7 +36,6 @@ let { ip: serverIP, mode, asset, theme } = queryParser();
// Unless there is an asset URL specified, use the wasabi one
const DEFAULT_HOST = "http://attorneyoffline.de/base/";
import { showname_click } from './dom/showNameClick'
-import { onReplayGo } from './dom/onReplayGo'
import { updateActionCommands } from './dom/updateActionCommands'
export let AO_HOST = asset || DEFAULT_HOST;
export const setAOhost = (val: string) => {
@@ -139,16 +138,20 @@ function isLowMemory() {
oldLoading = true;
}
}
+
const fpPromise = FingerprintJS.load();
+
fpPromise
.then((fp) => fp.get())
.then((result) => {
hdid = result.visitorId;
+ console.log("NEW CLIENT");
client = new Client(serverIP);
isLowMemory();
client.loadResources();
});
+
export const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
let lastICMessageTime = new Date(0);
@@ -950,7 +953,29 @@ class Client extends EventEmitter {
}
}
+/**
+ * Triggered when the Return key is pressed on the out-of-character chat input box.
+ * @param {KeyboardEvent} event
+ */
+ export function onOOCEnter(event: KeyboardEvent) {
+ if (event.keyCode === 13) {
+ client.sendOOC(
+ (<HTMLInputElement>document.getElementById("client_oocinputbox")).value
+ );
+ (<HTMLInputElement>document.getElementById("client_oocinputbox")).value =
+ "";
+ }
+}
+window.onOOCEnter = onOOCEnter;
+/**
+ * Triggered when the user click replay GOOOOO
+ * @param {KeyboardEvent} event
+ */
+ export function onReplayGo(_event: Event) {
+ client.handleReplay();
+}
+window.onReplayGo = onReplayGo;
/**
@@ -1073,6 +1098,70 @@ export function resetICParams() {
}
}
+/**
+ * Triggered when the music search bar is changed
+ * @param {MouseEvent} event
+ */
+ export function musiclist_filter(_event: Event) {
+ const musiclist_element = <HTMLSelectElement>(
+ document.getElementById("client_musiclist")
+ );
+ const searchname = (<HTMLInputElement>(
+ document.getElementById("client_musicsearch")
+ )).value;
+
+ musiclist_element.innerHTML = "";
+
+ for (const trackname of client.musics) {
+ if (trackname.toLowerCase().indexOf(searchname.toLowerCase()) !== -1) {
+ const newentry = <HTMLOptionElement>document.createElement("OPTION");
+ newentry.text = trackname;
+ musiclist_element.options.add(newentry);
+ }
+ }
+}
+window.musiclist_filter = musiclist_filter;
+
+/**
+ * Triggered when an item on the music list is clicked.
+ * @param {MouseEvent} event
+ */
+export function musiclist_click(_event: Event) {
+ const playtrack = (<HTMLInputElement>(
+ document.getElementById("client_musiclist")
+ )).value;
+ client.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 = (<HTMLSelectElement>(
+ document.getElementById("client_musiclist")
+ )).selectedOptions;
+ for (let i = 0; i < musiclist_elements.length; i++) {
+ musiclist_elements[i].selected = false;
+ }
+}
+window.musiclist_click = musiclist_click;
+
+/**
+ * Triggered when a character in the mute list is clicked
+ * @param {MouseEvent} event
+ */
+export function mutelist_click(_event: Event) {
+ const mutelist = <HTMLSelectElement>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;
+ }
+}
+window.mutelist_click = mutelist_click;
/**
* Triggered when an item on the area list is clicked.
@@ -1602,9 +1691,29 @@ export function updateEvidenceIcon() {
}
window.updateEvidenceIcon = updateEvidenceIcon;
+/**
+ * Change background via OOC.
+ */
+ export function changeBackgroundOOC() {
+ const selectedBG = <HTMLSelectElement>document.getElementById("bg_select");
+ const changeBGCommand = "bg $1";
+ const bgFilename = <HTMLInputElement>document.getElementById("bg_filename");
+
+ let filename = "";
+ if (selectedBG.selectedIndex === 0) {
+ filename = bgFilename.value;
+ } else {
+ filename = selectedBG.value;
+ }
-
+ if (mode === "join") {
+ client.sendOOC(`/${changeBGCommand.replace("$1", filename)}`);
+ } else if (mode === "replay") {
+ client.sendSelf(`BN#${filename}#%`);
+ }
+}
+window.changeBackgroundOOC = changeBackgroundOOC;
/**
* Change role via OOC.
@@ -1707,6 +1816,34 @@ export function redHPP() {
window.redHPP = redHPP;
/**
+ * Update background preview.
+ */
+ export function updateBackgroundPreview() {
+ const background_select = <HTMLSelectElement>(
+ document.getElementById("bg_select")
+ );
+ const background_filename = <HTMLInputElement>(
+ document.getElementById("bg_filename")
+ );
+ const background_preview = <HTMLImageElement>(
+ document.getElementById("bg_preview")
+ );
+
+ if (background_select.selectedIndex === 0) {
+ background_filename.style.display = "initial";
+ background_preview.src = `${AO_HOST}background/${encodeURI(
+ background_filename.value.toLowerCase()
+ )}/defenseempty.png`;
+ } else {
+ background_filename.style.display = "none";
+ background_preview.src = `${AO_HOST}background/${encodeURI(
+ background_select.value.toLowerCase()
+ )}/defenseempty.png`;
+ }
+}
+window.updateBackgroundPreview = updateBackgroundPreview;
+
+/**
* Highlights and selects a menu.
* @param {number} menu the menu to be selected
*/
diff --git a/webAO/dom/changeBackgroundOOC.ts b/webAO/dom/changeBackgroundOOC.ts
deleted file mode 100644
index abf3a97..0000000
--- a/webAO/dom/changeBackgroundOOC.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { client } from "../client";
-import queryParser from "../utils/queryParser";
-
-let { mode } = queryParser();
-
-/**
- * Change background via OOC.
- */
-export function changeBackgroundOOC() {
- const selectedBG = <HTMLSelectElement>document.getElementById("bg_select");
- const changeBGCommand = "bg $1";
- const bgFilename = <HTMLInputElement>document.getElementById("bg_filename");
-
- let filename = "";
- if (selectedBG.selectedIndex === 0) {
- filename = bgFilename.value;
- } else {
- filename = selectedBG.value;
- }
-
- if (mode === "join") {
- client.sendOOC(`/${changeBGCommand.replace("$1", filename)}`);
- } else if (mode === "replay") {
- client.sendSelf(`BN#${filename}#%`);
- }
-}
-window.changeBackgroundOOC = changeBackgroundOOC; \ No newline at end of file
diff --git a/webAO/dom/musicListClick.ts b/webAO/dom/musicListClick.ts
deleted file mode 100644
index 1eb6619..0000000
--- a/webAO/dom/musicListClick.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { client } from "../client";
-/**
- * Triggered when an item on the music list is clicked.
- * @param {MouseEvent} event
- */
-export function musiclist_click(_event: Event) {
- const playtrack = (<HTMLInputElement>(
- document.getElementById("client_musiclist")
- )).value;
- client.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 = (<HTMLSelectElement>(
- document.getElementById("client_musiclist")
- )).selectedOptions;
- for (let i = 0; i < musiclist_elements.length; i++) {
- musiclist_elements[i].selected = false;
- }
-}
-window.musiclist_click = musiclist_click; \ No newline at end of file
diff --git a/webAO/dom/musicListFilter.ts b/webAO/dom/musicListFilter.ts
deleted file mode 100644
index c44978d..0000000
--- a/webAO/dom/musicListFilter.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { client } from "../client";
-/**
- * Triggered when the music search bar is changed
- * @param {MouseEvent} event
- */
-export function musiclist_filter(_event: Event) {
- const musiclist_element = <HTMLSelectElement>(
- document.getElementById("client_musiclist")
- );
- const searchname = (<HTMLInputElement>(
- document.getElementById("client_musicsearch")
- )).value;
-
- musiclist_element.innerHTML = "";
-
- for (const trackname of client.musics) {
- if (trackname.toLowerCase().indexOf(searchname.toLowerCase()) !== -1) {
- const newentry = <HTMLOptionElement>document.createElement("OPTION");
- newentry.text = trackname;
- musiclist_element.options.add(newentry);
- }
- }
-}
-window.musiclist_filter = musiclist_filter; \ No newline at end of file
diff --git a/webAO/dom/muteListClick.ts b/webAO/dom/muteListClick.ts
deleted file mode 100644
index 6ae3eea..0000000
--- a/webAO/dom/muteListClick.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { client } from "../client";
-/**
- * Triggered when a character in the mute list is clicked
- * @param {MouseEvent} event
- */
-export function mutelist_click(_event: Event) {
- const mutelist = <HTMLSelectElement>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;
- }
-}
-window.mutelist_click = mutelist_click; \ No newline at end of file
diff --git a/webAO/dom/onOOCEnter.ts b/webAO/dom/onOOCEnter.ts
deleted file mode 100644
index a24928b..0000000
--- a/webAO/dom/onOOCEnter.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import {client} from '../client'
-/**
- * Triggered when the Return key is pressed on the out-of-character chat input box.
- * @param {KeyboardEvent} event
- */
- export function onOOCEnter(event: KeyboardEvent) {
- if (event.keyCode === 13) {
- client.sendOOC(
- (<HTMLInputElement>document.getElementById("client_oocinputbox")).value
- );
- (<HTMLInputElement>document.getElementById("client_oocinputbox")).value =
- "";
- }
- }
- window.onOOCEnter = onOOCEnter;
- \ No newline at end of file
diff --git a/webAO/dom/onReplayGo.ts b/webAO/dom/onReplayGo.ts
deleted file mode 100644
index c13a8e6..0000000
--- a/webAO/dom/onReplayGo.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { client } from "../client";
-/**
- * Triggered when the user click replay GOOOOO
- * @param {KeyboardEvent} event
- */
- export function onReplayGo(_event: Event) {
- client.handleReplay();
- }
- window.onReplayGo = onReplayGo; \ No newline at end of file
diff --git a/webAO/dom/updateBackgroundPreview.ts b/webAO/dom/updateBackgroundPreview.ts
deleted file mode 100644
index e55bf60..0000000
--- a/webAO/dom/updateBackgroundPreview.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { AO_HOST } from "../client";
-
-/**
- * Update background preview.
- */
-export function updateBackgroundPreview() {
- const background_select = <HTMLSelectElement>(
- document.getElementById("bg_select")
- );
- const background_filename = <HTMLInputElement>(
- document.getElementById("bg_filename")
- );
- const background_preview = <HTMLImageElement>(
- document.getElementById("bg_preview")
- );
-
- if (background_select.selectedIndex === 0) {
- background_filename.style.display = "initial";
- background_preview.src = `${AO_HOST}background/${encodeURI(
- background_filename.value.toLowerCase()
- )}/defenseempty.png`;
- } else {
- background_filename.style.display = "none";
- background_preview.src = `${AO_HOST}background/${encodeURI(
- background_select.value.toLowerCase()
- )}/defenseempty.png`;
- }
-}
-window.updateBackgroundPreview = updateBackgroundPreview; \ No newline at end of file
diff --git a/webAO/packets/handlers/handleBN.ts b/webAO/packets/handlers/handleBN.ts
index 9dabc15..f7b8447 100644
--- a/webAO/packets/handlers/handleBN.ts
+++ b/webAO/packets/handlers/handleBN.ts
@@ -1,7 +1,6 @@
-import { AO_HOST, client, getIndexFromSelect } from "../../client";
+import { AO_HOST, client, getIndexFromSelect, updateBackgroundPreview } from "../../client";
import { safeTags } from "../../encoding";
import tryUrls from "../../utils/tryUrls";
-import { updateBackgroundPreview } from '../../dom/updateBackgroundPreview'
/**
* Handles a background change.
diff --git a/webAO/viewport.ts b/webAO/viewport.ts
index 58186a0..e6b8d00 100644
--- a/webAO/viewport.ts
+++ b/webAO/viewport.ts
@@ -1,7 +1,6 @@
import tryUrls from "./utils/tryUrls";
import fileExists from "./utils/fileExists";
-import Client, { opusCheck } from "./client";
-import { delay } from "./client";
+import Client, { opusCheck, delay } from "./client";
import { UPDATE_INTERVAL } from "./client";
import { setChatbox } from "./client";
import { resizeChatbox } from "./client";