summaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-20 19:32:50 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-20 19:32:50 -0700
commit8416c9d633ed15f679c9871b9940731fb9a7b386 (patch)
tree1c951a141d1135266e8867d2b5ac1f5d442bf7a2 /ext/fg
parent18fc8d9865406a74dbea47f49ac959a543035ec7 (diff)
More cleanup
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/client.js4
-rw-r--r--ext/fg/js/frame.js8
-rw-r--r--ext/fg/js/popup.js6
-rw-r--r--ext/fg/js/source-element.js2
-rw-r--r--ext/fg/js/source-range.js4
5 files changed, 11 insertions, 13 deletions
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index 1bd68aea..628d5b30 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -158,9 +158,7 @@ class Client {
}
api_addNote({index, mode}) {
- const state = {};
- state[mode] = false;
-
+ const state = {[mode]: false};
bgAddDefinition(this.definitions[index], mode).then((success) => {
if (success) {
this.popup.sendMessage('setActionState', {index, state, sequence: this.sequence});
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index 165a9795..8f3d3877 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -18,7 +18,7 @@
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) => {
e.preventDefault();
window.parent.postMessage({action: 'displayKanji', params: e.target.innerHTML}, '*');
@@ -27,7 +27,7 @@ function registerKanjiLinks() {
}
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) => {
e.preventDefault();
const ds = e.currentTarget.dataset;
@@ -37,7 +37,7 @@ function registerAddNoteLinks() {
}
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) => {
e.preventDefault();
const ds = e.currentTarget.dataset;
@@ -60,7 +60,7 @@ function onMessage(e) {
}
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}"]`);
if (matches.length === 0) {
return;
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 78106319..a0eb725c 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -19,15 +19,15 @@
class Popup {
constructor() {
- this.popup = null;
+ this.popup = null;
this.offset = 10;
}
showAt(pos, content) {
this.inject();
- this.popup.style.left = pos.x + 'px';
- this.popup.style.top = pos.y + 'px';
+ this.popup.style.left = pos.x + 'px';
+ this.popup.style.top = pos.y + 'px';
this.popup.style.visibility = 'visible';
this.setContent(content);
diff --git a/ext/fg/js/source-element.js b/ext/fg/js/source-element.js
index 3110ed53..d3cc42a1 100644
--- a/ext/fg/js/source-element.js
+++ b/ext/fg/js/source-element.js
@@ -71,6 +71,6 @@ class TextSourceElement {
}
equals(other) {
- return other.element && other.textRaw() == this.textRaw();
+ return other.element && other.textRaw() === this.textRaw();
}
}
diff --git a/ext/fg/js/source-range.js b/ext/fg/js/source-range.js
index a25b3fdc..6d445f54 100644
--- a/ext/fg/js/source-range.js
+++ b/ext/fg/js/source-range.js
@@ -81,7 +81,7 @@ class TextSourceRange {
}
static seekForward(node, length) {
- const state = {node, offset: 0, length};
+ const state = {node, length, offset: 0};
if (!TextSourceRange.seekForwardHelper(node, state)) {
return state;
}
@@ -115,7 +115,7 @@ class TextSourceRange {
}
static seekBackward(node, length) {
- const state = {node, offset: node.length, length};
+ const state = {node, length, offset: node.length};
if (!TextSourceRange.seekBackwardHelper(node, state)) {
return state;
}