51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
// Simple app.js for additional functionality
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Auto-dismiss alerts after 5 seconds
|
|
const alerts = document.querySelectorAll('.alert:not(.alert-info)');
|
|
alerts.forEach(function(alert) {
|
|
setTimeout(function() {
|
|
const bsAlert = new bootstrap.Alert(alert);
|
|
bsAlert.close();
|
|
}, 5000);
|
|
});
|
|
|
|
// Add loading state to forms
|
|
const forms = document.querySelectorAll('form');
|
|
forms.forEach(function(form) {
|
|
form.addEventListener('submit', function(e) {
|
|
const submitBtn = form.querySelector('button[type="submit"]');
|
|
if (submitBtn) {
|
|
submitBtn.disabled = true;
|
|
submitBtn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Przetwarzanie...';
|
|
}
|
|
});
|
|
});
|
|
|
|
// Code input - accept only numbers
|
|
const codeInput = document.getElementById('code');
|
|
if (codeInput) {
|
|
codeInput.addEventListener('keypress', function(e) {
|
|
// Allow only numbers
|
|
if (e.key < '0' || e.key > '9') {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
// Auto-submit when 6 digits entered
|
|
codeInput.addEventListener('input', function(e) {
|
|
if (this.value.length === 6) {
|
|
// Optional: auto-submit after 6 digits
|
|
// this.form.submit();
|
|
}
|
|
});
|
|
}
|
|
|
|
// Add smooth scroll behavior
|
|
document.documentElement.style.scrollBehavior = 'smooth';
|
|
});
|
|
|
|
// Console styling for verification code (if shown)
|
|
console.log('%cSystem Logowania 2FA', 'color: #667eea; font-size: 24px; font-weight: bold;');
|
|
console.log('%cAplikacja demonstracyjna', 'color: #666; font-size: 12px;');
|