MediaWiki:Common.js
来自帮助文档
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ /* 重写首页代码 */ if (mw.config.get('wgPageName') === '首页') { $(function() { $("#contentwrapper").html('<div class="documentimg"><div class="container"><h2 class="title">文档</h2><img src="/images/2/2e/Documentimg.jpg" style="width: 100%;height: 100%;"></div></div><div class="container"><div class="row"><div class="col-3 doc-link"><a href="/index.php/开局指南" class="documentlist"><div class="doc-beancurd-cube-left"><div class="doc-beancurd-cube-title"><span>开局指南</span></div><div class="doc-beancurd-cube-des">设备开局相关文档</div></div><div class="doc-beancurd-cube-right"><img src="/images/6/64/Open-book.png" loading="lazy" style="width: 52px;height: 52px;"></div></a></div><div class="col-3 doc-link"><a href="/index.php/FAQ" class="documentlist"><div class="doc-beancurd-cube-left"><div class="doc-beancurd-cube-title"><span>FAQ</span></div><div class="doc-beancurd-cube-des">日常运维常见问题</div></div><div class="doc-beancurd-cube-right"><img src="/images/6/69/Cloud-computing.png" loading="lazy" style="width: 52px;height: 52px;"></div></a></div></div></div>')});} /* 重写开局指南代码 */ if (mw.config.get('wgPageName') === '开局指南') { $(function() { $("#contentwrapper").html('<div class="container"><div class="row welcome"><div class="col-12 Index--title--DvfFkW0">欢迎来到开局指南文档</div></div><div class="row"><div class="col-12 ModuleCard--left--Pzs9WCH">网关服务器</div><div class="col-3 model-col"><a href="/index.php/SMARTCT-E600P" class="model model-SMARTCT-E600P">SMARTCT-E600P</a></div><div class="col-3 model-col"><a href="/index.php/SMARTCT-E600" class="model model-SMARTCT-E600">SMARTCT-E600</a></div><div class="col-3 model-col"><a href="/index.php/MSG600" class="model">MSG600</a></div><div class="col-3 model-col"><a href="/index.php/MSG500M" class="model">MSG500M</a></div><div class="col-3 model-col"><a href="/index.php/MSG500S" class="model">MSG500S</a></div></div></div>')});} /* 重写Document页面代码 */ if (mw.config.get('wgPageName') === 'Document') { $(function() { $("#contentwrapper").html('<div class="documentimg"><div class="container"><h2 class="title">这里存放内部文档</h2><img src="/images/2/2e/Documentimg.jpg" style="width: 100%;height: 100%;"></div></div><div class="container"><div class="row"><div class="col-3 doc-link"><a href="/index.php/Document-cloud" class="documentlist"><div class="doc-beancurd-cube-left"><div class="doc-beancurd-cube-title"><span>云平台</span></div><div class="doc-beancurd-cube-des">云平台相关文档</div></div><div class="doc-beancurd-cube-right"><img src="/images/6/69/Cloud-computing.png" loading="lazy" style="width: 52px;height: 52px;"></div></a></div><div class="col-3 doc-link"><a href="/index.php/Know_issue" class="documentlist"><div class="doc-beancurd-cube-left"><div class="doc-beancurd-cube-title"><span>Know issue</span></div><div class="doc-beancurd-cube-des">版本已知问题</div></div><div class="doc-beancurd-cube-right"><img src="/images/6/69/Cloud-computing.png" loading="lazy" style="width: 52px;height: 52px;"></div></a></div></div></div>')});} // 添加事件监听器 $('#video').prepend('<video style="width:100%;height:100%"controls src="/768DM.mp4">') $('#ca-edit').html("<span class='fa fa-pen'></span> 编辑本页") $("#mw-toc-heading a").text('返回顶部') $("#pt-userpage").text("用户页") $('#MSG600').click(function(){ localStorage.clear(); window.location.href = 'http://192.168.10.58:8080/index.php?title=%E5%B8%AE%E5%8A%A9'; }); $('#MSG500').click(function(){ localStorage.clear(); window.location.href = 'http://192.168.10.58:8080/index.php?title=%E5%BC%80%E5%B1%80%E6%8C%87%E5%AF%BC'; }); $('#FAQ').click(function(){ localStorage.clear(); window.location.href = 'http://192.168.10.58:8080/index.php?title=FAQ'; }); $('#Qlinkbailn').click(function(){ localStorage.clear(); window.location.href = 'http://192.168.10.58:8080/index.php?title=Qlinkbailn'; }); $('#SMARTCT-E600').click(function(){ localStorage.clear(); window.location.href = 'http://192.168.10.58:8080/index.php?title=SMARTCT-E600'; }); // 等待页面加载完成后执行 $(document).ready(function() { // 监听页面滚动事件 $(window).scroll(function() { const scrollPosition = $(window).scrollTop(); // 获取当前滚动距离 // 遍历所有内容区块,判断哪个处于视野中 $('.mw-body').each(function() { const section = $(this); const sectionId = section.attr('id'); const sectionTop = section.offset().top; // 区块顶部距离页面顶部的距离 const sectionHeight = section.outerHeight(); // 区块总高度 // 偏移量(提前 100px 高亮标签,可根据导航高度调整) const offset = 100; // 判断:滚动距离超过区块顶部 - 偏移量,且未超过区块底部 if (scrollPosition >= sectionTop - offset && scrollPosition < sectionTop + sectionHeight - offset) { // 移除所有标签的选中状态 $('.nav-link').removeClass('active'); // 给对应标签添加选中状态 $(`.nav-link[data-target="${sectionId}"]`).addClass('active'); } }); }); // 初始加载时触发一次滚动事件,确保默认状态正确 $(window).trigger('scroll'); });