PageSourceSearch

https://luks.ru/local/components/uw/phone-login/templates/.default/script.js?17380206645070

js luks.ru collected 2026-10-04 05:42:57 UTC 5,070 bytes, 138 lines download raw bytes

1let PhoneLoginComponent = {
2    init: () => {
3        let openFormBtns = document.querySelectorAll('[data-action="phoneLoginOpen"]');
4        openFormBtns.forEach((openFormBtn) => {
5            openFormBtn.addEventListener('click', (e) => {
6                PhoneLoginComponent.container = e.currentTarget.closest('.bx-system-auth-form');
7
8                let formData = new FormData();
9                formData.append('action', 'openForm');
10                PhoneLoginComponent.sendRequest(formData);
11            });
12        });
13    },
14    formInit: () => {
15        let formBtns = document.querySelectorAll('form button[data-action]');
16        formBtns.forEach((formBtn) => {
17            formBtn.addEventListener('click', (e) => {
18                e.preventDefault();
19                let action = e.currentTarget.dataset.action;
20                let formData = new FormData();
21
22                switch (action) {
23                    case 'open_form':
24                        formData.append('action', 'openForm');
25                        break;
26                    case 'submit':
27                        let form = e.currentTarget.closest('form');
28                        formData = new FormData(form);
29                        break;
30                }
31
32                PhoneLoginComponent.sendRequest(formData);
33            });
34        });
35    },
36
37    sendRequest: (formData) => {
38        fetch('',{
39            method: 'POST',
40            body: formData,
41        })
42            .then(response => response.text())
43            .then(text => {
44                PhoneLoginComponent.closeForm();
45
46                let form = document.createElement('div');
47                form.classList.add('phone-login');
48                form.innerHTML = text;
49                // form.dataset.action = 'close';
50
51                let codeResendBtn = form.querySelector('[data-code-resend-time]');
52                if (codeResendBtn)
53                    CodeResendTimer.timeLeft = codeResendBtn.dataset.codeResendTime;
54
55
56                PhoneLoginComponent.container.append(form);
57                //document.body.append(form)
58
59                CodeResendTimer.renderTimer();
60                PhoneLoginComponent.closeInit();
61                PhoneLoginComponent.formInit();
62
63                if (text.includes('success'))
64                    setTimeout(() => window.location.href = '', 1000);
65            });
66    },
67
68    closeInit: () => {
69        let closeBtns = document.querySelectorAll('[data-action="close"]');
70        closeBtns.forEach((closeBtn) => {
71            closeBtn.addEventListener('click', (e) => {
72                if (e.currentTarget !== e.target)
73                    return;
74
75                PhoneLoginComponent.closeForm();
76            });
77        });
78    },
79    closeForm: () => {
80        if (CodeResendTimer.id)
81            clearInterval(CodeResendTimer.id);
82
83        if (document.querySelector('.phone-login'))
84            document.querySelector('.phone-login').remove();
85    }
86}
87
88let CodeResendTimer = {
89    timeLeft: 300,
90    id: 0,
91    update: () => {
92        CodeResendTimer.timeLeft--;
93
94        let minutes = Math.floor((CodeResendTimer.timeLeft / 60) % 60);
95        let seconds = Math.floor(CodeResendTimer.timeLeft % 60);
96
97        CodeResendTimer.minutesEl.innerText = String(minutes).padStart(2, '0');
98        CodeResendTimer.secondsEl.innerText = String(seconds).padStart(2, '0');
99
100        if (CodeResendTimer.timerEl)
101            CodeResendTimer.timerEl.style.display = 'block';
102
103        if (CodeResendTimer.timeLeft === 0) {
104            clearInterval(CodeResendTimer.id);
105
106            if (CodeResendTimer.timerEl)
107                CodeResendTimer.timerEl.remove();
108
109            CodeResendTimer.codeResendBtn.disabled = false;
110        }
111    },
112    renderTimer: () => {
113        CodeResendTimer.codeResendBtn = document.querySelector('button[data-code-resend-time]');
114        if (CodeResendTimer.codeResendBtn) {
115            if (CodeResendTimer.codeResendBtn.dataset.codeResendTime > 0) {
116                CodeResendTimer.caption = document.createElement('span');
117                CodeResendTimer.caption.innerText = 'Через ';
118
119                CodeResendTimer.minutesEl = document.createElement('span');
120                CodeResendTimer.secondsEl = document.createElement('span');
121                CodeResendTimer.separatorEl = document.createElement('span');
122                CodeResendTimer.separatorEl.innerText = ':';
123
124                CodeResendTimer.timerEl = document.createElement('div');
125                CodeResendTimer.timerEl.append(CodeResendTimer.caption, CodeResendTimer.minutesEl, CodeResendTimer.separatorEl, CodeResendTimer.secondsEl);
126                CodeResendTimer.timerEl.style.display = 'none';
127
128                CodeResendTimer.codeResendBtn.append(CodeResendTimer.timerEl);
129
130                clearInterval(CodeResendTimer.id);
131                CodeResendTimer.update();
132                CodeResendTimer.id = setInterval(CodeResendTimer.update, 1000);
133            }
134        }
135    }
136}
137
138document.addEventListener('DOMContentLoaded', PhoneLoginComponent.init);

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.