aboutsummaryrefslogtreecommitdiff
path: root/webAO/client.js
diff options
context:
space:
mode:
authorcaleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu>2022-03-23 17:36:01 -0400
committercaleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu>2022-03-23 17:36:01 -0400
commite28fcc59a76772eae64ed480919cddb60a3b5fce (patch)
treedb7ed6cf18f928fae734f3cc9430bb2b220ba2a0 /webAO/client.js
parenta7facd6e825e3a2d60752df0b8526482b19a12de (diff)
parentffa23343e0a0badd9e50a005359fdb79efead995 (diff)
Merge branch 'master' of https://github.com/AttorneyOnline/webAO into multipleBackgroundTypes
Diffstat (limited to 'webAO/client.js')
-rw-r--r--webAO/client.js43
1 files changed, 21 insertions, 22 deletions
diff --git a/webAO/client.js b/webAO/client.js
index dd7989b..06defa2 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -9,8 +9,8 @@ import { EventEmitter } from 'events';
import tryUrls from './utils/tryUrls'
import {
escapeChat, encodeChat, prepChat, safeTags,
-} from './encoding.js';
-
+} from './encoding';
+import mlConfig from './utils/aoml';
// Load some defaults for the background and evidence dropdowns
import vanilla_character_arr from './constants/characters.js';
import vanilla_music_arr from './constants/music.js';
@@ -43,6 +43,8 @@ const DEFAULT_HOST = 'http://attorneyoffline.de/base/';
let AO_HOST = asset || DEFAULT_HOST;
const THEME = theme || 'default';
+const attorneyMarkdown = mlConfig(AO_HOST)
+
const UPDATE_INTERVAL = 60;
/**
@@ -1671,15 +1673,8 @@ class Viewport {
];
// Allocate multiple blip audio channels to make blips less jittery
-
- this.blipChannels = new Array(
- new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`),
- new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`),
- new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`),
- new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`),
- new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`),
- new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`),
- );
+ const blipSelectors = document.getElementsByClassName('blipSound')
+ this.blipChannels = [...blipSelectors];
this.blipChannels.forEach((channel) => channel.volume = 0.5);
this.blipChannels.forEach((channel) => channel.onerror = opusCheck(channel));
this.currentBlipChannel = 0;
@@ -1695,12 +1690,8 @@ class Viewport {
this.testimonyAudio = document.getElementById('client_testimonyaudio');
this.testimonyAudio.src = `${AO_HOST}sounds/general/sfx-guilty.opus`;
- this.music = new Array(
- new Audio(`${AO_HOST}sounds/music/trial (aa).opus`),
- new Audio(`${AO_HOST}sounds/music/trial (aa).opus`),
- new Audio(`${AO_HOST}sounds/music/trial (aa).opus`),
- new Audio(`${AO_HOST}sounds/music/trial (aa).opus`),
- );
+ const audioChannels = document.getElementsByClassName('audioChannel')
+ this.music = [...audioChannels];
this.music.forEach((channel) => channel.volume = 0.5);
this.music.forEach((channel) => channel.onerror = opusCheck(channel));
@@ -1939,6 +1930,7 @@ class Viewport {
* @param {object} chatmsg the new chat message
*/
async say(chatmsg) {
+
this.chatmsg = chatmsg;
this.textnow = '';
this.sfxplayed = 0;
@@ -2090,7 +2082,7 @@ class Viewport {
if (soundChecks.some((check) => this.chatmsg.sound === check)) {
this.chatmsg.sound = this.chatmsg.effects[2];
}
-
+ this.chatmsg.parsed = await attorneyMarkdown.applyMarkdown(chatmsg.content, this.colors[this.chatmsg.color])
this.tick();
}
@@ -2242,8 +2234,10 @@ class Viewport {
this.currentBlipChannel %= this.blipChannels.length;
}
this.textnow = this.chatmsg.content.substring(0, this.textnow.length + 1);
-
- chatBoxInner.innerText = this.textnow;
+ const characterElement = this.chatmsg.parsed[this.textnow.length - 1]
+ if (characterElement) {
+ chatBoxInner.appendChild(this.chatmsg.parsed[this.textnow.length - 1]);
+ }
// scroll to bottom
chatBox.scrollTop = chatBox.scrollHeight;
@@ -2326,6 +2320,7 @@ export function onEnter(event) {
if (emote_mod === 0) { emote_mod = 1; }
} else if (emote_mod === 1) { emote_mod = 0; }
+
client.sendIC(
'chat',
myemo.preanim,
@@ -2620,6 +2615,10 @@ window.imgError = imgError;
* @param {HTMLImageElement} image the element containing the missing sound
*/
export function opusCheck(channel) {
+ const audio = channel.src
+ if (audio === '') {
+ return
+ }
console.info(`failed to load sound ${channel.src}`);
let oldsrc = '';
oldsrc = channel.src;
@@ -2959,7 +2958,7 @@ window.updateActionCommands = updateActionCommands;
*/
export function changeBackgroundOOC() {
const selectedBG = document.getElementById('bg_select');
- const changeBGCommand = document.getElementById('bg_command').value;
+ const changeBGCommand = "bg $1";
const bgFilename = document.getElementById('bg_filename');
let filename = '';
@@ -2989,7 +2988,7 @@ window.changeRoleOOC = changeRoleOOC;
* Random character via OOC.
*/
export function randomCharacterOOC() {
- client.sendOOC(`/${document.getElementById('randomchar_command').value}`);
+ client.sendOOC(`/randomchar`);
}
window.randomCharacterOOC = randomCharacterOOC;