PageSourceSearch

https://vtv.gov.vn/themes/viettelfamily/js/game.js?v=20200612142221

js vtv.gov.vn collected 2026-09-24 10:16:21 UTC 11,940 bytes, 401 lines download raw bytes

1if(typeof config === 'undefined') var config = '';
2class Ajax {
3
4    constructor(hasFile = false) {
5        this.hasFile = hasFile;
6    }
7
8    call(url, data, type = 'POST') {
9        return new Promise((resolve, reject) => {
10
11            let options = {
12                url: url,
13                type: type,
14                data: data,
15                datatype: 'JSON',
16                beforeSend: function () {
17
18                },
19                success: function (data) {
20                    resolve(data);
21                },
22                error: function (xhr) {
23                    reject(xhr);
24                },
25                complete: function () {
26
27                },
28            };
29
30            if (this.hasFile) {
31                options = {
32                    ...options, ...{
33                        cache: false,
34                        processData: false,
35                        contentType: false,
36                    }
37                }
38            }
39
40            $.ajax(options);
41        })
42    }
43}
44
45class AjaxList {
46
47    constructor(url, data = {}, configFilter = {}, dataType = 'GET') {
48        this.data = {
49            'category_id': 0,
50        }
51        if (typeof data.category_id !== "undefined") {
52            delete this.data.category_id
53        }
54        this.data = {...this.data, ...data};
55        this.url = url;
56        this.configInput = configFilter;
57        this.dataType = dataType;
58        this.old = {};
59        this.old_info = {};
60        
61    }
62
63    run(boxList = '') {
64
65        if (typeof boxList === "string" && boxList.length > 0) {
66            this.boxList = boxList;
67        }
68
69        this.ajax(this.data);
70        this.pagination();
71        this.tab();
72        this.filter();
73    }
74
75    runDone(data) {}
76
77    done(func) {
78        this.runDone = func;
79    }
80
81    ajax(dataAjax = {}, boxList = '') {
82        let _this = this;
83
84        if (jQuery.isEmptyObject(dataAjax)) {
85            dataAjax = _this.data;
86        }
87
88        if (typeof boxList === "string" && boxList.length > 0) {
89            _this.boxList = boxList;
90        }
91
92        let key_old = Object.entries(_this.data).map(([key, val]) => `${key}=${val}`).join('&');
93        var key_old_info = Object.entries(_this.data).map(([key, val]) => `${key}=${val}`).join('&');
94
95        if (typeof _this.old[key_old] !== "undefined") {
96            $(_this.boxList).html(_this.old[key_old].data.html || '');
97            _this.runDone( _this.old[key_old] );
98            return;
99        }
100
101        return new Ajax()
102            .call(_this.url, dataAjax, _this.dataType)
103            .then((res) => {
104                _this.old[key_old] = res;
105                _this.old_info[key_old_info] = res;
106                if (typeof _this.boxList !== "undefined") {
107                    $(_this.boxList).html(res.data.html || '');
108                }
109                _this.runDone(res);
110                return res;
111            })
112    }
113
114    pagination() {
115        let _this = this;
116        $(document).on("click", ".pagination a", function (event) {
117            event.preventDefault();
118            _this.data.page = $(this).attr('href').split('page=')[1] || 0;
119
120            _this.ajax(_this.data);
121        });
122    }
123
124    // block TAB required id "tabCategory"
125    tab(idBox = '#tabCategory') {
126        let _this = this;
127        $(idBox).on("click", "a", function (event) {
128            event.preventDefault();
129            let id = $(this).data('id');
130            if (parseInt(_this.data.category_id) !== parseInt(id)) {
131                $(this).closest(idBox).find('a').removeClass('active');
132                $(this).addClass('active');
133                delete _this.data.page;
134                _this.data.category_id = id;
135                _this.ajax(_this.data);
136            }
137        });
138    }
139
140    // block FORM required id "formFilter"
141    filter(idBox = '#formFilter', isAuto = true) {
142        let _this = this;
143
144        if (isAuto) {
145
146            if (!jQuery.isEmptyObject(_this.configInput)) {
147
148                Object.keys(_this.configInput).map(function (key, index) {
149
150                    $(idBox).on("change", _this.configInput[key], function (event) {
151
152                        delete _this.data.page;
153                        _this.data[key] = $(this).val();
154                        _this.ajax(_this.data);
155                    });
156                });
157            }
158        } else {
159
160            $(document).on("submit", idBox, function (event) {
161                event.preventDefault();
162
163                let data = $(this).serializeArray();
164
165                new Promise((resolve => {
166                    data.map((e, i) => {
167                        _this.data[e.name] = e.value;
168                    });
169                    delete _this.data.page;
170                    resolve(_this.data);
171                })).then((res) => {
172                    _this.ajax(res);
173                });
174
175            })
176
177        }
178    }
179    selectTwo(idBox = '#formFilter',classSelect2){
180        $(idBox).find(classSelect2).select2();
181        $(idBox).on('select2:select','classSelect2', function (e) {
182            let obj = e.params.data;
183            delete _this.data.page;
184            _this.data['event']=obj.id;
185            _this.ajax(_this.data);
186        });
187    }
188    oldInfo(){
189        return this.old_info;
190    }
191
192}
193
194var WIDGET_GAME_ENGLISH = {
195    init () {
196        if ($('.html-widget-game-english').length) {
197            this.run();
198        }
199    },
200    run () {
201        let ajax_list = new AjaxList('/ajax-get-rank-widget-games-english');
202        ajax_list.ajax({}, '.html-widget-game-english');
203    }
204}
205
206WIDGET_GAME_ENGLISH.init();
207
208let categoryId = $('#cateRank li.active').data('id');
209let methodId = $('#formFilterRank [name="method"]').val();
210let week = $('#formFilterRank [name="week"]').val();
211let quarter = $('#formFilterRank [name="quarter"]').val();
212let event = $('#formFilterRank [name="event"]').val();
213
214
215
216// $('#formFilterRank').on('select2:select','.select-event', function (e) {
217//     var data = e.params.data;
218//     $('.input-event').val(data.id);
219//     $('.input-event').change();
220// });
221$('#cateRank li').on('click',function(){
222    $('#circularG').show();
223    $('.mess_null').css('display','none');
224    $('#myRanking').html('');
225    $('#infoRanking').html('');
226    $('#listRanking').html('');
227});
228$('.search-radio-ranking .i-check').on('click',function(){
229    $('#circularG').show();
230    $('.mess_null').css('display','none');
231    $('#myRanking').html('');
232    $('#infoRanking').html('');
233    $('#listRanking').html('');
234});
235$('select[name="quarter"]').on('change',function(){
236    $('#circularG').show();
237    $('.mess_null').css('display','none');
238    $('#myRanking').html('');
239    $('#infoRanking').html('');
240    $('#listRanking').html('');
241});
242$('select[name="week"]').on('change',function(){
243    $('#circularG').show();
244    $('.mess_null').css('display','none');
245    $('#myRanking').html('');
246    $('#infoRanking').html('');
247    $('#listRanking').html('');
248});
249$('select[name="quarter"]').on('change',function(){
250    $('#circularG').show();
251    $('.mess_null').css('display','none');
252    $('#myRanking').html('');
253    $('#infoRanking').html('');
254    $('#listRanking').html('');
255});
256$('select[name="event"]').on('change',function(){
257    $('#circularG').show();
258    $('.mess_null').css('display','none');
259    $('#myRanking').html('');
260    $('#infoRanking').html('');
261    $('#listRanking').html('');
262});
263$('.search-input-ranking input[name="keyword"]').on('change',function(){
264    $('#circularG').show();
265    $('.mess_null').css('display','none');
266    $('#myRanking').html('');
267    $('#infoRanking').html('');
268    $('#listRanking').html('');
269})
270
271
272$('#cateRank li').on("click", function () {
273    $('#cateRank li').removeClass('active');
274    $(this).addClass('active');
275    let id = $(this).data('id');
276    $('.search-select-ranking .form-control').removeClass('show');
277    $('.search-select-ranking .form-control.s' + id).addClass('show');
278});
279
280let data = {
281    category_id: categoryId,
282    method: methodId,
283    week: week,
284    quarter: quarter,
285    event: event,
286    info: '',
287}
288
289if(config){
290    var ajax_list = new AjaxList(config.routes.zone, data, {
291        method: '[name="method"]',
292        keyword: '[name="keyword"]',
293        week: '[name="week"]',
294        quarter: '[name="quarter"]',
295        event: '[name="event"]',
296    
297    });
298    ajax_list.tab('#cateRank');
299    ajax_list.pagination();
300    ajax_list.filter('#formFilterRank', true);
301    ajax_list.selectTwo('#formFilterRank','.select-event');
302    ajax_list.ajax({}, '#listRanking');
303    ajax_list.done((res) => {
304        $('.wrap-list-ranking #circularG').hide();
305    
306    
307        if($('.method_input').val()==2) $('.name-group-game').show();
308        else $('.name-group-game').hide();
309    
310        
311        $('#myRanking').html(res.data.html_my);
312        $('#infoRanking').html(res.data.html_info);
313        
314        if($('.detail-person-ranking').length==0 && $('.rank_list').length==0 && $('.ranking-me').length==0){
315            $('.mess_null').css('display','flex');
316        }else $('.mess_null').css('display','none');
317    
318    });
319}
320
321// $('.search-radio-ranking input[name="method"]').on('click',function(){
322//     if($(this).val()==2) $('.name-group-game').show();
323//     else $('.name-group-game').hide();
324// });
325
326$('.select2-container').addClass('form-control');
327$('.select2-container').addClass('S3');
328$('#nav_user_name').dropdown();
329
330$('#cateRank li').on('click',function(){
331    var data_id = $(this).attr('data-id');
332
333    if(data_id==3){
334        $('#select-ranking').addClass('event');
335    }else if(data_id==2){
336        $('#select-ranking').removeClass('event');
337    }else if(data_id==1){
338        $('#select-ranking').removeClass('event');
339    }
340})
341
342
343$('.avt-game').each(function(){
344    let src = $(this).attr('src');
345    
346})
347$('input[name="method"]').on('click',function(){
348    let val = $(this).val();
349    $('.method_input').val(val);
350})
351
352if(config){
353    var old_info = ajax_list.oldInfo();
354    // click user detail
355    $('#listRanking').on('click','.item-person-ranking',function(event){
356
357    let html_load = '<div class="detail-person-ranking"><div id="circularG" class="circularG_two"><div id="circularG_1" class="circularG"></div><div id="circularG_2" class="circularG"></div><div id="circularG_3" class="circularG"></div><div id="circularG_4" class="circularG"></div><div id="circularG_5" class="circularG"></div><div id="circularG_6" class="circularG"></div><div id="circularG_7" class="circularG"></div><div id="circularG_8" class="circularG"></div></div></div>';
358    let data_code = $(this).data('code');
359
360
361    if(!$(this).hasClass('active')){
362        $('.item-person-ranking').removeClass('active');
363        $(this).addClass('active');
364        $('#infoRanking').html(html_load);
365        data_info = {
366            category_id: $('#cateRank li.active').data('id'),
367            method: $('.method_input').val(),
368            week: $('#formFilterRank [name="week"]').val(),
369            quarter: $('#formFilterRank [name="quarter"]').val(),
370            event: $('#formFilterRank [name="event"]').val(),
371            info: data_code,
372        }
373        
374        key_old_info = Object.entries(data_info).map(([key, val]) => `${key}=${val}`).join('&');
375        
376        if (typeof old_info [key_old_info] !== "undefined") {
377            $('#infoRanking').html(old_info[key_old_info].data.html_info || '');
378            return;
379        }
380        
381        $.ajaxSetup({
382            headers: {
383                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
384            }
385        });
386        $.ajax({
387            type: "GET",
388            url: config.routes.zone,
389            data:  data_info,
390            dataType: "json",
391            success: function (res) {
392                old_info[key_old_info] = res;
393                console.log(old_info);
394                $('#infoRanking').html(res.data.html_info);
395            }
396        });
397    }
398
399    })
400// end
401}

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.