aboutsummaryrefslogtreecommitdiff
path: root/webAO/dom
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-09-07 23:41:55 +0200
committerGitHub <noreply@github.com>2022-09-07 23:41:55 +0200
commit84cdbfff31c31eff9e7ba2a1d6c73f6d08ac5e43 (patch)
treefe9a18c8c0cdbf1ab8ef037af6f98a53b0ea018f /webAO/dom
parent5362069a05b4bfbef03f37605af979aa3cf0e066 (diff)
parent3f8d0974b327e663328bc36cd97f1ba1855a2269 (diff)
Merge pull request #169 from caleb-mabry/evenMoreWindowFunctions
Added more functions
Diffstat (limited to 'webAO/dom')
-rw-r--r--webAO/dom/cancelEvidence.ts3
-rw-r--r--webAO/dom/changeBackgroundOOC.ts28
-rw-r--r--webAO/dom/changeCallwords.ts13
-rw-r--r--webAO/dom/editEvidence.ts22
-rw-r--r--webAO/dom/getIndexFromSelect.ts16
-rw-r--r--webAO/dom/iniEdit.ts14
-rw-r--r--webAO/dom/modCallTest.ts8
-rw-r--r--webAO/dom/pickEmotion.ts24
-rw-r--r--webAO/dom/pickEvidence.ts5
-rw-r--r--webAO/dom/switchPanTilt.ts16
-rw-r--r--webAO/dom/toggleShout.ts5
-rw-r--r--webAO/dom/updateEvidenceIcon.ts28
12 files changed, 177 insertions, 5 deletions
diff --git a/webAO/dom/cancelEvidence.ts b/webAO/dom/cancelEvidence.ts
index 6565288..a906613 100644
--- a/webAO/dom/cancelEvidence.ts
+++ b/webAO/dom/cancelEvidence.ts
@@ -1,4 +1,5 @@
-import { client, updateEvidenceIcon } from "../client";
+import { client, } from "../client";
+import { updateEvidenceIcon } from './updateEvidenceIcon'
import { AO_HOST } from "../client/aoHost";
diff --git a/webAO/dom/changeBackgroundOOC.ts b/webAO/dom/changeBackgroundOOC.ts
new file mode 100644
index 0000000..f840729
--- /dev/null
+++ b/webAO/dom/changeBackgroundOOC.ts
@@ -0,0 +1,28 @@
+
+import queryParser from '../utils/queryParser'
+import { client } from '../client'
+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/changeCallwords.ts b/webAO/dom/changeCallwords.ts
new file mode 100644
index 0000000..28be674
--- /dev/null
+++ b/webAO/dom/changeCallwords.ts
@@ -0,0 +1,13 @@
+import { client } from '../client'
+import setCookie from '../utils/setCookie';
+
+/**
+ * Triggered by a changed callword list
+ */
+export function changeCallwords() {
+ client.callwords = (<HTMLInputElement>(
+ document.getElementById("client_callwords")
+ )).value.split("\n");
+ setCookie("callwords", client.callwords.join("\n"));
+}
+window.changeCallwords = changeCallwords; \ No newline at end of file
diff --git a/webAO/dom/editEvidence.ts b/webAO/dom/editEvidence.ts
new file mode 100644
index 0000000..2cc4565
--- /dev/null
+++ b/webAO/dom/editEvidence.ts
@@ -0,0 +1,22 @@
+import { client } from '../client'
+import { cancelEvidence } from './cancelEvidence';
+
+/**
+ * Edit selected evidence.
+ */
+export function editEvidence() {
+ const evidence_select = <HTMLSelectElement>(
+ document.getElementById("evi_select")
+ );
+ const id = client.selectedEvidence - 1;
+ client.sendEE(
+ id,
+ (<HTMLInputElement>document.getElementById("evi_name")).value,
+ (<HTMLInputElement>document.getElementById("evi_desc")).value,
+ evidence_select.selectedIndex === 0
+ ? (<HTMLInputElement>document.getElementById("evi_filename")).value
+ : evidence_select.options[evidence_select.selectedIndex].text
+ );
+ cancelEvidence();
+}
+window.editEvidence = editEvidence; \ No newline at end of file
diff --git a/webAO/dom/getIndexFromSelect.ts b/webAO/dom/getIndexFromSelect.ts
new file mode 100644
index 0000000..2f21653
--- /dev/null
+++ b/webAO/dom/getIndexFromSelect.ts
@@ -0,0 +1,16 @@
+/**
+ * Find index of anything in select box.
+ * @param {string} select_box the select element name
+ * @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 = <HTMLSelectElement>document.getElementById(select_box);
+ for (let i = 1; i < select_element.length; ++i) {
+ if (select_element.options[i].value === value) {
+ return i;
+ }
+ }
+ return 0;
+}
+window.getIndexFromSelect = getIndexFromSelect; \ No newline at end of file
diff --git a/webAO/dom/iniEdit.ts b/webAO/dom/iniEdit.ts
new file mode 100644
index 0000000..359a226
--- /dev/null
+++ b/webAO/dom/iniEdit.ts
@@ -0,0 +1,14 @@
+import { client } from "../client";
+import { packetHandler } from "../packets/packetHandler";
+
+/**
+ * Triggered by the ini button.
+ */
+export async function iniedit() {
+ const ininame = (<HTMLInputElement>document.getElementById("client_ininame"))
+ .value;
+ const inicharID = client.charID;
+ await client.handleCharacterInfo(ininame.split("&"), inicharID);
+ packetHandler.get("PV")!(`PV#0#CID#${inicharID}`.split("#"));
+}
+window.iniedit = iniedit;
diff --git a/webAO/dom/modCallTest.ts b/webAO/dom/modCallTest.ts
new file mode 100644
index 0000000..7058caf
--- /dev/null
+++ b/webAO/dom/modCallTest.ts
@@ -0,0 +1,8 @@
+import { packetHandler } from "../packets/packetHandler";
+/**
+ * Triggered by the modcall sfx dropdown
+ */
+export function modcall_test() {
+ packetHandler.get("ZZ")!("test#test".split("#"));
+}
+window.modcall_test = modcall_test; \ No newline at end of file
diff --git a/webAO/dom/pickEmotion.ts b/webAO/dom/pickEmotion.ts
new file mode 100644
index 0000000..b72583f
--- /dev/null
+++ b/webAO/dom/pickEmotion.ts
@@ -0,0 +1,24 @@
+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
+ }
+ client.selectedEmote = emo;
+ document.getElementById(`emo_${emo}`)!.className = "emote_button dark";
+
+ (<HTMLInputElement>document.getElementById("sendsfx")).checked =
+ client.emote.sfx.length > 1;
+
+ (<HTMLInputElement>document.getElementById("sendpreanim")).checked =
+ client.emote.zoom == 1;
+}
+window.pickEmotion = pickEmotion; \ No newline at end of file
diff --git a/webAO/dom/pickEvidence.ts b/webAO/dom/pickEvidence.ts
index 32e52ba..411acc1 100644
--- a/webAO/dom/pickEvidence.ts
+++ b/webAO/dom/pickEvidence.ts
@@ -1,4 +1,7 @@
-import { cancelEvidence, client, getIndexFromSelect, updateEvidenceIcon } from '../client'
+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.
diff --git a/webAO/dom/switchPanTilt.ts b/webAO/dom/switchPanTilt.ts
new file mode 100644
index 0000000..7ceea06
--- /dev/null
+++ b/webAO/dom/switchPanTilt.ts
@@ -0,0 +1,16 @@
+/**
+ * Triggered by the pantilt checkbox
+ */
+export async function switchPanTilt() {
+ const fullview = document.getElementById("client_fullview")!;
+ const checkbox = <HTMLInputElement>document.getElementById("client_pantilt");
+
+ if (checkbox.checked) {
+ fullview.style.transition = "0.5s ease-in-out";
+ } else {
+ fullview.style.transition = "none";
+ }
+
+ return;
+}
+window.switchPanTilt = switchPanTilt; \ No newline at end of file
diff --git a/webAO/dom/toggleShout.ts b/webAO/dom/toggleShout.ts
index 8094691..cb12f49 100644
--- a/webAO/dom/toggleShout.ts
+++ b/webAO/dom/toggleShout.ts
@@ -1,6 +1,5 @@
import { selectedShout, setSelectedShout } from "../client";
-
/**
* Highlights and selects a shout for in-character chat.
* If the same shout button is selected, then the shout is canceled.
@@ -9,14 +8,14 @@ import { selectedShout, setSelectedShout } from "../client";
export function toggleShout(shout: number) {
if (shout === selectedShout) {
document.getElementById(`button_${shout}`)!.className = "client_button";
- selectedShout = 0;
+ setSelectedShout(0);
} else {
document.getElementById(`button_${shout}`)!.className = "client_button dark";
if (selectedShout) {
document.getElementById(`button_${selectedShout}`)!.className =
"client_button";
}
- selectedShout = shout;
+ setSelectedShout(shout);
}
}
window.toggleShout = toggleShout;
diff --git a/webAO/dom/updateEvidenceIcon.ts b/webAO/dom/updateEvidenceIcon.ts
new file mode 100644
index 0000000..bff0475
--- /dev/null
+++ b/webAO/dom/updateEvidenceIcon.ts
@@ -0,0 +1,28 @@
+import { AO_HOST } from "../client/aoHost";
+/**
+ * Update evidence icon.
+ */
+export function updateEvidenceIcon() {
+ const evidence_select = <HTMLSelectElement>(
+ document.getElementById("evi_select")
+ );
+ const evidence_filename = <HTMLInputElement>(
+ document.getElementById("evi_filename")
+ );
+ const evidence_iconbox = <HTMLImageElement>(
+ 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()
+ )}`;
+ }
+}
+window.updateEvidenceIcon = updateEvidenceIcon;