summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-06 18:58:00 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-06 18:58:00 -0800
commit7fa51d682f29fbf51ed1228ca8840ff60be48e5e (patch)
tree12312aff5a7b59afd3c23ec5eaae1d56f568bd32 /ext/bg/js
parent73c7c225f11b9a1da550b9b866f106b188bd82ea (diff)
More work on options
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/options-form.js23
-rw-r--r--ext/bg/js/templates.js2
2 files changed, 21 insertions, 4 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index f9346d7d..9919031a 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -91,7 +91,7 @@ function getFormValues() {
optsNew.ankiKanjiModel = $('#anki-kanji-model').val();
optsNew.ankiKanjiFields = fieldsToDict($('#kanji .anki-field-value'));
- $('.dictionary').each((index, element) => {
+ $('.dict').each((index, element) => {
const dictionary = $(element);
const name = dictionary.data('name');
const enableTerms = dictionary.find('.dict-enable-terms').prop('checked');
@@ -163,7 +163,7 @@ function populateAnkiDeckAndModel(opts) {
}
function populateDictionaries(opts) {
- const container = $('.dictionaries');
+ const container = $('.dicts');
container.empty();
yomichan().translator.dictionary.getInfo().then(rows => {
@@ -181,7 +181,7 @@ function populateDictionaries(opts) {
container.append($(html));
});
- container.find('.dictionary input').change(onOptionsChanged);
+ container.find('.dict input').change(onOptionsChanged);
});
}
@@ -289,6 +289,23 @@ $(document).ready(() => {
$('input, select').not('.anki-model').change(onOptionsChanged);
$('.anki-model').change(onAnkiModelChanged);
+ $('#dict-import a').click(e => {
+ e.preventDefault();
+ const control = $('#dict-import-url');
+ const url = $(e.target).data('url');
+ if (url.includes('/')) {
+ control.val(url);
+ } else {
+ control.val(chrome.extension.getURL(`bg/data/${url}`));
+ }
+ control.trigger('change');
+ });
+
+ $('#dict-import-url').on('change keyup paste', () => {
+ const disable = $('#dict-import-url').val().trim().length === 0;
+ $('#dict-import-start').prop('disabled', disable);
+ });
+
populateDictionaries(opts);
populateAnkiDeckAndModel(opts);
updateVisibility(opts);
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index fe4d95ca..2caf6ba8 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -7,7 +7,7 @@ templates['dictionary.html'] = template({"1":function(container,depth0,helpers,p
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
- return "<div class=\"dictionary well well-sm\" data-name=\""
+ return "<div class=\"dict well well-sm\" data-name=\""
+ 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 <div class=\"row\">\n <div class=\"col-xs-8\">\n <h4><span class=\"text-muted glyphicon glyphicon-book\"></span> "
+ 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)))