32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
document.addEventListener('DOMContentLoaded', () => {
|
|
const toastEl = document.getElementById('appToast');
|
|
if (toastEl && window.bootstrap) {
|
|
const toast = new window.bootstrap.Toast(toastEl, { delay: 4200 });
|
|
toast.show();
|
|
}
|
|
|
|
if (window.location.hash === '#results') {
|
|
document.getElementById('results')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
}
|
|
|
|
document.querySelectorAll('[data-autosubmit="change"]').forEach((field) => {
|
|
field.addEventListener('change', () => {
|
|
if (field.form) {
|
|
field.form.requestSubmit();
|
|
}
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('[data-count-target]').forEach((field) => {
|
|
const counter = document.getElementById(field.dataset.countTarget || '');
|
|
if (!counter) {
|
|
return;
|
|
}
|
|
const update = () => {
|
|
counter.textContent = `${field.value.trim().length} chars`;
|
|
};
|
|
update();
|
|
field.addEventListener('input', update);
|
|
});
|
|
});
|