From c08dc6e00a0786438d785d3c7f62ce86205386fd Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 29 Oct 2017 12:20:56 -0700 Subject: add dictionary update nag screen --- ext/bg/js/database.js | 2 +- ext/bg/js/settings.js | 24 +++++++++++++++--------- ext/bg/js/templates.js | 18 +++++++++++------- 3 files changed, 27 insertions(+), 17 deletions(-) (limited to 'ext/bg/js') 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 "

This dictionary is outdated and may not support new extension features; please import the latest version.

\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))) + " 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))) - + "\n\n
\n