More cleanup
This commit is contained in:
parent
18fc8d9865
commit
8416c9d633
@ -158,9 +158,7 @@ class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
api_addNote({index, mode}) {
|
api_addNote({index, mode}) {
|
||||||
const state = {};
|
const state = {[mode]: false};
|
||||||
state[mode] = false;
|
|
||||||
|
|
||||||
bgAddDefinition(this.definitions[index], mode).then((success) => {
|
bgAddDefinition(this.definitions[index], mode).then((success) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
this.popup.sendMessage('setActionState', {index, state, sequence: this.sequence});
|
this.popup.sendMessage('setActionState', {index, state, sequence: this.sequence});
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
function registerKanjiLinks() {
|
function registerKanjiLinks() {
|
||||||
for (let link of [].slice.call(document.getElementsByClassName('kanji-link'))) {
|
for (const link of Array.from(document.getElementsByClassName('kanji-link'))) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.parent.postMessage({action: 'displayKanji', params: e.target.innerHTML}, '*');
|
window.parent.postMessage({action: 'displayKanji', params: e.target.innerHTML}, '*');
|
||||||
@ -27,7 +27,7 @@ function registerKanjiLinks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function registerAddNoteLinks() {
|
function registerAddNoteLinks() {
|
||||||
for (let link of [].slice.call(document.getElementsByClassName('action-add-note'))) {
|
for (const link of Array.from(document.getElementsByClassName('action-add-note'))) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const ds = e.currentTarget.dataset;
|
const ds = e.currentTarget.dataset;
|
||||||
@ -37,7 +37,7 @@ function registerAddNoteLinks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function registerAudioLinks() {
|
function registerAudioLinks() {
|
||||||
for (let link of [].slice.call(document.getElementsByClassName('action-play-audio'))) {
|
for (const link of Array.from(document.getElementsByClassName('action-play-audio'))) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const ds = e.currentTarget.dataset;
|
const ds = e.currentTarget.dataset;
|
||||||
@ -60,7 +60,7 @@ function onMessage(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function api_setActionState({index, state, sequence}) {
|
function api_setActionState({index, state, sequence}) {
|
||||||
for (let mode in state) {
|
for (const mode in state) {
|
||||||
const matches = document.querySelectorAll(`.action-bar[data-sequence="${sequence}"] .action-add-note[data-index="${index}"][data-mode="${mode}"]`);
|
const matches = document.querySelectorAll(`.action-bar[data-sequence="${sequence}"] .action-add-note[data-index="${index}"][data-mode="${mode}"]`);
|
||||||
if (matches.length === 0) {
|
if (matches.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -71,6 +71,6 @@ class TextSourceElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
equals(other) {
|
equals(other) {
|
||||||
return other.element && other.textRaw() == this.textRaw();
|
return other.element && other.textRaw() === this.textRaw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class TextSourceRange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static seekForward(node, length) {
|
static seekForward(node, length) {
|
||||||
const state = {node, offset: 0, length};
|
const state = {node, length, offset: 0};
|
||||||
if (!TextSourceRange.seekForwardHelper(node, state)) {
|
if (!TextSourceRange.seekForwardHelper(node, state)) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ class TextSourceRange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static seekBackward(node, length) {
|
static seekBackward(node, length) {
|
||||||
const state = {node, offset: node.length, length};
|
const state = {node, length, offset: node.length};
|
||||||
if (!TextSourceRange.seekBackwardHelper(node, state)) {
|
if (!TextSourceRange.seekBackwardHelper(node, state)) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user