dict priority work
This commit is contained in:
parent
0c88d3fa27
commit
434ccc18ee
@ -54,9 +54,10 @@ function getFormData() {
|
|||||||
$('.dict-group').each((index, element) => {
|
$('.dict-group').each((index, element) => {
|
||||||
const dictionary = $(element);
|
const dictionary = $(element);
|
||||||
const title = dictionary.data('title');
|
const title = dictionary.data('title');
|
||||||
|
const priority = parseInt(dictionary.find('.dict-priority').val(), 10);
|
||||||
const enableTerms = dictionary.find('.dict-enable-terms').prop('checked');
|
const enableTerms = dictionary.find('.dict-enable-terms').prop('checked');
|
||||||
const enableKanji = dictionary.find('.dict-enable-kanji').prop('checked');
|
const enableKanji = dictionary.find('.dict-enable-kanji').prop('checked');
|
||||||
optionsNew.dictionaries[title] = {enableTerms, enableKanji};
|
optionsNew.dictionaries[title] = {priority, enableTerms, enableKanji};
|
||||||
});
|
});
|
||||||
|
|
||||||
return {optionsNew, optionsOld};
|
return {optionsNew, optionsOld};
|
||||||
@ -147,22 +148,23 @@ function populateDictionaries(options) {
|
|||||||
let dictCount = 0;
|
let dictCount = 0;
|
||||||
return database().getDictionaries().then(rows => {
|
return database().getDictionaries().then(rows => {
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
const dictoptions = options.dictionaries[row.title] || {enableTerms: false, enableKanji: false};
|
const dictOptions = options.dictionaries[row.title] || {enableTerms: false, enableKanji: false, priority: 0};
|
||||||
const html = Handlebars.templates['dictionary.html']({
|
const html = Handlebars.templates['dictionary.html']({
|
||||||
title: row.title,
|
title: row.title,
|
||||||
version: row.version,
|
version: row.version,
|
||||||
revision: row.revision,
|
revision: row.revision,
|
||||||
hasTerms: row.hasTerms,
|
hasTerms: row.hasTerms,
|
||||||
hasKanji: row.hasKanji,
|
hasKanji: row.hasKanji,
|
||||||
enableTerms: dictoptions.enableTerms,
|
priority: dictOptions.priority,
|
||||||
enableKanji: dictoptions.enableKanji
|
enableTerms: dictOptions.enableTerms,
|
||||||
|
enableKanji: dictOptions.enableKanji
|
||||||
});
|
});
|
||||||
|
|
||||||
dictGroups.append($(html));
|
dictGroups.append($(html));
|
||||||
++dictCount;
|
++dictCount;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.dict-enable-terms, .dict-enable-kanji').change(onOptionsChanged);
|
$('.dict-enable-terms, .dict-enable-kanji, .dict-priority').change(onOptionsChanged);
|
||||||
$('.dict-delete').click(onDictionaryDelete);
|
$('.dict-delete').click(onDictionaryDelete);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
showDictionaryError(error);
|
showDictionaryError(error);
|
||||||
|
@ -20,28 +20,28 @@
|
|||||||
function optionsSetDefaults(options) {
|
function optionsSetDefaults(options) {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
general: {
|
general: {
|
||||||
autoStart: true,
|
autoStart: true,
|
||||||
audioPlayback: true,
|
audioPlayback: true,
|
||||||
softKatakana: true,
|
softKatakana: true,
|
||||||
groupResults: true,
|
groupResults: true,
|
||||||
showAdvanced: false
|
showAdvanced: false
|
||||||
},
|
},
|
||||||
|
|
||||||
scanning: {
|
scanning: {
|
||||||
requireShift: true,
|
requireShift: true,
|
||||||
selectText: true,
|
selectText: true,
|
||||||
delay: 15,
|
delay: 15,
|
||||||
length: 10
|
length: 10
|
||||||
},
|
},
|
||||||
|
|
||||||
dictionaries: {},
|
dictionaries: {},
|
||||||
|
|
||||||
anki: {
|
anki: {
|
||||||
enable: false,
|
enable: false,
|
||||||
tags: ['yomichan'],
|
tags: ['yomichan'],
|
||||||
sentenceExt: 200,
|
sentenceExt: 200,
|
||||||
terms: {deck: '', model: '', fields: {}},
|
terms: {deck: '', model: '', fields: {}},
|
||||||
kanji: {deck: '', model: '', fields: {}},
|
kanji: {deck: '', model: '', fields: {}}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,10 +53,10 @@ function optionsSetDefaults(options) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
combine(options, defaults);
|
combine(options, defaults);
|
||||||
combine(options.general, defaults.general);
|
combine(options.general, defaults.general);
|
||||||
combine(options.scanning, defaults.scanning);
|
combine(options.scanning, defaults.scanning);
|
||||||
combine(options.anki, defaults.anki);
|
combine(options.anki, defaults.anki);
|
||||||
combine(options.anki.terms, defaults.anki.terms);
|
combine(options.anki.terms, defaults.anki.terms);
|
||||||
combine(options.anki.kanji, defaults.anki.kanji);
|
combine(options.anki.kanji, defaults.anki.kanji);
|
||||||
|
|
||||||
@ -74,28 +74,32 @@ function optionsVersion(options) {
|
|||||||
() => {
|
() => {
|
||||||
optionsSetDefaults(options);
|
optionsSetDefaults(options);
|
||||||
|
|
||||||
copy(options.general, 'autoStart', options, 'activateOnStartup');
|
copy(options.general, 'autoStart', options, 'activateOnStartup');
|
||||||
copy(options.general, 'audioPlayback', options, 'enableAudioPlayback');
|
copy(options.general, 'audioPlayback', options, 'enableAudioPlayback');
|
||||||
copy(options.general, 'softKatakana', options, 'enableSoftKatakanaSearch');
|
copy(options.general, 'softKatakana', options, 'enableSoftKatakanaSearch');
|
||||||
copy(options.general, 'groupResults', options, 'groupTermResults');
|
copy(options.general, 'groupResults', options, 'groupTermResults');
|
||||||
copy(options.general, 'showAdvanced', options, 'showAdvancedOptions');
|
copy(options.general, 'showAdvanced', options, 'showAdvancedOptions');
|
||||||
|
|
||||||
copy(options.scanning, 'requireShift', options, 'holdShiftToScan');
|
copy(options.scanning, 'requireShift', options, 'holdShiftToScan');
|
||||||
copy(options.scanning, 'selectText', options, 'selectMatchedText');
|
copy(options.scanning, 'selectText', options, 'selectMatchedText');
|
||||||
copy(options.scanning, 'delay', options, 'scanDelay');
|
copy(options.scanning, 'delay', options, 'scanDelay');
|
||||||
copy(options.scanning, 'length', options, 'scanLength');
|
copy(options.scanning, 'length', options, 'scanLength');
|
||||||
|
|
||||||
options.anki.enable = options.ankiMethod === 'ankiconnect';
|
options.anki.enable = options.ankiMethod === 'ankiconnect';
|
||||||
|
|
||||||
copy(options.anki, 'tags', options, 'ankiCardTags');
|
copy(options.anki, 'tags', options, 'ankiCardTags');
|
||||||
copy(options.anki, 'sentenceExt', options, 'sentenceExtent');
|
copy(options.anki, 'sentenceExt', options, 'sentenceExtent');
|
||||||
copy(options.anki.terms, 'deck', options, 'ankiTermDeck');
|
copy(options.anki.terms, 'deck', options, 'ankiTermDeck');
|
||||||
copy(options.anki.terms, 'model', options, 'ankiTermModel');
|
copy(options.anki.terms, 'model', options, 'ankiTermModel');
|
||||||
copy(options.anki.terms, 'fields', options, 'ankiTermFields');
|
copy(options.anki.terms, 'fields', options, 'ankiTermFields');
|
||||||
copy(options.anki.kanji, 'deck', options, 'ankiKanjiDeck');
|
copy(options.anki.kanji, 'deck', options, 'ankiKanjiDeck');
|
||||||
copy(options.anki.kanji, 'model', options, 'ankiKanjiModel');
|
copy(options.anki.kanji, 'model', options, 'ankiKanjiModel');
|
||||||
copy(options.anki.kanji, 'fields', options, 'ankiKanjiFields');
|
copy(options.anki.kanji, 'fields', options, 'ankiKanjiFields');
|
||||||
},
|
|
||||||
|
for (const title in options.dictionaries) {
|
||||||
|
options.dictionaries[title].priority = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
if (options.version < fixups.length) {
|
if (options.version < fixups.length) {
|
||||||
|
@ -17,7 +17,13 @@ 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)))
|
+ 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>v."
|
+ " <small>v."
|
||||||
+ alias4(((helper = (helper = helpers.version || (depth0 != null ? depth0.version : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"version","hash":{},"data":data}) : helper)))
|
+ alias4(((helper = (helper = helpers.version || (depth0 != null ? depth0.version : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"version","hash":{},"data":data}) : helper)))
|
||||||
+ "</small></h4> -->\n <!-- </div> -->\n <!-- <div class=\"col-xs-4 text-right disabled\"> -->\n <!-- <button type=\"button\" class=\"dict-group-controls dict-delete btn btn-danger\">Delete</button> -->\n <!-- </div> -->\n <!-- </div> -->\n\n <div class=\"dict-delete-progress\">\n Dictionary data is being deleted, please be patient...\n <div class=\"progress\">\n <div class=\"progress-bar progress-bar-striped progress-bar-danger\" style=\"width: 0%\"></div>\n </div>\n </div>\n\n <div class=\"checkbox dict-group-controls "
|
+ "</small></h4> -->\n <!-- </div> -->\n <!-- <div class=\"col-xs-4 text-right disabled\"> -->\n <!-- <button type=\"button\" class=\"dict-group-controls dict-delete btn btn-danger\">Delete</button> -->\n <!-- </div> -->\n <!-- </div> -->\n\n <div class=\"dict-delete-progress\">\n Dictionary data is being deleted, please be patient...\n <div class=\"progress\">\n <div class=\"progress-bar progress-bar-striped progress-bar-danger\" style=\"width: 0%\"></div>\n </div>\n </div>\n\n <div class=\"form-group dict-group-controls\">\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)))
|
||||||
|
+ "\">Priority</label>\n <input type=\"number\" value=\""
|
||||||
|
+ alias4(((helper = (helper = helpers.priority || (depth0 != null ? depth0.priority : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"priority","hash":{},"data":data}) : helper)))
|
||||||
|
+ "\" id=\"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)))
|
||||||
|
+ "\" class=\"form-control dict-priority\">\n </div>\n <div class=\"checkbox dict-group-controls "
|
||||||
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.hasTerms : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.hasTerms : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
||||||
+ "\">\n <label><input type=\"checkbox\" class=\"dict-enable-terms\" "
|
+ "\">\n <label><input type=\"checkbox\" class=\"dict-enable-terms\" "
|
||||||
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.hasTerms : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.hasTerms : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
||||||
@ -173,7 +179,7 @@ templates['term-list.html'] = template({"1":function(container,depth0,helpers,pa
|
|||||||
+ " </ul>\n";
|
+ " </ul>\n";
|
||||||
},"6":function(container,depth0,helpers,partials,data) {
|
},"6":function(container,depth0,helpers,partials,data) {
|
||||||
var stack1, helper, options, buffer =
|
var stack1, helper, options, buffer =
|
||||||
" <li><span class=\"term-glossary-item\">";
|
" <li><span class=\"term-glossary-item\">";
|
||||||
stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper));
|
stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper));
|
||||||
if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
|
if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
|
||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
@ -182,7 +188,7 @@ templates['term-list.html'] = template({"1":function(container,depth0,helpers,pa
|
|||||||
return container.escapeExpression(container.lambda(depth0, depth0));
|
return container.escapeExpression(container.lambda(depth0, depth0));
|
||||||
},"9":function(container,depth0,helpers,partials,data) {
|
},"9":function(container,depth0,helpers,partials,data) {
|
||||||
var stack1, helper, options, buffer =
|
var stack1, helper, options, buffer =
|
||||||
" <div class=\"term-glossary-group term-glossary-item\">";
|
" <div class=\"term-glossary-group term-glossary-item\">";
|
||||||
stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper));
|
stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper));
|
||||||
if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
|
if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
|
||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
|
@ -123,7 +123,7 @@ function groupTermDefs(definitions) {
|
|||||||
reading: firstDef.reading,
|
reading: firstDef.reading,
|
||||||
reasons: firstDef.reasons,
|
reasons: firstDef.reasons,
|
||||||
score: groupDefs.reduce((x, y) => x > y ? x : y, Number.MIN_SAFE_INTEGER),
|
score: groupDefs.reduce((x, y) => x > y ? x : y, Number.MIN_SAFE_INTEGER),
|
||||||
source: firstDef.source,
|
source: firstDef.source
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ function formatField(field, definition, mode) {
|
|||||||
'reading',
|
'reading',
|
||||||
'sentence',
|
'sentence',
|
||||||
'tags',
|
'tags',
|
||||||
'url',
|
'url'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const marker of markers) {
|
for (const marker of markers) {
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group dict-group-controls">
|
||||||
|
<label for="dict-{{title}}">Priority</label>
|
||||||
|
<input type="number" value="{{priority}}" id="dict-{{title}}" class="form-control dict-priority">
|
||||||
|
</div>
|
||||||
<div class="checkbox dict-group-controls {{#unless hasTerms}}disabled{{/unless}}">
|
<div class="checkbox dict-group-controls {{#unless hasTerms}}disabled{{/unless}}">
|
||||||
<label><input type="checkbox" class="dict-enable-terms" {{#unless hasTerms}}disabled{{/unless}} {{#if enableTerms}}checked{{/if}}> Enable term search</label>
|
<label><input type="checkbox" class="dict-enable-terms" {{#unless hasTerms}}disabled{{/unless}} {{#if enableTerms}}checked{{/if}}> Enable term search</label>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user