PageSourceSearch

https://pskcs.org/admin/javascript/signin-script.js

js pskcs.org collected 2026-09-28 18:49:35 UTC 38,111 bytes, 1,017 lines download raw bytes

1(function (window, document) {
2    'use strict';
3
4    function qs(selector, root) {
5        return (root || document).querySelector(selector);
6    }
7
8    function qsa(selector, root) {
9        return Array.prototype.slice.call((root || document).querySelectorAll(selector));
10    }
11
12    function addClass(el, className) {
13        if (el && el.classList) {
14            el.classList.add(className);
15        }
16    }
17
18    function removeClass(el, className) {
19        if (el && el.classList) {
20            el.classList.remove(className);
21        }
22    }
23
24    function hasClass(el, className) {
25        return !!(el && el.classList && el.classList.contains(className));
26    }
27
28    function on(el, eventName, handler) {
29        if (el) {
30            el.addEventListener(eventName, handler);
31        }
32    }
33
34    function getClosest(element, selector) {
35        if (!element) {
36            return null;
37        }
38        if (typeof element.closest === 'function') {
39            return element.closest(selector);
40        }
41        var current = element;
42        while (current && current !== document) {
43            if (current.matches && current.matches(selector)) {
44                return current;
45            }
46            current = current.parentNode;
47        }
48        return null;
49    }
50
51    function each(elements, callback) {
52        for (var i = 0; i < elements.length; i++) {
53            callback(elements[i], i);
54        }
55    }
56
57    function getFormValue(form, fieldName) {
58        return form && form[fieldName] ? form[fieldName].value : '';
59    }
60
61    function setFormValue(form, fieldName, value) {
62        if (form && form[fieldName] != null) {
63            form[fieldName].value = value;
64        }
65    }
66
67    function getCookie(name) {
68        var dc = document.cookie;
69        var prefix = name + '=';
70        var begin = dc.indexOf('; ' + prefix);
71        if (begin === -1) {
72            begin = dc.indexOf(prefix);
73            if (begin !== 0) {
74                return null;
75            }
76        } else {
77            begin += 2;
78        }
79        var end = document.cookie.indexOf(';', begin);
80        if (end === -1) {
81            end = dc.length;
82        }
83        return unescape(dc.substring(begin + prefix.length, end));
84    }
85
86    function deleteCookie(name) {
87        if (getCookie(name)) {
88            document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:00 GMT; path=/';
89        }
90    }
91
92    function expireCookie(cookieName) {
93        var cookieDate = new Date();
94        cookieDate.setTime(cookieDate.getTime() - 1);
95        document.cookie = cookieName + "=; expires='" + cookieDate.toGMTString() + "'; path=/";
96    }
97
98    function getURLParameter(name) {
99        return unescape((RegExp(name + '=' + '(.+?)(&|$)').exec(window.location.search) || [, null])[1]);
100    }
101
102    function setPageLocale(locale) {
103        var current = String(window.location);
104        var rlpos = current.indexOf('request_locale=');
105        var afterPart = '';
106        if (rlpos > 0) {
107            var afterBegin = current.indexOf('&', rlpos);
108            if (afterBegin > 0) {
109                afterPart = current.substring(afterBegin);
110            }
111            current = current.substring(0, rlpos - 1);
112        }
113        var separator = current.indexOf('?') > 0 ? '&' : '?';
114        window.location = current + separator + 'request_locale=' + locale + afterPart;
115    }
116
117    function translatorRole() {
118        var translator = getURLParameter('translator');
119        var translatorInput = qs('#translatorInput');
120        if (translatorInput) {
121            translatorInput.style.display = translator === 'true' ? '' : 'none';
122        }
123
124        each(qsa('a.popWin'), function (anchor) {
125            on(anchor, 'click', function (e) {
126                e.preventDefault();
127                var winURL = anchor.getAttribute('href');
128                if (!winURL) {
129                    return;
130                }
131                window.open(winURL);
132            });
133        });
134    }
135
136    function doAdminLogin(form) {
137        var pw = getFormValue(form, 'password');
138        if (form && form.ldappassword != null) {
139            form.ldappassword.value = pw;
140        }
141        return true;
142    }
143
144    function doTeacherLogin(form) {
145        var pw = getFormValue(form, 'password');
146        if (form && form.ldappassword != null) {
147            form.ldappassword.value = pw;
148        }
149
150        var translatorpw = getFormValue(form, 'translatorpw');
151        var i = translatorpw.indexOf(';');
152        if (i < 0) {
153            setFormValue(form, 'translator_username', translatorpw);
154            setFormValue(form, 'translator_password', '');
155        } else {
156            setFormValue(form, 'translator_username', translatorpw.substring(0, i));
157            translatorpw = translatorpw.substring(i + 1);
158            setFormValue(form, 'translator_password', translatorpw);
159            if (form && form.translator_ldappassword != null) {
160                form.translator_ldappassword.value = translatorpw;
161            }
162        }
163
164        return true;
165    }
166
167    function doPCASLogin(form) {
168        var originalpw = getFormValue(form, 'pw');
169        setFormValue(form, 'dbpw', originalpw);
170        if (form && form.ldappassword != null) {
171            form.ldappassword.value = originalpw;
172        }
173
174        var translatorpw = getFormValue(form, 'translatorpw');
175        var i = translatorpw.indexOf(';');
176        if (i < 0) {
177            setFormValue(form, 'translator_username', translatorpw);
178            setFormValue(form, 'translator_password', '');
179        } else {
180            setFormValue(form, 'translator_username', translatorpw.substring(0, i));
181            translatorpw = translatorpw.substring(i + 1);
182            setFormValue(form, 'translator_password', translatorpw);
183            if (form && form.translator_ldappassword != null) {
184                form.translator_ldappassword.value = translatorpw;
185            }
186        }
187
188        return true;
189    }
190
191    function encryptMultipleStudentsAccesPasswords() { return true; }
192    function encryptSingleStudentAccesPassword() { return true; }
193    function encryptGuardianPassword() { return true; }
194    function encryptGuardianPasswords() { return true; }
195    function encryptRecoverPasswords() { return true; }
196    function doChangePassword() { return true; }
197
198    function trim(stringToTrim) {
199        return String(stringToTrim).replace(/^\s+|\s+$/g, '');
200    }
201
202    function alertwindow(directory, alerttype, frn) {
203        window.open('/' + directory + '/alerts/' + alerttype + 'alert.html?frn=' + frn, 'alert', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=350,height=250');
204    }
205
206    function helpwindow(url) {
207        window.open(url, 'help', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=570,height=500');
208    }
209
210    function helptext(text) {
211        window.status = text;
212        return true;
213    }
214
215    function maxlength(field, maxlimit) {
216        if (field.value.length >= maxlimit) {
217            field.value = field.value.substring(0, maxlimit - 1);
218            return false;
219        }
220        return true;
221    }
222
223    function noNumbers(e) {
224        var keynum;
225        if (window.event) {
226            keynum = e.keyCode;
227        } else if (e.which) {
228            keynum = e.which;
229        }
230        var keychar = String.fromCharCode(keynum);
231        return !/\d/.test(keychar);
232    }
233
234    function onlyNumbers(e) {
235        return !noNumbers(e);
236    }
237
238    function initAdminPage() {
239        if (window !== window.top) {
240            window.top.location.href = window.location.href;
241        }
242
243        if (typeof window.isMobileUserAgent === 'function' && window.isMobileUserAgent()) {
244            if (typeof window.insertCss === 'function') {
245                window.insertCss('/scripts/mobile/mobile.css');
246            }
247        }
248        if (typeof window.removeMobileHomeCookie === 'function') {
249            window.removeMobileHomeCookie();
250        }
251
252        if (window.localStorage) {
253            var student = window.localStorage.getItem('lastSelectedStudentDcid');
254            if (student != null) {
255                window.localStorage.setItem('lastSession-lastSelectedStudentDcid', student);
256            } else {
257                window.localStorage.removeItem('lastSession-lastSelectedStudentDcid');
258            }
259
260            var staff = window.localStorage.getItem('lastSelectedSchoolStaffDcid');
261            if (staff != null) {
262                window.localStorage.setItem('lastSession-lastSelectedSchoolStaffDcid', staff);
263            } else {
264                window.localStorage.removeItem('lastSession-lastSelectedSchoolStaffDcid');
265            }
266
267            window.localStorage.removeItem('lastSelectedStudentDcid');
268            window.localStorage.removeItem('lastSelectedSchoolStaffDcid');
269        }
270
271        var noScript = qs('#noscript');
272        var loginInputs = qs('#login-inputs');
273        var fieldUsername = qs('#fieldUsername');
274        var btnEnter = qs('#btnEnter');
275        var spanServerVersion = qs('#spanServerVersion');
276        var loginServerDetails = qs('#login-server-details');
277        var externalIDP = qs('#externalIDP');
278        var loginTargetInput = qs('#loginTarget');
279        var loginForm = qs('#LoginForm');
280
281        if (noScript) {
282            noScript.style.display = 'none';
283        }
284        removeClass(loginInputs, 'hide');
285        if (fieldUsername) {
286            fieldUsername.focus();
287        }
288
289        on(btnEnter, 'click', function (e) {
290            e.preventDefault();
291            var form = document.forms.LoginForm;
292            if (doAdminLogin(form)) {
293                form.submit();
294            }
295        });
296
297        (function setupServerDetailsModal() {
298            var backdrop = null;
299            var lastFocusedElement = null;
300
301            function hasJqueryUiDialog() {
302                return !!(window.jQuery && window.jQuery.fn && typeof window.jQuery.fn.dialog === 'function');
303            }
304
305            function ensureBackdrop() {
306                if (backdrop) {
307                    return backdrop;
308                }
309                backdrop = document.createElement('div');
310                backdrop.id = 'login-server-details-backdrop';
311                backdrop.style.position = 'fixed';
312                backdrop.style.top = '0';
313                backdrop.style.right = '0';
314                backdrop.style.bottom = '0';
315                backdrop.style.left = '0';
316                backdrop.style.backgroundColor = 'rgba(0, 0, 0, 0.45)';
317                backdrop.style.zIndex = '9998';
318                backdrop.style.display = 'none';
319                document.body.appendChild(backdrop);
320                on(backdrop, 'click', closeServerDetails);
321                return backdrop;
322            }
323
324            function applyModalCardStyles() {
325                loginServerDetails.style.zIndex = '9999';
326                loginServerDetails.style.width = 'min(92vw, 560px)';
327                loginServerDetails.style.maxHeight = '80vh';
328                loginServerDetails.style.overflowY = 'auto';
329                loginServerDetails.style.padding = '16px 20px';
330                loginServerDetails.style.borderRadius = '8px';
331                loginServerDetails.style.border = '1px solid #d1d5db';
332                loginServerDetails.style.boxShadow = '0 10px 30px rgba(0, 0, 0, 0.35)';
333                loginServerDetails.style.backgroundColor = '#ffffff';
334                loginServerDetails.style.color = '#1f2937';
335                loginServerDetails.style.textAlign = 'left';
336            }
337
338            function clearFallbackModalStyles() {
339                loginServerDetails.style.position = '';
340                loginServerDetails.style.top = '';
341                loginServerDetails.style.left = '';
342                loginServerDetails.style.transform = '';
343                loginServerDetails.style.zIndex = '';
344                loginServerDetails.style.width = '';
345                loginServerDetails.style.maxHeight = '';
346                loginServerDetails.style.overflowY = '';
347                loginServerDetails.style.padding = '';
348                loginServerDetails.style.borderRadius = '';
349                loginServerDetails.style.border = '';
350                loginServerDetails.style.boxShadow = '';
351                loginServerDetails.style.backgroundColor = '';
352                loginServerDetails.style.color = '';
353                loginServerDetails.style.textAlign = '';
354            }
355
356            function centerAsModalCard() {
357                applyModalCardStyles();
358                loginServerDetails.style.position = 'fixed';
359                loginServerDetails.style.top = '50%';
360                loginServerDetails.style.left = '50%';
361                loginServerDetails.style.transform = 'translate(-50%, -50%)';
362                loginServerDetails.style.display = 'block';
363            }
364
365            function updateAriaState(isOpen) {
366                if (spanServerVersion) {
367                    spanServerVersion.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
368                }
369                if (loginServerDetails) {
370                    loginServerDetails.setAttribute('aria-hidden', isOpen ? 'false' : 'true');
371                }
372            }
373
374            function onEscToClose(e) {
375                if (e.key === 'Escape') {
376                    closeServerDetails();
377                }
378            }
379
380            function openServerDetails() {
381                if (!loginServerDetails) {
382                    return;
383                }
384
385                lastFocusedElement = document.activeElement;
386
387                if (hasJqueryUiDialog()) {
388                    clearFallbackModalStyles();
389                    var $dialog = window.jQuery(loginServerDetails);
390                    if (!$dialog.data('ui-dialog')) {
391                        $dialog.dialog({
392                            autoOpen: false,
393                            modal: true,
394                            title: 'Server Details',
395                            width: 400,
396                            resizable: false,
397                            draggable: false,
398                            closeOnEscape: true,
399                            open: function () {
400                                updateAriaState(true);
401                            },
402                            close: function () {
403                                updateAriaState(false);
404                                if (lastFocusedElement && typeof lastFocusedElement.focus === 'function') {
405                                    lastFocusedElement.focus();
406                                }
407                            }
408                        });
409                    }
410                    $dialog.dialog('open');
411                    return;
412                }
413
414                if (typeof loginServerDetails.showModal === 'function') {
415                    try {
416                        loginServerDetails.showModal();
417                        updateAriaState(true);
418                        return;
419                    } catch (ignored) {
420                        // Fallback to styled div modal behavior if dialog show fails.
421                    }
422                }
423
424                ensureBackdrop().style.display = 'block';
425                centerAsModalCard();
426                updateAriaState(true);
427                document.addEventListener('keydown', onEscToClose);
428            }
429
430            function closeServerDetails() {
431                if (!loginServerDetails) {
432                    return;
433                }
434
435                if (hasJqueryUiDialog()) {
436                    var $dialog = window.jQuery(loginServerDetails);
437                    if ($dialog.data('ui-dialog')) {
438                        $dialog.dialog('close');
439                        return;
440                    }
441                }
442
443                if (typeof loginServerDetails.close === 'function' && loginServerDetails.hasAttribute('open')) {
444                    loginServerDetails.close();
445                } else {
446                    loginServerDetails.style.display = 'none';
447                }
448
449                if (backdrop) {
450                    backdrop.style.display = 'none';
451                }
452                document.removeEventListener('keydown', onEscToClose);
453                updateAriaState(false);
454                if (lastFocusedElement && typeof lastFocusedElement.focus === 'function') {
455                    lastFocusedElement.focus();
456                }
457            }
458
459            on(spanServerVersion, 'click', function (e) {
460                openServerDetails();
461                if (e && e.detail > 0 && typeof spanServerVersion.blur === 'function') {
462                    // Clear pointer-triggered focus ring without impacting keyboard activation.
463                    spanServerVersion.blur();
464                }
465            });
466
467            on(loginServerDetails, 'cancel', function (e) {
468                e.preventDefault();
469                closeServerDetails();
470            });
471
472            on(loginServerDetails, 'close', function () {
473                closeServerDetails();
474            });
475        })();
476
477        if (loginTargetInput && externalIDP) {
478            var href = externalIDP.getAttribute('href');
479            if (href) {
480                var loginTarget = encodeURIComponent(loginTargetInput.value || '');
481                externalIDP.setAttribute('href', href + '?loginTarget=' + loginTarget);
482            }
483        }
484
485        on(loginForm, 'submit', function (e) {
486            if (!doAdminLogin(this)) {
487                e.preventDefault();
488            }
489        });
490    }
491
492    function initTeacherPage() {
493        if (typeof window.isMobileUserAgent === 'function' && window.isMobileUserAgent()) {
494            if (typeof window.insertCss === 'function') {
495                window.insertCss('/scripts/mobile/mobile.css');
496            }
497        }
498        if (typeof window.removeMobileHomeCookie === 'function') {
499            window.removeMobileHomeCookie();
500        }
501
502        translatorRole();
503        var noScript = qs('#noscript');
504        var loginInputs = qs('#login-inputs');
505        var fieldUsername = qs('#fieldUsername');
506        var loginForm = qs('#LoginForm');
507
508        if (noScript) {
509            noScript.style.display = 'none';
510        }
511        removeClass(loginInputs, 'hide');
512        if (fieldUsername) {
513            fieldUsername.focus();
514        }
515
516        on(loginForm, 'submit', function (e) {
517            var result = doTeacherLogin(this);
518            if (this.request_locale) {
519                document.cookie = 'request_locale=' + (this.request_locale.value || null);
520            }
521            if (!result) {
522                e.preventDefault();
523            }
524        });
525    }
526
527    function initSubstitutePage() {
528        if (typeof window.isMobileUserAgent === 'function' && window.isMobileUserAgent()) {
529            if (typeof window.insertCss === 'function') {
530                window.insertCss('/scripts/mobile/mobile.css');
531            }
532        }
533
534        var noScript = qs('#noscript');
535        var loginInputs = qs('#login-inputs');
536        var schoolSelect = qs('#schoolid');
537        var teacherSelect = qs('#teacher');
538
539        if (noScript) {
540            noScript.style.display = 'none';
541        }
542        removeClass(loginInputs, 'hide');
543        if (schoolSelect) {
544            schoolSelect.focus();
545        }
546
547        on(schoolSelect, 'change', function () {
548            if (typeof window.setMenu === 'function') {
549                window.setMenu(this);
550            }
551        });
552        on(teacherSelect, 'change', function () {
553            if (typeof window.setTeacher === 'function') {
554                window.setTeacher(this);
555            }
556        });
557    }
558
559    function parseBooleanValue(selector) {
560        var el = qs(selector);
561        return !!el && el.value === '1';
562    }
563
564    function initPublicHomePage() {
565        translatorRole();
566        var noScript = qs('#noscript');
567        var loginInputs = qs('#login-inputs');
568        var fieldAccount = qs('#fieldAccount');
569        var tabs = qs('#tabs');
570        var tabsContainer = qs('div.tabs');
571        var loginFieldset = qs('#login_fieldset');
572
573        if (noScript) {
574            noScript.style.display = 'none';
575        }
576        removeClass(loginInputs, 'hide');
577        if (fieldAccount) {
578            fieldAccount.focus();
579        }
580
581        var hidelogin = 0;
582        var samlEnabled = parseBooleanValue('#signin-saml-enabled');
583        var guardianSamlLogin = parseBooleanValue('#signin-guardian-saml-login');
584        var studentSamlLogin = parseBooleanValue('#signin-student-saml-login');
585        var guardianSpEnabled = parseBooleanValue('#signin-guardian-sp-enabled');
586        var studentSpEnabled = parseBooleanValue('#signin-student-sp-enabled');
587
588        if (samlEnabled) {
589            if (guardianSamlLogin) {
590                hidelogin++;
591                addClass(tabs, 'hide');
592            } else if (guardianSpEnabled) {
593                addClass(tabs, 'hide');
594            }
595
596            if (studentSamlLogin) {
597                hidelogin++;
598            } else if (studentSpEnabled) {
599                addClass(tabs, 'hide');
600            }
601        }
602
603        var hideLoginForm = Number(window.hideLoginForm || 0);
604        if (hideLoginForm === 0 && hidelogin <= 1) {
605            removeClass(loginFieldset, 'hide');
606        }
607
608        if (window.jQuery && window.jQuery.fn && typeof window.jQuery.fn.tabs === 'function' && tabsContainer) {
609            var tabLinks = qsa('ul li a[href^="#"]', tabsContainer);
610            if (tabLinks.length) {
611                window.jQuery(tabsContainer).tabs();
612            }
613        }
614
615        var loginTargetInput = qs('#loginTarget');
616        if (loginTargetInput) {
617            var studentSignIn = qs('#studentSignIn');
618            var parentSignIn = qs('#parentSignIn');
619            var loginHelpLink = qs('#loginHelpLink');
620            var studentHref = studentSignIn ? studentSignIn.getAttribute('href') : null;
621            var parentHref = parentSignIn ? parentSignIn.getAttribute('href') : null;
622            var loginHelpHref = loginHelpLink ? loginHelpLink.getAttribute('href') : null;
623
624            if ((loginTargetInput.value || '').includes('public/openid')) {
625                loginTargetInput.value = loginTargetInput.value.replace('public/openid', 'guardian/openid');
626            }
627            var loginTarget = encodeURIComponent(loginTargetInput.value || '');
628
629            if (studentHref) {
630                studentSignIn.setAttribute('href', studentHref + '&loginTarget=' + loginTarget);
631            }
632            if (parentHref) {
633                parentSignIn.setAttribute('href', parentHref + '&loginTarget=' + loginTarget);
634            }
635            if (loginHelpHref) {
636                loginHelpLink.setAttribute('href', loginHelpHref + '?loginTarget=' + loginTarget);
637            }
638        }
639
640        var loginForm = qs('#LoginForm');
641        on(loginForm, 'submit', function (e) {
642            if (!doPCASLogin(this)) {
643                e.preventDefault();
644            }
645        });
646    }
647
648    function initMfaVerifyPage() {
649        var inputs = qsa('.otp-digit');
650        var hiddenField = qs('#fieldTOTP');
651
652        if (!inputs.length || !hiddenField) {
653            return;
654        }
655
656        inputs[0].focus();
657
658        function updateHiddenField() {
659            var code = '';
660            each(inputs, function (input) {
661                code += input.value;
662            });
663            hiddenField.value = code;
664            if (code.length === 6) {
665                var errorDiv = document.getElementById('mfa-client-error');
666                if (errorDiv) {
667                    errorDiv.textContent = '';
668                    errorDiv.style.display = 'none';
669                }
670            }
671        }
672
673        each(inputs, function (input) {
674            on(input, 'input', function () {
675                var value = input.value;
676                if (!/^\d*$/.test(value)) {
677                    input.value = '';
678                    return;
679                }
680                if (value.length === 1) {
681                    var index = inputs.indexOf(input);
682                    if (index < inputs.length - 1) {
683                        inputs[index + 1].focus();
684                    }
685                }
686                updateHiddenField();
687            });
688
689            on(input, 'keydown', function (e) {
690                if (e.key === 'Backspace') {
691                    if (input.value === '') {
692                        var backIndex = inputs.indexOf(input);
693                        if (backIndex > 0) {
694                            e.preventDefault();
695                            inputs[backIndex - 1].focus();
696                            inputs[backIndex - 1].value = '';
697                            updateHiddenField();
698                        }
699                    } else {
700                        window.setTimeout(updateHiddenField, 10);
701                    }
702                } else if (e.key === 'ArrowLeft') {
703                    var leftIndex = inputs.indexOf(input);
704                    if (leftIndex > 0) {
705                        e.preventDefault();
706                        inputs[leftIndex - 1].focus();
707                    }
708                } else if (e.key === 'ArrowRight') {
709                    var rightIndex = inputs.indexOf(input);
710                    if (rightIndex < inputs.length - 1) {
711                        e.preventDefault();
712                        inputs[rightIndex + 1].focus();
713                    }
714                }
715            });
716
717            on(input, 'paste', function (e) {
718                e.preventDefault();
719                var clipboardData = e.clipboardData || (window.clipboardData ? window.clipboardData : null);
720                var pastedData = clipboardData && clipboardData.getData ? clipboardData.getData('text') : '';
721                var cleanedData = pastedData.replace(/\D/g, '').substring(0, 6);
722
723                if (cleanedData.length === 6) {
724                    for (var i = 0; i < 6; i++) {
725                        inputs[i].value = cleanedData[i];
726                    }
727                    inputs[inputs.length - 1].focus();
728                    updateHiddenField();
729                } else if (cleanedData.length > 0) {
730                    var currentIndex = inputs.indexOf(input);
731                    for (var j = 0; j < cleanedData.length && (currentIndex + j) < 6; j++) {
732                        inputs[currentIndex + j].value = cleanedData[j];
733                    }
734                    updateHiddenField();
735                    var nextIndex = Math.min(currentIndex + cleanedData.length, 5);
736                    inputs[nextIndex].focus();
737                }
738            });
739        });
740
741        each(qsa('form'), function (form) {
742            on(form, 'submit', function (e) {
743                updateHiddenField();
744                if (hiddenField.value.length !== 6) {
745                    e.preventDefault();
746                    var errorDiv = document.getElementById('mfa-client-error');
747                    var errorMsg = document.getElementById('mfa-error-message');
748                    if (errorDiv && errorMsg) {
749                        errorDiv.textContent = errorMsg.value;
750                        errorDiv.style.display = 'block';
751                    }
752                    inputs[0].focus();
753                    return false;
754                }
755                return true;
756            });
757        });
758    }
759
760    function initRecoverPasswordTabs(container, selectedTabFromServer) {
761        if (window.jQuery && window.jQuery.fn && typeof window.jQuery.fn.tabs === 'function') {
762            var activeIndex = selectedTabFromServer === 't2-content' ? 1 : 0;
763            var $container = window.jQuery(container);
764            $container.tabs({ active: activeIndex });
765            return {
766                activateTabById: function (targetId) {
767                    $container.tabs('option', 'active', targetId === 't2-content' ? 1 : 0);
768                },
769                useJqueryUiTabs: true
770            };
771        }
772
773        var tabLinks = qsa('ul li a[href^="#"]', container);
774        var tabPanels = qsa('[id$="-content"]', container);
775
776        if (!tabLinks.length || !tabPanels.length) {
777            return null;
778        }
779
780        function activateTabById(targetId) {
781            each(tabLinks, function (link) {
782                var href = link.getAttribute('href') || '';
783                if (href === '#' + targetId) {
784                    addClass(link.parentNode, 'active');
785                    link.setAttribute('aria-selected', 'true');
786                } else {
787                    removeClass(link.parentNode, 'active');
788                    link.setAttribute('aria-selected', 'false');
789                }
790            });
791
792            each(tabPanels, function (panel) {
793                if (panel.id === targetId) {
794                    removeClass(panel, 'hide');
795                    removeClass(panel, 'blank');
796                    panel.style.display = '';
797                } else {
798                    addClass(panel, 'hide');
799                    panel.style.display = 'none';
800                }
801            });
802        }
803
804        each(tabLinks, function (link) {
805            on(link, 'click', function (e) {
806                e.preventDefault();
807                var href = link.getAttribute('href') || '';
808                if (href.charAt(0) === '#') {
809                    activateTabById(href.substring(1));
810                }
811            });
812        });
813
814        var defaultId = selectedTabFromServer === 't2-content' ? 't2-content' : 't1-content';
815        activateTabById(defaultId);
816        return {
817            activateTabById: activateTabById
818        };
819    }
820
821    function initRecoverPasswordPage() {
822        var noScript = qs('#noscript');
823        if (noScript) {
824            noScript.style.display = 'none';
825        }
826
827        var selectedTabFromServer = (qs('#selectedTabServer') ? qs('#selectedTabServer').value : '') || '';
828        var tabs = qs('.tabs');
829
830        function setSelectedTab(tabId) {
831            var form = qs('#myForm');
832            if (form && form.selectedTab) {
833                form.selectedTab.value = tabId;
834            }
835        }
836
837        var tabApi = tabs ? initRecoverPasswordTabs(tabs, selectedTabFromServer) : null;
838        if (tabApi) {
839            var selectedTabId = selectedTabFromServer === 't2-content' ? 't2-content' : 't1-content';
840            tabApi.activateTabById(selectedTabId);
841            setSelectedTab(selectedTabId);
842
843            if (tabApi.useJqueryUiTabs) {
844                if (window.jQuery && window.jQuery.fn && typeof window.jQuery.fn.tabs === 'function') {
845                    window.jQuery(tabs).on('tabsactivate', function (event, ui) {
846                        var newId = ui && ui.newPanel && ui.newPanel.attr ? ui.newPanel.attr('id') : '';
847                        if (!newId) {
848                            return;
849                        }
850
851                        var errorContainer = qs('#error-container');
852                        if (errorContainer) {
853                            errorContainer.className = (newId === selectedTabFromServer) ? 'show' : 'hide';
854                        }
855                        setSelectedTab(newId);
856                    });
857                }
858            } else {
859
860                each(qsa('ul li a[href^="#"]', tabs), function (link) {
861                    on(link, 'click', function () {
862                        var href = link.getAttribute('href') || '';
863                        if (href.charAt(0) !== '#') {
864                            return;
865                        }
866                        var newId = href.substring(1);
867
868                        var errorContainer = qs('#error-container');
869                        if (errorContainer) {
870                            errorContainer.className = (newId === selectedTabFromServer) ? 'show' : 'hide';
871                        }
872                        setSelectedTab(newId);
873                    });
874                });
875            }
876        }
877
878        var tabsContainer = qs('#tabs');
879        removeClass(tabsContainer, 'hide');
880        removeClass(tabsContainer, 'blank');
881
882        on(qs('#myForm_emailAddressForUsername'), 'keydown', function (e) {
883            if (e.keyCode === 13) {
884                var myForm = qs('#myForm');
885                if (myForm) {
886                    myForm.submit();
887                }
888                e.preventDefault();
889                return false;
890            }
891            return true;
892        });
893    }
894
895    function initCreateAccountPage() {
896        each(qsa('input[name="suggestedUsername"]'), function (radio) {
897            on(radio, 'change', function () {
898                var usernameInput = qs('#myForm_accountInfo_username');
899                if (usernameInput) {
900                    usernameInput.value = radio.value;
901                }
902            });
903        });
904
905        on(qs('#myForm_accountInfo_password'), 'keyup', function () {
906            if (typeof window.checkPasswordStrength === 'function') {
907                window.checkPasswordStrength(this.value, 'password-strength-meter');
908            }
909        });
910    }
911
912    function initPasswordToggles(root) {
913        each(qsa('.pw-toggle', root || document), function (button) {
914            if (button.getAttribute('data-pw-toggle-ready') === '1') {
915                return;
916            }
917
918            var targetId = button.getAttribute('data-pw-target');
919            var input = targetId ? document.getElementById(targetId) : null;
920            if (!input) {
921                return;
922            }
923
924            var showLabel = button.getAttribute('data-show-label') || 'Show password';
925            var hideLabel = button.getAttribute('data-hide-label') || 'Hide password';
926
927            function setState(revealed) {
928                // Changing the type keeps the entered value and the field name intact,
929                // so login submit handlers still read the same field.
930                input.type = revealed ? 'text' : 'password';
931                button.setAttribute('aria-pressed', revealed ? 'true' : 'false');
932                button.setAttribute('aria-label', revealed ? hideLabel : showLabel);
933                button.setAttribute('title', revealed ? hideLabel : showLabel);
934            }
935
936            setState(false);
937
938            on(button, 'click', function (e) {
939                e.preventDefault();
940                var revealed = input.type === 'password';
941                setState(revealed);
942                input.focus();
943            });
944
945            button.setAttribute('data-pw-toggle-ready', '1');
946        });
947    }
948
949    function initCommonSigninFeatures() {
950        expireCookie('InformAuthToken');
951        initPasswordToggles(document);
952    }
953
954    function initByPage() {
955        initCommonSigninFeatures();
956
957        var body = document.body;
958        var bodyId = body ? body.id : '';
959
960        if (bodyId === 'adminlogin') {
961            initAdminPage();
962        } else if (bodyId === 'teacherlogin') {
963            if (qs('#schoolid')) {
964                initSubstitutePage();
965            } else {
966                initTeacherPage();
967            }
968        } else if (bodyId === 'pslogin' && qs('#fieldAccount')) {
969            initPublicHomePage();
970        } else if (bodyId === 'recover-password') {
971            initRecoverPasswordPage();
972        } else if (bodyId === 'parent-create') {
973            initCreateAccountPage();
974        } else if (qs('#fieldTOTP')) {
975            initMfaVerifyPage();
976        }
977    }
978
979    window.getURLParameter = getURLParameter;
980    window.setPageLocale = setPageLocale;
981    window.translatorRole = translatorRole;
982    window.initPasswordToggles = initPasswordToggles;
983    window.doAdminLogin = doAdminLogin;
984    window.doTeacherLogin = doTeacherLogin;
985    window.doPCASLogin = doPCASLogin;
986    window.encryptMultipleStudentsAccesPasswords = encryptMultipleStudentsAccesPasswords;
987    window.encryptSingleStudentAccesPassword = encryptSingleStudentAccesPassword;
988    window.encryptGuardianPassword = encryptGuardianPassword;
989    window.encryptGuardianPasswords = encryptGuardianPasswords;
990    window.encryptRecoverPasswords = encryptRecoverPasswords;
991    window.doChangePassword = doChangePassword;
992    window.getCookie = getCookie;
993    window.deleteCookie = deleteCookie;
994    window.trim = trim;
995    window.alertwindow = alertwindow;
996    window.helpwindow = helpwindow;
997    window.helptext = helptext;
998    window.maxlength = maxlength;
999    window.noNumbers = noNumbers;
1000    window.onlyNumbers = onlyNumbers;
1001    // Preserve legacy compatibility: expose $j when jQuery is already present.
1002    if (!window.$j && window.jQuery) {
1003        window.$j = window.jQuery;
1004    }
1005    window.psEnter = function () {
1006        var form = document.forms.LoginForm;
1007        if (doAdminLogin(form)) {
1008            form.submit();
1009        }
1010    };
1011
1012    if (document.readyState === 'loading') {
1013        document.addEventListener('DOMContentLoaded', initByPage);
1014    } else {
1015        initByPage();
1016    }
1017})(window, document);

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.