Cleanup
This commit is contained in:
parent
9cb099e5f6
commit
22cbafb7b7
@ -112,7 +112,9 @@ class Client {
|
|||||||
(content) => {
|
(content) => {
|
||||||
this.definitions = definitions;
|
this.definitions = definitions;
|
||||||
this.showPopup(range, content);
|
this.showPopup(range, content);
|
||||||
canAddNotes(definitions, (states) => this.popup.sendMessage('setActionStates', states));
|
canAddNotes(definitions, (states) => {
|
||||||
|
states.forEach((state, index) => this.popup.sendMessage('setActionState', {index: index, state: state}));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -120,7 +122,10 @@ class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actionAddNote(mode, index, callback) {
|
actionAddNote(mode, index, callback) {
|
||||||
|
const state = {};
|
||||||
|
state[mode] = false;
|
||||||
|
|
||||||
|
this.popup.sendMessage('setActionState', {index: index, state: state});
|
||||||
}
|
}
|
||||||
|
|
||||||
actionDisplayKanji(kanji) {
|
actionDisplayKanji(kanji) {
|
||||||
|
@ -43,19 +43,18 @@ function onDomContentLoaded() {
|
|||||||
|
|
||||||
function onMessage(e) {
|
function onMessage(e) {
|
||||||
const {action, params} = e.data, handlers = {
|
const {action, params} = e.data, handlers = {
|
||||||
setActionStates: (states) => {
|
setActionState: ({index, state}) => {
|
||||||
for (let i = 0, count = states.length; i < count; ++i) {
|
for (const mode in state) {
|
||||||
const state = states[i];
|
const matches = document.querySelectorAll(`.action-link[data-index="${index}"][data-mode="${mode}"]`);
|
||||||
for (const mode in state) {
|
if (matches.length === 0) {
|
||||||
const matches = document.querySelectorAll(`.action-link[data-index="${i}"][data-mode="${mode}"]`);
|
return;
|
||||||
if (matches.length > 0) {
|
}
|
||||||
const classes = matches[0].classList;
|
|
||||||
if (state[mode]) {
|
const classes = matches[0].classList;
|
||||||
classes.remove('disabled');
|
if (state[mode]) {
|
||||||
} else {
|
classes.remove('disabled');
|
||||||
classes.add('disabled');
|
} else {
|
||||||
}
|
classes.add('disabled');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user