aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/templates.js8
-rw-r--r--ext/fg/js/client.js20
-rw-r--r--ext/manifest.json2
3 files changed, 24 insertions, 6 deletions
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index 0b7d83e7..3388ec9b 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -7,13 +7,15 @@ templates['defs.html'] = template({"1":function(container,depth0,helpers,partial
+ ((stack1 = container.invokePartial(partials["term.html"],depth0,{"name":"term.html","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
+ " </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
- var stack1, helper, alias1=depth0 != null ? depth0 : {};
+ var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title></title>\n <link rel=\"stylesheet\" href=\""
- + container.escapeExpression(((helper = (helper = helpers.root || (depth0 != null ? depth0.root : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"root","hash":{},"data":data}) : helper)))
+ + alias4(((helper = (helper = helpers.root || (depth0 != null ? depth0.root : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"root","hash":{},"data":data}) : helper)))
+ "/css/popup.css\">\n </head>\n <body>\n <div class=\"dictionary\">\n <a href=\"javascript:selectDict('edict');\">単</a><a href=\"javascript:selectDict('enamdict')\">名</a><a href=\"javascript:selectDict('kanjidic');\">漢</a>\n </div>\n\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.defs : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + " </body>\n</html>\n";
+ + "\n <script src=\""
+ + alias4(((helper = (helper = helpers.root || (depth0 != null ? depth0.root : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"root","hash":{},"data":data}) : helper)))
+ + "/js/popup.js\"></script>\n </body>\n</html>\n";
},"usePartial":true,"useData":true});
templates['term.html'] = template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index 8739fa2d..b757123c 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -31,7 +31,8 @@ class Client {
this.popup.addEventListener('scroll', (e) => e.stopPropagation());
document.body.appendChild(this.popup);
- chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
+ chrome.runtime.onMessage.addListener(this.onBgMessage.bind(this));
+ window.addEventListener('message', this.onFrameMessage.bind(this));
window.addEventListener('mousedown', this.onMouseDown.bind(this));
window.addEventListener('mousemove', this.onMouseMove.bind(this));
window.addEventListener('keydown', this.onKeyDown.bind(this));
@@ -39,6 +40,7 @@ class Client {
window.addEventListener('resize', (e) => this.hidePopup());
getOptions((opts) => {
+ this.setDict('edict');
this.setOptions(opts);
getState((state) => this.setEnabled(state === 'enabled'));
});
@@ -66,7 +68,7 @@ class Client {
}
}
- onMessage({name, value}, sender, callback) {
+ onBgMessage({name, value}, sender, callback) {
switch (name) {
case 'state':
this.setEnabled(value === 'enabled');
@@ -79,6 +81,15 @@ class Client {
callback();
}
+ onFrameMessage(e) {
+ const {action, data} = e.data;
+ switch (action) {
+ case 'selectDict':
+ this.setDict(data);
+ break;
+ }
+ }
+
searchAtPoint(point) {
const range = getRangeAtPoint(point, this.options.scanLength);
if (range === null) {
@@ -156,6 +167,11 @@ class Client {
setOptions(opts) {
this.options = opts;
}
+
+ setDict(dict) {
+ this.dict = dict;
+ alert(dict);
+ }
}
window.yomiClient = new Client();
diff --git a/ext/manifest.json b/ext/manifest.json
index e5b21268..18b37b91 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/popup.css"],
+ "web_accessible_resources": ["fg/css/popup.css", "fg/js/popup.js"],
"content_scripts": [{
"matches": ["*://*/*"],