aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-24 16:48:30 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-24 16:48:30 -0700
commit8143e372cdb61012ec8683feb01688adfa39dde1 (patch)
treee7336df5bd9fd3bb676e5063d649c5dd8b83fee3
parent59989cd78c60b4c8d089b3bed070b11eb62622b6 (diff)
Stub handler for kanji click
-rw-r--r--ext/bg/js/templates.js2
-rw-r--r--ext/fg/js/frame.js14
-rw-r--r--ext/manifest.json2
-rw-r--r--util/tmpl/kanji-link.html2
4 files changed, 17 insertions, 3 deletions
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index f6c6025a..1c14e569 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -30,7 +30,7 @@ templates['kanji.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(co
templates['kanji-link.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;
- return "<a href=\"#\">"
+ return "<a href=\"#\" class=\"kanji-link\">"
+ container.escapeExpression(((helper = (helper = helpers.kanji || (depth0 != null ? depth0.kanji : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"kanji","hash":{},"data":data}) : helper)))
+ "</a>\n";
},"useData":true});
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index 868f07ce..c8f8211e 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -17,3 +17,17 @@
*/
+function onKanjiQuery(kanji) {
+ alert(kanji);
+}
+
+function registerKanjiLinks() {
+ for (const link of [].slice.call(document.getElementsByClassName('kanji-link'))) {
+ link.addEventListener('click', (e) => {
+ e.preventDefault();
+ onKanjiQuery(e.target.innerHTML);
+ });
+ }
+}
+
+document.addEventListener('DOMContentLoaded', registerKanjiLinks, false);
diff --git a/ext/manifest.json b/ext/manifest.json
index e766c140..639ad921 100644
--- a/ext/manifest.json
+++ b/ext/manifest.json
@@ -20,7 +20,7 @@
"background": {"page": "bg/background.html"},
"options_page": "bg/options.html",
"permissions": ["storage"],
- "web_accessible_resources": ["fg/css/frame.css", "fg/css/frame.js"],
+ "web_accessible_resources": ["fg/css/frame.css", "fg/js/frame.js"],
"content_scripts": [{
"matches": ["*://*/*"],
diff --git a/util/tmpl/kanji-link.html b/util/tmpl/kanji-link.html
index 21533282..f4f8dc69 100644
--- a/util/tmpl/kanji-link.html
+++ b/util/tmpl/kanji-link.html
@@ -1 +1 @@
-<a href="#">{{kanji}}</a>
+<a href="#" class="kanji-link">{{kanji}}</a>