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。
/* ========== 固定顶部导航栏 ========== */
$(function() {
if ($('.fixed-top-nav').length === 0) {
var navHtml = `
<div class="fixed-top-nav">
<a href="/首页" class="nav-logo">
<img src="/wikibg/logo.jpg" alt="网站Logo">
<span>万华镜</span>
</a>
<div class="nav-links">
<a href="/首页" class="nav-link">📚 首页</a>
<a href="/游戏攻略" class="nav-link">📖 游戏攻略</a>
<a href="/棋子图鉴" class="nav-link">⚔️ 棋子图鉴</a>
<a href="/天赋图鉴" class="nav-link">🗺️ 天赋图鉴</a>
<a href="/装备图鉴" class="nav-link">📊 装备图鉴</a>
<a href="/moniqi/moniqi.html" class="nav-link">📊 阵容模拟器</a>
</div>
</div>
`;
$('body').prepend(navHtml);
$(window).scroll(function() {
if ($(window).scrollTop() > 50) {
$('.fixed-top-nav').addClass('scrolled');
} else {
$('.fixed-top-nav').removeClass('scrolled');
}
});
}
});
/* ========== 固定页脚底部边距自适应 ========== */
$(function() {
function adjustFooterPadding() {
var footer = $('#footer, .mw-footer');
if (footer.length > 0) {
var footerHeight = footer.outerHeight();
$('body').css('padding-bottom', footerHeight + 20 + 'px');
}
}
adjustFooterPadding();
$(window).resize(adjustFooterPadding);
});
/* ========== 首页侧边栏高度对齐 ========== */
$(function() {
function adjustSidebarHeight() {
var leftHeight = $('.custom-homepage .left-column').outerHeight();
var rightHeight = $('.custom-homepage .right-column').outerHeight();
if (rightHeight < leftHeight && $(window).width() > 768) {
$('.custom-homepage .right-column').css('min-height', leftHeight);
} else {
$('.custom-homepage .right-column').css('min-height', '');
}
}
setTimeout(adjustSidebarHeight, 500);
$(window).resize(adjustSidebarHeight);
});