PageSourceSearch

https://metatft.gg/wp-content/themes/tftmeta/dist/js/custom.js?ver=1790973371

js metatft.gg collected 2026-10-02 22:29:03 UTC 9,422 bytes, 242 lines download raw bytes

1(function ($) {
2    "use strict";
3    function tftmeta_ajax_tooltipster(){
4        $('[data-tooltip]').tooltipster({
5            interactive:true,
6            maxWidth:400,
7            trigger:tftmeta_object.trigger_tooltip,
8            //trigger:'click',
9            contentAsHTML:true,
10            content:'Loading...',
11            animation:'',
12            functionBefore: (instance, helper)=>{
13                var $origin = $(helper.origin)
14                var tooltip = $origin.data('tooltip');
15                var tooltip_id = tooltip.type + '__' + tooltip.id
16
17                if ($('#' + tooltip_id).length) {
18                    instance.content($('#' + tooltip_id).html());
19                } else {
20                    $.ajax({
21                        type: 'POST',
22                        url: tftmeta_object.ajax_url,
23                        data: {
24                            action: 'tftmeta_ajax_tooltip',
25                            nonce: tftmeta_object.nonce,
26                            tooltip: tooltip
27                        },
28                        success: (response) => {
29                            $('body').append('<div class="ajax-tooltip-loaded" id="' + tooltip_id + '">' + response + '</div>')
30                            instance.content(response);
31                        }
32                    });
33                }
34
35            }
36        });
37        $('.tooltipster').tooltipster({
38            maxWidth:300,
39            trigger:tftmeta_object.trigger_tooltip,
40        })
41    }
42    tftmeta_ajax_tooltipster()
43
44    $( document ).ajaxComplete(function() {
45        tftmeta_ajax_tooltipster()
46    });
47
48    $(document).on('click','.comp__button__more',function (){
49        var id = $(this).data('id');
50        $('#'+id).toggleClass('opend')
51    })
52    $('[data-comp_id]').each(function(index, element) {
53        let comp_id = $(this).data('comp_id')
54        $.ajax({
55            type: 'POST',
56            url: tftmeta_object.ajax_url,
57            data: {
58                action: 'f9_ajax_get_comp',
59                nonce: tftmeta_object.nonce,
60                comp_id: comp_id
61            },
62            success: (response) => {
63                $(this).html(response)
64            }
65        });
66    });
67    $(document).ready( function () {
68        var options = {
69            responsive: true,
70            select: true,
71            paging: false,
72            language:{
73                "zeroRecords":    "Không tìm thấy kết quả nào",
74                "info":           "Hiển thị _START_ đến _END_ của _TOTAL_ kết quả",
75                "infoEmpty":      "Hiển thị 0 đến 0 của 0 kết quả",
76                "infoFiltered":   "(được lọc từ tổng số _MAX_ mục nhập)",
77            },
78            layout: {
79                topEnd: {
80                    search: {
81                        placeholder: 'Tìm kiếm'
82                    }
83                }
84            }
85        }
86        var table = $('.data__table').DataTable(options);
87        function hashfilter(hashtag){
88            var arr = hashtag.split('-')
89            if (arr[0] && arr[1]){
90                table.columns().search('').draw();
91                var column = arr[0].replace('#','')
92                var val = arr[1]
93                table.column(parseInt(column)).search(val).draw();
94                $('.dt-container>.dt-layout-row .dt-layout-start').html('<span class="fillter__result"><span>Lọc Theo: '+val +'</span><svg class="clear__fillter" viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></span>')
95            }
96        }
97        if (window.location.hash) {
98            // The URL has a hashtag
99            let hashtag = decodeURIComponent(window.location.hash)
100
101            hashfilter(hashtag)
102            // You can perform actions based on the hash here
103        }
104        $(window).on('hashchange', function() {
105            // This function will execute whenever the URL hash changes.
106            let hashtag = decodeURIComponent(window.location.hash)
107            hashfilter(hashtag)
108
109        });
110        function remove_hash_from_url() {
111            var uri = window.location.toString();
112            if (uri.indexOf("#") > 0) {
113                var clean_uri = uri.substring(0,
114                    uri.indexOf("#"));
115
116                window.history.replaceState({},
117                    document.title, clean_uri);
118            }
119            table.columns().search('').draw();
120        }
121        $(document).on('click','.clear__fillter', ()=>{
122            remove_hash_from_url()
123            $('.dt-container>.dt-layout-row .dt-layout-start').html('')
124        })
125        $('.filter__item').click(function() {
126            $(this).toggleClass('active');
127            data_table_custom_filter()
128        });
129        $('.f9_data_table_filter input[data-type="text"]').keyup(function() {
130
131            data_table_custom_filter()
132        });
133        $('.f9_data_table_filter select[data-type="select"]').change(function() {
134
135            data_table_custom_filter()
136        });
137        $('.f9_data_table_filter .filter__button').click(function() {
138            $('.filter__item').each(function() {
139                $(this).removeClass('active')
140            })
141            $('.f9_data_table_filter input[data-type="text"]').each(function() {
142                $(this).val('')
143            })
144            $('.f9_data_table_filter select[data-type="select"]').each(function() {
145                $(this).val('')
146            })
147            data_table_custom_filter()
148        });
149
150
151        function data_table_custom_filter(){
152            table.columns().search('').draw();
153            let data ={}
154            $('.filter__item').each(function() {
155                if ($(this).hasClass('active')){
156                    var value = $(this).data('value')
157                    var column = $(this).closest('tr').data('column')
158                    if (value!=''){
159                        if (!data[column]){
160                            data[column] =[]
161                        }
162                        data[column].push(value)
163                    }
164                }
165            });
166            $('.f9_data_table_filter input[data-type="text"]').each(function() {
167                var value = $(this).val()
168                var column = $(this).closest('tr').data('column')
169                if (value!=''){
170                    if (!data[column]){
171                        data[column] =[]
172                    }
173                    data[column].push(value)
174                }
175
176            })
177            $('.f9_data_table_filter select[data-type="select"]').each(function() {
178                var value = $(this).val()
179                var column = $(this).closest('tr').data('column')
180                if (value!=''){
181                    if (!data[column]){
182                        data[column] =[]
183                    }
184                    data[column].push(value)
185                }
186            })
187            if (jQuery.isEmptyObject(data)){
188                table.columns().search('').draw();
189                $('.f9_data_table_filter tfoot').hide()
190            }else {
191                $.each(data, (key, value)=> {
192                    var regex = value.join('|')
193                    if(key =='all'){
194                        table.columns().search(regex,true, false, true)
195                    }else {
196                        table.column(key).search(regex,true, false, true)
197                    }
198
199                });
200                table.draw()
201                $('.f9_data_table_filter tfoot').show()
202            }
203            console.log(data)
204        }
205
206
207        function formatResult(state) {
208            if (!state.id) {
209                return state.text;
210            }
211            // Access the custom property directly from the state object
212            if (state.image) {
213                var $state = $('<span><img src="' + state.image + '" style="vertical-align: middle; width: 25px; margin-right: 5px;" /> ' + state.text + '</span>');
214                return $state;
215            }
216            return state.text;
217        }
218        var filter = $('#comp__filter_select').select2({
219            placeholder: 'Đội Hình Tiêu biểu',
220            data:tftmeta_object.filter_data,
221            allowClear: true,
222            templateResult: formatResult,
223            templateSelection: formatResult,
224            escapeMarkup: function(m) { return m; }
225        })
226        filter.on('select2:select', function(e) {
227            var selectedData = e.params.data;
228            console.log(selectedData)
229
230            // Check if the selected item has a specific 'url' property
231            if (selectedData.url) {
232                window.location.href = selectedData.url; // Redirect to the URL
233            }
234            // Otherwise, you can use the default 'id' property as the URL
235            else if (selectedData.id && selectedData.id.startsWith('https://')) {
236                window.location.href = selectedData.id;
237            }
238        });
239
240    } );
241
242})(jQuery);

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.