diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-04-22 13:02:06 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-04-22 13:02:06 -0700 |
commit | e661c4bd4383816f3f14c7458944795b44a40bad (patch) | |
tree | 47c02e8ee3edc83924ffae6cc19f41a07b70975a /ext/bg/js/util.js | |
parent | 56fe02e9453f2b40a8af52b6f8a8125d67d2ad9f (diff) |
add option to disable searching of alphanumeric text, fixes #471.1.14
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r-- | ext/bg/js/util.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 64143ffe..09337c63 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -31,6 +31,20 @@ function promiseCallback(promise, callback) { /* + * Japanese + */ + +function jpIsKanji(c) { + const code = c.charCodeAt(0); + return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0; +} + +function jpIsKana(c) { + return wanakana.isKana(c); +} + + +/* * Commands */ @@ -98,6 +112,7 @@ function optionsSetDefaults(options) { middleMouse: true, selectText: true, imposter: true, + alphanumeric: true, delay: 15, length: 10 }, @@ -489,14 +504,9 @@ function jsonLoadDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) { */ function handlebarsKanjiLinks(options) { - const isKanji = c => { - const code = c.charCodeAt(0); - return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0; - }; - let result = ''; for (const c of options.fn(this)) { - if (isKanji(c)) { + if (jpIsKanji(c)) { result += `<a href="#" class="kanji-link">${c}</a>`; } else { result += c; |