PageSourceSearch

https://smartbarter.ru/assets/js/public/home_page.js?v6

js smartbarter.ru collected 2026-10-09 23:10:17 UTC 7,795 bytes, 248 lines download raw bytes

1$(document).ready(function () {
2
3  $('#company_city').keyup(function() {
4    let $city = $('#company_city');
5    $city.kladr({
6      type: $.kladr.type.city,
7      limit: 1,
8      check: function(obj) {
9        if (obj) {
10          $('#company_city').css('color', 'black');
11        } else {
12          $('#company_city').css('color', 'red');
13        }
14      },
15      receive: function(obj) {
16        if (obj.length > 0) {
17          $('#name_city_company').attr('value', obj[0].name);
18          $('#id_city_company_kladr').attr('value', obj[0].id);
19          $('#zip_city_company').attr('value', obj[0].zip);
20        }
21      },
22      select: function(obj) {
23        $('#name_city_company').attr('value', obj.name);
24        $('#id_city_company_kladr').attr('value', obj.id);
25        $('#zip_city_company').attr('value', obj.zip);
26      },
27    });
28  });
29//Функция регистрации компании в системе
30  $('#registration_form').submit(function(e) {
31    e.preventDefault();
32    var data = new FormData(this);
33
34    //добавляем скрытые поля
35    var fields = $('.hidden_field');
36    for (var i = 0; i < fields.length; i++) {
37      data.append($(fields[i]).attr('id'), $(fields[i]).val());
38    }
39
40    $.ajax({
41      url: $('#registration_form').attr('action'),
42      type: 'POST',
43      data: data,
44      processData: false,
45      contentType: false,
46      cache: false,
47      async: false,
48      success: function(data) {
49
50        //валидируем данные
51        var result = validate_data_server_response(data);
52
53        if (result) {//если все успешно
54          redirect('registration_form', 'success_registration', 'company/cabinet',
55              data);
56
57        } else {//если потерпели ошибку
58          //вставляем хэш
59          insert_csrf_hash(data);//функция берется из all_area_scripts!
60        }
61      },
62    });
63  });
64
65  $('#company_phone').blur(function() {
66    let login = $('#company_phone').val().replace(/\D/g, '');
67    $.ajax({
68      type: 'POST',
69      url: base_url + 'public_ajax/registr_and_login/check_phone',
70      data: {
71        'company_phone': login,
72        'token_form': $('#token_form').val(),
73      },
74      dataType: 'JSON',
75      success: function(data) {
76        validate_data_server_response(data);
77        insert_csrf_hash(data);
78
79        if (+data.phone_exists === 1) {
80          document.getElementById('btn_to_login').click();
81        }
82      },
83    });
84  });
85
86  $('#login_form').submit(function(e) {
87    e.preventDefault();
88    var btn_txt = $('#send_login_form').text();
89    $('#send_login_form').prop( "disabled", true );
90    $('#send_login_form').text('Подождите...');
91
92    let login = $('#company_login_phone').val().replace(/\D/g, '');
93    var send_data = {
94      'company_login_phone': login,
95      'company_login_password': $('#company_login_password').val(),
96      'remember_me': document.getElementById('remember_me').checked ? 1 : 0,
97      'token_form': $('#token_form').val(),
98    };
99
100    $.ajax({
101      url: window.location.origin + '/public_ajax/registr_and_login/login_check_pass',
102      type: 'POST',
103      dataType: 'JSON',
104      data: send_data,
105      cache: false,
106      success: function(data) {
107
108        insert_csrf_hash(data);//функция берется из all_area_scripts!
109        //валидируем данные
110        var result = validate_data_server_response(data);
111
112        if (data.force_login !== undefined && data.force_login == 1) {
113          $('#login_form').hide();
114          $('#forgot_pass_button').hide();
115          redirect('login_form', 'success_login', 'company/cabinet', data);
116          return;
117        }
118        if (result) {
119          $('#login_form').hide();
120          $('#company_login_phone_code').val(send_data.company_login_phone);
121          $('#company_login_password_code').val(send_data.company_login_password);
122          $('#login_form_code').show();
123          $('#send_auth_code_sms').show();
124          $('#forgot_pass_button').hide();
125        }
126        $('#send_login_form').prop( "disabled", false );
127        $('#send_login_form').text(btn_txt);
128      },
129    });
130  });
131
132  $('#login_form_code').submit(function(e) {
133    e.preventDefault();
134    var send_data = {
135      'company_login_code': $('#company_login_code').val(),
136      'company_login_phone': $('#company_login_phone_code').val(),
137      'company_login_password': $('#company_login_password').val(),
138      'remember_me': document.getElementById('remember_me').checked ? 1 : 0,
139      'token_form': $('#token_form').val(),
140    };
141
142    $.ajax({
143      url: window.location.origin + '/public_ajax/registr_and_login/login_secret_code',
144      type: 'POST',
145      dataType: 'JSON',
146      data: send_data,
147      cache: false,
148      error: function () {
149        Swal.fire({
150          title: 'Ошибка!',
151          text: 'Ошибка выполнения запроса!',
152          icon: 'error',
153          confirmButtonText: 'Ок'
154        });
155        setTimeout(function() {
156          reload_page();
157        }, 1000);
158      },
159      success: function(data) {
160
161        insert_csrf_hash(data);//функция берется из all_area_scripts!
162        //валидируем данные
163        var result = validate_data_server_response(data);
164
165        if (result) {
166          $('#login_form_code').hide();
167          $('#send_auth_code_sms').hide();
168          redirect('login_form', 'success_login', 'company/cabinet', data);
169        }
170        else {
171          if (typeof(data.text_message) !== 'undefined') {
172            Swal.fire({
173              title: 'Ошибка!',
174              text: data.text_message,
175              icon: 'error',
176              confirmButtonText: 'Ок'
177            });
178          }
179          if (typeof(data.return) !== 'undefined') {
180            $('#company_login_phone').val('');
181            $('#company_login_password').val('');
182            $('#company_login_phone_code').val('');
183            $('#company_login_password_code').val('');
184            $('#company_login_code_wa').show();
185            $('#company_login_code_sms').hide();
186            $('#send_auth_code_sms').hide();
187            $('#forgot_pass_button').show();
188            $('#login_form').show();
189            $('#login_form_code').hide();
190          }
191        }
192      },
193    });
194  });
195
196  $('#send_auth_code_sms').click(function () {
197
198    $('#send_auth_code_sms').hide();
199
200    var send_data = {
201      'company_login_phone': $('#company_login_phone_code').val(),
202      'token_form': $('#token_form').val(),
203    };
204
205    $.ajax({
206      url: window.location.origin + '/public_ajax/registr_and_login/send_auth_code_sms',
207      type: 'POST',
208      dataType: 'JSON',
209      data: send_data,
210      cache: false,
211      error: function () {
212        Swal.fire({
213          title: 'Ошибка!',
214          text: 'Ошибка выполнения запроса!',
215          icon: 'error',
216          confirmButtonText: 'Ок'
217        });
218        setTimeout(function() {
219          reload_page();
220        }, 1000);
221      },
222      success: function(data) {
223        insert_csrf_hash(data);//функция берется из all_area_scripts!
224        //валидируем данные
225        var result = validate_data_server_response(data);
226
227        if (result) {
228          $('#company_login_code_wa').hide();
229          $('#company_login_code_sms').show();
230        }
231        else {
232          Swal.fire({
233            title: 'Ошибка!',
234            text: data.text_message,
235            icon: 'error',
236            confirmButtonText: 'Ок'
237          });
238          setTimeout(function() {
239            reload_page();
240          }, 1000);
241        }
242      },
243    });
244  }); //End #send_auth_code_sms click
245
246}); //End Document ready
247
248

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.