aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-04 17:30:10 -0800
committerAlex Yatskov <alex@foosoft.net>2017-03-04 17:30:10 -0800
commitc8eb77cfd9e30625ae33739b7de5a86f59d0457c (patch)
tree8125b75868077259df691c5cf86c7bae0c2b145b /ext/fg/js/util.js
parent2e7ce451126342a9e77c43e757cd1ffdac00d807 (diff)
wip
Diffstat (limited to 'ext/fg/js/util.js')
-rw-r--r--ext/fg/js/util.js59
1 files changed, 14 insertions, 45 deletions
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index c38112f5..4fb8f288 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -119,6 +119,20 @@ function docImposterHide() {
}
function docRangeFromPoint(point, imposter) {
+ if (!document.elementFromPoint) {
+ document.elementFromPoint = (x, y) => {
+ const position = document.caretPositionFromPoint(x,y);
+ if (position === null) {
+ return null;
+ }
+
+ const range = document.createRange();
+ range.setStart(position.offsetNode, position.offset);
+ range.setEnd(position.offsetNode, position.offset);
+ return range;
+ };
+ }
+
const element = document.elementFromPoint(point.x, point.y);
if (element !== null) {
if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') {
@@ -195,51 +209,6 @@ function docSentenceExtract(source, extent) {
/*
- * Audio
- */
-
-function audioUrlBuild(definition) {
- let kana = definition.reading;
- let kanji = definition.expression;
-
- if (!kana && !kanji) {
- return null;
- }
-
- if (!kana && wanakana.isHiragana(kanji)) {
- kana = kanji;
- kanji = null;
- }
-
- const params = [];
- if (kanji) {
- params.push(`kanji=${encodeURIComponent(kanji)}`);
- }
- if (kana) {
- params.push(`kana=${encodeURIComponent(kana)}`);
- }
-
- return `https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?${params.join('&')}`;
-}
-
-function audioFilenameBuild(definition) {
- if (!definition.reading && !definition.expression) {
- return null;
- }
-
- let filename = 'yomichan';
- if (definition.reading) {
- filename += `_${definition.reading}`;
- }
- if (definition.expression) {
- filename += `_${definition.expression}`;
- }
-
- return filename += '.mp3';
-}
-
-
-/*
* Error
*/