document.querySelectorAll('.email-input').forEach(input => { input.addEventListener('input', function () { if (/^\S+@\S+\.\S+$/.test(this.value)) { this.classList.remove('is-invalid'); } else { this.classList.add('is-invalid'); } }); }); document.addEventListener('DOMContentLoaded', function () { var dropdownItems = document.querySelectorAll('.culture-dropdown-item'); dropdownItems.forEach(function (item) { item.addEventListener('click', async function(event) { event.preventDefault(); var language = this.getAttribute('data-language'); var flagCode = this.getAttribute('data-flag'); document.getElementById('selectedFlag').className = 'fi ' + flagCode + ' me-2'; await setLanguage(language); }); }); }); document.getElementById('readonly-send').addEventListener('click', async () => { const receiverMail = document.getElementById('readonly-receiver-mail'); const dateValid = document.getElementById('readonly-date-valid'); const receiverMail_value = receiverMail.value; const dateValid_value = dateValid.value; //check email if (!receiverMail_value || receiverMail.classList.contains('is-invalid')) { Swal.fire({ icon: "error", title: "Falsche Email", text: "Die E-Mail-Adresse ist ungültig. Bitte verwenden Sie das richtige Format, z. B.: user@mail.com." }); return; } //check the date const tomorrow = new Date(Date.now() + 86400000); if (new Date(dateValid_value) < tomorrow) { Swal.fire({ icon: "error", title: "Falsches Datum", text: "Die Verteilung der Umschläge sollte mindestens einen Tag dauern." }); return; } shareEnvelope(receiverMail_value, dateValid_value) .then(res => { if (res.ok) { Swal.fire({ title: "Gesendet", icon: "success" }); } else { Swal.fire({ icon: "error", title: `Fehler ${res.status}`, text: "Der Vorgang ist fehlgeschlagen. Bitte wenden Sie sich an das IT-Team." }); } }) .catch(err => { Swal.fire({ icon: "error", title: "Unerwarteter Fehler", text: "Der Vorgang ist fehlgeschlagen. Bitte wenden Sie sich an das IT-Team." }); }) receiverMail.value = ''; dateValid.valueAsDate = new Date(new Date().setDate(new Date().getDate() + 8)); }); $('#geoloc').leafletLocationPicker({ alwaysOpen: true, mapContainer: "#fixedMapCont" }); const bsNotify = (message, options) => alertify.notify( ``, 'custom', options?.delay ?? 5); class Comp { static ActPanel = class { static __Root; static get Root() { Comp.ActPanel.__Root ??= document.getElementById("flex-action-panel") return Comp.ActPanel.__Root } static get Elements() { return [...Comp.ActPanel.Root.children] } static get IsHided() { return Comp.ActPanel.Root.style.display == 'none'; } /** * @param {string} value */ static set Display(value) { Comp.ActPanel.Root.style.display = value Comp.ActPanel.Elements.forEach(e => e.style.display = value); } static Toggle() { Comp.ActPanel.Display = Comp.ActPanel.IsHided ? '' : 'none' } } static SignatureProgress = class { static __SignatureCount; static get SignatureCount() { this.__SignatureCount = parseInt(document.getElementById("signature-count").innerText); return this.__SignatureCount; } static __SignedCountSpan; static get SignedCountSpan() { this.__SignedCountSpan ??= document.getElementById("signed-count"); return Comp.SignatureProgress.__SignedCountSpan; } static __signedCount = 0; static get SignedCount() { return this.__signedCount; } static set SignedCount(value) { this.__signedCount = value; const width = (value / this.SignatureCount) * 100; this.SignedCountBar.style.setProperty('--progress-width', width + '%'); this.SignedCountSpan.innerText = value.toString(); } static __SignedCountBar; static get SignedCountBar() { this.__SignedCountBar ??= document.getElementById("signed-count-bar"); return this.__SignedCountBar; } } static __ShareBackdrop; static get ShareBackdrop() { Comp.__ShareBackdrop ??= new bootstrap.Modal(document.getElementById('shareBackdrop')); return this.__ShareBackdrop; } static __LocationBackdrop; static get LocationBackdrop() { Comp.__LocationBackdrop ??= new bootstrap.Modal(document.getElementById('locationBackdrop')); return this.__LocationBackdrop; } }