summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-06 21:02:31 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-06 21:02:31 -0700
commit03b02070b7b5ec14867c286c5aafc9f676ccea91 (patch)
treeb3d7241b9bf42e6dd62428af0381cdcbac298d2e /ext/bg
parent53b63e8ddcdfdb81990a0f406c92f2d3188e707d (diff)
Add load on startup checkbox
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/options-form.js8
-rw-r--r--ext/bg/js/options.js3
-rw-r--r--ext/bg/js/yomichan.js2
-rw-r--r--ext/bg/options.html12
4 files changed, 19 insertions, 6 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index adde147c..a495813d 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -19,18 +19,20 @@
function optionsToForm(opts) {
$('#scanLength').val(opts.scanLength);
+ $('#loadOnStartup').prop('checked', opts.loadOnStartup);
}
function formToOptions() {
return sanitizeOptions({
- scanLength: $('#scanLength').val()
+ scanLength: $('#scanLength').val(),
+ loadOnStartup: $('#loadOnStartup').prop('checked')
});
}
$('#saveOptions').click(() => {
- const opt = formToOptions();
+ const opts = formToOptions();
const yomichan = chrome.extension.getBackgroundPage().yomichan;
- saveOptions(() => yomichan.updateOptions(opts));
+ saveOptions(opts, () => yomichan.updateOptions(opts));
});
$('#resetOptions').click(() => {
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 4c1135d2..0ab33612 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -19,7 +19,8 @@
function sanitizeOptions(options) {
const defaults = {
- scanLength: 20
+ scanLength: 20,
+ loadOnStartup: false
};
for (const key in defaults) {
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index fe7007eb..05da4007 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -83,7 +83,7 @@ class Yomichan {
}
updateOptions(options) {
- this.options = sanitizeOptions(options);
+ this.options = options;
Yomichan.notifyChange('options', this.options);
}
diff --git a/ext/bg/options.html b/ext/bg/options.html
index f73162ec..fb908d04 100644
--- a/ext/bg/options.html
+++ b/ext/bg/options.html
@@ -15,7 +15,17 @@
<form class="form-horizontal">
<div class="form-group">
<label for="scanLength" class="control-label col-sm-2">Scan length</label>
- <div class="col-sm-10"><input type="number" value="1" min="1" id="scanLength" class="form-control"></div>
+ <div class="col-sm-10"><input type="number" value="20" min="1" id="scanLength" class="form-control"></div>
+ </div>
+
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-sm-10">
+ <div class="checkbox">
+ <label>
+ <input type="checkbox" id="loadOnStartup"> Load on startup
+ </label>
+ </div>
+ </div>
</div>
<div class="text-right">