diff options
| author | stonedDiscord <stoned@derpymail.org> | 2019-12-19 16:06:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-19 16:06:08 +0100 |
| commit | b07a069095ff06ecb3fada03e6228b4c13bb5bba (patch) | |
| tree | 98ea41455fd976427360f32a7ee5557dfaa1cae4 /webAO | |
| parent | b317fba28af94d433ebd64a2c30a905e8f0e9d10 (diff) | |
| parent | f771ffbec8977013c82d75213e23c326858938b5 (diff) | |
Merge pull request #30 from AttorneyOnline/cookies_reeeee
move resource loading and spectator code
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.js | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/webAO/client.js b/webAO/client.js index 9cf59fb..24f2617 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"; + } } /** @@ -2214,12 +2195,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({ |
