跳转到内容
打开/关闭搜索
搜索
打开/关闭菜单
1
条目
1
用户
147
编辑
Anachronism
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
打开/关闭外观设置菜单
无法加载外观设置。请检查您的网络连接并重试。
重试
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
登录
查看“︁MediaWiki:Common.js”︁的源代码
MediaWiki界面页面
查看
阅读
查看源代码
查看历史
相关页面
系统消息
讨论
更多操作
更多
工具
链入页面
相关更改
页面信息
←
MediaWiki:Common.js
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
旅人
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此JavaScript页面,因为编辑此页面可能会影响所有访问者。
您可以查看和复制此页面的源代码。
/* ===== 侧边工具栏 Rail ===== */ (function () { function initRail() { // 避免重复注入 if (document.getElementById('custom-rail')) return; // 创建按钮 var btn = document.createElement('button'); btn.id = 'custom-rail-toggle'; btn.className = 'custom-rail-toggle'; btn.setAttribute('aria-label', '打开工具栏'); btn.innerHTML = '<span class="custom-rail-toggle__icon">★</span>'; // 创建面板 var panel = document.createElement('aside'); panel.id = 'custom-rail'; panel.className = 'custom-rail'; panel.innerHTML = [ '<div class="custom-rail__header">', ' <span class="custom-rail__title">工具栏</span>', ' <button class="custom-rail__close" aria-label="关闭">×</button>', '</div>', '<div class="custom-rail__content">', ' <h3>快速导航</h3>', ' <ul>', ' <li><a href="/index.php/首页">首页</a></li>', ' <li><a href="/index.php/特殊:最近更改">最近更改</a></li>', ' <li><a href="/index.php/特殊:随机">随机页面</a></li>', ' <li><a href="/index.php/Category:站点样式">站点样式</a></li>', ' </ul>', ' <h3>公告</h3>', ' <p>本 Wiki 正在建设中。</p>', '</div>' ].join(''); // 创建遮罩 var overlay = document.createElement('div'); overlay.id = 'custom-rail-overlay'; overlay.className = 'custom-rail-overlay'; document.body.appendChild(btn); document.body.appendChild(overlay); document.body.appendChild(panel); var closeBtn = panel.querySelector('.custom-rail__close'); function openRail() { document.body.classList.add('custom-rail-open'); btn.setAttribute('aria-label', '关闭工具栏'); } function closeRail() { document.body.classList.remove('custom-rail-open'); btn.setAttribute('aria-label', '打开工具栏'); } btn.addEventListener('click', function () { if (document.body.classList.contains('custom-rail-open')) { closeRail(); } else { openRail(); } }); closeBtn.addEventListener('click', closeRail); overlay.addEventListener('click', closeRail); // 按 Esc 关闭 document.addEventListener('keydown', function (e) { if (e.key === 'Escape') closeRail(); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initRail); } else { initRail(); } })(); /* ===== 首页轮播图 ===== */ (function () { function initHomeCarousel() { var carousel = document.getElementById('home-carousel'); if (!carousel) return; var items = carousel.querySelectorAll('.home-carousel-item'); var dotsBox = document.getElementById('home-carousel-dots'); var prevBtn = document.getElementById('home-carousel-prev'); var nextBtn = document.getElementById('home-carousel-next'); if (!items.length || !dotsBox || !prevBtn || !nextBtn) return; var current = 0; var timer = null; items.forEach(function (_, i) { var dot = document.createElement('span'); dot.className = 'home-carousel-dot' + (i === 0 ? ' active' : ''); dot.addEventListener('click', function () { goTo(i); }); dotsBox.appendChild(dot); }); var dots = dotsBox.querySelectorAll('.home-carousel-dot'); function goTo(index) { items[current].classList.remove('active'); dots[current].classList.remove('active'); current = (index + items.length) % items.length; items[current].classList.add('active'); dots[current].classList.add('active'); } function next() { goTo(current + 1); } function prev() { goTo(current - 1); } function startAuto() { stopAuto(); timer = setInterval(next, 5000); } function stopAuto() { if (timer) { clearInterval(timer); timer = null; } } nextBtn.addEventListener('click', function () { next(); startAuto(); }); prevBtn.addEventListener('click', function () { prev(); startAuto(); }); carousel.addEventListener('mouseenter', stopAuto); carousel.addEventListener('mouseleave', startAuto); startAuto(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initHomeCarousel); } else { initHomeCarousel(); } })();
返回
MediaWiki:Common.js
。
查看“︁MediaWiki:Common.js”︁的源代码
MediaWiki界面页面