summaryrefslogtreecommitdiff
path: root/ext/fg/js/frame.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r--ext/fg/js/frame.js25
1 files changed, 12 insertions, 13 deletions
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index 5a910dfc..38848bfc 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -43,19 +43,18 @@ function onDomContentLoaded() {
function onMessage(e) {
const {action, params} = e.data, handlers = {
- 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');
- }
- }
+ setActionState: ({index, state}) => {
+ for (const mode in state) {
+ const matches = document.querySelectorAll(`.action-link[data-index="${index}"][data-mode="${mode}"]`);
+ if (matches.length === 0) {
+ return;
+ }
+
+ const classes = matches[0].classList;
+ if (state[mode]) {
+ classes.remove('disabled');
+ } else {
+ classes.add('disabled');
}
}
}