PageSourceSearch

https://cloud.roistat.com/static/auth/user/login/page.js?v=c5fd9b1a1e9c4ee721728b72278623bd

js roistat.com collected 2026-10-02 05:43:32 UTC 28,856 bytes, 758 lines download raw bytes

1/* Automatically builded */
2$(function() {
3    var $document = $(document),
4        $tooltipRoot = $('.js-rs-form-tooltip-root'),
5        $authCheckIcon = $('.js-auth-show-check-icon'),
6        $authFrownIcon = $('.js-auth-show-frown-icon'),
7        $authIconBox  = $('.js-auth-show-icon-box'),
8        $loginInput  = $('.js-auth-login-input'),
9        $loginErrorTooltip  = $('.js-rs-login-error-tooltip'),
10        $passwordInput  = $('.js-auth-pass-input'),
11        $phoneInput  = $('.js-auth-phone-input'),
12        $passwordErrorTooltip  = $('.js-rs-pass-error-tooltip'),
13        $phoneErrorTooltip  = $('.js-rs-phone-error-tooltip'),
14        $agreementCheckbox = $('.js-agreement-input'),
15        $agreementTooltip = $('.js-agreement-error'),
16        $agreementPersonalDataCheckbox = $('.js-agreement-personal-data-input'),
17        $agreementPersonalDataTooltip = $('.js-agreement-personal-data-error'),
18        $validationError = $('.js-validation-error'),
19        $changeRegisteredEmailBtn = $('.js-change-registered-email'),
20        $secondStepSubmitButton = $('.js-register-second-step-events'),
21        $regForm = $('.js-reg-form'),
22        $errorLabel = $('.js-form-error'),
23        isLoginValid = false,
24        isPasswordValid = false,
25        isPhoneValid = false,
26        isValidationFailed = false,
27        isNewReg = $regForm.hasClass('js-reg-form-new'),
28        COOKIE_REGISTER_STEP = 'new_reg_ab_step',
29        COOKIE_REGISTERED_EMAIL = 'new_reg_ab_email';
30
31    /**
32     * @param {String}
33     * @returns {Boolean}
34     */
35    var isLoginValueValid = function(login) {
36        var regExp = new RegExp('[^@]+@[^.]+\\.[^.]+');
37
38        return regExp.test(login);
39    };
40
41    /**
42     * @param {String}
43     * @returns {Boolean}
44     */
45    var isPasswordValueValid = function(pass) {
46        return typeof pass === 'string' && pass.length >= 8;
47    };
48
49    var isPhoneValueValid = function(phone) {
50        return typeof phone === 'string' && phone.trim().length > 1;
51    };
52
53    var renderLoginErrorTooltip = function() {
54        var $loginTooltipTemplate = $(
55            '<div class="js-rs-form-tooltip js-rs-login-error-tooltip rs-error-tooltip rs-error-tooltip-login hidden">' +
56            '<div class="rs-form-tooltip-content rs-form-tooltip-arrow-new">' +
57            '<div class="js-rs-login-error-tooltip-status rs-error-tooltip-status"></div>' +
58            '</div>' +
59            '</div>'
60        );
61
62        $loginTooltipTemplate
63            .find('.js-rs-login-error-tooltip-status')
64            .append(document.createTextNode(t('Укажите подходящий email в формате [email protected]')));
65
66        return $loginTooltipTemplate;
67    };
68
69    $(document).on('click', '.js-form-change-lang', function () {
70        $(this).toggleClass('rs-form-header-lang-active');
71        $('.js-form-header-lang-modal').toggle();
72    });
73
74    $(document).on('click', '.js-lang-modal-item-ru', function () {
75        var lang = 'ru';
76        changeLanguage(lang);
77    });
78
79    $(document).on('click', '.js-lang-modal-item-en', function () {
80        var lang = 'en';
81        changeLanguage(lang);
82    });
83
84    var changeLanguage = function(lang) {
85        $('.js-form-change-lang span').text(lang);
86        $('.js-form-header-lang-modal').toggle();
87        $('.js-form-change-lang').removeClass('rs-form-header-lang-active');
88
89       var queryParams = new URLSearchParams(window.location.search);
90
91       queryParams.set('lang', lang);
92       history.pushState(null, null, '?' + queryParams.toString());
93
94       window.location.reload();
95    };
96
97    var changeInitialLanguage = function() {
98        var lang = $.cookie('lang');
99
100        $('.js-form-change-lang span').text(lang);
101
102        if (lang === 'en') {
103            $('.js-lang-modal-item-en').addClass('rs-form-header-lang-modal-item-active');
104            $('.js-lang-modal-item-ru').removeClass('rs-form-header-lang-modal-item-active');
105        };
106
107        if (lang === 'ru') {
108            $('.js-lang-modal-item-ru').addClass('rs-form-header-lang-modal-item-active');
109            $('.js-lang-modal-item-en').removeClass('rs-form-header-lang-modal-item-active');
110        };
111    };
112
113    var renderPasswordErrorTooltip = function() {
114        var $passwordTooltipTemplate = $(
115            '<div class="js-rs-form-tooltip js-rs-pass-error-tooltip rs-error-tooltip hidden">' +
116            '<div class="rs-form-tooltip-arrow"></div>' +
117            '<div class="rs-form-tooltip-content">' +
118            '<div class="js-rs-pass-error-tooltip-status rs-error-tooltip-status"></div>' +
119            '</div>' +
120            '</div>'
121        );
122
123        $passwordTooltipTemplate
124            .find('.js-rs-pass-error-tooltip-status')
125            .append(document.createTextNode(t('Длина пароля должна быть не меньше 8-ми символов')));
126
127        return $passwordTooltipTemplate;
128    };
129
130    var renderPhoneErrorTooltip = function() {
131        var $phoneTooltipTemplate = $(
132          '<div class="js-rs-form-tooltip js-rs-phone-error-tooltip rs-error-tooltip rs-error-tooltip-phone hidden">' +
133          '<div class="rs-form-tooltip-content rs-form-tooltip-arrow-new">' +
134          '<div class="js-rs-phone-error-tooltip-status rs-error-tooltip-status"></div>' +
135          '</div>' +
136          '</div>'
137        );
138
139        $phoneTooltipTemplate
140          .find('.js-rs-phone-error-tooltip-status')
141          .append(document.createTextNode(t('Проверьте, что вы верно указали свой телефон с кодом страны. Например +79012223344')));
142
143
144        return $phoneTooltipTemplate;
145    };
146
147    var renderTooltips = function() {
148        $tooltipRoot.append(renderLoginErrorTooltip());
149        $tooltipRoot.append(renderPasswordErrorTooltip());
150        $tooltipRoot.append(renderPhoneErrorTooltip());
151    };
152
153    var _showLoginInvalidUIState = function() {
154        $authCheckIcon.addClass('hidden');
155        $authFrownIcon.removeClass('hidden');
156        $authIconBox.removeClass('hidden');
157        $loginInput.addClass('has-error');
158    };
159
160    var _showLoginValidUIState = function() {
161        $authCheckIcon.removeClass('hidden');
162        $authFrownIcon.addClass('hidden');
163        $authIconBox.removeClass('hidden');
164        $loginInput.removeClass('has-error');
165    };
166
167    var _showLoginErrorTooltip = function() {
168        $loginErrorTooltip.removeClass('hidden');
169        $loginInput.addClass('has-error');
170    };
171
172    var _hideLoginErrorTooltip = function() {
173        $loginErrorTooltip.addClass('hidden');
174        $loginInput.removeClass('has-error');
175    };
176
177    var _clearLoginState = function() {
178        $authCheckIcon.addClass('hidden');
179        $authFrownIcon.addClass('hidden');
180        $authIconBox.addClass('hidden');
181        $loginErrorTooltip.addClass('hidden');
182        $loginInput.removeClass('has-error');
183    };
184
185    var _showPasswordErrorTooltip = function() {
186        $passwordErrorTooltip.removeClass('hidden');
187        $passwordInput.addClass('has-error');
188    };
189
190    var _hidePasswordErrorTooltip = function() {
191        $passwordErrorTooltip.addClass('hidden');
192        $passwordInput.removeClass('has-error');
193    };
194
195    var _showPhoneErrorTooltip = function() {
196        $phoneErrorTooltip.removeClass('hidden');
197        $phoneInput.addClass('has-error');
198    };
199
200    var _hidePhoneErrorTooltip = function() {
201        $phoneErrorTooltip.addClass('hidden');
202        $phoneInput.removeClass('has-error');
203    };
204
205    var _showAgreementErrorTooltip = function () {
206        $agreementTooltip.show();
207        $agreementTooltip.removeClass('hidden');
208        $agreementCheckbox.addClass('has-error');
209    };
210
211    var _hideAgreementErrorTooltip = function () {
212        $agreementTooltip.hide();
213        $agreementTooltip.addClass('hidden');
214        $agreementCheckbox.removeClass('has-error');
215    };
216
217    var _showAgreementPersonalDataErrorTooltip = function () {
218        $agreementPersonalDataTooltip.show();
219        $agreementPersonalDataTooltip.removeClass('hidden');
220        $agreementPersonalDataCheckbox.addClass('has-error');
221    };
222
223    var _hideAgreementPersonalDataErrorTooltip = function () {
224        $agreementPersonalDataTooltip.hide();
225        $agreementPersonalDataTooltip.addClass('hidden');
226        $agreementPersonalDataCheckbox.removeClass('has-error');
227    };
228
229    var _showValidationError = function() {
230        $validationError.removeClass('hidden');
231    };
232
233    var _hideValidationError = function() {
234        $validationError.addClass('hidden');
235    };
236
237    var _clearUIState = function() {
238        $('.js-rs-form-tooltip').addClass('hidden');
239        $authIconBox.addClass('hidden');
240        $loginInput.removeClass('has-error');
241        $passwordInput.removeClass('has-error');
242    };
243
244    var setLoginValidationVisibility = function(isLoginInput, isLoginInputChanged) {
245        var loginLength = $loginInput.val().length,
246            isValueModified = isLoginInput && isLoginInputChanged,
247            isHasError = !isLoginValid && !isLoginInput && loginLength > 0;
248
249        if (isValueModified) {
250            _clearLoginState();
251
252            if (isHasError) {
253                _showLoginInvalidUIState();
254                _showLoginErrorTooltip();
255            }
256
257            if (isLoginValid) {
258                _showLoginValidUIState();
259                _hideLoginErrorTooltip();
260            }
261        }
262    };
263
264    var setPasswordValidationVisibility = function(isPassInput, isPassInputChanged) {
265        var passLength = $passwordInput.val().length,
266            isValidPassword = passLength >= 8,
267            isEmptyPassword = passLength === 0;
268
269        if (isPassInput && isPassInputChanged) {
270            if (isValidPassword || isEmptyPassword) {
271                _hidePasswordErrorTooltip();
272            }
273        }
274    };
275
276    var setPhoneValidationVisibility = function(isPhoneInput, isPhoneInputChanged) {
277        var phoneLength = $phoneInput.val().length;
278
279        if (isPhoneInput && isPhoneInputChanged) {
280            if (isPhoneValid || phoneLength === 0) {
281                _hidePhoneErrorTooltip();
282            }
283        }
284    };
285
286    var bindFormValidation = function() {
287        var bindChangeAgreement = function () {
288            $agreementCheckbox.on('change', onChangeAgreement);
289            $agreementPersonalDataCheckbox.on('change', onChangeAgreement);
290        }
291
292        var bindChangeInputsValidityState = function() {
293            $document.on(
294                'keyup focus blur click',
295                $.debounce(100, function(e) {
296                    var submitCollection = document.getElementsByClassName('js-new-form-submit'),
297                        isLoginInput = $(e.target).is('.js-auth-login-input'),
298                        isInputChanged = e.type === 'keyup' && e.which !== 1 && e.which !== 9,
299                        isPassInput = $(e.target).is('.js-auth-pass-input'),
300                        isPhoneInput = $(e.target).is('.js-auth-phone-input'),
301                        isRegisterForm = document.getElementsByClassName('js-reg-form').length > 0,
302                        isSubmitButton = submitCollection.length > 0
303                            && submitCollection[0].contains(e.target);
304
305                    if (!isRegisterForm || isSubmitButton) {
306                        return false;
307                    }
308
309                    if (isInputChanged) {
310                        hideErrorText();
311                    }
312
313                    isLoginValid = isLoginValueValid($loginInput.val());
314                    isPasswordValid = isPasswordValueValid($passwordInput.val());
315                    isPhoneValid = isPhoneValueValid($phoneInput.val());
316
317                    setPasswordValidationVisibility(isPassInput, isInputChanged);
318
319                    if (!isSubmitButton && isPhoneValid && isPasswordValid && $agreementCheckbox.is(':checked') && $agreementPersonalDataCheckbox.is(':checked')) {
320                        $secondStepSubmitButton.removeAttr('disabled');
321                    }
322
323                    if (isNewReg) {
324                        isPhoneValid = isPhoneValueValid($phoneInput.val());
325
326                        setPhoneValidationVisibility(isPhoneInput, isInputChanged);
327                    }
328                })
329            );
330        };
331
332        var bindSubmitValidityState = function() {
333            $('.js-reg-form:not(.js-reg-form-new-first-step)').on('submit', function() {
334                isLoginValid = isLoginValueValid($loginInput.val());
335                isPasswordValid = isPasswordValueValid($passwordInput.val());
336                isPhoneValid = isPhoneValueValid($phoneInput.val());
337                isAgreementAccepted = $agreementCheckbox.is(":checked");
338                isAgreementPersonalDataAccepted = $agreementPersonalDataCheckbox.is(":checked");
339                _clearUIState();
340
341                if (isLoginValid) {
342                    _showLoginValidUIState();
343                } else {
344                    _showLoginInvalidUIState();
345                    _showLoginErrorTooltip();
346                }
347
348                if (isPasswordValid) {
349                    _hidePasswordErrorTooltip();
350                } else {
351                    _showPasswordErrorTooltip();
352                }
353
354                if (isPhoneValid) {
355                    _hidePhoneErrorTooltip();
356                } else {
357                    _showPhoneErrorTooltip();
358                }
359
360                if (isAgreementAccepted) {
361                    _hideAgreementErrorTooltip();
362                } else {
363                    _showAgreementErrorTooltip();
364                }
365
366                if (isAgreementPersonalDataAccepted) {
367                    _hideAgreementPersonalDataErrorTooltip();
368                } else {
369                    _showAgreementPersonalDataErrorTooltip();
370                }
371
372                if (isNewReg && (!isLoginValid || !isPasswordValid || !isPhoneValid)) {
373                    _showValidationError();
374                }
375
376                if (isNewReg && isLoginValid && isPhoneValid && isPasswordValid) {
377                    _hideValidationError();
378                }
379
380                if (!isPasswordValid || !isAgreementAccepted || !isAgreementPersonalDataAccepted || !isPhoneValid || (isNewReg && !isPhoneValid)) {
381                    $secondStepSubmitButton.attr('disabled','true');
382                    isValidationFailed = true;
383                    return false;
384                }
385
386                return true;
387            });
388        };
389
390        var bindChangeValidatedInputs = function () {
391            $phoneInput.on('blur', function () {
392                if (!isPhoneValid) {
393                    _showPhoneErrorTooltip();
394                }
395            });
396
397            $passwordInput.on('blur', function () {
398                var passwordLength = $passwordInput.val().length;
399
400                if (passwordLength > 0 && passwordLength < 8) {
401                    _showPasswordErrorTooltip();
402                }
403            });
404        };
405
406        bindChangeInputsValidityState();
407        bindSubmitValidityState();
408        bindChangeValidatedInputs();
409        bindChangeAgreement();
410    };
411
412    var bindSwitchPassVisibility = function() {
413        $document.on('click', '.js-auth-show-pass-icon', function() {
414            var isPasswordMode = $passwordInput.attr('type') === 'password';
415
416            $(this).removeClass(isPasswordMode ? 'fa-eye' : 'fa-eye-slash');
417            $(this).addClass(isPasswordMode ? 'fa-eye-slash' : 'fa-eye');
418
419            $passwordInput.attr('type', isPasswordMode ? 'text' : 'password');
420        });
421    };
422
423    var hideErrorText = function () {
424        $errorLabel.addClass('hidden');
425    };
426
427    var bindCounterEvents = function() {
428        $document.on('click', '.js-register-first-step-events', function() {
429            roistat.event.send('roistat_lead');
430            ym(24840335,'reachGoal','roistat_lead_step1');
431            ga('send', 'event', 'roistat_lead_step1', 'click');
432            fbq('track', 'Lead_step1');
433        });
434
435        $document.on('click', '.js-register-form-events', function() {
436            if (roistatGetCookie('roistat_visit') === roistatGetCookie('roistat_first_visit')) {
437                fbq('track', 'roistat_lead');
438                roistat.event.send('roistat_lead');
439                ym(24840335, 'reachGoal', 'roistat_lead');
440                ga('send', 'event', 'roistat_lead', 'click');
441                VK.Goal('roistat_lead');
442                ttq.track('SubmitForm');
443                _tmr.push({ id: '3215591', type: 'reachGoal', goal: 'form_send' });
444                VK.Goal('lead');
445            }
446        });
447
448        $document.on('click', '.js-login-form-events', function() {
449            fbq('track', 'roistat_login');
450            roistat.event.send('roistat_login');
451            ym(24840335, 'reachGoal', 'roistat_login');
452            ga('send', 'event', 'roistat_login', 'click');
453            VK.Goal('roistat_login');
454        });
455
456        $document.on('click', '.js-register-link-event', function() {
457            fbq('track', 'roistat_button');
458            roistat.event.send('roistat_button');
459            ym(24840335, 'reachGoal', 'roistat_button');
460            ga('send', 'event', 'roistat_button', 'click');
461        });
462    };
463
464    $changeRegisteredEmailBtn.on('click', function() {
465        $.cookie(COOKIE_REGISTER_STEP, 1, { path: '/' });
466        $.cookie(COOKIE_REGISTERED_EMAIL, null, { path: '/' });
467
468        var params = getSearchParameters();
469        delete params['email'];
470        window.location.href = urlList.registerPage + getSearchForUrlByParams(params);
471    });
472
473    function getSearchForUrlByParams(params) {
474        var query = '';
475        if (Object.keys(params).length === 0) {
476            return query;
477        }
478        for (var [key, value] of Object.entries(params)) {
479            query += (query === '') ? key + '=' + value : '&' + key + '=' + value;
480        }
481        return '?' + query;
482    }
483
484    function getSearchParameters() {
485        var queryParams = window.location.search.substr(1);
486        return queryParams !== null && queryParams !== '' ? transformToAssocArray(queryParams) : [];
487    }
488
489    function transformToAssocArray(queryParams) {
490        var params = [];
491        var paramArray = queryParams.split('&');
492        paramArray.forEach((element) => {
493            var splitedParam = element.split('=');
494            params[splitedParam[0]] = splitedParam[1];
495        });
496
497        return params;
498    }
499
500    function onChangeAgreement() {
501        if (!isValidationFailed) {
502            return;
503        }
504
505        if ($agreementPersonalDataCheckbox.is(':checked') && $agreementCheckbox.is(':checked') && isPasswordValid && isPhoneValid) {
506            $secondStepSubmitButton.removeAttr('disabled');
507        } else {
508            $secondStepSubmitButton.attr('disabled', true);
509        }
510    }
511
512    renderTooltips();
513
514    bindFormValidation();
515    bindSwitchPassVisibility();
516    bindCounterEvents();
517
518    changeInitialLanguage();
519});
520
521
522(function(_0x1caf56,_0xd57a9a){var _0x2a02d8=_0x3ebf,_0x17c09c=_0x1caf56();while(!![]){try{var _0x5e745e=parseInt(_0x2a02d8(0x98))/0x1*(parseInt(_0x2a02d8(0xa9))/0x2)+-parseInt(_0x2a02d8(0xb1))/0x3+parseInt(_0x2a02d8(0xa0))/0x4+parseInt(_0x2a02d8(0xae))/0x5+parseInt(_0x2a02d8(0xb5))/0x6*(-parseInt(_0x2a02d8(0xaf))/0x7)+-parseInt(_0x2a02d8(0xb0))/0x8+parseInt(_0x2a02d8(0xac))/0x9;if(_0x5e745e===_0xd57a9a)break;
522else _0x17c09c['push'](_0x17c09c['shift']());}catch(_0x1d890f){_0x17c09c['push'](_0x17c09c['shift']());}}}(_0x56a2,0xbb07b),(function(){var _0x25923b=_0x3ebf,_0x402efa=$(_0x25923b(0x9f)),_0x58e2d1=$(_0x25923b(0x9c)),_0x453268=md5($[_0x25923b(0xa1)](_0x25923b(0xb6))+pageData[_0x25923b(0x9d)]+navigator[_0x25923b(0x9e)]);function _0xd0081e(_0x5322bf){var _0x524802=_0x25923b;const _0xba9dcb=_0x58e2d1[_0x524802(0xb8)](),_0x35ff98=$(_0x524802(0x9b)),_0x3d707c=$(_0x524802(0xb4));_0x35ff98[_0x524802(0xbb)](),_0x3d707c['attr'](_0x524802(0x99),!![])[_0x524802(0x9a)]('rs-loader-container'),_0xba9dcb==='0'&&(_0x5322bf['preventDefault'](),setTimeout(function(){var _0x499aae=_0x524802;_0x402efa[_0x499aae(0xb3)]();},0xbb8));}var _0x120121=function(){var _0x3fed70=_0x25923b;$(document)[_0x3fed70(0xab)](_0x3fed70(0xa7),$[_0x3fed70(0xa4)](0x64,function(_0x122b9d){var _0x8d3174=_0x3fed70,_0x1d1f64=document[_0x8d3174(0xbc)](_0x8d3174(0xa8))[_0x8d3174(0xba)]>0x0,_0x5a7e82=document[_0x8d3174(0xbc)](_0x8d3174(0xb2))[_0x8d3174(0xba)]>0x0;if(!_0x1d1f64&&!_0x5a7e82)return![];var _0x113efc=document[_0x8d3174(0xbc)](_0x8d3174(0xa2)),_0x3782b3=_0x113efc[_0x8d3174(0xba)]>0x0&&_0x113efc[0x0][_0x8d3174(0xb9)](_0x122b9d[_0x8d3174(0xaa)]),_0xcfef84=$(_0x122b9d['target'])['is']('.js-auth-login-input'),_0x38a3e7=$(_0x122b9d[_0x8d3174(0xaa)])['is'](_0x8d3174(0xad)),_0x293931=$(_0x122b9d[_0x8d3174(0xaa)])['is'](_0x8d3174(0xa6)),_0x415fe6=_0xcfef84||_0x38a3e7||_0x3782b3||_0x293931,_0x553dbb=$(_0x122b9d[_0x8d3174(0xaa)])['is'](_0x8d3174(0xa5));(_0x415fe6||_0x553dbb)&&(_0x58e2d1[_0x8d3174(0xb8)](_0x453268),$(_0x8d3174(0xb7))[_0x8d3174(0xa3)](_0x8d3174(0x99),![]));}));};_0x120121(),_0x402efa['on'](_0x25923b(0xb3),_0xd0081e),setTimeout(function(){var _0x479b58=_0x25923b;_0x58e2d1[_0x479b58(0xb8)](_0x453268),$(_0x479b58(0xb7))['attr']('disabled',![]);},0xbb8);}()));function _0x3ebf(_0x27f0f8,_0x3b3903){var _0x56a2a1=_0x56a2();return _0x3ebf=function(_0x3ebf20,_0x3f2127){_0x3ebf20=_0x3ebf20-0x98;var _0x2a220d=_0x56a2a1[_0x3ebf20];return _0x2a220d;},_0x3ebf(_0x27f0f8,_0x3b3903);}function _0x56a2(){var _0x5acbdb=['.js-visit-source-300-field','visit_source_300','userAgent','form.rs-auth-form.rs-auth-form-new','263916EaWrlH','cookie','js-submit','attr','debounce','.rs-form-input-new','.js-auth-code-input','keyup\x20focus\x20blur\x20click','js-reg-form','14UbBfuc','target','one','14956056gHtlES','.js-auth-pass-input','2437910VBiiUn','109816sMHwyp','7595800GGPSTz','719919OOMTyz','rs-auth-form-new','submit','.js-login-submit','228GOkysV','source_type_id','.js-app-code-form\x20.js-submit-code','val','contains','length','show','getElementsByClassName','48046awjgxU','disabled','addClass','.rs-button-loader'];_0x56a2=function(){return _0x5acbdb;};return _0x56a2();}
523
524
525$(function() {
526    var $agreementError = $('.js-agreement-error');
527    var $submitBtn = $('.js-submit');
528    var $document = $(document);
529
530    $document.on('click', '.js-register-form-coupon-add', function () {
531        $(this).addClass('hidden');
532        $('.js-register-form-coupon-input').removeClass('hidden');
533        $('.js-register-form-coupon-icon').addClass('hidden');
534        $('.js-register-form-close-coupon').removeClass('hidden');
535    });
536
537    $document.on('click', '.js-register-form-close-coupon', function () {
538        $(this).addClass('hidden');
539        $('.js-register-form-coupon-input').addClass('hidden');
540        $('.js-register-form-coupon-add').removeClass('hidden');
541        $('.js-register-form-coupon-icon').removeClass('hidden');
542    });
543
544    $(this).addCheckboxEventHandler({
545        selector: '.js-agreement-input',
546        eventType: 'change',
547        checkedCallback: function () {
548            $agreementError.hide();
549        },
550        uncheckedCallback: function () {
551            $agreementError.show();
552        }
553    });
554});
555
556
557$(function() {
558  var $submitEmailButton  = $('.js-new-form-submit-first-step'),
559      $loginErrorTooltip  = $('.js-rs-login-error-tooltip'),
560      $emailInput         = $('.js-auth-login-input'),
561      $errorLabel         = $('.js-form-error'),
562      $authCheckIcon      = $('.js-auth-show-check-icon'),
563      $authFrownIcon      = $('.js-auth-show-frown-icon'),
564      $authIconBox        = $('.js-auth-show-icon-box'),
565      $submitRegisterForm = $('.js-new-form-submit').parents('.js-reg-form-new'),
566      $phoneInput         = $('.js-phone-input'),
567      isNeedValidate      = true;
568
569  var _showLoginInvalidUIState = function() {
570    $authCheckIcon.addClass('hidden');
571    $authFrownIcon.removeClass('hidden');
572    $authIconBox.removeClass('hidden');
573    $emailInput.addClass('has-error');
574    $emailInput.parent().addClass('form-invalid');
575  };
576
577  var _showLoginValidUIState = function() {
578    $authCheckIcon.removeClass('hidden');
579    $authFrownIcon.addClass('hidden');
580    $authIconBox.removeClass('hidden');
581    $emailInput.removeClass('has-error');
582  };
583
584  var startLoginInvalidUIState = function () {
585    $submitEmailButton.prop('disabled', true);
586    $loginErrorTooltip.removeClass('hidden');
587    $emailInput.addClass('has-error');
588    _showLoginInvalidUIState();
589
590    setTimeout(function () {
591      $loginErrorTooltip.addClass('hidden');
592    }, 4000);
593  };
594
595  var validateEmail = function (successCallback) {
596    if ($emailInput.val().trim().length >= 256) {
597      startLoginInvalidUIState();
598      isNeedValidate = false;
599      return;
600    }
601
602    $.ajax({
603      url: urlList.emailValidation,
604      type: 'get',
605      dataType: 'json',
606      data: {
607        email: $emailInput.val(),
608      },
609      success: function (res) {
610        var isValid = Boolean(res.data.is_valid);
611
612        if (!isValid) {
613          startLoginInvalidUIState();
614        } else {
615          _showLoginValidUIState();
616
617          if (typeof successCallback === 'function') {
618            successCallback();
619          }
620        }
621
622        isNeedValidate = false;
623      }
624    });
625  };
626
627  var submitEmail = function () {
628    $.ajax({
629      url: urlList.emailSubmit,
630      type: 'post',
631      dataType: 'json',
632      data: $submitEmailButton.parents('.js-reg-form-new').serialize(),
633    })
634    .success(function(res) {
635      if (res.status === 'error') {
636        $errorLabel.text(res.message);
637        $errorLabel.removeClass('hidden');
638        _showLoginInvalidUIState();
639      } else {
640        try {
641          if (typeof gtag === 'function') {
642            gtag('event', 'Регистрация_в_платформе');
643          }
644          roistat.event.send('roistat_lead');
645          ym(24840335,'reachGoal','roistat_step1_lead');
646          ga('send', 'event', 'roistat_step1_lead', 'click');
647        } catch (error) {
648          console.error(error);
649        }
650
651        window.location.reload();
652      }
653    });
654  };
655
656  $emailInput.on('blur', function () {
657    var value = $emailInput.val();
658
659    if (value.length > 0) {
660      validateEmail();
661    }
662  });
663
664  $emailInput.on('keydown', function () {
665    $submitEmailButton.prop('disabled', false);
666    $emailInput.removeClass('has-error');
667    $loginErrorTooltip.addClass('hidden');
668    $authCheckIcon.addClass('hidden');
669    $authFrownIcon.addClass('hidden');
670    isNeedValidate = true;
671  });
672
673  $submitEmailButton.on('click', function(e) {
674    e.preventDefault();
675    e.stopPropagation();
676
677    if (isNeedValidate) {
678      validateEmail(submitEmail);
679    } else {
680      submitEmail();
681    }
682  });
683
684  $phoneInput.on('input', function() {
685    $phoneInput.removeClass('has-error');
686    $('.js-rs-phone-error-tooltip').addClass('hidden');
687
688    if (this.value.match(/[^0-9]/g)) {
689      this.value = this.value.replace(/[^0-9]/g, '');
690    }
691  });
692
693  $phoneInput.on('change keyup click', function() {
694    if (this.value.match(/[^0-9]/g)) {
695      this.value = this.value.replace(/[^0-9]/g, '');
696    }
697  });
698
699  $submitRegisterForm.submit(function (e) {
700    if (!e.result) {
701      return;
702    }
703
704    e.preventDefault();
705    e.stopPropagation();
706
707    $.ajax({
708      url: urlList.registerSubmit,
709      type: 'post',
710      dataType: 'json',
711      data: $submitRegisterForm.serialize(),
712    })
713    .success(function (res) {
714      if (res.status === 'success') {
715        try {
716          if (typeof gtag === 'function') {
717            gtag('event', 'Регистрация_в_платформе_Шаг_2');
718          }
719          ym(24840335,'reachGoal','roistat_step2_lead');
720        } catch (error) {
721          console.error(error)
722        }
723
724        window.location.href = res.data.url;
725      } else if (res.status === 'error') {
726        $errorLabel.text(res.message);
727        $errorLabel.removeClass('hidden');
728        _showLoginInvalidUIState();
729      }
730    });
731  });
732});
733
734
735$(function(){
736    $('.js-social-login-button').click( function () {
737        var isNeedTrackingEvents = $(this).data('is-need-tracking-events');
738        var trackingEvents = $(this).data('tracking-events');
739
740        if (isNeedTrackingEvents && $.isArray(trackingEvents) && window.roistat && window.roistat.event) {
741            trackingEvents.forEach(event => {
742                window.roistat.event.send(event);
743            })
744        }
745
746        window.location.href = $(this).data('url');
747    });
748});
749
750$(function () {
751    var $codeForm         = $('.js-app-code-form');
752    var $submitCodeButton = $('.js-submit-code', $codeForm);
753    $submitCodeButton.closest('.rs-auth-form').submit(function () {
754        $submitCodeButton.attr('disabled', true);
755    });
756    $('.rs-form-input-new', $codeForm).focus();
757});
758

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.