diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-05-04 20:43:29 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-05-04 20:43:29 -0700 |
commit | e74386faa4b5a987c41140df5b28de8dce06f401 (patch) | |
tree | 707b1dbce964f3dae77b91dad3e827c1b66d0773 /ext/fg/js/frame.js | |
parent | bc11e7cbe3a3a3c57967f78933302f7a06dfde24 (diff) |
WIP
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r-- | ext/fg/js/frame.js | 16 |
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); |