aboutsummaryrefslogtreecommitdiff
path: root/public/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/app.js')
-rw-r--r--public/js/app.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/public/js/app.js b/public/js/app.js
index 2e61595..3c6d91f 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -856,6 +856,16 @@ function preload(url) {
}
}
+ function notInside(element, name) {
+ if (typeof element.parentElement === "undefined" ||
+ element.parentElement === null
+ ) { return true; }
+ var parentTag = element.parentElement;
+ var tagName = element.tagName;
+ if (tagName === name) { return false; }
+ return notInside(parentTag, name);
+ }
+
function dictionary(event) {
if (
event.ctrlKey == true ||
@@ -865,8 +875,9 @@ function preload(url) {
return;
}
var word = "" + window.getSelection();
- var container = window.getSelection().anchorNode.parentElement.tagName;
- if (word > "" && word.length > 1 && container !== "CODE") {
+ var container = window.getSelection().anchorNode.parentElement;
+
+ if (word > "" && word.length > 1 && notInside(container, 'PRE')) {
dictionary_access(word);
}
}