aboutsummaryrefslogtreecommitdiff
path: root/ext/content.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-03-23 19:25:32 -0700
committerAlex Yatskov <alex@foosoft.net>2016-03-23 19:25:32 -0700
commit2fe2e993ee1cdc80c91b03809a715f62995a8132 (patch)
tree8c03b81f97c89c166b87ff7561d42d35a7eda86f /ext/content.js
parentc30837065889d4fc4d2984b14b365cc276c79214 (diff)
WIP
Diffstat (limited to 'ext/content.js')
-rw-r--r--ext/content.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/content.js b/ext/content.js
index 4938805f..c36b7381 100644
--- a/ext/content.js
+++ b/ext/content.js
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
function getRangeAtCursor(e, lookAhead) {
const range = document.caretRangeFromPoint(e.clientX, e.clientY);
if (range === null) {
@@ -36,6 +37,8 @@ function getRangeAtCursor(e, lookAhead) {
function onMouseDown(e) {
+ e.preventDefault();
+
const range = getRangeAtCursor(e, 20);
if (range === null) {
return;
@@ -45,11 +48,9 @@ function onMouseDown(e) {
selection.removeAllRanges();
selection.addRange(range);
- e.preventDefault();
-
- console.log(range.toString());
+ findTerm(range.toString(), response => {
+ console.log(response);
+ });
}
-
-
-// window.addEventListener('mousedown', onMouseDown, false);
+window.addEventListener('mousedown', onMouseDown, false);