From ab396c71295f76e62739c01bc8e6a29f1896ba8c Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 13 Nov 2023 00:11:21 +0100 Subject: Use URLSearchParams and set default directly --- webAO/client.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'webAO/client.ts') diff --git a/webAO/client.ts b/webAO/client.ts index f7b8ebb..ca3b816 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -19,7 +19,6 @@ import { fetchBackgroundList, fetchEvidenceList, fetchCharacterList, fetchManife const version = process.env.npm_package_version; const { ip: serverIP, mode, theme } = queryParser(); -const THEME: string = theme || "default"; export let CHATBOX: string; export const setCHATBOX = (val: string) => { CHATBOX = val @@ -69,6 +68,11 @@ fpPromise .then((result) => { hdid = result.visitorId; + if (!serverIP) { + alert("No server IP specified!"); + return; + } + client = new Client(serverIP); client.connect() isLowMemory(); @@ -146,7 +150,7 @@ class Client extends EventEmitter { this.musics_time = false; this.callwords = []; this.manifest = []; - this.resources = getResources(AO_HOST, THEME); + this.resources = getResources(AO_HOST, theme); this.selectedEmote = -1; this.selectedEvidence = 0; this.checkUpdater = null; -- cgit From 95197e9ef7bf9577afb9afd764ed217ac2ce2671 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 13 Nov 2023 00:11:31 +0100 Subject: Formatting --- webAO/client.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'webAO/client.ts') diff --git a/webAO/client.ts b/webAO/client.ts index ca3b816..806d575 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -37,7 +37,7 @@ export const UPDATE_INTERVAL = 60; */ export let oldLoading = false; export const setOldLoading = (val: boolean) => { - console.warn("old loading set to "+val) + console.warn("old loading set to " + val) oldLoading = val } @@ -221,7 +221,7 @@ class Client extends EventEmitter { console.error(`The connection was closed: ${e.reason} (${e.code})`); if (extrafeatures.length == 0 && banned === false) { document.getElementById("client_errortext").textContent = - "Could not connect to the server"; + "Could not connect to the server"; } document.getElementById("client_waiting").style.display = "block"; document.getElementById("client_error").style.display = "flex"; @@ -239,15 +239,14 @@ class Client extends EventEmitter { console.debug(`S: ${msg}`); this.handle_server_packet(msg); - + } /** * Decode the packet * @param {MessageEvent} e */ - handle_server_packet(p_data: string) - { + handle_server_packet(p_data: string) { let in_data = p_data; if (!p_data.endsWith("%")) { @@ -284,8 +283,7 @@ class Client extends EventEmitter { } // Take the first arg as the command const command = f_contents[0]; - if(command!=="") - { + if (command !== "") { // The rest is contents of the packet packetHandler.has(command) ? packetHandler.get(command)(f_contents) -- cgit From 83b7b869452816cfb0be7eb25fc7f26d3a8a6b7b Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 13 Nov 2023 00:12:00 +0100 Subject: Remove unused things in client.ts --- webAO/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/client.ts') diff --git a/webAO/client.ts b/webAO/client.ts index 806d575..b5a5fce 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -15,8 +15,8 @@ import { onReplayGo } from './dom/onReplayGo' import { packetHandler } from './packets/packetHandler' import { loadResources } from './client/loadResources' import { AO_HOST } from './client/aoHost' -import { fetchBackgroundList, fetchEvidenceList, fetchCharacterList, fetchManifest } from './client/fetchLists' -const version = process.env.npm_package_version; +import { fetchBackgroundList, fetchEvidenceList, fetchCharacterList } from './client/fetchLists' + const { ip: serverIP, mode, theme } = queryParser(); export let CHATBOX: string; -- cgit From 611b412d4935a905d2bf60c4ec0febc9709ebadd Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 13 Nov 2023 00:14:31 +0100 Subject: Add serverName to queryParams --- webAO/client.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'webAO/client.ts') diff --git a/webAO/client.ts b/webAO/client.ts index b5a5fce..3170ec8 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -17,7 +17,9 @@ import { loadResources } from './client/loadResources' import { AO_HOST } from './client/aoHost' import { fetchBackgroundList, fetchEvidenceList, fetchCharacterList } from './client/fetchLists' -const { ip: serverIP, mode, theme } = queryParser(); +const { ip: serverIP, mode, theme, serverName } = queryParser(); + +document.title = serverName; export let CHATBOX: string; export const setCHATBOX = (val: string) => { -- cgit