summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-10-29 12:20:56 -0700
committerAlex Yatskov <alex@foosoft.net>2017-10-29 12:20:56 -0700
commitc08dc6e00a0786438d785d3c7f62ce86205386fd (patch)
tree7f65834ec0e988b978418a6f331a95776b96c887 /ext/bg/js
parentd6603fd03155939ba98e8e74f98d1c5ce7ca9b0f (diff)
add dictionary update nag screen
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/database.js2
-rw-r--r--ext/bg/js/settings.js24
-rw-r--r--ext/bg/js/templates.js18
3 files changed, 27 insertions, 17 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index e63d95de..3c7f6aab 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -234,7 +234,7 @@ class Database {
}
const indexDataLoaded = async summary => {
- if (summary.version > 2) {
+ if (summary.version > 3) {
throw 'Unsupported dictionary version';
}
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index 9a7b20b6..dcc9c43d 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -60,11 +60,11 @@ async function formRead() {
optionsNew.general.mainDictionary = $('#dict-main').val();
$('.dict-group').each((index, element) => {
const dictionary = $(element);
- const title = dictionary.data('title');
- const priority = parseInt(dictionary.find('.dict-priority').val(), 10);
- const enabled = dictionary.find('.dict-enabled').prop('checked');
- const allowSecondarySearches = dictionary.find('.dict-allow-secondary-searches').prop('checked');
- optionsNew.dictionaries[title] = {priority, enabled, allowSecondarySearches};
+ optionsNew.dictionaries[dictionary.data('title')] = {
+ priority: parseInt(dictionary.find('.dict-priority').val(), 10),
+ enabled: dictionary.find('.dict-enabled').prop('checked'),
+ allowSecondarySearches: dictionary.find('.dict-allow-secondary-searches').prop('checked')
+ };
});
return {optionsNew, optionsOld};
@@ -277,14 +277,20 @@ async function dictionaryGroupsPopulate(options) {
}
for (const dictRow of dictRowsSort(dictRows, options)) {
- const dictOptions = options.dictionaries[dictRow.title] || {enabled: false, priority: 0, allowSecondarySearches: false};
+ const dictOptions = options.dictionaries[dictRow.title] || {
+ enabled: false,
+ priority: 0,
+ allowSecondarySearches: false
+ };
+
const dictHtml = await apiTemplateRender('dictionary.html', {
+ enabled: dictOptions.enabled,
+ priority: dictOptions.priority,
+ allowSecondarySearches: dictOptions.allowSecondarySearches,
title: dictRow.title,
version: dictRow.version,
revision: dictRow.revision,
- priority: dictOptions.priority,
- enabled: dictOptions.enabled,
- allowSecondarySearches: dictOptions.allowSecondarySearches
+ outdated: dictRow.version < 3
});
dictGroups.append($(dictHtml));
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index f3f680d5..680ec742 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -1,6 +1,8 @@
(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['dictionary.html'] = template({"1":function(container,depth0,helpers,partials,data) {
+ return " <p class=\"text-warning\">This dictionary is outdated and may not support new extension features; please import the latest version.</p>\n";
+},"3":function(container,depth0,helpers,partials,data) {
return "checked";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
@@ -11,10 +13,12 @@ templates['dictionary.html'] = template({"1":function(container,depth0,helpers,p
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ " <small>rev."
+ alias4(((helper = (helper = helpers.revision || (depth0 != null ? depth0.revision : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"revision","hash":{},"data":data}) : helper)))
- + "</small></h4>\n\n <div class=\"checkbox\">\n <label><input type=\"checkbox\" class=\"dict-enabled\" "
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.enabled : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + "</small></h4>\n"
+ + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.outdated : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + "\n <div class=\"checkbox\">\n <label><input type=\"checkbox\" class=\"dict-enabled\" "
+ + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.enabled : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "> Enable search</label>\n </div>\n <div class=\"checkbox options-advanced\">\n <label><input type=\"checkbox\" class=\"dict-allow-secondary-searches\" "
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.allowSecondarySearches : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.allowSecondarySearches : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "> Allow secondary searches</label>\n </div>\n <div class=\"form-group options-advanced\">\n <label for=\"dict-"
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "\">Result priority</label>\n <input type=\"number\" value=\""
@@ -310,19 +314,19 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
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 : "");
},"29":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", buffer =
- "<div class=\"expression\"><!--\n --><span class=\"expression-"
+ "<div class=\"expression\">\n <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)))
+ "\">";
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));
if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
if (stack1 != null) { buffer += stack1; }
- return buffer + "</span><!--\n --><div class=\"peek-wrapper\">"
+ return buffer + "</span>\n <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,(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.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(38, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "</div><!--\n --><span class=\""
+ + "</div>\n <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 : "")
- + "\">、</span><!--\n --></div>";
+ + "\">、</span>\n </div>";
},"30":function(container,depth0,helpers,partials,data) {
var stack1, helper, options;