Add load on startup checkbox
This commit is contained in:
parent
53b63e8ddc
commit
03b02070b7
@ -19,18 +19,20 @@
|
|||||||
|
|
||||||
function optionsToForm(opts) {
|
function optionsToForm(opts) {
|
||||||
$('#scanLength').val(opts.scanLength);
|
$('#scanLength').val(opts.scanLength);
|
||||||
|
$('#loadOnStartup').prop('checked', opts.loadOnStartup);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formToOptions() {
|
function formToOptions() {
|
||||||
return sanitizeOptions({
|
return sanitizeOptions({
|
||||||
scanLength: $('#scanLength').val()
|
scanLength: $('#scanLength').val(),
|
||||||
|
loadOnStartup: $('#loadOnStartup').prop('checked')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#saveOptions').click(() => {
|
$('#saveOptions').click(() => {
|
||||||
const opt = formToOptions();
|
const opts = formToOptions();
|
||||||
const yomichan = chrome.extension.getBackgroundPage().yomichan;
|
const yomichan = chrome.extension.getBackgroundPage().yomichan;
|
||||||
saveOptions(() => yomichan.updateOptions(opts));
|
saveOptions(opts, () => yomichan.updateOptions(opts));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#resetOptions').click(() => {
|
$('#resetOptions').click(() => {
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
function sanitizeOptions(options) {
|
function sanitizeOptions(options) {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
scanLength: 20
|
scanLength: 20,
|
||||||
|
loadOnStartup: false
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in defaults) {
|
for (const key in defaults) {
|
||||||
|
@ -83,7 +83,7 @@ class Yomichan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateOptions(options) {
|
updateOptions(options) {
|
||||||
this.options = sanitizeOptions(options);
|
this.options = options;
|
||||||
Yomichan.notifyChange('options', this.options);
|
Yomichan.notifyChange('options', this.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,17 @@
|
|||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="scanLength" class="control-label col-sm-2">Scan length</label>
|
<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>
|
||||||
|
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
|
Loading…
Reference in New Issue
Block a user