75 lines
3.0 KiB
JavaScript
Raw Normal View History

import optionsService from "../../services/options.js";
import server from "../../services/server.js";
2019-10-20 10:00:18 +02:00
import toastService from "../../services/toast.js";
export default class ProtectedSessionOptions {
constructor() {
this.$spellCheckEnabled = $("#spell-check-enabled");
this.$spellCheckLanguageCode = $("#spell-check-language-code");
this.$spellCheckEnabled.change(() => {
const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" };
2019-10-20 10:00:18 +02:00
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
return false;
});
this.$spellCheckLanguageCode.change(() => {
const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() };
2019-10-20 10:00:18 +02:00
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
return false;
});
2019-11-03 17:59:11 +01:00
this.$protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
this.$protectedSessionTimeout.change(() => {
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
optionsService.reloadOptions();
2019-10-20 10:00:18 +02:00
toastService.showMessage("Options change have been saved.");
});
return false;
});
2019-11-03 17:59:11 +01:00
this.$noteRevisionsTimeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
this.$noteRevisionsTimeInterval.change(() => {
const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() };
2019-10-20 10:00:18 +02:00
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
return false;
});
2019-11-03 17:59:11 +01:00
this.$imageMaxWidthHeight = $("#image-max-width-height");
this.$imageJpegQuality = $("#image-jpeg-quality");
this.$imageMaxWidthHeight.change(() => {
const opts = { 'imageMaxWidthHeight': this.$imageMaxWidthHeight.val() };
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
return false;
});
this.$imageJpegQuality.change(() => {
const opts = { 'imageJpegQuality': this.$imageJpegQuality.val() };
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
return false;
});
}
optionsLoaded(options) {
this.$spellCheckEnabled.prop("checked", options['spellCheckEnabled'] === 'true');
this.$spellCheckLanguageCode.val(options['spellCheckLanguageCode']);
this.$protectedSessionTimeout.val(options['protectedSessionTimeout']);
this.$noteRevisionsTimeInterval.val(options['noteRevisionSnapshotTimeInterval']);
2019-11-03 17:59:11 +01:00
this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']);
this.$imageJpegQuality.val(options['imageJpegQuality']);
}
}