PageSourceSearch

https://rtknet.ru/wp-content/themes/zblackbeard/include/frontend/admin.js?ver=4.9.3

js rtknet.ru collected 2026-09-24 10:18:16 UTC 17,996 bytes, 423 lines download raw bytes

1/*
2 * Cabinet with synchronization on a remote server
3 * front-end admin scripts
4 * by GTXTYMT - https://gtxtymt.xyz
5 */
6jQuery(function($) {
7    $(document).ready(function() {
8        $('.admin_get_user button.btn').click(function(e) {
9            e.preventDefault();
10            is = {
11                'answer': '.admin_get_user .answer',
12                'form': '.admin_get_user',
13                'error': false,
14                'append_data': '.user_append'
15            };
16
17            $(is.append_data).empty();
18
19            $('.admin_get_user input').each(function() {
20                if($(this).val().length > 0) return true;
21                $(this).parents('.form-group').addClass('has-error');
22                is.error = true;
23            });
24
25            if(is.error) {
26                $(is.answer).text('Заполните все поля.');
27                return false;
28            }
29
30            $(is.answer).text('Поиск пользователя...');
31
32            $.ajax({
33                type: 'POST',
34                url: gtx_config.ajax,
35                data: {'action': 'cabinet_admin_get_user', 'form': $(is.form).serializeArray()},
36                dataType: 'json',
37                success: function(response) {
38                    if(response.error) {
39                        $(is.answer).text(response.answer);
40                    }
41                    else {
42                        $(is.answer).empty();
43                        $(is.append_data).html('<form class="user_info"></form>');
44                        $.each(response.items, function() {
45                            $.each(this, function(key, value) {
46                                if(key == 'USERPASSWORD')
47                                    $(is.append_data).find('.user_info').append('<div hidden class="form-group"><div class="col-md-3"><label>' + key + '</label></div><div class="col-md-9"><input disabled autocomplete="off" type="password" class="form-control" name="' + key + '" value="' + value + '"></div></div>');
48                                else
49                                    if(key !== 'ID' && key !== 'PUSEDATA' && key !== 'Concurrent_User' && key !== 'ScopeName' && key !== 'UserName'  && key !== 'created_by')
50                                        $(is.append_data).find('.user_info').append('<div class="form-group"><div class="col-md-3"><label>' + key + '</label></div><div class="col-md-9"><input type="text" class="form-control" name="' + key + '" value="' + value + '"></div></div>');
51                                    else
52                                        $(is.append_data).find('.user_info').append('<div class="form-group"><div class="col-md-3"><label>' + key + '</label></div><div class="col-md-9"><input disabled autocomplete="off" type="text" class="form-control" name="' + key + '" value="' + value + '"></div></div>');
53                            });
54                        });
55                        $(is.append_data).find('.user_info').append('<button type="submit" class="btn btn-default save">Сохранить</button><button type="submit" class="btn btn-default delete">Удалить пользователя</button>');
56                    }
57                }
58            });
59        });
60
61        $('.user_append')
62            .on('click', 'button.btn.save', function(e) {
63            e.preventDefault();
64            is = {
65                'answer': '.admin_get_user .answer',
66                'form': '.user_info'
67            };
68
69            $(is.answer).text('Изменение данных...');
70
71            $.ajax({
72                type: 'POST',
73                url: gtx_config.ajax,
74                data: {'action': 'cabinet_admin_change_user', 'form': $(is.form).serializeArray(), 'id': $(is.form).find('input[name=ID]').val()},
75                dataType: 'json',
76                success: function(response) {
77                    $(is.answer).text(response.answer);
78                }
79            });
80        })
81            .on('click', 'button.btn.delete', function(e) {
82                e.preventDefault();
83                is = {
84                    'answer': '.admin_get_user .answer',
85                    'id': $('.user_info input[name=ID]').val(),
86                    'append_data': '.user_append'
87                };
88
89                if(!confirm('Вы уверены, что хотите удалить данного пользователя? Это действие нельзя будет отменить.'))
90                    return false;
91                if(is.id.length < 1) {
92                    $(is.answer).text('Не найден ID пользователя.');
93                    return false;
94                }
95
96                $(is.answer).text('Удаление пользователя...');
97
98                $.ajax({
99                    type: 'POST',
100                    url: gtx_config.ajax,
101                    data: {'action': 'cabinet_admin_delete_user', 'id': is.id},
102                    dataType: 'json',
103                    success: function(response) {
104                        $(is.answer).text(response.answer);
105                        if(!response.answer)
106                            $(is.append_data).empty();
107                    }
108                });
109            });
110
111        $('.send_message button.btn').click(function(e) {
112            e.preventDefault();
113            is = {
114                'answer': '.send_message .answer',
115                'form': '.send_message',
116                'error': false
117            };
118
119            $('.send_message input, .send_message textarea').each(function() {
120                if($(this).val().length > 0 || $(this).attr('name') === 'id') {
121                    $(this).parents('.form-group').removeClass('has-error');
122                }
123                else {
124                    $(this).parents('.form-group').addClass('has-error');
125                    is.error = true;
126                }
127            });
128
129            if(is.error) {
130                $(is.answer).text('Заполните все поля.');
131                return false;
132            }
133
134            $(is.answer).text('Отправка сообщения...');
135
136            $.ajax({
137                type: 'POST',
138                url: gtx_config.ajax,
139                data: {'action': 'cabinet_admin_send_message', 'form': $(is.form).serializeArray()},
140                dataType: 'json',
141                success: function(response) {
142                    $(is.answer).text(response.answer);
143                }
144            });
145        });
146
147        $('.admin_search_pay button.btn').click(function(e) {
148            e.preventDefault();
149            is = {
150                'answer': '.admin_search_pay .answer',
151                'form': '.admin_search_pay',
152                'error': false,
153                'append_data': '.pays_search'
154            };
155
156            $(is.append_data).empty();
157
158            $('.admin_search_pay input').each(function() {
159                if($(this).val().length > 0) return true;
160                $(this).parents('.form-group').addClass('has-error');
161                is.error = true;
162            });
163
164            if(is.error) {
165                $(is.answer).text('Заполните все поля.');
166                return false;
167            }
168
169            $(is.answer).text('Поиск оплат...');
170
171            $.ajax({
172                type: 'POST',
173                url: gtx_config.ajax,
174                data: {'action': 'cabinet_admin_pay_search', 'form': $(is.form).serializeArray()},
175                dataType: 'json',
176                success: function(response) {
177                    if(response.error)
178                        $(is.answer).text(response.answer);
179                    else {
180                        $(is.answer).empty();
181                        $(is.append_data).html('<table class="table' +
182                            ' table-hover"><thead><tr><th>ID</th><th>Пригласил</th><th>Создано</th><th>Тариф</th><th>Комментарий</th><th>Дата оплаты</th></tr></thead><tbody></tbody></table>');
183                        $.each(response.items, function() {
184                            $(is.append_data).find('tbody').append('<tr><td>' + this.user_login + '</td><td>' + this.invite + '</td><td>' + this.created_by_login + '</td><td>' + this.tarif_time + '</td><td>' + this.comment + '</td><td>' + this.payed_date + '</td></tr>');
185                        });
186                    }
187                }
188            });
189        });
190
191        $('.admin_get_user input, .send_message textarea').keyup(function() {
192            if($(this).val().length > 0)
193                $(this).parents('.form-group').removeClass('has-error');
194            else
195                $(this).parents('.form-group').addClass('has-error');
196        });
197
198        $('.pay_table thead th').click(function() {
199            var isActive = $(this).hasClass('active');
200
201            $(this).parent().find('th').removeClass('active');
202            $(this).addClass('active');
203
204            if(isActive) {
205                var sortBy = $(this).data('by') == 'DESC' ? 'ASC' : 'DESC';
206                $(this).data('by', sortBy);
207            }
208            else {
209                var sortBy = $(this).data('by');
210            }
211
212            var table = $(this).parents('.pay_table').find('tbody'),
213                page = $('.pagination.pay li.active').data('page'),
214                sort = $(this).data('sort'),
215                date = {
216                    from: $('.datetime_filter input[name=from]').val(),
217                    to: $('.datetime_filter input[name=to]').val()
218                };
219
220            table.empty();
221
222            $.ajax({
223                type: 'POST',
224                url: gtx_config.ajax,
225                data: {action: 'cabinet_admin_pay_getlist', sort: sort, sortby: sortBy, page: page, date: date},
226                dataType: 'json',
227                success: function(response) {
228                    if(response.error) {
229                        return false;
230                    }
231
232                    $('.all_count').text(response.allSum.pays_count);
233                    $('.all_sum').text(response.allSum.pays_sum);
234                    $('.pay_count').text(response.paySum.pays_count);
235                    $('.pay_sum').text(response.paySum.pays_sum);
236
237                    $.each(response.items, function() {
238                        var payed_date = this.is_pay == 1 ? this.payed_date : '-';
239                        table.append('<tr><td>' + this.user_login + '</td><td>' + this.invite + '</td><td>'+ this.created_by_login +'</td><td>' + this.tarif_time + '</td><td>' + this.comment + '</td><td>' + payed_date + '</td></tr>');
240                    });
241
242                    var pagination = $('.pagination.pay');
243                    pagination.empty();
244                    for(i = 1; i <= response.pages; i++) {
245                        pagination.append('<li data-page="' + i + '"><a href="#">' + i + '</a></li>');
246                    }
247                }
248            });
249        });
250
251        $('.pagination.pay').on('click', 'li a', function(e) {
252            e.preventDefault();
253            $(this).parents('.pagination.pay').find('li').removeClass('active');
254            $(this).parent().addClass('active');
255
256            var page = $(this).parent().data('page'),
257                sort = $('.pay_table thead th.active').data('sort'),
258                sortBy = $($('.pay_table thead th.active')).data('by'),
259                table = $('.pay_table tbody'),
260                date = {
261                    from: $('.datetime_filter input[name=from]').val(),
262                    to: $('.datetime_filter input[name=to]').val()
263                };;
264
265            table.empty();
266
267            $.ajax({
268                type: 'POST',
269                url: gtx_config.ajax,
270                data: {action: 'cabinet_admin_pay_getlist', sort: sort, sortby: sortBy, page: page, date: date},
271                dataType: 'json',
272                success: function(response) {
273                    if(response.error) {
274                        return false;
275                    }
276
277                    $('.all_count').text(response.allSum.pays_count);
278                    $('.all_sum').text(response.allSum.pays_sum);
279                    $('.pay_count').text(response.paySum.pays_count);
280                    $('.pay_sum').text(response.paySum.pays_sum);
281
282                    $.each(response.items, function() {
283                        var payed_date = this.is_pay == 1 ? this.payed_date : '-';
284                        table.append('<tr><td>' + this.user_login + '</td><td>' + this.invite + '</td><td>'+ this.created_by_login +'</td><td>' + this.tarif_time + '</td><td>' + this.comment + '</td><td>' + payed_date + '</td></tr>');
285                    });
286
287                    var pagination = $('.pagination.pay');
288                    pagination.empty();
289                    for(i = 1; i <= response.pages; i++) {
290                        pagination.append('<li data-page="' + i + '"><a href="#">' + i + '</a></li>');
291                    }
292                }
293            });
294        });
295
296        $('.admin_dealer_add button').click(function(e) {
297            e.preventDefault();
298            var answer = $(this).parents('.admin_dealer_add').find('.answer'),
299                dealer_id = $(this).parents('.admin_dealer_add').find('input[name=id]');
300
301            answer.text('Обработка...');
302            $.ajax({
303                type: 'POST',
304                url: gtx_config.ajax,
305                data: {action: 'cabinet_admin_dealer_add', id: dealer_id.val()},
306                dataType: 'json',
307                success: function(response) {
308                    answer.text(response.answer);
309                }
310            });
311        });
312
313        $('.dealers_list .delete').click(function(e) {
314            e.preventDefault();
315            var dealer_id = $(this).data('id'),
316                _this = $(this);
317            $.ajax({
318                type: 'POST',
319                url: gtx_config.ajax,
320                data: {action: 'cabinet_admin_dealer_remove', id: dealer_id},
321                dataType: 'json',
322                success: function(response) {
323                    if(response.error) {
324                        alert(response.answer);
325                    }
326                    else {
327                        _this.parents('tr').remove();
328                    }
329                }
330            });
331        });
332
333        $('.dealer_user_add button').click(function(e) {
334            e.preventDefault();
335            var form = $('.dealer_user_add').serializeArray(),
336                answer = $('.dealer_user_add .answer');
337
338            answer.text('Создание пользователя...');
339            $.ajax({
340                type: 'POST',
341                url: gtx_config.ajax,
342                data: {action: 'cabinet_dealer_user_add', form: form},
343                dataType: 'json',
344                success: function(response) {
345                    answer.text(response.answer);
346                }
347            });
348        });
349
350        $('.dealer_subscription button').click(function(e) {
351            e.preventDefault();
352
353            var form = $('.dealer_subscription').serializeArray(),
354                answer = $('.dealer_subscription .answer');
355
356            answer.text('Отправка данных...');
357
358            $.ajax({
359                type: 'POST',
360                url: gtx_config.ajax,
361                data: {action: 'cabinet_dealer_subscribe', form: form},
362                dataType: 'json',
363                success: function(response) {
364                    answer.text(response.answer);
365
366                    if(!response.error && response.form !== undefined) {
367                        $('.dealer_subscription').empty().before(response.form);
368                        setTimeout(function () {
369                            $('.robokassa').submit();
370                        }, 3000);
371                    }
372                }
373            });
374        });
375
376        $('input.datetime').datepicker({
377            todayHighlight: true
378        });
379
380        $('.datetime_filter').submit(function(e) {
381            e.preventDefault();
382
383            var page = $('.pagination.pay li.active').data('page'),
384                sort = $('.pay_table thead th.active').data('sort'),
385                sortBy = $($('.pay_table thead th.active')).data('by'),
386                table = $('.pay_table tbody'),
387                date = {
388                    from: $(this).find('input[name=from]').val(),
389                    to: $(this).find('input[name=to]').val()
390                };
391
392            table.empty();
393
394            $.ajax({
395                type: 'POST',
396                url: gtx_config.ajax,
397                data: {action: 'cabinet_admin_pay_getlist', sort: sort, sortby: sortBy, page: page, date: date},
398                dataType: 'json',
399                success: function(response) {
400                    if(response.error) {
401                        return false;
402                    }
403
404                    $('.all_count').text(response.allSum.pays_count);
405                    $('.all_sum').text(response.allSum.pays_sum);
406                    $('.pay_count').text(response.paySum.pays_count);
407                    $('.pay_sum').text(response.paySum.pays_sum);
408
409                    $.each(response.items, function() {
410                        var payed_date = this.is_pay == 1 ? this.payed_date : '-';
411                        table.append('<tr><td>' + this.user_login + '</td><td>' + this.invite + '</td><td>'+ this.created_by_login +'</td><td>' + this.tarif_time + '</td><td>' + this.comment + '</td><td>' + payed_date + '</td></tr>');
412                    });
413
414                    var pagination = $('.pagination.pay');
415                    pagination.empty();
416                    for(i = 1; i <= response.pages; i++) {
417                        pagination.append('<li data-page="' + i + '"><a href="#">' + i + '</a></li>');
418                    }
419                }
420            });
421        });
422    });
423});

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.