PageSourceSearch

https://tdxy.com.cn/static/js/js.js

js tdxy.com.cn collected 2026-10-06 13:14:49 UTC 6,723 bytes, 184 lines download raw bytes

1//导航二级菜单
2function ds_mainmenu(ulclass) {
3    document.addEventListener("DOMContentLoaded", function () {
4        document.querySelectorAll(ulclass + " li").forEach(function (li) {
5            li.addEventListener("mouseenter", function () {
6                let submenu = li.querySelector("ul");
7                if (submenu) submenu.style.display = "block";
8            });
9            li.addEventListener("mouseleave", function () {
10                let submenu = li.querySelector("ul");
11                if (submenu) submenu.style.display = "none";
12            });
13        });
14    });
15}
16ds_mainmenu(".header-menu-ul");
17
18
19
20/*刷新页面ajaxloading*/
21document.addEventListener("DOMContentLoaded", function () {
22    document.body.classList.add("ajaxloading");
23    setTimeout(function () {
24        document.body.classList.remove("ajaxloading");
25    }, 500);
26});
27
28
29
30//table预设calss
31document.querySelectorAll('.wznrys table').forEach(table => {
32    table.classList.add('table', 'text-nowrap');
33    let wrapper = document.createElement('div');
34    wrapper.className = 'overflow-x-auto';
35    table.parentNode.insertBefore(wrapper, table);
36    wrapper.appendChild(table);
37});
38
39
40//toc
41document.addEventListener('DOMContentLoaded', function () {
42  var box = document.querySelector('.text_name_box');
43  var toc = document.getElementById('toc');
44  if (!box || !toc) return;
45  var heads = box.querySelectorAll('h1,h2,h3,h4,h5,h6');
46  if (!heads.length) return;
47  var ul = document.createElement('ul');
48  heads.forEach(function (h, i) {
49    if (!h.id) h.id = 'toc-' + i;
50    var a = document.createElement('a');
51    a.href = '#' + h.id;
52    a.textContent = h.textContent.trim();
53    a.addEventListener('click', function (e) {
54      e.preventDefault();
55      h.scrollIntoView({ behavior: 'smooth', block: 'start' });
56    });
57    var li = document.createElement('li');
58    li.appendChild(a);
59    ul.appendChild(li);
60  });
61  toc.innerHTML = '';
62  toc.appendChild(ul);
63  var links = ul.querySelectorAll('a');
64  function setActive() {
65    var bt = box.getBoundingClientRect().top;
66    var active = 0;
67    heads.forEach(function (h, i) {
68      if (h.getBoundingClientRect().top - bt <= 10) active = i;
69    });
70    links.forEach(function (a, i) {
71      a.classList.toggle('active', i === active);
72    });
73  }
74  box.addEventListener('scroll', setActive);
75  setActive();
76});
77
78/* ====================================================
79   移动端 Offcanvas 菜单原生驱动 (替代 Bootstrap)
80   ==================================================== */
81document.addEventListener('DOMContentLoaded', function() {
82    var mobBtn = document.querySelector('.mobile-menu-btn');
83    var mobNav = document.getElementById('mobile_right_nav');
84    
85    if(mobBtn && mobNav) {
86        // 点击汉堡按钮展开菜单
87        mobBtn.addEventListener('click', function(e) {
88            e.preventDefault();
89            mobNav.classList.add('is-open');
90        });
91        
92        // 点击 X 按钮关闭菜单
93        var closeBtn = mobNav.querySelector('button[aria-label="Close"]');
94        if(closeBtn) {
95            closeBtn.addEventListener('click', function() {
96                mobNav.classList.remove('is-open');
97            });
98        }
99    }
100});
101
102/* ====================================================
103   修复脱离 Bootstrap 后的选项卡切换 (Tabs)
104   ==================================================== */
105document.addEventListener('DOMContentLoaded', function() {
106    const tabs = document.querySelectorAll('.jzt-conf-tabs .nav-link');
107    
108    // 只有当前页面存在选项卡时才执行,避免全局报错
109    if (tabs.length > 0) {
110        const panes = document.querySelectorAll('.tab-content .tab-pane');
111
112        tabs.forEach(tab => {
113            tab.addEventListener('click', function(e) {
114                e.preventDefault();
115                
116                // 1. 移除所有选项卡和内容区的高亮与显示状态
117                tabs.forEach(t => t.classList.remove('active'));
118                panes.forEach(p => p.classList.remove('active', 'show'));
119                
120                // 2. 激活当前点击的选项卡
121                this.classList.add('active');
122                
123                // 3. 找到对应的目标内容区并显示
124                const targetId = this.getAttribute('data-bs-target');
125                if (targetId) {
126                    const targetPane = document.querySelector(targetId);
127                    if (targetPane) {
128                        targetPane.classList.add('active', 'show');
129                    }
130                }
131            });
132        });
133    }
134});
135
136
137document.addEventListener('DOMContentLoaded', function() {
138    // 1. 顶部跑马灯初始化
139    if (document.querySelector('.jzt-ticker-swiper') && typeof Swiper !== 'undefined') {
140        new Swiper('.jzt-ticker-swiper', {
141            slidesPerView: 1.5, spaceBetween: 10, freeMode: true,
142            navigation: { nextEl: '.ticker-btn-next', prevEl: '.ticker-btn-prev' },
143            breakpoints: { 768: { slidesPerView: 3.5 }, 1200: { slidesPerView: 5 } }
144        });
145    }
146
147    // 2. 体育直播大厅 Tab 过滤逻辑 (中间大厅)
148    const hallTabs = document.querySelectorAll('#jzt-home-tabs li');
149    const mixItems = document.querySelectorAll('.mix-item');
150    hallTabs.forEach(tab => {
151        tab.addEventListener('click', function() {
152            hallTabs.forEach(t => t.classList.remove('active'));
153            this.classList.add('active');
154            const filter = this.getAttribute('data-filter');
155            mixItems.forEach(item => {
156                item.style.display = (filter === 'all' || item.classList.contains('mix-' + filter)) ? 'flex' : 'none';
157            });
158        });
159    });
160
161    // 3. 🔥 新增:侧边栏积分榜切换逻辑 (解决中超点击没反应)
162    const sideTabs = document.querySelectorAll('.side-tabs-mini span');
163    sideTabs.forEach(tab => {
164        tab.addEventListener('click', function() {
165            const targetId = this.getAttribute('data-tab');
166            const parent = this.closest('.side-widget');
167            
168            // 切换按钮高亮
169            sideTabs.forEach(s => s.classList.remove('active'));
170            this.classList.add('active');
171            
172            // 切换内容显隐
173            parent.querySelectorAll('.s-tab-pane').forEach(pane => {
174                pane.classList.remove('active');
175                pane.style.display = 'none';
176            });
177            const activePane = document.getElementById(targetId);
178            if(activePane) {
179                activePane.classList.add('active');
180                activePane.style.display = 'block';
181            }
182        });
183    });
184});

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.