aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frame.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-05-05 20:06:13 -0700
committerAlex Yatskov <alex@foosoft.net>2016-05-05 20:06:13 -0700
commit9cb099e5f6aad33c70d986bd6a48668e54ee211c (patch)
treed46de3d97388764f15f8f319d8455e60d3c2d9f4 /ext/fg/js/frame.js
parentdd4b2f73656d652bc56be784a27e7378ab969ac6 (diff)
Optimization
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r--ext/fg/js/frame.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index 80fa099a..5a910dfc 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -43,9 +43,21 @@ function onDomContentLoaded() {
function onMessage(e) {
const {action, params} = e.data, handlers = {
- disableAction: ({mode, index}) => {
- const matches = document.querySelectorAll(`.action-link[data-index="${index}"][data-mode="${mode}"]`);
- matches[0].classList.add('disabled');
+ setActionStates: (states) => {
+ for (let i = 0, count = states.length; i < count; ++i) {
+ const state = states[i];
+ for (const mode in state) {
+ const matches = document.querySelectorAll(`.action-link[data-index="${i}"][data-mode="${mode}"]`);
+ if (matches.length > 0) {
+ const classes = matches[0].classList;
+ if (state[mode]) {
+ classes.remove('disabled');
+ } else {
+ classes.add('disabled');
+ }
+ }
+ }
+ }
}
};