MediaWiki:Common.js:修订间差异
来自勿忘草与永远的少女
跳到导航跳到搜索
无编辑摘要 标签:已被回退 |
无编辑摘要 标签:手工回退 |
||
| 第1行: | 第1行: | ||
/* | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
$(function() { | $(function() { | ||
// 检查是否已存在导航栏,避免重复添加 | |||
if ($('.fixed-top-nav').length === 0) { | if ($('.fixed-top-nav').length === 0) { | ||
// 导航栏 HTML 结构 | |||
var navHtml = ` | var navHtml = ` | ||
<div class="fixed-top-nav"> | <div class="fixed-top-nav"> | ||
| 第9行: | 第12行: | ||
</a> | </a> | ||
<div class="nav-links"> | <div class="nav-links"> | ||
<a href=" | <a href="index.php?title=%E9%A6%96%E9%A1%B5" class="nav-link"> | ||
<a href="/游戏攻略" class="nav-link">📖 游戏攻略</a> | 📚 首页 | ||
<a href=" | </a> | ||
<a href="/天赋图鉴" class="nav-link">🗺️ 天赋图鉴</a> | <a href="/游戏攻略" class="nav-link"> | ||
<a href="/装备图鉴" class="nav-link">📊 装备图鉴</a> | 📖 游戏攻略 | ||
<a href=" | </a> | ||
<a href="index.php?title=%E6%A3%8B%E5%AD%90" 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> | ||
</div> | </div> | ||
`; | `; | ||
// 将导航栏插入到 body 开头 | |||
$('body').prepend(navHtml); | $('body').prepend(navHtml); | ||
// 滚动时添加效果(可选) | |||
$(window).scroll(function() { | $(window).scroll(function() { | ||
if ($(window).scrollTop() > 50) { | if ($(window).scrollTop() > 50) { | ||
| 第30行: | 第48行: | ||
}); | }); | ||
$(function() { | $(function() { | ||
// 确保页脚固定在底部 | |||
var footer = $('#footer, .mw-footer'); | |||
var | if (footer.length > 0) { | ||
$('body').css('padding-bottom', | // 设置底部内边距避免内容被遮挡 | ||
} | var footerHeight = footer.outerHeight(); | ||
$('body').css('padding-bottom', footerHeight + 20 + 'px'); | |||
// 窗口大小改变时重新计算 | |||
$(window).resize(function() { | |||
var newHeight = footer.outerHeight(); | |||
$('body').css('padding-bottom', newHeight + 20 + 'px'); | |||
}); | |||
} | } | ||
}); | }); | ||
$(function() { | $(function() { | ||
// 为角色卡片添加悬停效果(可选,纯CSS已有,这里作为备用) | |||
$('.character-card').hover( | |||
function() { $(this).addClass('hover'); }, | |||
function() { $(this).removeClass('hover'); } | |||
); | |||
// 动态计算右侧边栏高度(可选,用于对齐) | |||
function adjustSidebarHeight() { | function adjustSidebarHeight() { | ||
var leftHeight = $('.custom-homepage .left-column').outerHeight(); | var leftHeight = $('.custom-homepage .left-column').outerHeight(); | ||
| 第51行: | 第79行: | ||
if (rightHeight < leftHeight && $(window).width() > 768) { | if (rightHeight < leftHeight && $(window).width() > 768) { | ||
$('.custom-homepage .right-column').css('min-height', leftHeight); | $('.custom-homepage .right-column').css('min-height', leftHeight); | ||
} | } | ||
} | } | ||
// 延迟执行,等待图片加载完成 | |||
setTimeout(adjustSidebarHeight, 500); | setTimeout(adjustSidebarHeight, 500); | ||
$(window).resize(adjustSidebarHeight); | $(window).resize(adjustSidebarHeight); | ||
}); | }); | ||
2026年3月28日 (六) 23:38的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
$(function() {
// 检查是否已存在导航栏,避免重复添加
if ($('.fixed-top-nav').length === 0) {
// 导航栏 HTML 结构
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="index.php?title=%E9%A6%96%E9%A1%B5" class="nav-link">
📚 首页
</a>
<a href="/游戏攻略" class="nav-link">
📖 游戏攻略
</a>
<a href="index.php?title=%E6%A3%8B%E5%AD%90" 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 开头
$('body').prepend(navHtml);
// 滚动时添加效果(可选)
$(window).scroll(function() {
if ($(window).scrollTop() > 50) {
$('.fixed-top-nav').addClass('scrolled');
} else {
$('.fixed-top-nav').removeClass('scrolled');
}
});
}
});
$(function() {
// 确保页脚固定在底部
var footer = $('#footer, .mw-footer');
if (footer.length > 0) {
// 设置底部内边距避免内容被遮挡
var footerHeight = footer.outerHeight();
$('body').css('padding-bottom', footerHeight + 20 + 'px');
// 窗口大小改变时重新计算
$(window).resize(function() {
var newHeight = footer.outerHeight();
$('body').css('padding-bottom', newHeight + 20 + 'px');
});
}
});
$(function() {
// 为角色卡片添加悬停效果(可选,纯CSS已有,这里作为备用)
$('.character-card').hover(
function() { $(this).addClass('hover'); },
function() { $(this).removeClass('hover'); }
);
// 动态计算右侧边栏高度(可选,用于对齐)
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);
}
}
// 延迟执行,等待图片加载完成
setTimeout(adjustSidebarHeight, 500);
$(window).resize(adjustSidebarHeight);
});