From fe5e05f8aab195819339db5a8ce975a3733c0a6f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 12 Jan 2020 21:31:04 -0500 Subject: Fix incorrect result ordering --- ext/bg/js/dictionary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 92adc532..ee7ee756 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -67,7 +67,7 @@ function dictTermsSort(definitions, dictionaries=null) { i = v2.source.length - v1.source.length; if (i !== 0) { return i; } - i = v2.reasons.length - v1.reasons.length; + i = v1.reasons.length - v2.reasons.length; if (i !== 0) { return i; } i = v2.score - v1.score; -- cgit v1.2.3 From 8292be92d8958fc09dceb7c6bf252ac1c170ed1a Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 16 Jan 2020 23:22:38 +0200 Subject: use TextScanner in QueryParser --- ext/bg/js/search-query-parser.js | 112 ++++++++++++++------------------------- ext/bg/js/search.js | 5 ++ ext/fg/js/frontend.js | 3 +- ext/mixed/js/text-scanner.js | 1 + 4 files changed, 48 insertions(+), 73 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 0b3eccbd..8115dd46 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -17,73 +17,47 @@ */ -class QueryParser { +class QueryParser extends TextScanner { constructor(search) { + super(document.querySelector('#query-parser'), [], [], []); this.search = search; - this.pendingLookup = false; - this.clickScanPrevent = false; this.parseResults = []; this.selectedParser = null; this.queryParser = document.querySelector('#query-parser'); this.queryParserSelect = document.querySelector('#query-parser-select'); - - this.queryParser.addEventListener('mousedown', (e) => this.onMouseDown(e)); - this.queryParser.addEventListener('mouseup', (e) => this.onMouseUp(e)); } onError(error) { logError(error, false); } - onMouseDown(e) { - if (DOM.isMouseButtonPressed(e, 'primary')) { - this.clickScanPrevent = false; - } + onClick(e) { + super.onClick(e); + this.searchAt(e.clientX, e.clientY, 'click'); } - onMouseUp(e) { - if ( - this.search.options.scanning.enablePopupSearch && - !this.clickScanPrevent && - DOM.isMouseButtonPressed(e, 'primary') - ) { - const selectText = this.search.options.scanning.selectText; - this.onTermLookup(e, {disableScroll: true, selectText}); - } - } + async onSearchSource(textSource, cause) { + if (textSource === null) { return null; } - onMouseMove(e) { - if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) { - return; - } + this.setTextSourceScanLength(textSource, this.search.options.scanning.length); + const searchText = textSource.text(); + if (searchText.length === 0) { return; } - const scanningOptions = this.search.options.scanning; - const scanningModifier = scanningOptions.modifier; - if (!( - TextScanner.isScanningModifierPressed(scanningModifier, e) || - (scanningOptions.middleMouse && DOM.isMouseButtonDown(e, 'auxiliary')) - )) { - return; - } + const {definitions, length} = await apiTermsFind(searchText, {}, this.search.getOptionsContext()); + if (definitions.length === 0) { return null; } - const selectText = this.search.options.scanning.selectText; - this.onTermLookup(e, {disableScroll: true, disableHistory: true, selectText}); - } + textSource.setEndOffset(length); - onMouseLeave(e) { - this.clickScanPrevent = true; - clearTimeout(e.target.dataset.timer); - delete e.target.dataset.timer; - } + this.search.setContent('terms', {definitions, context: { + focus: false, + disableHistory: cause === 'mouse' ? true : false, + sentence: {text: searchText, offset: 0}, + url: window.location.href + }}); - onTermLookup(e, params) { - this.pendingLookup = true; - (async () => { - await this.search.onTermLookup(e, params); - this.pendingLookup = false; - })(); + return {definitions, type: 'terms'}; } onParserChange(e) { @@ -93,6 +67,27 @@ class QueryParser { this.renderParseResult(this.getParseResult()); } + getMouseEventListeners() { + return [ + [this.node, 'click', this.onClick.bind(this)], + [this.node, 'mousedown', this.onMouseDown.bind(this)], + [this.node, 'mousemove', this.onMouseMove.bind(this)], + [this.node, 'mouseover', this.onMouseOver.bind(this)], + [this.node, 'mouseout', this.onMouseOut.bind(this)] + ]; + } + + getTouchEventListeners() { + return [ + [this.node, 'auxclick', this.onAuxClick.bind(this)], + [this.node, 'touchstart', this.onTouchStart.bind(this)], + [this.node, 'touchend', this.onTouchEnd.bind(this)], + [this.node, 'touchcancel', this.onTouchCancel.bind(this)], + [this.node, 'touchmove', this.onTouchMove.bind(this), {passive: false}], + [this.node, 'contextmenu', this.onContextMenu.bind(this)] + ]; + } + refreshSelectedParser() { if (this.parseResults.length > 0) { if (this.selectedParser === null) { @@ -156,10 +151,6 @@ class QueryParser { terms: previewTerms, preview: true }); - - for (const charElement of this.queryParser.querySelectorAll('.query-parser-char')) { - this.activateScanning(charElement); - } } renderParserSelect() { @@ -190,27 +181,6 @@ class QueryParser { 'query-parser.html', {terms: QueryParser.processParseResultForDisplay(parseResult.parsedText)} ); - - for (const charElement of this.queryParser.querySelectorAll('.query-parser-char')) { - this.activateScanning(charElement); - } - } - - activateScanning(element) { - element.addEventListener('mousemove', (e) => { - clearTimeout(e.target.dataset.timer); - if (this.search.options.scanning.modifier === 'none') { - e.target.dataset.timer = setTimeout(() => { - this.onMouseMove(e); - delete e.target.dataset.timer; - }, this.search.options.scanning.delay); - } else { - this.onMouseMove(e); - } - }); - element.addEventListener('mouseleave', (e) => { - this.onMouseLeave(e); - }); } static processParseResultForDisplay(result) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index a4103ef2..ba66d5a9 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -236,6 +236,11 @@ class DisplaySearch extends Display { } } + async updateOptions(options) { + await super.updateOptions(options); + this.queryParser.setOptions(this.options); + } + initClipboardMonitor() { // ignore copy from search page window.addEventListener('copy', () => { diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 034d9075..9621ed2b 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -90,9 +90,8 @@ class Frontend extends TextScanner { } async updateOptions() { - this.options = await apiOptionsGet(this.getOptionsContext()); + this.setOptions(await apiOptionsGet(this.getOptionsContext())); await this.popup.setOptions(this.options); - this.setEnabled(this.options.general.enable); } async onSearchSource(textSource, cause) { diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index a05dd2ee..e037109d 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -281,6 +281,7 @@ class TextScanner { setOptions(options) { this.options = options; + this.setEnabled(this.options.general.enable); } async searchAt(x, y, cause) { -- cgit v1.2.3 From a50e2fb0f12838673543131c02e7ca37fe4b66fb Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 27 Dec 2019 15:08:55 -0500 Subject: Fix furigana segmentation --- ext/bg/js/dictionary.js | 3 ++- ext/bg/js/translator.js | 33 +++++++++++++++++++++------------ ext/mixed/js/display-generator.js | 8 ++++++-- 3 files changed, 29 insertions(+), 15 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index ee7ee756..67128725 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -147,8 +147,9 @@ function dictTermsGroup(definitions, dictionaries) { definitions: groupDefs, expression: firstDef.expression, reading: firstDef.reading, + furiganaSegments: firstDef.furiganaSegments, reasons: firstDef.reasons, - termTags: groupDefs[0].termTags, + termTags: firstDef.termTags, score: groupDefs.reduce((p, v) => v.score > p ? v.score : p, Number.MIN_SAFE_INTEGER), source: firstDef.source }); diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 7473c6ad..e31f9f62 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -121,16 +121,10 @@ class Translator { dictTermsSort(result.definitions, dictionaries); const expressions = []; - for (const expression of result.expressions.keys()) { - for (const reading of result.expressions.get(expression).keys()) { - const termTags = result.expressions.get(expression).get(reading); + for (const [expression, readingMap] of result.expressions.entries()) { + for (const [reading, termTags] of readingMap.entries()) { const score = termTags.map((tag) => tag.score).reduce((p, v) => p + v, 0); - expressions.push({ - expression: expression, - reading: reading, - termTags: dictTagsSort(termTags), - termFrequency: Translator.scoreToTermFrequency(score) - }); + expressions.push(Translator.createExpression(expression, reading, dictTagsSort(termTags), Translator.scoreToTermFrequency(score))); } } @@ -194,7 +188,7 @@ class Translator { const strayDefinitions = defaultDefinitions.filter((definition, index) => !mergedByTermIndices.has(index)); for (const groupedDefinition of dictTermsGroup(strayDefinitions, dictionaries)) { - groupedDefinition.expressions = [{expression: groupedDefinition.expression, reading: groupedDefinition.reading}]; + groupedDefinition.expressions = [Translator.createExpression(expression, reading)]; definitionsMerged.push(groupedDefinition); } @@ -241,14 +235,18 @@ class Translator { definitionTags.push(dictTagBuildSource(definition.dictionary)); const termTags = await this.expandTags(definition.termTags, definition.dictionary); + const {expression, reading} = definition; + const furiganaSegments = jpDistributeFurigana(expression, reading); + definitions.push({ source: deinflection.source, reasons: deinflection.reasons, score: definition.score, id: definition.id, dictionary: definition.dictionary, - expression: definition.expression, - reading: definition.reading, + expression, + reading, + furiganaSegments, glossary: definition.glossary, definitionTags: dictTagsSort(definitionTags), termTags: dictTagsSort(termTags), @@ -504,6 +502,17 @@ class Translator { return tagMetaList; } + static createExpression(expression, reading, termTags=null, termFrequency=null) { + const furiganaSegments = jpDistributeFurigana(expression, reading); + return { + expression, + reading, + furiganaSegments, + termTags, + termFrequency + }; + } + static scoreToTermFrequency(score) { if (score > 0) { return 'popular'; diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index 37be5041..1921a454 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -76,8 +76,12 @@ class DisplayGenerator { } if (expressionContainer !== null) { - const segments = [{text: details.expression, furigana: details.reading}]; // TODO : Use proper furigana segmentation - DisplayGenerator._appendFurigana(expressionContainer, segments, this._appendKanjiLinks.bind(this)); + let furiganaSegments = details.furiganaSegments; + if (!Array.isArray(furiganaSegments)) { + // This case should not occur + furiganaSegments = [{text: details.expression, furigana: details.reading}]; + } + DisplayGenerator._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this)); } DisplayGenerator._appendMultiple(tagContainer, this.createTag.bind(this), details.termTags); -- cgit v1.2.3 From 6c58cbcf51b4ecd587ee780b5fcecac9ead9a1bd Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 27 Dec 2019 15:12:21 -0500 Subject: Remove kanji.html and terms.html --- ext/bg/js/templates.js | 469 ------------------------------------------------- tmpl/kanji.html | 101 ----------- tmpl/terms.html | 139 --------------- 3 files changed, 709 deletions(-) delete mode 100644 tmpl/kanji.html delete mode 100644 tmpl/terms.html (limited to 'ext/bg/js') diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index eae4e014..2f65be31 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -1,178 +1,5 @@ (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; -templates['kanji.html'] = template({"1":function(container,depth0,helpers,partials,data) { - var stack1; - - return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.data : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(8, data, 0),"data":data})) != null ? stack1 : ""); -},"2":function(container,depth0,helpers,partials,data) { - var stack1; - - return "\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.data : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
\n"; -},"3":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return " \n " - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.notes : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : "") - + "\n " - + container.escapeExpression(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper))) - + "\n \n"; -},"4":function(container,depth0,helpers,partials,data) { - var helper; - - return container.escapeExpression(((helper = (helper = helpers.notes || (depth0 != null ? depth0.notes : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"notes","hash":{},"data":data}) : helper))); -},"6":function(container,depth0,helpers,partials,data) { - var helper; - - return container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"name","hash":{},"data":data}) : helper))); -},"8":function(container,depth0,helpers,partials,data) { - return "No data found\n"; -},"10":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return "
\n
\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + " \n
\n\n
" - + container.escapeExpression(((helper = (helper = helpers.character || (depth0 != null ? depth0.character : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"character","hash":{},"data":data}) : helper))) - + "
\n\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"if","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
GlossaryReadingsStatistics
\n" - + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(19, data, 0),"inverse":container.program(22, data, 0),"data":data})) != null ? stack1 : "") - + " \n " - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.onyomi : depth0),{"name":"if","hash":{},"fn":container.program(24, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n " - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"if","hash":{},"fn":container.program(27, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n " - + ((stack1 = container.invokePartial(partials.table,depth0,{"name":"table","hash":{"data":((stack1 = (depth0 != null ? depth0.stats : depth0)) != null ? stack1.misc : stack1)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") - + "
Classifications
" - + ((stack1 = container.invokePartial(partials.table,depth0,{"name":"table","hash":{"data":((stack1 = (depth0 != null ? depth0.stats : depth0)) != null ? stack1["class"] : stack1)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") - + "
Codepoints
" - + ((stack1 = container.invokePartial(partials.table,depth0,{"name":"table","hash":{"data":((stack1 = (depth0 != null ? depth0.stats : depth0)) != null ? stack1.code : stack1)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") - + "
Dictionary Indices
" - + ((stack1 = container.invokePartial(partials.table,depth0,{"name":"table","hash":{"data":((stack1 = (depth0 != null ? depth0.stats : depth0)) != null ? stack1.index : stack1)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") - + "
\n\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(29, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
\n"; -},"11":function(container,depth0,helpers,partials,data) { - return " \n \n"; -},"13":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
\n"; -},"14":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return " " - + alias4(((helper = (helper = helpers.dictionary || (depth0 != null ? depth0.dictionary : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"dictionary","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))) - + "\n"; -},"16":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(17, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
\n"; -},"17":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return " " - + 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))) - + "\n"; -},"19":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    " - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(20, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
\n"; -},"20":function(container,depth0,helpers,partials,data) { - return "
  • " - + container.escapeExpression(container.lambda(depth0, depth0)) - + "
  • "; -},"22":function(container,depth0,helpers,partials,data) { - var stack1; - - return " " - + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["0"] : stack1), depth0)) - + "\n"; -},"24":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    " - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.onyomi : depth0),{"name":"each","hash":{},"fn":container.program(25, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    "; -},"25":function(container,depth0,helpers,partials,data) { - return "
    " - + container.escapeExpression(container.lambda(depth0, depth0)) - + "
    "; -},"27":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    " - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(25, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    "; -},"29":function(container,depth0,helpers,partials,data) { - var stack1, helper, options, buffer = - "
    ";
    -  stack1 = ((helper = (helper = helpers.dumpObject || (depth0 != null ? depth0.dumpObject : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"dumpObject","hash":{},"fn":container.program(30, 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 (stack1 != null) { buffer += stack1; }
    -  return buffer + "
    \n"; -},"30":function(container,depth0,helpers,partials,data) { - var stack1; - - return ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : ""); -},"32":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return "
    \n \n \n
    \n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(41, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"33":function(container,depth0,helpers,partials,data) { - return "class=\"source-term\""; -},"35":function(container,depth0,helpers,partials,data) { - return "class=\"source-term invisible\""; -},"37":function(container,depth0,helpers,partials,data) { - return "class=\"next-term\""; -},"39":function(container,depth0,helpers,partials,data) { - return "class=\"next-term invisible\""; -},"41":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(42, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n" - + ((stack1 = container.invokePartial(partials.kanji,depth0,{"name":"kanji","hash":{"root":(depths[1] != null ? depths[1].root : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1]),"debug":(depths[1] != null ? depths[1].debug : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); -},"42":function(container,depth0,helpers,partials,data) { - return "
    "; -},"44":function(container,depth0,helpers,partials,data) { - return "

    No results found

    \n"; -},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return "\n\n" - + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(32, data, 0, blockParams, depths),"inverse":container.program(44, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); -},"main_d": function(fn, props, container, depth0, data, blockParams, depths) { - - var decorators = container.decorators; - - fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"args":["table"],"data":data}) || fn; - fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(10, data, 0, blockParams, depths),"inverse":container.noop,"args":["kanji"],"data":data}) || fn; - return fn; - } - -,"useDecorators":true,"usePartial":true,"useData":true,"useDepths":true}); templates['query-parser.html'] = template({"1":function(container,depth0,helpers,partials,data) { var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); @@ -224,301 +51,5 @@ templates['query-parser.html'] = template({"1":function(container,depth0,helpers return fn; } -,"useDecorators":true,"usePartial":true,"useData":true,"useDepths":true}); -templates['terms.html'] = template({"1":function(container,depth0,helpers,partials,data) { - var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer = - "
    \n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.definitionTags : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.only : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.program(19, data, 0),"data":data})) != null ? stack1 : "") - + "
    \n"; -},"2":function(container,depth0,helpers,partials,data) { - var helper; - - return container.escapeExpression(((helper = (helper = helpers.dictionary || (depth0 != null ? depth0.dictionary : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"dictionary","hash":{},"data":data}) : helper))); -},"4":function(container,depth0,helpers,partials,data) { - var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return "
    \n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.definitionTags : depth0),{"name":"each","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n"; -},"5":function(container,depth0,helpers,partials,data) { - return "class=\"compact-info\""; -},"7":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return " " - + 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))) - + "\n"; -},"9":function(container,depth0,helpers,partials,data) { - var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return "
    \n (" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.only : depth0),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + " only)\n
    \n"; -},"10":function(container,depth0,helpers,partials,data) { - var stack1; - - return ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : "") - + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.last),{"name":"unless","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n"; -},"11":function(container,depth0,helpers,partials,data) { - return ", "; -},"13":function(container,depth0,helpers,partials,data) { - var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return "
      \n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n"; -},"14":function(container,depth0,helpers,partials,data) { - return "class=\"compact-glossary\""; -},"16":function(container,depth0,helpers,partials,data) { - var stack1, helper, options, buffer = - "
  • "; - stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(17, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); - if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} - if (stack1 != null) { buffer += stack1; } - return buffer + "
  • \n"; -},"17":function(container,depth0,helpers,partials,data) { - return container.escapeExpression(container.lambda(depth0, depth0)); -},"19":function(container,depth0,helpers,partials,data) { - var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer = - "
    "; - stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(22, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper)); - if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} - if (stack1 != null) { buffer += stack1; } - return buffer + "
    \n"; -},"20":function(container,depth0,helpers,partials,data) { - return "compact-glossary"; -},"22":function(container,depth0,helpers,partials,data) { - var stack1; - - return container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["0"] : stack1), depth0)); -},"24":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return "
    \n
    \n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","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(27, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + " \n
    \n\n" - + ((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" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(48, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(52, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n
    \n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.grouped : depth0),{"name":"if","hash":{},"fn":container.program(55, data, 0, blockParams, depths),"inverse":container.program(61, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") - + "
    \n\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(64, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n"; -},"25":function(container,depth0,helpers,partials,data) { - return " \n \n \n"; -},"27":function(container,depth0,helpers,partials,data) { - var stack1; - - return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.playback : depth0),{"name":"if","hash":{},"fn":container.program(28, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"28":function(container,depth0,helpers,partials,data) { - return " \n"; -},"30":function(container,depth0,helpers,partials,data,blockParams,depths) { - var 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 : ""); -},"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 = - "
    "; - 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 (stack1 != null) { buffer += stack1; } - return buffer + "
    " - + ((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(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(40, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    "; -},"32":function(container,depth0,helpers,partials,data) { - 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(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 (stack1 != null) { return stack1; } - else { return ''; } -},"33":function(container,depth0,helpers,partials,data) { - var stack1; - - return ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : ""); -},"35":function(container,depth0,helpers,partials,data) { - return ""; -},"37":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    " - + ((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 : "") - + "
    "; -},"38":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return " " - + 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))) - + "\n"; -},"40":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    " - + ((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 : "") - + "
    "; -},"41":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return " " - + alias4(((helper = (helper = helpers.dictionary || (depth0 != null ? depth0.dictionary : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"dictionary","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))) - + "\n"; -},"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 = - "
    "; - 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 (stack1 != null) { buffer += stack1; } - return buffer + "
    \n" - + ((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 : ""); -},"46":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    \n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n"; -},"48":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    \n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.reasons : depth0),{"name":"each","hash":{},"fn":container.program(49, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n"; -},"49":function(container,depth0,helpers,partials,data) { - var stack1; - - return " " - + container.escapeExpression(container.lambda(depth0, depth0)) - + " " - + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.last),{"name":"unless","hash":{},"fn":container.program(50, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n"; -},"50":function(container,depth0,helpers,partials,data) { - return "«"; -},"52":function(container,depth0,helpers,partials,data) { - var stack1; - - return "
    \n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(53, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n"; -},"53":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return " " - + alias4(((helper = (helper = helpers.dictionary || (depth0 != null ? depth0.dictionary : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"dictionary","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))) - + "\n"; -},"55":function(container,depth0,helpers,partials,data,blockParams,depths) { - 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(56, data, 0, blockParams, depths),"inverse":container.program(59, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); -},"56":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return "
      \n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(57, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "
    \n"; -},"57":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return "
  • " - + ((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 : "") - + "
  • \n"; -},"59":function(container,depth0,helpers,partials,data) { - 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 : ""); -},"61":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(55, data, 0, blockParams, depths),"inverse":container.program(62, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); -},"62":function(container,depth0,helpers,partials,data) { - 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 : "") - + " "; -},"64":function(container,depth0,helpers,partials,data) { - var stack1, helper, options, buffer = - "
    ";
    -  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 (stack1 != null) { buffer += stack1; }
    -  return buffer + "
    \n"; -},"66":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - - return "
    \n \n \n
    \n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(75, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"67":function(container,depth0,helpers,partials,data) { - return "class=\"source-term\""; -},"69":function(container,depth0,helpers,partials,data) { - return "class=\"source-term invisible\""; -},"71":function(container,depth0,helpers,partials,data) { - return "class=\"next-term\""; -},"73":function(container,depth0,helpers,partials,data) { - return "class=\"next-term invisible\""; -},"75":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(76, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\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 : ""); -},"76":function(container,depth0,helpers,partials,data) { - return "
    "; -},"78":function(container,depth0,helpers,partials,data) { - return "

    No results found.

    \n"; -},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return "\n\n" - + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(66, data, 0, blockParams, depths),"inverse":container.program(78, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); -},"main_d": function(fn, props, container, depth0, data, blockParams, depths) { - - var decorators = container.decorators; - - fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"args":["definition"],"data":data}) || fn; - fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(24, data, 0, blockParams, depths),"inverse":container.noop,"args":["term"],"data":data}) || fn; - return fn; - } - ,"useDecorators":true,"usePartial":true,"useData":true,"useDepths":true}); })(); \ No newline at end of file diff --git a/tmpl/kanji.html b/tmpl/kanji.html deleted file mode 100644 index d205cda5..00000000 --- a/tmpl/kanji.html +++ /dev/null @@ -1,101 +0,0 @@ -{{#*inline "table"}} -{{#if data}} - - {{#each data}} - - - - - {{/each}} -
    {{#if notes}}{{notes}}{{else}}{{name}}{{/if}}{{value}}
    -{{else}} -No data found -{{/if}} -{{/inline}} - -{{#*inline "kanji"}} -
    -
    - {{#if addable}} - - - {{/if}} - -
    - -
    {{character}}
    - - {{#if frequencies}} -
    - {{#each frequencies}} - {{dictionary}}:{{frequency}} - {{/each}} -
    - {{/if}} - - {{#if tags}} -
    - {{#each tags}} - {{name}} - {{/each}} -
    - {{/if}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    GlossaryReadingsStatistics
    - {{#if glossary.[1]}} -
      {{#each glossary}}
    1. {{.}}
    2. {{/each}}
    - {{else}} - {{glossary.[0]}} - {{/if}} -
    - {{#if onyomi}}
    {{#each onyomi}}
    {{.}}
    {{/each}}
    {{/if}} - {{#if kunyomi}}
    {{#each kunyomi}}
    {{.}}
    {{/each}}
    {{/if}} -
    {{> table data=stats.misc}}
    Classifications
    {{> table data=stats.class}}
    Codepoints
    {{> table data=stats.code}}
    Dictionary Indices
    {{> table data=stats.index}}
    - - {{#if debug}} -
    {{#dumpObject}}{{{.}}}{{/dumpObject}}
    - {{/if}} -
    -{{/inline}} - -{{#if definitions}} -
    - - -
    -{{#each definitions}} -{{#unless @first}}
    {{/unless}} -{{> kanji debug=../debug addable=../addable root=../root}} -{{/each}} -{{else}} -

    No results found

    -{{/if}} diff --git a/tmpl/terms.html b/tmpl/terms.html deleted file mode 100644 index d0c142d9..00000000 --- a/tmpl/terms.html +++ /dev/null @@ -1,139 +0,0 @@ -{{#*inline "definition"}} -
    - {{#if definitionTags}} -
    - {{#each definitionTags}} - {{name}} - {{/each}} -
    - {{/if}} - {{#if only}} -
    - ( - {{~#each only~}} - {{{.}}}{{#unless @last}}, {{/unless}} - {{/each}} - only) -
    - {{/if}} - {{#if glossary.[1]}} -
      - {{#each glossary}} -
    • {{#multiLine}}{{.}}{{/multiLine}}
    • - {{/each}} -
    - {{else}} -
    {{#multiLine}}{{glossary.[0]}}{{/multiLine}}
    - {{/if}} -
    -{{/inline}} - -{{#*inline "term"}} -
    -
    - {{#if addable}} - - - - {{/if}} - {{#unless merged}} - {{#if playback}} - - {{/if}} - {{/unless}} - -
    - - {{#if merged}} - {{~#each expressions~}} -
    {{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}
    - {{~#if ../playback~}} - - {{~/if~}} - {{~#if termTags~}} -
    - {{~#each termTags}} - {{name}} - {{/each~}} -
    - {{~/if~}} - {{~#if frequencies~}} -
    - {{~#each frequencies}} - {{dictionary}}:{{frequency}} - {{/each~}} -
    - {{~/if~}} -
    - {{~/each~}} - {{else}} -
    {{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}
    - {{#if termTags}} -
    - {{#each termTags}} - {{name}} - {{/each}} -
    - {{/if}} - {{/if}} - - {{#if reasons}} -
    - {{#each reasons}} - {{.}} {{#unless @last}}«{{/unless}} - {{/each}} -
    - {{/if}} - - {{#if frequencies}} -
    - {{#each frequencies}} - {{dictionary}}:{{frequency}} - {{/each}} -
    - {{/if}} - -
    - {{#if grouped}} - {{#if definitions.[1]}} -
      - {{#each definitions}} -
    1. {{> definition compactGlossaries=../compactGlossaries}}
    2. - {{/each}} -
    - {{else}} - {{> definition definitions.[0] compactGlossaries=compactGlossaries}} - {{/if}} - {{else if merged}} - {{#if definitions.[1]}} -
      - {{#each definitions}} -
    1. {{> definition compactGlossaries=../compactGlossaries}}
    2. - {{/each}} -
    - {{else}} - {{> definition definitions.[0] compactGlossaries=compactGlossaries}} - {{/if}} - {{else}} - {{> definition compactGlossaries=compactGlossaries}} - {{/if}} -
    - - {{#if debug}} -
    {{#dumpObject}}{{{.}}}{{/dumpObject}}
    - {{/if}} -
    -{{/inline}} - -{{#if definitions}} -
    - - -
    -{{#each definitions}} -{{#unless @first}}
    {{/unless}} -{{> term debug=../debug grouped=../grouped merged=../merged addable=../addable playback=../playback compactGlossaries=../compactGlossaries}} -{{/each}} -{{else}} -

    No results found.

    -{{/if}} -- cgit v1.2.3 From dbbcfa5739d10a6e45eb6e8b964e6a576431ff20 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 27 Dec 2019 17:42:36 -0500 Subject: Only use Display.setContent --- ext/bg/js/search.js | 4 ++-- ext/fg/js/float.js | 2 +- ext/mixed/js/display.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index ba66d5a9..673f066b 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -220,12 +220,12 @@ class DisplaySearch extends Display { this.updateSearchButton(); if (valid) { const {definitions} = await apiTermsFind(query, details, this.optionsContext); - this.setContentTerms(definitions, { + this.setContent('terms', {definitions, context: { focus: false, disableHistory: true, sentence: {text: query, offset: 0}, url: window.location.href - }); + }}); } else { this.container.textContent = ''; } diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 513d246b..c550579d 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -35,7 +35,7 @@ class DisplayFloat extends Display { onError(error) { if (this._orphaned) { - this.setContentOrphaned(); + this.setContent('orphaned'); } else { logError(error, true); } diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index f5b2225d..cc5bc95f 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -77,7 +77,7 @@ class Display { }; const definitions = await apiKanjiFind(link.textContent, this.getOptionsContext()); - this.setContentKanji(definitions, context); + this.setContent('kanji', {definitions, context}); } catch (error) { this.onError(error); } @@ -131,7 +131,7 @@ class Display { }); } - this.setContentTerms(definitions, context); + this.setContent('terms', {definitions, context}); if (selectText) { textSource.select(); -- cgit v1.2.3 From 7686e56c00c724ad6f9e133134787e2cd083b062 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 27 Dec 2019 18:58:11 -0500 Subject: Move display templates into a single file --- ext/bg/js/api.js | 4 ++ ext/bg/js/backend.js | 8 +++- ext/bg/js/request.js | 21 +++++----- ext/bg/search.html | 78 ------------------------------------- ext/fg/float.html | 78 ------------------------------------- ext/mixed/display-templates.html | 81 +++++++++++++++++++++++++++++++++++++++ ext/mixed/js/api.js | 4 ++ ext/mixed/js/display-generator.js | 74 +++++++++++++++++++++++++++-------- ext/mixed/js/display.js | 10 +++++ 9 files changed, 176 insertions(+), 182 deletions(-) create mode 100644 ext/mixed/display-templates.html (limited to 'ext/bg/js') diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index 906aaa30..285b8016 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -25,6 +25,10 @@ function apiAudioGetUrl(definition, source, optionsContext) { return _apiInvoke('audioGetUrl', {definition, source, optionsContext}); } +function apiGetDisplayTemplatesHtml() { + return _apiInvoke('getDisplayTemplatesHtml'); +} + function _apiInvoke(action, params={}) { const data = {action, params}; return new Promise((resolve, reject) => { diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 28b0201e..391d6243 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -522,6 +522,11 @@ class Backend { return result; } + async _onApiGetDisplayTemplatesHtml() { + const url = chrome.runtime.getURL('/mixed/display-templates.html'); + return await requestText(url, 'GET'); + } + // Command handlers async _onCommandSearch(params) { @@ -735,7 +740,8 @@ Backend._messageHandlers = new Map([ ['frameInformationGet', (self, ...args) => self._onApiFrameInformationGet(...args)], ['injectStylesheet', (self, ...args) => self._onApiInjectStylesheet(...args)], ['getEnvironmentInfo', (self, ...args) => self._onApiGetEnvironmentInfo(...args)], - ['clipboardGet', (self, ...args) => self._onApiClipboardGet(...args)] + ['clipboardGet', (self, ...args) => self._onApiClipboardGet(...args)], + ['getDisplayTemplatesHtml', (self, ...args) => self._onApiGetDisplayTemplatesHtml(...args)] ]); Backend._commandHandlers = new Map([ diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js index b584c9a9..778f933b 100644 --- a/ext/bg/js/request.js +++ b/ext/bg/js/request.js @@ -17,10 +17,10 @@ */ -function requestJson(url, action, params) { +function requestText(url, action, params) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); - xhr.overrideMimeType('application/json'); + xhr.overrideMimeType('text/plain'); xhr.addEventListener('load', () => resolve(xhr.responseText)); xhr.addEventListener('error', () => reject(new Error('Failed to connect'))); xhr.open(action, url); @@ -29,12 +29,15 @@ function requestJson(url, action, params) { } else { xhr.send(); } - }).then((responseText) => { - try { - return JSON.parse(responseText); - } - catch (e) { - return Promise.reject(new Error('Invalid response')); - } }); } + +async function requestJson(url, action, params) { + const responseText = await requestText(url, action, params); + try { + return JSON.parse(responseText); + } + catch (e) { + throw new Error('Invalid response'); + } +} diff --git a/ext/bg/search.html b/ext/bg/search.html index 819c8505..74afbb68 100644 --- a/ext/bg/search.html +++ b/ext/bg/search.html @@ -66,84 +66,6 @@ - - - - - - - - - - - - - - - - - diff --git a/ext/fg/float.html b/ext/fg/float.html index 9cc0dc39..bec5ae68 100644 --- a/ext/fg/float.html +++ b/ext/fg/float.html @@ -40,84 +40,6 @@ - - - - - - - - - - - - - - - - - diff --git a/ext/mixed/display-templates.html b/ext/mixed/display-templates.html new file mode 100644 index 00000000..01cfeffc --- /dev/null +++ b/ext/mixed/display-templates.html @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index 8ed1d996..9f0835b0 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -101,6 +101,10 @@ function apiClipboardGet() { return _apiInvoke('clipboardGet'); } +function apiGetDisplayTemplatesHtml() { + return _apiInvoke('getDisplayTemplatesHtml'); +} + function _apiInvoke(action, params={}) { const data = {action, params}; return new Promise((resolve, reject) => { diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index 44b250e7..8eb699e0 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -19,22 +19,39 @@ class DisplayGenerator { constructor() { - this._termEntryTemplate = document.querySelector('#term-entry-template'); - this._termExpressionTemplate = document.querySelector('#term-expression-template'); - this._termDefinitionItemTemplate = document.querySelector('#term-definition-item-template'); - this._termDefinitionOnlyTemplate = document.querySelector('#term-definition-only-template'); - this._termGlossaryItemTemplate = document.querySelector('#term-glossary-item-template'); - this._termReasonTemplate = document.querySelector('#term-reason-template'); - - this._kanjiEntryTemplate = document.querySelector('#kanji-entry-template'); - this._kanjiInfoTableTemplate = document.querySelector('#kanji-info-table-template'); - this._kanjiInfoTableItemTemplate = document.querySelector('#kanji-info-table-item-template'); - this._kanjiInfoTableEmptyTemplate = document.querySelector('#kanji-info-table-empty-template'); - this._kanjiGlossaryItemTemplate = document.querySelector('#kanji-glossary-item-template'); - this._kanjiReadingTemplate = document.querySelector('#kanji-reading-template'); - - this._tagTemplate = document.querySelector('#tag-template'); - this._tagFrequencyTemplate = document.querySelector('#tag-frequency-template'); + this._isInitialized = false; + this._initializationPromise = null; + + this._termEntryTemplate = null; + this._termExpressionTemplate = null; + this._termDefinitionItemTemplate = null; + this._termDefinitionOnlyTemplate = null; + this._termGlossaryItemTemplate = null; + this._termReasonTemplate = null; + + this._kanjiEntryTemplate = null; + this._kanjiInfoTableTemplate = null; + this._kanjiInfoTableItemTemplate = null; + this._kanjiInfoTableEmptyTemplate = null; + this._kanjiGlossaryItemTemplate = null; + this._kanjiReadingTemplate = null; + + this._tagTemplate = null; + this._tagFrequencyTemplate = null; + } + + isInitialized() { + return this._isInitialized; + } + + initialize() { + if (this._isInitialized) { + return Promise.resolve(); + } + if (this._initializationPromise === null) { + this._initializationPromise = this._initializeInternal(); + } + return this._initializationPromise; } createTermEntry(details) { @@ -259,6 +276,31 @@ class DisplayGenerator { return node; } + async _initializeInternal() { + const html = await apiGetDisplayTemplatesHtml(); + const doc = new DOMParser().parseFromString(html, 'text/html'); + this._setTemplates(doc); + } + + _setTemplates(doc) { + this._termEntryTemplate = doc.querySelector('#term-entry-template'); + this._termExpressionTemplate = doc.querySelector('#term-expression-template'); + this._termDefinitionItemTemplate = doc.querySelector('#term-definition-item-template'); + this._termDefinitionOnlyTemplate = doc.querySelector('#term-definition-only-template'); + this._termGlossaryItemTemplate = doc.querySelector('#term-glossary-item-template'); + this._termReasonTemplate = doc.querySelector('#term-reason-template'); + + this._kanjiEntryTemplate = doc.querySelector('#kanji-entry-template'); + this._kanjiInfoTableTemplate = doc.querySelector('#kanji-info-table-template'); + this._kanjiInfoTableItemTemplate = doc.querySelector('#kanji-info-table-item-template'); + this._kanjiInfoTableEmptyTemplate = doc.querySelector('#kanji-info-table-empty-template'); + this._kanjiGlossaryItemTemplate = doc.querySelector('#kanji-glossary-item-template'); + this._kanjiReadingTemplate = doc.querySelector('#kanji-reading-template'); + + this._tagTemplate = doc.querySelector('#tag-template'); + this._tagFrequencyTemplate = doc.querySelector('#tag-frequency-template'); + } + _appendKanjiLinks(container, text) { let part = ''; for (const c of text) { diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index eabb73ca..75b43aa0 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -356,6 +356,11 @@ class Display { window.focus(); } + if (!this.displayGenerator.isInitialized()) { + await this.displayGenerator.initialize(); + if (this.setContentToken !== token) { return; } + } + this.definitions = definitions; if (context.disableHistory) { delete context.disableHistory; @@ -415,6 +420,11 @@ class Display { window.focus(); } + if (!this.displayGenerator.isInitialized()) { + await this.displayGenerator.initialize(); + if (this.setContentToken !== token) { return; } + } + this.definitions = definitions; if (context.disableHistory) { delete context.disableHistory; -- cgit v1.2.3 From 0b1bee8c00252b4412ab0d2f88b17d7a2b63bc0b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 28 Dec 2019 22:55:29 -0500 Subject: Fix invalid variables --- ext/bg/js/translator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index e31f9f62..b6e9604d 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -188,7 +188,7 @@ class Translator { const strayDefinitions = defaultDefinitions.filter((definition, index) => !mergedByTermIndices.has(index)); for (const groupedDefinition of dictTermsGroup(strayDefinitions, dictionaries)) { - groupedDefinition.expressions = [Translator.createExpression(expression, reading)]; + groupedDefinition.expressions = [Translator.createExpression(groupedDefinition.expression, groupedDefinition.reading)]; definitionsMerged.push(groupedDefinition); } -- cgit v1.2.3 From 62da7ec5cc3efa7011260bebe7366fabcb610ab4 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 16 Jan 2020 18:56:20 -0500 Subject: Update expression-scan-toggle to term-expression-text --- ext/bg/js/search-frontend.js | 2 +- ext/fg/js/popup-nested.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index 2fe50a13..bd2ddb50 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -27,7 +27,7 @@ async function searchFrontendSetup() { const ignoreNodes = ['.scan-disable', '.scan-disable *']; if (!options.scanning.enableOnPopupExpressions) { - ignoreNodes.push('.expression-scan-toggle', '.expression-scan-toggle *'); + ignoreNodes.push('.term-expression-text', '.term-expression-text *'); } window.frontendInitializationData = {depth: 1, ignoreNodes, proxy: false}; diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js index bacf3b93..e0e52cb7 100644 --- a/ext/fg/js/popup-nested.js +++ b/ext/fg/js/popup-nested.js @@ -35,7 +35,7 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) { const ignoreNodes = ['.scan-disable', '.scan-disable *']; if (!options.scanning.enableOnPopupExpressions) { - ignoreNodes.push('.expression-scan-toggle', '.expression-scan-toggle *'); + ignoreNodes.push('.term-expression-text', '.term-expression-text *'); } window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url, proxy: true}; -- cgit v1.2.3 From f969b5b8a9fa3b77bfc3bbb13830913c620c48da Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 16 Jan 2020 19:35:19 -0500 Subject: Update popup scan ignore selectors --- ext/bg/js/search-frontend.js | 2 +- ext/fg/js/popup-nested.js | 2 +- ext/mixed/display-templates.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index bd2ddb50..e453ccef 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -27,7 +27,7 @@ async function searchFrontendSetup() { const ignoreNodes = ['.scan-disable', '.scan-disable *']; if (!options.scanning.enableOnPopupExpressions) { - ignoreNodes.push('.term-expression-text', '.term-expression-text *'); + ignoreNodes.push('.source-text', '.source-text *'); } window.frontendInitializationData = {depth: 1, ignoreNodes, proxy: false}; diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js index e0e52cb7..3f3c945e 100644 --- a/ext/fg/js/popup-nested.js +++ b/ext/fg/js/popup-nested.js @@ -35,7 +35,7 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) { const ignoreNodes = ['.scan-disable', '.scan-disable *']; if (!options.scanning.enableOnPopupExpressions) { - ignoreNodes.push('.term-expression-text', '.term-expression-text *'); + ignoreNodes.push('.source-text', '.source-text *'); } window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url, proxy: true}; diff --git a/ext/mixed/display-templates.html b/ext/mixed/display-templates.html index 01cfeffc..62f3c69c 100644 --- a/ext/mixed/display-templates.html +++ b/ext/mixed/display-templates.html @@ -20,7 +20,7 @@
      
       
      -