aboutsummaryrefslogtreecommitdiff
path: root/webAO/client
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2023-09-20 13:10:36 +0200
committerstonedDiscord <Tukz@gmx.de>2023-09-20 13:10:36 +0200
commitdda92bd41f4bee11e2cc5de265ce4fbf5221f1ff (patch)
treebcb0f8121955ff815758b30ec4e24a1e6bde4fba /webAO/client
parent59028dd4046ad0715d80be8d1ed0031f20f05b7a (diff)
autoformat with eslint
Diffstat (limited to 'webAO/client')
-rw-r--r--webAO/client/__tests__/setEmote.test.js132
-rw-r--r--webAO/client/aoHost.ts2
-rw-r--r--webAO/client/saveChatLogHandle.ts6
-rw-r--r--webAO/client/sender/sendIC.ts2
-rw-r--r--webAO/client/sender/sendServer.ts2
-rw-r--r--webAO/client/setEmote.ts76
6 files changed, 110 insertions, 110 deletions
diff --git a/webAO/client/__tests__/setEmote.test.js b/webAO/client/__tests__/setEmote.test.js
index 829c94d..a0091c0 100644
--- a/webAO/client/__tests__/setEmote.test.js
+++ b/webAO/client/__tests__/setEmote.test.js
@@ -9,104 +9,104 @@ jest.mock('../../viewport/utils/createSfxAudio');
jest.mock('../../viewport/utils/createShoutAudio');
jest.mock('../../viewport/utils/createTestimonyAudio');
describe('setEmote', () => {
- const AO_HOST = '';
+ const AO_HOST = '';
- const client = new Client('127.0.0.1');
- const firstExtension = '.gif';
+ const client = new Client('127.0.0.1');
+ const firstExtension = '.gif';
- test('Should have a client_def_char_img with a valid source', async () => {
- fileExists.mockReturnValue(true);
- document.body.innerHTML = `
+ test('Should have a client_def_char_img with a valid source', async () => {
+ fileExists.mockReturnValue(true);
+ document.body.innerHTML = `
<img id="client_def_char_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'def');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_def_char_img').src).toEqual(expected);
- });
- test('Should have a client_pro_char_img to have a valid src', async () => {
- document.body.innerHTML = `
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'def');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ expect(document.getElementById('client_def_char_img').src).toEqual(expected);
+ });
+ test('Should have a client_pro_char_img to have a valid src', async () => {
+ document.body.innerHTML = `
<img id="client_pro_char_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'pro');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_pro_char_img').src).toEqual(expected);
- });
- test('Should have a client_wit_char_img', async () => {
- document.body.innerHTML = `
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'pro');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ expect(document.getElementById('client_pro_char_img').src).toEqual(expected);
+ });
+ test('Should have a client_wit_char_img', async () => {
+ document.body.innerHTML = `
<img id="client_wit_char_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'wit');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'wit');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_wit_char_img').src).toEqual(expected);
- });
- test('Should have a client_def_pair_img', async () => {
- document.body.innerHTML = `
+ expect(document.getElementById('client_wit_char_img').src).toEqual(expected);
+ });
+ test('Should have a client_def_pair_img', async () => {
+ document.body.innerHTML = `
<img id="client_def_pair_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'def');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'def');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_def_pair_img').src).toEqual(expected);
- });
- test('Should have a client_pro_pair_img', async () => {
- document.body.innerHTML = `
+ expect(document.getElementById('client_def_pair_img').src).toEqual(expected);
+ });
+ test('Should have a client_pro_pair_img', async () => {
+ document.body.innerHTML = `
<img id="client_pro_pair_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'pro');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'pro');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_pro_pair_img').src).toEqual(expected);
- });
- test('Should have a client_wit_pair_img', async () => {
- document.body.innerHTML = `
+ expect(document.getElementById('client_pro_pair_img').src).toEqual(expected);
+ });
+ test('Should have a client_wit_pair_img', async () => {
+ document.body.innerHTML = `
<img id="client_wit_pair_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'wit');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'wit');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_wit_pair_img').src).toEqual(expected);
- });
- test('Should have a client_char_img', async () => {
- document.body.innerHTML = `
+ expect(document.getElementById('client_wit_pair_img').src).toEqual(expected);
+ });
+ test('Should have a client_char_img', async () => {
+ document.body.innerHTML = `
<img id="client_char_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'notvalid');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 0, 'notvalid');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_char_img').src).toEqual(expected);
- });
- test('Should have a client_pair_img', async () => {
- document.body.innerHTML = `
+ expect(document.getElementById('client_char_img').src).toEqual(expected);
+ });
+ test('Should have a client_pair_img', async () => {
+ document.body.innerHTML = `
<img id="client_pair_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'notvalid');
- const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
+ await setEmote(AO_HOST, client, 'salanto', 'coding', '(a)', 1, 'notvalid');
+ const expected = `http://localhost/characters/salanto/(a)coding${firstExtension}`;
- expect(document.getElementById('client_pair_img').src).toEqual(expected);
- });
- test('Should handle .png urls differently', async () => {
- fileExists.mockReturnValueOnce(false);
- document.body.innerHTML = `
+ expect(document.getElementById('client_pair_img').src).toEqual(expected);
+ });
+ test('Should handle .png urls differently', async () => {
+ fileExists.mockReturnValueOnce(false);
+ document.body.innerHTML = `
<img id="client_pair_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid');
- const expected = 'http://localhost/characters/salanto/coding.png';
+ await setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid');
+ const expected = 'http://localhost/characters/salanto/coding.png';
- expect(document.getElementById('client_pair_img').src).toEqual(expected);
- });
- test('Should replace character if new character responds', async () => {
- fileExists.mockReturnValue(false);
- document.body.innerHTML = `
+ expect(document.getElementById('client_pair_img').src).toEqual(expected);
+ });
+ test('Should replace character if new character responds', async () => {
+ fileExists.mockReturnValue(false);
+ document.body.innerHTML = `
<img id="client_pair_img" />
`;
- await setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid');
- const expected = transparentPng;
- expect(document.getElementById('client_pair_img').src).toEqual(expected);
- });
+ await setEmote(AO_HOST, client, 'salanto', 'coding', 'prefixNotValid', 1, 'notvalid');
+ const expected = transparentPng;
+ expect(document.getElementById('client_pair_img').src).toEqual(expected);
+ });
});
diff --git a/webAO/client/aoHost.ts b/webAO/client/aoHost.ts
index 9b0a768..fa13e79 100644
--- a/webAO/client/aoHost.ts
+++ b/webAO/client/aoHost.ts
@@ -1,5 +1,5 @@
import queryParser from '../utils/queryParser'
-let { asset } = queryParser();
+const { asset } = queryParser();
const DEFAULT_HOST = 'http://attorneyoffline.de/base/';
export let AO_HOST = asset || DEFAULT_HOST
export const setAOhost = (val: string) => {
diff --git a/webAO/client/saveChatLogHandle.ts b/webAO/client/saveChatLogHandle.ts
index bcc1075..497dd50 100644
--- a/webAO/client/saveChatLogHandle.ts
+++ b/webAO/client/saveChatLogHandle.ts
@@ -14,9 +14,9 @@ export const saveChatlogHandle = async () => {
messages.push(message);
}
const d = new Date();
- let ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
- let mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
- let da = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(d);
+ 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);
diff --git a/webAO/client/sender/sendIC.ts b/webAO/client/sender/sendIC.ts
index 9064115..ca8984f 100644
--- a/webAO/client/sender/sendIC.ts
+++ b/webAO/client/sender/sendIC.ts
@@ -2,7 +2,7 @@ import { extrafeatures } from "../../client";
import { escapeChat } from "../../encoding";
import {client} from '../../client'
import queryParser from "../../utils/queryParser";
-let {mode} = queryParser()
+const {mode} = queryParser()
/**
* Sends an in-character chat message.
diff --git a/webAO/client/sender/sendServer.ts b/webAO/client/sender/sendServer.ts
index 7678381..ae95480 100644
--- a/webAO/client/sender/sendServer.ts
+++ b/webAO/client/sender/sendServer.ts
@@ -1,6 +1,6 @@
import { client } from "../../client";
import queryParser from "../../utils/queryParser";
-let { mode } = queryParser()
+const { mode } = queryParser()
/**
* Hook for sending messages to the server
* @param {string} message the message to send
diff --git a/webAO/client/setEmote.ts b/webAO/client/setEmote.ts
index f4fbdbb..2b5a614 100644
--- a/webAO/client/setEmote.ts
+++ b/webAO/client/setEmote.ts
@@ -8,48 +8,48 @@ 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;
+ 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;
+ }
}
- 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;