aboutsummaryrefslogtreecommitdiff
path: root/webAO
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2019-07-01 22:58:47 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2019-07-01 22:58:47 -0500
commit1ff53d9aed85aa31aafcbb72a00fc5f7eb761374 (patch)
treeefe66c3055abdef75376e0bde3aaeb55cc850bcd /webAO
parent393142f7001269140897a8ca191884e8c29bb699 (diff)
Ugh! It lives!
Diffstat (limited to 'webAO')
-rw-r--r--webAO/client.js19
-rw-r--r--webAO/ui.js9
2 files changed, 18 insertions, 10 deletions
diff --git a/webAO/client.js b/webAO/client.js
index 665dd81..50ea318 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -491,7 +491,7 @@ class Client extends EventEmitter {
resetICParams();
}
- viewport.say(chatmsg);
+ viewport.say(chatmsg); // no await
}
}
@@ -961,7 +961,7 @@ class Viewport {
* Sets a new emote.
* @param {object} chatmsg the new chat message
*/
- say(chatmsg) {
+ async say(chatmsg) {
this.chatmsg = chatmsg;
appendICLog(chatmsg.content, chatmsg.nameplate);
changeBackground(chatmsg.side);
@@ -972,7 +972,9 @@ class Viewport {
clearTimeout(this.updater);
// If preanim existed then determine the length
if (chatmsg.preanim !== "-") {
- chatmsg.preanimdelay = this.getAnimLength(`${AO_HOST}characters/${escape(chatmsg.name.toLowerCase())}/${chatmsg.preanim.toLowerCase()}.gif`, this.initUpdater);
+ const delay = await this.getAnimLength(`${AO_HOST}characters/${escape(chatmsg.name.toLowerCase())}/${chatmsg.preanim.toLowerCase()}.gif`);
+ chatmsg.preanimdelay = delay;
+ this.initUpdater(delay);
} else {
this.initUpdater(0);
}
@@ -1013,12 +1015,17 @@ class Viewport {
}
/**
- * Gets animation length.
+ * Gets animation length. If the animation cannot be found, it will
+ * silently fail and return 0 instead.
* @param {string} filename the animation file name
*/
async getAnimLength(filename) {
- const file = await request(filename).response;
- return gify.getInfo(file).duration;
+ try {
+ const file = await request(filename);
+ return gify.getInfo(file).duration;
+ } catch (err) {
+ return 0;
+ }
}
/**
diff --git a/webAO/ui.js b/webAO/ui.js
index 4aace2d..b44b425 100644
--- a/webAO/ui.js
+++ b/webAO/ui.js
@@ -1,8 +1,9 @@
/* eslint indent: ["error", 2] */
-import GoldenLayout from "./golden/js/goldenlayout.js";
+// import GoldenLayout from "./golden/js/goldenlayout.js";
+import GoldenLayout from "golden-layout";
-var config = {
+const config = {
settings: {
showPopoutIcon: false,
showCloseIcon: false
@@ -63,9 +64,9 @@ var config = {
}]
};
-var golden = new GoldenLayout(config);
+const golden = new GoldenLayout(config);
golden.registerComponent("template", function (container, componentState) {
- let template = document.querySelector(`#${componentState.id}`);
+ const template = document.querySelector(`#${componentState.id}`);
container.getElement().html(template.content);
// TODO: support multiple locales
// container.setTitle(document.querySelector(`#${componentState.id} meta[name='frame-title']`).getAttribute("content"));