PageSourceSearch

https://www.evansvillegov.org/egov/include/js/6.2_egov_mfa.js

js evansvillegov.org collected 2026-10-02 06:36:57 UTC 3,457 bytes, 114 lines download raw bytes

1var eGov_MfaClass = function() {
2	var objMfaBlock = {
3		init: function() {
4			this.countdown();
5			const inputs = document.querySelectorAll('.mfa-input-container input');
6			const form = (inputs.length > 0) ? inputs[0].form : null;
7
8			if (form === null) return;
9
10			const verifyBtn = form.querySelector('button.eGov_buttonLogin[type="submit"]');
11			const updateVerifyButton = () => {
12				if (verifyBtn) {
13					verifyBtn.disabled = !Array.from(inputs).every(input => /^\d$/.test(input.value));
14				}
15			};
16
17			if (inputs.length > 0) {
18				updateVerifyButton();
19
20				inputs.forEach((input, index) => {
21					// Move focus to the next input if a digit is entered
22					input.addEventListener('input', (e) => {
23						if (e.data && /^\d$/.test(e.data)) {
24							if (index < inputs.length - 1) {
25								inputs[index + 1].focus();
26							}
27						}
28						updateVerifyButton();
29					});
30
31					// Move focus to the previous input on Backspace if current is empty
32					input.addEventListener('keydown', (e) => {
33						if (e.key === 'Backspace' && input.value === '' && index > 0) {
34							inputs[index - 1].focus();
35						}
36					});
37				});
38
39				// Handle pasting the full code from clipboard
40				inputs[0].addEventListener('paste', (e) => {
41					const pasteData = e.clipboardData.getData('text').trim();
42					if (pasteData.length === inputs.length && /^\d+$/.test(pasteData)) {
43						e.preventDefault();
44						for (let i = 0; i < inputs.length; i++) {
45							inputs[i].value = pasteData[i];
46						}
47						// Optional: Focus the last input or submit
48						inputs[inputs.length - 1].focus();
49					}
50					updateVerifyButton();
51				});
52			}
53
54			// Form Check and Submit
55			form.addEventListener('submit', (e) => {
56				// Get desired function
57				const strLogin = e.submitter.innerHTML;
58				document.getElementById('login').value = strLogin;
59
60				// Combine all inputs into a single code string
61				if (inputs.length > 0) {
62					const mfaCode = Array.from(inputs).map(input => input.value).join('');
63					document.getElementById('nonce').value = mfaCode;
64
65					if (mfaCode.length === 6) {
66					} else {
67						alert('Please enter a complete 6-digit code.');
68						return false;
69					}
70				}
71			});
72		},
73		resend: function() {
74			const input = document.querySelectorAll('.mfa-input-container input')
75			document.getElementById('login').value = 'Resend Code';
76			input.forEach((input, index) => {
77				input.removeAttribute('required');
78			});
79			input[0].form.submit();
80		},
81		useRecovery: function() {
82			const input = document.querySelectorAll('.mfa-input-container input')
83			document.getElementById('login').value = 'Recovery Method';
84			input.forEach((input, index) => {
85				input.removeAttribute('required');
86			});
87			input[0].form.submit();
88		},
89		countdown: function() {
90			var o = document.getElementById('mfa-countdown');
91			if (o) {
92				var timer = o.innerHTML * 60;
93				let mfaCountdown = setInterval(function () {
94					minutes = parseInt(timer / 60, 10);
95					seconds = parseInt(timer % 60, 10);
96
97					minutes = minutes < 10 ? "0" + minutes : minutes;
98					seconds = seconds < 10 ? "0" + seconds : seconds;
99
100					o.innerHTML = minutes + ":" + seconds;
101					document.getElementById('mfa-countdown-container').style.display = '';
102
103					if (--timer < 0) {
104						clearInterval(mfaCountdown);
105						alert('The MFA code has expired. Please log in again.');
106						window.location.href = window.location.href;
107					}
108				}, 1000);
109			}
110		}
111	};
112
113	return objMfaBlock;
114};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.