add "get all from profile" feature
This commit is contained in:
@ -13,12 +13,13 @@
|
||||
<span class="fh">Enable autofill</span>
|
||||
<input name="enable" id="enable" type="checkbox" />
|
||||
</label>
|
||||
<button id="all-get-from-profile">Get all the data from my profile</button>
|
||||
<label class="item">
|
||||
<span class="fh">Your BahnCard 100 number</span><br />
|
||||
<span class="sh">The number on the front of your card starting with <span class="ms">7081</span>.</span><br>
|
||||
<input name="bcnum" id="bcnum" type="text" pattern="70814[0-9]{11}" required
|
||||
title="Your BahnCard number is 16 digits long and starts with 7081." />
|
||||
<button id="bcnum-get-from-profile">Get from profile (experimental)</button>
|
||||
<button id="bcnum-get-from-profile">Get from profile</button>
|
||||
</label>
|
||||
<label class="item">
|
||||
<span class="fh">Your date of birth</span><br>
|
||||
@ -32,15 +33,26 @@
|
||||
<fieldset>
|
||||
<legend>Address data</legend>
|
||||
<label class="item">
|
||||
<span class="fh">Title</span>
|
||||
<span class="fh">Appellation</span>
|
||||
<select name="title" id="title">
|
||||
<option value="">Please choose</option>
|
||||
<option value="mr">Mr</option>
|
||||
<option value="ms">Ms</option>
|
||||
<option value="HR">Mr</option>
|
||||
<option value="FR">Ms</option>
|
||||
<option value="NA">Neutral</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="item">
|
||||
<span class="fh">Name</span><br>
|
||||
<span class="fh">Title</span>
|
||||
<select name="title_addl" id="title_addl">
|
||||
<option value="">None</option>
|
||||
<option value="DR">Dr.</option>
|
||||
<option value="PD">Prof. Dr.</option>
|
||||
<option value="DD">Dr. Dr.</option>
|
||||
<option value="PDD">Prof. Dr. Dr.</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="item">
|
||||
<span class="fh">Given name</span><br>
|
||||
<input name="firstname" id="firstname" />
|
||||
</label>
|
||||
<label class="item">
|
||||
|
@ -78,6 +78,7 @@ async function saveOptions(ev) {
|
||||
let autoContinue = this.querySelector('#autocontinue').checked;
|
||||
let enable = this.querySelector('#enable').checked;
|
||||
let title = this.querySelector('#title').value;
|
||||
let title_addl = this.querySelector('#title_addl').value;
|
||||
let firstName = this.querySelector('#firstname').value;
|
||||
let surName = this.querySelector('#surname').value;
|
||||
let emailAddress = this.querySelector('#email').value;
|
||||
@ -96,6 +97,7 @@ async function saveOptions(ev) {
|
||||
autocontinue: autoContinue,
|
||||
enable: enable,
|
||||
addr__appellation: title,
|
||||
addr__title: title_addl,
|
||||
addr__firstName: firstName,
|
||||
addr__surName: surName,
|
||||
addr__email: emailAddress,
|
||||
@ -129,6 +131,7 @@ async function restoreOptions() {
|
||||
document.querySelector("#birthday").value = settings.bday || "";
|
||||
document.querySelector("#autocontinue").checked = settings.autocontinue || false;
|
||||
document.querySelector('#title').value = settings.addr__appellation || "";
|
||||
document.querySelector('#title_addl').value = settings.addr__title || "";
|
||||
document.querySelector('#firstname').value = settings.addr__firstName || "";
|
||||
document.querySelector('#surname').value = settings.addr__surName || "";
|
||||
document.querySelector('#email').value = settings.addr__email || "";
|
||||
@ -147,7 +150,6 @@ function startBcnumAcquisition(ev) {
|
||||
console.log(changes);
|
||||
for (const [key, changeSet] of Object.entries(changes)) {
|
||||
if (key === "bcnum") {
|
||||
bahncardWindow.close();
|
||||
browser.storage.sync.onChanged.removeListener(this);
|
||||
}
|
||||
}
|
||||
@ -158,7 +160,24 @@ function startBcnumAcquisition(ev) {
|
||||
}
|
||||
})
|
||||
}
|
||||
function startAllAcquisition(ev) {
|
||||
browser.storage.sync.set({"acquireAll":true}).then(() => {
|
||||
browser.storage.sync.onChanged.addListener(changes => {
|
||||
console.log(changes);
|
||||
for(const [key, changeSet] of Object.entries(changes)){
|
||||
if (key === "acquireAll"){
|
||||
document.location.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
bahncardWindow = window.open("https://www.bahn.de/buchung/kundenkonto/bahncard", "_blank", "popup")
|
||||
if (bahncardWindow instanceof Window) {
|
||||
bahncardWindow.postMessage("__WINDOW_OPENED_FOR_BC_ACQUISITION__");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
document.querySelector("#bcnum-get-from-profile").addEventListener("click", startBcnumAcquisition)
|
||||
document.querySelector("#bcnum-get-from-profile").addEventListener("click", startBcnumAcquisition)
|
||||
document.querySelector("#all-get-from-profile").addEventListener("click", startAllAcquisition)
|
@ -49,4 +49,12 @@ input:focus {
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#all-get-from-profile {
|
||||
width:100%;
|
||||
min-height:2rem;
|
||||
text-align: center;
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
}
|
Reference in New Issue
Block a user