silencing changelogs now available

This commit is contained in:
iw0 2024-05-29 13:47:08 +02:00
parent d9c2c818f1
commit 8c79c437c9
4 changed files with 43 additions and 4 deletions

View File

@ -5,10 +5,19 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BC100 Autofill :: Changelog</title>
</head>
<style>
.headline * {
display: inline;
}
</style>
<script src="changelog.js"></script>
</head>
<body>
<div class="headline">
<h1>BC100 Autofill has been updated</h1>
<button id="stop-it">Don't show this again</button>
</div>
<h2>New feature since v0.2.1:</h2>
<ul>
<li>You can now choose which disruption to enter by default:
@ -19,6 +28,8 @@
</ul>
</li>
</ul>
<h3>Go to settings to configure the new features</h3>
<p><button id="opensettings">Settings</button></p>
</body>
</html>

10
changelog.js Normal file
View File

@ -0,0 +1,10 @@
document.addEventListener("DOMContentLoaded",
ev => {
document.querySelector("#stop-it").addEventListener("click",
() => browser.storage.sync.set({"showChangelog": false})
);
document.querySelector("#opensettings").addEventListener("click",
() => browser.runtime.openOptionsPage()
);
}
);

View File

@ -365,6 +365,13 @@
<input name="bic" id="bic" />
</label>
</fieldset>
<fieldset>
<legend>Miscellaneous</legend>
<label class="item">
<span class="fh">Show me information about updates</span>
<input type="checkbox" id="showChangelog" name="showChangelog" />
</label>
</fieldset>
<div class="item"><button type="submit">Save</button><span id="success"></span></div>
<p id="errors"></p>
</form>

View File

@ -87,6 +87,7 @@ async function saveOptions(ev) {
let placeName = this.querySelector('#placename').value;
let iban = this.querySelector('#iban').value.replaceAll(" ", "");
let country = this.querySelector("#country").value;
let allowChangelogMessages = this.querySelector("#showChangelog").checked;
if (iban != "" && !ibanValidate(iban)) {
putError("Please check your IBAN for typing errors.");
return;
@ -107,7 +108,8 @@ async function saveOptions(ev) {
addr__placename: placeName,
addr__country: country,
pymt__iban: iban,
pymt__bic: bic
pymt__bic: bic,
showChangelog: allowChangelogMessages,
};
options = Object.fromEntries(Object.entries(options).filter(([k, v]) => v !== ""))
console.info("saving", options);
@ -121,6 +123,13 @@ async function saveOptions(ev) {
}
function boolDefaultTrue(dict, key){
if (key in dict){
return dict[key];
}
return true;
}
async function restoreOptions() {
// We do not save user data in managed storage.
// let res = await browser.storage.managed.get('colour');
@ -128,7 +137,8 @@ async function restoreOptions() {
let settings = await browser.storage.sync.get();
console.info("restoring", settings);
document.querySelector('#enable').checked = settings.enable || true;
document.querySelector('#enable').checked = boolDefaultTrue(settings, "enable");
document.querySelector("#bcnum").value = settings.bcnum || "";
document.querySelector("#birthday").value = settings.bday || "";
document.querySelector("#default_action").value = settings.defaultAction || "";
@ -143,6 +153,7 @@ async function restoreOptions() {
document.querySelector('#country').value = settings.addr__country || "";
document.querySelector('#iban').value = settings.pymt__iban || "";
document.querySelector('#bic').value = settings.pymt__bic || "";
document.querySelector('#showChangelog').checked = boolDefaultTrue(settings, "showChangelog");
}
let bahncardWindow;