aboutsummaryrefslogtreecommitdiff
path: root/webAO/client.js
diff options
context:
space:
mode:
authorsD <stoned@derpymail.org>2019-12-18 22:08:46 +0100
committersD <stoned@derpymail.org>2019-12-18 22:08:46 +0100
commitf771ffbec8977013c82d75213e23c326858938b5 (patch)
treee9af6aa7eadb36542d42715eedb8a3b1d409cd26 /webAO/client.js
parent8cdd83e1a78f6ae52cc3ea8574c1865c2c0c2723 (diff)
move resource loading and spectator code
Diffstat (limited to 'webAO/client.js')
-rw-r--r--webAO/client.js41
1 files changed, 8 insertions, 33 deletions
diff --git a/webAO/client.js b/webAO/client.js
index ec12c13..10fbb7a 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -309,25 +309,6 @@ class Client extends EventEmitter {
background_arr.forEach(background => {
background_select.add(new Option(background));
});
-
- this.resources.map(async (resource) => {
- // Check if image exists and replace `src` with an absolute URL
- const spriteSrc = `${AO_HOST}themes/default/${resource.src}.gif`;
- if (await fileExists(spriteSrc)) {
- Object.assign(resource, {
- src: spriteSrc,
- duration: await viewport.getAnimLength(spriteSrc)
- });
- }
-
- // Check if sfx exists and replace `sfx` with an absolute URL
- if (resource.sfx) {
- const sfxSrc = AO_HOST + resource.sfx.toLowerCase();
- if (await fileExists(sfxSrc)) {
- resource.sfx = sfxSrc;
- }
- }
- });
}
/**
@@ -389,13 +370,9 @@ class Client extends EventEmitter {
* Triggered when a connection is established to the server.
*/
onOpen(_e) {
- // XXX: Why does watching mean just SITTING there and doing nothing?
- if (mode === "watch") {
- document.getElementById("client_loading").style.display = "none";
- document.getElementById("client_charselect").style.display = "none";
- } else {
- client.joinServer();
- }
+ client.initialObservBBCode();
+ client.loadResources();
+ client.joinServer();
}
/**
@@ -730,7 +707,11 @@ class Client extends EventEmitter {
*/
handleDONE(_args) {
document.getElementById("client_loading").style.display = "none";
- document.getElementById("client_charselect").style.display = "block";
+ if (mode === "watch") { // Spectators don't need to pick a character
+ document.getElementById("client_charselect").style.display = "none";
+ } else {
+ document.getElementById("client_charselect").style.display = "block";
+ }
}
/**
@@ -2209,12 +2190,6 @@ function decodeBBCode(estring) {
let client = new Client(serverIP);
let viewport = new Viewport();
-export function onLoad(){
- client.initialObservBBCode();
- client.loadResources();
-}
-window.onLoad = onLoad;
-
// Create dialog and link to button
$(function () {
$("#callmod_dialog").dialog({