Merge pull request #172 from siikamiika/search-terms-from-terms

allow looking up terms from within terms
This commit is contained in:
Alex Yatskov 2019-08-03 19:54:56 -07:00 committed by GitHub
commit 0368641621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 142 additions and 72 deletions

View File

@ -25,6 +25,8 @@ class DisplaySearch extends Display {
this.query = $('#query').on('input', this.onSearchInput.bind(this)); this.query = $('#query').on('input', this.onSearchInput.bind(this));
this.intro = $('#intro'); this.intro = $('#intro');
this.dependencies = {...this.dependencies, ...{docRangeFromPoint, docSentenceExtract}};
window.wanakana.bind(this.query.get(0)); window.wanakana.bind(this.query.get(0));
} }

View File

@ -289,16 +289,17 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
return "<div class=\"entry\" data-type=\"term\">\n <div class=\"actions\">\n" return "<div class=\"entry\" data-type=\"term\">\n <div class=\"actions\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(23, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(23, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.merged : depth0),{"name":"unless","hash":{},"fn":container.program(25, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.merged : depth0),{"name":"unless","hash":{},"fn":container.program(25, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.source : depth0),{"name":"if","hash":{},"fn":container.program(28, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <img src=\"/mixed/img/entry-current.png\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n </div>\n\n" + " <img src=\"/mixed/img/entry-current.png\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n </div>\n\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(28, data, 0, blockParams, depths),"inverse":container.program(43, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(30, data, 0, blockParams, depths),"inverse":container.program(45, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "")
+ "\n" + "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(47, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(49, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n" + "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(51, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(53, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n <div class=\"glossary\">\n" + "\n <div class=\"glossary\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.grouped : depth0),{"name":"if","hash":{},"fn":container.program(54, data, 0, blockParams, depths),"inverse":container.program(60, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.grouped : depth0),{"name":"if","hash":{},"fn":container.program(56, data, 0, blockParams, depths),"inverse":container.program(62, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "")
+ " </div>\n\n" + " </div>\n\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(63, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(65, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n"; + "</div>\n";
},"23":function(container,depth0,helpers,partials,data) { },"23":function(container,depth0,helpers,partials,data) {
return " <a href=\"#\" class=\"action-view-note pending disabled\"><img src=\"/mixed/img/view-note.png\" title=\"View added note (Alt + V)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kanji\"><img src=\"/mixed/img/add-term-kanji.png\" title=\"Add expression (Alt + E)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kana\"><img src=\"/mixed/img/add-term-kana.png\" title=\"Add reading (Alt + R)\" alt></a>\n"; return " <a href=\"#\" class=\"action-view-note pending disabled\"><img src=\"/mixed/img/view-note.png\" title=\"View added note (Alt + V)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kanji\"><img src=\"/mixed/img/add-term-kanji.png\" title=\"Add expression (Alt + E)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kana\"><img src=\"/mixed/img/add-term-kana.png\" title=\"Add reading (Alt + R)\" alt></a>\n";
@ -308,45 +309,47 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.playback : depth0),{"name":"if","hash":{},"fn":container.program(26, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.playback : depth0),{"name":"if","hash":{},"fn":container.program(26, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"26":function(container,depth0,helpers,partials,data) { },"26":function(container,depth0,helpers,partials,data) {
return " <a href=\"#\" class=\"action-play-audio\"><img src=\"/mixed/img/play-audio.png\" title=\"Play audio (Alt + P)\" alt></a>\n"; return " <a href=\"#\" class=\"action-play-audio\"><img src=\"/mixed/img/play-audio.png\" title=\"Play audio (Alt + P)\" alt></a>\n";
},"28":function(container,depth0,helpers,partials,data,blockParams,depths) { },"28":function(container,depth0,helpers,partials,data) {
return " <a href=\"#\" class=\"source-term\"><img src=\"/mixed/img/source-term.png\" title=\"Source term (Alt + B)\" alt></a>\n";
},"30":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.expressions : depth0),{"name":"each","hash":{},"fn":container.program(29, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.expressions : depth0),{"name":"each","hash":{},"fn":container.program(31, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"29":function(container,depth0,helpers,partials,data,blockParams,depths) { },"31":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", buffer = var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", buffer =
"<div class=\"expression\"><span class=\"expression-" "<div class=\"expression\"><span class=\"expression-"
+ container.escapeExpression(((helper = (helper = helpers.termFrequency || (depth0 != null ? depth0.termFrequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"termFrequency","hash":{},"data":data}) : helper))) + container.escapeExpression(((helper = (helper = helpers.termFrequency || (depth0 != null ? depth0.termFrequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"termFrequency","hash":{},"data":data}) : helper)))
+ "\">"; + "\">";
stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : alias2),(options={"name":"kanjiLinks","hash":{},"fn":container.program(30, data, 0, blockParams, depths),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper)); stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : alias2),(options={"name":"kanjiLinks","hash":{},"fn":container.program(32, data, 0, blockParams, depths),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));
if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</span><div class=\"peek-wrapper\">" return buffer + "</span><div class=\"peek-wrapper\">"
+ ((stack1 = helpers["if"].call(alias1,(depths[1] != null ? depths[1].playback : depths[1]),{"name":"if","hash":{},"fn":container.program(33, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depths[1] != null ? depths[1].playback : depths[1]),{"name":"if","hash":{},"fn":container.program(35, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(35, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(37, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(38, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(40, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div><span class=\"" + "</div><span class=\""
+ ((stack1 = helpers["if"].call(alias1,(data && data.last),{"name":"if","hash":{},"fn":container.program(41, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(data && data.last),{"name":"if","hash":{},"fn":container.program(43, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">、</span></div>"; + "\">、</span></div>";
},"30":function(container,depth0,helpers,partials,data) { },"32":function(container,depth0,helpers,partials,data) {
var stack1, helper, options; var stack1, helper, options;
stack1 = ((helper = (helper = helpers.furigana || (depth0 != null ? depth0.furigana : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"furigana","hash":{},"fn":container.program(31, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); stack1 = ((helper = (helper = helpers.furigana || (depth0 != null ? depth0.furigana : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"furigana","hash":{},"fn":container.program(33, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper));
if (!helpers.furigana) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (!helpers.furigana) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
if (stack1 != null) { return stack1; } if (stack1 != null) { return stack1; }
else { return ''; } else { return ''; }
},"31":function(container,depth0,helpers,partials,data) { },"33":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : ""); return ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : "");
},"33":function(container,depth0,helpers,partials,data) {
return "<a href=\"#\" class=\"action-play-audio\"><img src=\"/mixed/img/play-audio.png\" title=\"Play audio\" alt></a>";
},"35":function(container,depth0,helpers,partials,data) { },"35":function(container,depth0,helpers,partials,data) {
return "<a href=\"#\" class=\"action-play-audio\"><img src=\"/mixed/img/play-audio.png\" title=\"Play audio\" alt></a>";
},"37":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return "<div class=\"tags\">" return "<div class=\"tags\">"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(36, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(38, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>"; + "</div>";
},"36":function(container,depth0,helpers,partials,data) { },"38":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <span class=\"label label-default tag-" return " <span class=\"label label-default tag-"
@ -356,13 +359,13 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
+ "\">" + "\">"
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "</span>\n"; + "</span>\n";
},"38":function(container,depth0,helpers,partials,data) { },"40":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return "<div class=\"frequencies\">" return "<div class=\"frequencies\">"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(39, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(41, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>"; + "</div>";
},"39":function(container,depth0,helpers,partials,data) { },"41":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <span class=\"label label-default tag-frequency\">" return " <span class=\"label label-default tag-frequency\">"
@ -370,23 +373,23 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
+ ":" + ":"
+ alias4(((helper = (helper = helpers.frequency || (depth0 != null ? depth0.frequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"frequency","hash":{},"data":data}) : helper))) + alias4(((helper = (helper = helpers.frequency || (depth0 != null ? depth0.frequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"frequency","hash":{},"data":data}) : helper)))
+ "</span>\n"; + "</span>\n";
},"41":function(container,depth0,helpers,partials,data) {
return "invisible";
},"43":function(container,depth0,helpers,partials,data) { },"43":function(container,depth0,helpers,partials,data) {
return "invisible";
},"45":function(container,depth0,helpers,partials,data) {
var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer = var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer =
" <div class=\"expression\">"; " <div class=\"expression\">";
stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"kanjiLinks","hash":{},"fn":container.program(30, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper)); stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"kanjiLinks","hash":{},"fn":container.program(32, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper));
if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</div>\n" return buffer + "</div>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(44, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(46, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"44":function(container,depth0,helpers,partials,data) { },"46":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return " <div style=\"display: inline-block;\">\n" return " <div style=\"display: inline-block;\">\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(45, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(47, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n"; + " </div>\n";
},"45":function(container,depth0,helpers,partials,data) { },"47":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <span class=\"label label-default tag-" return " <span class=\"label label-default tag-"
@ -396,29 +399,29 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
+ "\">" + "\">"
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "</span>\n"; + "</span>\n";
},"47":function(container,depth0,helpers,partials,data) { },"49":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return " <div class=\"reasons\">\n" return " <div class=\"reasons\">\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.reasons : depth0),{"name":"each","hash":{},"fn":container.program(48, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.reasons : depth0),{"name":"each","hash":{},"fn":container.program(50, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n"; + " </div>\n";
},"48":function(container,depth0,helpers,partials,data) { },"50":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return " <span class=\"reasons\">" return " <span class=\"reasons\">"
+ container.escapeExpression(container.lambda(depth0, depth0)) + container.escapeExpression(container.lambda(depth0, depth0))
+ "</span> " + "</span> "
+ ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.last),{"name":"unless","hash":{},"fn":container.program(49, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.last),{"name":"unless","hash":{},"fn":container.program(51, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n"; + "\n";
},"49":function(container,depth0,helpers,partials,data) {
return "&laquo;";
},"51":function(container,depth0,helpers,partials,data) { },"51":function(container,depth0,helpers,partials,data) {
return "&laquo;";
},"53":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return " <div>\n" return " <div>\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(52, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(54, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n"; + " </div>\n";
},"52":function(container,depth0,helpers,partials,data) { },"54":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <span class=\"label label-default tag-frequency\">" return " <span class=\"label label-default tag-frequency\">"
@ -426,61 +429,61 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
+ ":" + ":"
+ alias4(((helper = (helper = helpers.frequency || (depth0 != null ? depth0.frequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"frequency","hash":{},"data":data}) : helper))) + alias4(((helper = (helper = helpers.frequency || (depth0 != null ? depth0.frequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"frequency","hash":{},"data":data}) : helper)))
+ "</span>\n"; + "</span>\n";
},"54":function(container,depth0,helpers,partials,data,blockParams,depths) { },"56":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.definitions : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(55, data, 0, blockParams, depths),"inverse":container.program(58, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.definitions : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(57, data, 0, blockParams, depths),"inverse":container.program(60, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "");
},"55":function(container,depth0,helpers,partials,data,blockParams,depths) { },"57":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return " <ol>\n" return " <ol>\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(56, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(58, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </ol>\n"; + " </ol>\n";
},"56":function(container,depth0,helpers,partials,data,blockParams,depths) { },"58":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return " <li>" return " <li>"
+ ((stack1 = container.invokePartial(partials.definition,depth0,{"name":"definition","hash":{"compactGlossaries":(depths[1] != null ? depths[1].compactGlossaries : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + ((stack1 = container.invokePartial(partials.definition,depth0,{"name":"definition","hash":{"compactGlossaries":(depths[1] != null ? depths[1].compactGlossaries : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
+ "</li>\n"; + "</li>\n";
},"58":function(container,depth0,helpers,partials,data) { },"60":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return ((stack1 = container.invokePartial(partials.definition,((stack1 = (depth0 != null ? depth0.definitions : depth0)) != null ? stack1["0"] : stack1),{"name":"definition","hash":{"compactGlossaries":(depth0 != null ? depth0.compactGlossaries : depth0)},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); return ((stack1 = container.invokePartial(partials.definition,((stack1 = (depth0 != null ? depth0.definitions : depth0)) != null ? stack1["0"] : stack1),{"name":"definition","hash":{"compactGlossaries":(depth0 != null ? depth0.compactGlossaries : depth0)},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "");
},"60":function(container,depth0,helpers,partials,data,blockParams,depths) { },"62":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(54, data, 0, blockParams, depths),"inverse":container.program(61, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(56, data, 0, blockParams, depths),"inverse":container.program(63, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "");
},"61":function(container,depth0,helpers,partials,data) { },"63":function(container,depth0,helpers,partials,data) {
var stack1; var stack1;
return ((stack1 = container.invokePartial(partials.definition,depth0,{"name":"definition","hash":{"compactGlossaries":(depth0 != null ? depth0.compactGlossaries : depth0)},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") return ((stack1 = container.invokePartial(partials.definition,depth0,{"name":"definition","hash":{"compactGlossaries":(depth0 != null ? depth0.compactGlossaries : depth0)},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
+ " "; + " ";
},"63":function(container,depth0,helpers,partials,data) { },"65":function(container,depth0,helpers,partials,data) {
var stack1, helper, options, buffer = var stack1, helper, options, buffer =
" <pre>"; " <pre>";
stack1 = ((helper = (helper = helpers.dumpObject || (depth0 != null ? depth0.dumpObject : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"dumpObject","hash":{},"fn":container.program(31, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); stack1 = ((helper = (helper = helpers.dumpObject || (depth0 != null ? depth0.dumpObject : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"dumpObject","hash":{},"fn":container.program(33, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper));
if (!helpers.dumpObject) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (!helpers.dumpObject) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</pre>\n"; return buffer + "</pre>\n";
},"65":function(container,depth0,helpers,partials,data,blockParams,depths) { },"67":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(66, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(68, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"66":function(container,depth0,helpers,partials,data,blockParams,depths) { },"68":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(67, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(69, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n" + "\n"
+ ((stack1 = container.invokePartial(partials.term,depth0,{"name":"term","hash":{"compactGlossaries":(depths[1] != null ? depths[1].compactGlossaries : depths[1]),"playback":(depths[1] != null ? depths[1].playback : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1]),"merged":(depths[1] != null ? depths[1].merged : depths[1]),"grouped":(depths[1] != null ? depths[1].grouped : depths[1]),"debug":(depths[1] != null ? depths[1].debug : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); + ((stack1 = container.invokePartial(partials.term,depth0,{"name":"term","hash":{"source":(depths[1] != null ? depths[1].source : depths[1]),"compactGlossaries":(depths[1] != null ? depths[1].compactGlossaries : depths[1]),"playback":(depths[1] != null ? depths[1].playback : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1]),"merged":(depths[1] != null ? depths[1].merged : depths[1]),"grouped":(depths[1] != null ? depths[1].grouped : depths[1]),"debug":(depths[1] != null ? depths[1].debug : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "");
},"67":function(container,depth0,helpers,partials,data) {
return "<hr>";
},"69":function(container,depth0,helpers,partials,data) { },"69":function(container,depth0,helpers,partials,data) {
return "<hr>";
},"71":function(container,depth0,helpers,partials,data) {
return "<p class=\"note\">No results found.</p>\n"; return "<p class=\"note\">No results found.</p>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1; var stack1;
return "\n\n" return "\n\n"
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(65, data, 0, blockParams, depths),"inverse":container.program(69, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(67, data, 0, blockParams, depths),"inverse":container.program(71, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "");
},"main_d": function(fn, props, container, depth0, data, blockParams, depths) { },"main_d": function(fn, props, container, depth0, data, blockParams, depths) {
var decorators = container.decorators; var decorators = container.decorators;

View File

@ -43,6 +43,8 @@
<script src="/bg/js/handlebars.js"></script> <script src="/bg/js/handlebars.js"></script>
<script src="/bg/js/templates.js"></script> <script src="/bg/js/templates.js"></script>
<script src="/bg/js/util.js"></script> <script src="/bg/js/util.js"></script>
<script src="/fg/js/document.js"></script>
<script src="/fg/js/source.js"></script>
<script src="/mixed/js/display.js"></script> <script src="/mixed/js/display.js"></script>
<script src="/mixed/js/japanese.js"></script> <script src="/mixed/js/japanese.js"></script>

View File

@ -36,6 +36,8 @@
<script src="/fg/js/api.js"></script> <script src="/fg/js/api.js"></script>
<script src="/fg/js/util.js"></script> <script src="/fg/js/util.js"></script>
<script src="/fg/js/document.js"></script>
<script src="/fg/js/source.js"></script>
<script src="/mixed/js/display.js"></script> <script src="/mixed/js/display.js"></script>
<script src="/fg/js/float.js"></script> <script src="/fg/js/float.js"></script>

View File

@ -23,6 +23,8 @@ class DisplayFloat extends Display {
this.autoPlayAudioTimer = null; this.autoPlayAudioTimer = null;
this.styleNode = null; this.styleNode = null;
this.dependencies = {...this.dependencies, ...{docRangeFromPoint, docSentenceExtract}};
$(window).on('message', utilAsync(this.onMessage.bind(this))); $(window).on('message', utilAsync(this.onMessage.bind(this)));
} }

View File

@ -28,6 +28,8 @@ class Display {
this.index = 0; this.index = 0;
this.audioCache = {}; this.audioCache = {};
this.dependencies = {};
$(document).keydown(this.onKeyDown.bind(this)); $(document).keydown(this.onKeyDown.bind(this));
$(document).on('wheel', this.onWheel.bind(this)); $(document).on('wheel', this.onWheel.bind(this));
} }
@ -53,13 +55,15 @@ class Display {
const context = { const context = {
source: { source: {
definitions: this.definitions, definitions: this.definitions,
index: Display.entryIndexFind(link) index: Display.entryIndexFind(link),
scroll: $('html,body').scrollTop()
} }
}; };
if (this.context) { if (this.context) {
context.sentence = this.context.sentence; context.sentence = this.context.sentence;
context.url = this.context.url; context.url = this.context.url;
context.source.source = this.context.source;
} }
const kanjiDefs = await apiKanjiFind(link.text()); const kanjiDefs = await apiKanjiFind(link.text());
@ -69,6 +73,45 @@ class Display {
} }
} }
async onTermLookup(e) {
try {
e.preventDefault();
const {docRangeFromPoint, docSentenceExtract} = this.dependencies;
const clickedElement = $(e.target);
const textSource = docRangeFromPoint({x: e.clientX, y: e.clientY});
textSource.setEndOffset(this.options.scanning.length);
const {definitions, length} = await apiTermsFind(textSource.text());
if (definitions.length === 0) {
return false;
}
textSource.setEndOffset(length);
const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
const context = {
source: {
definitions: this.definitions,
index: Display.entryIndexFind(clickedElement),
scroll: $('html,body').scrollTop()
}
};
if (this.context) {
context.sentence = sentence;
context.url = this.context.url;
context.source.source = this.context.source;
}
this.termsShow(definitions, this.options, context);
} catch (e) {
this.onError(e);
}
}
onAudioPlay(e) { onAudioPlay(e) {
e.preventDefault(); e.preventDefault();
const link = $(e.currentTarget); const link = $(e.currentTarget);
@ -114,42 +157,42 @@ class Display {
33: /* page up */ () => { 33: /* page up */ () => {
if (e.altKey) { if (e.altKey) {
this.entryScrollIntoView(this.index - 3, true); this.entryScrollIntoView(this.index - 3, null, true);
return true; return true;
} }
}, },
34: /* page down */ () => { 34: /* page down */ () => {
if (e.altKey) { if (e.altKey) {
this.entryScrollIntoView(this.index + 3, true); this.entryScrollIntoView(this.index + 3, null, true);
return true; return true;
} }
}, },
35: /* end */ () => { 35: /* end */ () => {
if (e.altKey) { if (e.altKey) {
this.entryScrollIntoView(this.definitions.length - 1, true); this.entryScrollIntoView(this.definitions.length - 1, null, true);
return true; return true;
} }
}, },
36: /* home */ () => { 36: /* home */ () => {
if (e.altKey) { if (e.altKey) {
this.entryScrollIntoView(0, true); this.entryScrollIntoView(0, null, true);
return true; return true;
} }
}, },
38: /* up */ () => { 38: /* up */ () => {
if (e.altKey) { if (e.altKey) {
this.entryScrollIntoView(this.index - 1, true); this.entryScrollIntoView(this.index - 1, null, true);
return true; return true;
} }
}, },
40: /* down */ () => { 40: /* down */ () => {
if (e.altKey) { if (e.altKey) {
this.entryScrollIntoView(this.index + 1, true); this.entryScrollIntoView(this.index + 1, null, true);
return true; return true;
} }
}, },
@ -210,10 +253,10 @@ class Display {
const handler = () => { const handler = () => {
if (event.altKey) { if (event.altKey) {
if (event.deltaY < 0) { // scroll up if (event.deltaY < 0) { // scroll up
this.entryScrollIntoView(this.index - 1, true); this.entryScrollIntoView(this.index - 1, null, true);
return true; return true;
} else if (event.deltaY > 0) { // scroll down } else if (event.deltaY > 0) { // scroll down
this.entryScrollIntoView(this.index + 1, true); this.entryScrollIntoView(this.index + 1, null, true);
return true; return true;
} }
} }
@ -235,6 +278,7 @@ class Display {
const sequence = ++this.sequence; const sequence = ++this.sequence;
const params = { const params = {
definitions, definitions,
source: context && context.source,
addable: options.anki.enable, addable: options.anki.enable,
grouped: options.general.resultOutputMode === 'group', grouped: options.general.resultOutputMode === 'group',
merged: options.general.resultOutputMode === 'merge', merged: options.general.resultOutputMode === 'merge',
@ -255,7 +299,8 @@ class Display {
const content = await apiTemplateRender('terms.html', params); const content = await apiTemplateRender('terms.html', params);
this.container.html(content); this.container.html(content);
this.entryScrollIntoView(context && context.index || 0); const {index, scroll} = context || {};
this.entryScrollIntoView(index || 0, scroll);
if (this.options.general.autoPlayAudio && this.options.general.audioSource !== 'disabled') { if (this.options.general.autoPlayAudio && this.options.general.audioSource !== 'disabled') {
this.autoPlayAudio(); this.autoPlayAudio();
@ -265,6 +310,8 @@ class Display {
$('.action-view-note').click(this.onNoteView.bind(this)); $('.action-view-note').click(this.onNoteView.bind(this));
$('.action-play-audio').click(this.onAudioPlay.bind(this)); $('.action-play-audio').click(this.onAudioPlay.bind(this));
$('.kanji-link').click(this.onKanjiLookup.bind(this)); $('.kanji-link').click(this.onKanjiLookup.bind(this));
$('.source-term').click(this.onSourceTermView.bind(this));
$('.glossary-item').click(this.onTermLookup.bind(this));
await this.adderButtonUpdate(['term-kanji', 'term-kana'], sequence); await this.adderButtonUpdate(['term-kanji', 'term-kana'], sequence);
} catch (e) { } catch (e) {
@ -300,7 +347,8 @@ class Display {
const content = await apiTemplateRender('kanji.html', params); const content = await apiTemplateRender('kanji.html', params);
this.container.html(content); this.container.html(content);
this.entryScrollIntoView(context && context.index || 0); const {index, scroll} = context || {};
this.entryScrollIntoView(index || 0, scroll);
$('.action-add-note').click(this.onNoteAdd.bind(this)); $('.action-add-note').click(this.onNoteAdd.bind(this));
$('.action-view-note').click(this.onNoteView.bind(this)); $('.action-view-note').click(this.onNoteView.bind(this));
@ -341,7 +389,7 @@ class Display {
} }
} }
entryScrollIntoView(index, smooth) { entryScrollIntoView(index, scroll, smooth) {
index = Math.min(index, this.definitions.length - 1); index = Math.min(index, this.definitions.length - 1);
index = Math.max(index, 0); index = Math.max(index, 0);
@ -349,7 +397,13 @@ class Display {
const container = $('html,body').stop(); const container = $('html,body').stop();
const entry = $('.entry').eq(index); const entry = $('.entry').eq(index);
const target = index === 0 ? 0 : entry.offset().top; let target;
if (scroll) {
target = scroll;
} else {
target = index === 0 ? 0 : entry.offset().top;
}
if (smooth) { if (smooth) {
container.animate({scrollTop: target}, 200); container.animate({scrollTop: target}, 200);
@ -365,7 +419,9 @@ class Display {
const context = { const context = {
url: this.context.source.url, url: this.context.source.url,
sentence: this.context.source.sentence, sentence: this.context.source.sentence,
index: this.context.source.index index: this.context.source.index,
scroll: this.context.source.scroll,
source: this.context.source.source
}; };
this.termsShow(this.context.source.definitions, this.options, context); this.termsShow(this.context.source.definitions, this.options, context);

View File

@ -39,6 +39,9 @@
<a href="#" class="action-play-audio"><img src="/mixed/img/play-audio.png" title="Play audio (Alt + P)" alt></a> <a href="#" class="action-play-audio"><img src="/mixed/img/play-audio.png" title="Play audio (Alt + P)" alt></a>
{{/if}} {{/if}}
{{/unless}} {{/unless}}
{{#if source}}
<a href="#" class="source-term"><img src="/mixed/img/source-term.png" title="Source term (Alt + B)" alt></a>
{{/if}}
<img src="/mixed/img/entry-current.png" class="current" title="Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)" alt> <img src="/mixed/img/entry-current.png" class="current" title="Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)" alt>
</div> </div>
@ -126,7 +129,7 @@
{{#if definitions}} {{#if definitions}}
{{#each definitions}} {{#each definitions}}
{{#unless @first}}<hr>{{/unless}} {{#unless @first}}<hr>{{/unless}}
{{> term debug=../debug grouped=../grouped merged=../merged addable=../addable playback=../playback compactGlossaries=../compactGlossaries}} {{> term debug=../debug grouped=../grouped merged=../merged addable=../addable playback=../playback compactGlossaries=../compactGlossaries source=../source}}
{{/each}} {{/each}}
{{else}} {{else}}
<p class="note">No results found.</p> <p class="note">No results found.</p>