diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-22 21:51:29 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-22 21:51:29 +0900 |
commit | 685164629da8a28fae19128a198ba6b9a57e55f9 (patch) | |
tree | cc689084b0b48e527b212c71a2258d41f2c379ad /src/content | |
parent | a052ec92b7c7f27447211222231f43f07c2990c8 (diff) |
remove follow on activated
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/follow.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/content/follow.js b/src/content/follow.js index d678351..ffa16b9 100644 --- a/src/content/follow.js +++ b/src/content/follow.js @@ -35,7 +35,8 @@ export default class Follow { return; } else if (keyCode === KeyboardEvent.DOM_VK_ENTER || keyCode === KeyboardEvent.DOM_VK_RETURN) { - this.openUrl(this.keys); + let chars = Follow.codeChars(this.keys); + this.hintElements[chars].activate(); return; } else if (Follow.availableKey(keyCode)) { this.keys.push(keyCode); @@ -44,20 +45,23 @@ export default class Follow { this.keys.pop(); } + this.refreshKeys(); + } - let keysAsString = Follow.codeChars(this.keys); + refreshKeys() { + let chars = Follow.codeChars(this.keys); let shown = Object.keys(this.hintElements).filter((key) => { - return key.startsWith(keysAsString); + return key.startsWith(chars); }); let hidden = Object.keys(this.hintElements).filter((key) => { - return !key.startsWith(keysAsString); + return !key.startsWith(chars); }); if (shown.length == 0) { this.remove(); return; } else if (shown.length == 1) { - this.openUrl(this.keys); - return; + this.remove(); + this.hintElements[chars].activate(); } shown.forEach((key) => { @@ -76,11 +80,6 @@ export default class Follow { }); } - openUrl(keys) { - let chars = Follow.codeChars(keys); - this.hintElements[chars].activate(); - } - static availableKey(keyCode) { return ( KeyboardEvent.DOM_VK_0 <= keyCode && keyCode <= KeyboardEvent.DOM_VK_9 || |