Plumbing
This commit is contained in:
parent
be43981e25
commit
bcd34149ab
@ -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 : "")
|
+ ((stack1 = container.invokePartial(partials["term.html"],depth0,{"name":"term.html","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
|
||||||
+ " </div>\n";
|
+ " </div>\n";
|
||||||
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
},"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=\""
|
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"
|
+ "/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 : "")
|
+ ((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});
|
},"usePartial":true,"useData":true});
|
||||||
templates['term.html'] = template({"1":function(container,depth0,helpers,partials,data) {
|
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;
|
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
|
||||||
|
@ -31,7 +31,8 @@ class Client {
|
|||||||
this.popup.addEventListener('scroll', (e) => e.stopPropagation());
|
this.popup.addEventListener('scroll', (e) => e.stopPropagation());
|
||||||
document.body.appendChild(this.popup);
|
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('mousedown', this.onMouseDown.bind(this));
|
||||||
window.addEventListener('mousemove', this.onMouseMove.bind(this));
|
window.addEventListener('mousemove', this.onMouseMove.bind(this));
|
||||||
window.addEventListener('keydown', this.onKeyDown.bind(this));
|
window.addEventListener('keydown', this.onKeyDown.bind(this));
|
||||||
@ -39,6 +40,7 @@ class Client {
|
|||||||
window.addEventListener('resize', (e) => this.hidePopup());
|
window.addEventListener('resize', (e) => this.hidePopup());
|
||||||
|
|
||||||
getOptions((opts) => {
|
getOptions((opts) => {
|
||||||
|
this.setDict('edict');
|
||||||
this.setOptions(opts);
|
this.setOptions(opts);
|
||||||
getState((state) => this.setEnabled(state === 'enabled'));
|
getState((state) => this.setEnabled(state === 'enabled'));
|
||||||
});
|
});
|
||||||
@ -66,7 +68,7 @@ class Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessage({name, value}, sender, callback) {
|
onBgMessage({name, value}, sender, callback) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'state':
|
case 'state':
|
||||||
this.setEnabled(value === 'enabled');
|
this.setEnabled(value === 'enabled');
|
||||||
@ -79,6 +81,15 @@ class Client {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onFrameMessage(e) {
|
||||||
|
const {action, data} = e.data;
|
||||||
|
switch (action) {
|
||||||
|
case 'selectDict':
|
||||||
|
this.setDict(data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
searchAtPoint(point) {
|
searchAtPoint(point) {
|
||||||
const range = getRangeAtPoint(point, this.options.scanLength);
|
const range = getRangeAtPoint(point, this.options.scanLength);
|
||||||
if (range === null) {
|
if (range === null) {
|
||||||
@ -156,6 +167,11 @@ class Client {
|
|||||||
setOptions(opts) {
|
setOptions(opts) {
|
||||||
this.options = opts;
|
this.options = opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDict(dict) {
|
||||||
|
this.dict = dict;
|
||||||
|
alert(dict);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.yomiClient = new Client();
|
window.yomiClient = new Client();
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
"background": {"page": "bg/background.html"},
|
"background": {"page": "bg/background.html"},
|
||||||
"options_page": "bg/options.html",
|
"options_page": "bg/options.html",
|
||||||
"permissions": ["storage"],
|
"permissions": ["storage"],
|
||||||
"web_accessible_resources": ["fg/css/popup.css"],
|
"web_accessible_resources": ["fg/css/popup.css", "fg/js/popup.js"],
|
||||||
|
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
"matches": ["*://*/*"],
|
"matches": ["*://*/*"],
|
||||||
|
@ -15,5 +15,7 @@
|
|||||||
{{> term.html}}
|
{{> term.html}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
|
<script src="{{root}}/js/popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user