experiment: acquire bc number from account
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
<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>
|
||||
</label>
|
||||
<label class="item">
|
||||
<span class="fh">Your date of birth</span><br>
|
||||
|
@ -1,3 +1,4 @@
|
||||
"use strict;"
|
||||
function luhnValidate(cardNumber) {
|
||||
cardNumber = String(cardNumber).replace(/[\s]/g, "");
|
||||
let odd = false;
|
||||
@ -37,7 +38,7 @@ async function saveOptions(ev) {
|
||||
clearError();
|
||||
ev.preventDefault();
|
||||
let bcNum = this.querySelector("#bcnum").value;
|
||||
if (!bcNum.length == 16 || !bcNum.startsWith("70814") || !luhnValidate(bcNum)) {
|
||||
if (bcNum.length !== 16 || !bcNum.startsWith("70814") || !luhnValidate(bcNum)) {
|
||||
putError("Your BahnCard number is not valid. Please make sure you haven't made any typos.");
|
||||
return;
|
||||
}
|
||||
@ -75,5 +76,15 @@ async function restoreOptions() {
|
||||
document.querySelector("#autocontinue").checked = settings.autocontinue || false;
|
||||
}
|
||||
|
||||
function startBcnumAcquisition(ev) {
|
||||
browser.storage.sync.set({"acquireBahncard":true}).then(() => {
|
||||
win = window.open("https://www.bahn.de/buchung/kundenkonto/bahncard", "_blank", "popup")
|
||||
if (win instanceof Window){
|
||||
win.postMessage("__WINDOW_OPENED_FOR_BC_ACQUISITION__");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
document.querySelector("#bcnum-get-from-profile").addEventListener("click", startBcnumAcquisition)
|
Reference in New Issue
Block a user