PageSourceSearch

https://www.sammu.uz/new/assets/js/admission.js?v=1.0.65

js sammu.uz collected 2026-09-24 09:03:28 UTC 4,219 bytes, 148 lines download raw bytes

1(function () {
2    "use strict";
3
4    function initCascade() {
5        var typeEl = document.getElementById('admission-type');
6        var dirEl = document.getElementById('admission-direction');
7        if (!typeEl || !dirEl) {
8            return;
9        }
10
11        var all = Array.prototype.slice.call(dirEl.querySelectorAll('option')).map(function (o) {
12            return {
13                value: o.value,
14                text: o.textContent,
15                type: o.getAttribute('data-type'),
16                prompt: o.value === ''
17            };
18        });
19
20        function render(keepValue) {
21            var t = typeEl.value;
22            var current = keepValue ? dirEl.value : '';
23            dirEl.innerHTML = '';
24
25            all.forEach(function (o) {
26                if (o.prompt || o.type === t) {
27                    var opt = document.createElement('option');
28                    opt.value = o.value;
29                    opt.textContent = o.text;
30                    if (o.type) {
31                        opt.setAttribute('data-type', o.type);
32                    }
33                    if (o.value === current && current !== '') {
34                        opt.selected = true;
35                    }
36                    dirEl.appendChild(opt);
37                }
38            });
39
40            if (!t) {
41                dirEl.value = '';
42                dirEl.setAttribute('disabled', 'disabled');
43            } else {
44                dirEl.removeAttribute('disabled');
45            }
46        }
47
48        typeEl.addEventListener('change', function () {
49            render(false);
50        });
51
52        render(true);
53    }
54
55    function localDigits(value) {
56        var d = value.replace(/\D/g, '');
57        if (d.indexOf('998') === 0) {
58            d = d.slice(3);
59        }
60        return d.slice(0, 9);
61    }
62
63    function formatPhone(value) {
64        var d = localDigits(value);
65        var out = '+998';
66        if (d.length > 0) {
67            out += ' (' + d.slice(0, 2);
68        }
69        if (d.length >= 2) {
70            out += ')';
71        }
72        if (d.length > 2) {
73            out += ' ' + d.slice(2, 5);
74        }
75        if (d.length > 5) {
76            out += '-' + d.slice(5, 7);
77        }
78        if (d.length > 7) {
79            out += '-' + d.slice(7, 9);
80        }
81        return out;
82    }
83
84    function initPhoneMask() {
85        var fields = document.querySelectorAll('.js-phone');
86        Array.prototype.forEach.call(fields, function (el) {
87            el.addEventListener('focus', function () {
88                if (el.value.trim() === '') {
89                    el.value = '+998 ';
90                }
91            });
92            el.addEventListener('input', function () {
93                el.value = formatPhone(el.value);
94            });
95            el.addEventListener('blur', function () {
96                if (localDigits(el.value).length === 0) {
97                    el.value = '';
98                }
99            });
100            if (el.value.trim() !== '') {
101                el.value = formatPhone(el.value);
102            }
103        });
104    }
105
106    function setBusy() {
107        var form = document.getElementById('admission-form');
108        if (!form) {
109            return;
110        }
111        var btn = form.querySelector('.admission-submit');
112        if (!btn) {
113            return;
114        }
115        var busy = btn.getAttribute('data-disabled-text');
116        if (busy) {
117            btn.textContent = busy;
118        }
119        btn.classList.add('is-loading');
120        btn.setAttribute('disabled', 'disabled');
121    }
122
123    function initSubmitGuard() {
124        var form = document.getElementById('admission-form');
125        if (!form || typeof window.jQuery === 'undefined') {
126            return;
127        }
128        window.jQuery(form).on('beforeSubmit', function () {
129            setBusy();
130            return true;
131        });
132    }
133
134    window.admissionSubmit = function () {
135        var form = document.getElementById('admission-form');
136        if (!form) {
137            return;
138        }
139        setBusy();
140        form.submit();
141    };
142
143    document.addEventListener('DOMContentLoaded', function () {
144        initCascade();
145        initPhoneMask();
146        initSubmitGuard();
147    });
148})();

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.