aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frame.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-05-04 20:43:29 -0700
committerAlex Yatskov <alex@foosoft.net>2016-05-04 20:43:29 -0700
commite74386faa4b5a987c41140df5b28de8dce06f401 (patch)
tree707b1dbce964f3dae77b91dad3e827c1b66d0773 /ext/fg/js/frame.js
parentbc11e7cbe3a3a3c57967f78933302f7a06dfde24 (diff)
WIP
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r--ext/fg/js/frame.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index c8528fe7..4d126b94 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -36,9 +36,21 @@ function registerActionLinks() {
}
}
-function domContentLoaded() {
+function onDomContentLoaded() {
registerKanjiLinks();
registerActionLinks();
}
-document.addEventListener('DOMContentLoaded', domContentLoaded, false);
+function onMessage(e) {
+ const {action, data} = e.data, handlers = {
+ 'disableAction': ({mode, index}) => {
+ const matches = document.querySelectorAll(`.action-link[data-index="${index}"][data-mode="${mode}"]`);
+ matches[0].classList.add('disabled');
+ }
+ };
+
+ handlers[action](data);
+}
+
+document.addEventListener('DOMContentLoaded', onDomContentLoaded, false);
+window.addEventListener('message', onMessage);