打开/关闭搜索
搜索
打开/关闭菜单
通知
打开/关闭个人菜单
查看“MediaWiki:Mainpage.js”的源代码
MediaWiki界面页面
查看
阅读
查看源代码
查看历史
associated-pages
消息
讨论
更多操作
←
MediaWiki:Mainpage.js
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于这些用户组的用户执行:
用户
、admin
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。 如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此JavaScript页面,因为编辑此页面可能会影响所有访问者。
此页面已被保护以防止编辑或其他操作。
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
$(function() { if (mw.config.get('wgPageName') == '首页') { /* 获取服务器人数信息 */ function getServerStatus() { if ($("#live-player-status").length > 0) { $("#live-info-start").css("display" , "none"); $("#live-info-stop").css("display" , "none"); $.getJSON("https://api.hydcraft.cn/query/NitrogenStatus.php", function(data) { if (data.code == 200) { if (data.status == 3) { $("#live-info-start").css("display" , "block"); var curPlayers = data.players.now; var maxPlayers = data.players.max; var width = curPlayers / maxPlayers; var statusText = curPlayers + " / " + maxPlayers; $("#live-player-progress").css("background-color" , "#096dd9"); $("#live-player-status").html(statusText + " (" + (width * 100).toFixed(1) + "%)"); $("#live-player-progress").width(width * 100 + '%'); } else if (data.status == 2) { $("#live-info-stop").css("display" , "block"); var statusText = "服务器启动中"; $("#live-player-status").html(statusText); $("#live-player-progress").width(0 + '%'); } else if (data.status == 1) { $("#live-info-stop").css("display" , "block"); var statusText = "服务器关闭中"; $("#live-player-status").html(statusText); $("#live-player-progress").width(0 + '%'); } else if (data.status == 0) { $("#live-info-stop").css("display" , "block"); var statusText = "服务器未启动"; $("#live-player-status").html(statusText); $("#live-player-progress").width(0 + '%'); } } else { $("#live-info-stop").css("display" , "block"); var statusText = "API 无法连接服务器"; $("#live-player-status").html(statusText); $("#live-player-progress").width(0 + '%'); } }) .fail(function (xhr) { $("#live-player-status").html("无法获取服务器信息"); $("#live-player-progress").width(100 + '%'); $("#live-player-progress").css("background-color" , "#ff0000"); }); } } getServerStatus(); setInterval(getServerStatus, 60000); var interval = setInterval(function() { if (typeof sakanaLoaded !== 'undefined' && sakanaLoaded) { clearInterval(interval); animate(); } }, 100); /* 获取海报 */ if ($('body.page-首页').length) { var newDiv = $('<div>', { 'class': 'banner-image' }); $('#content').before(newDiv); } /* 字体动画 */ function animate() { return new Promise(resolve => { let textBox = $('#title'); let ani_index = 0; let str = 'Welcome to HydCraft Wiki! :D'; let len = str.length; function input() { textBox.html(str.substr(0, ani_index) + '<span class="animate">|</span>'); setTimeout(function() { ani_index++; if (ani_index === len + 1) { $('.animate').addClass('on'); resolve(); // 动画执行完成后,调用 resolve() 以解析 Promise return; } input(); }, Math.random() * 600); } input(); }); } animate(); } else if (mw.config.get('wgPageName') == '首页副本') { /** * 水平工具栏控制移动方向的函数 * * @param { "left" | "right" } direction - 移动的方向,只能是 "left" 或 "right" * @returns {void} */ function navHorizonTool(direction) { const horizonTool = $(".h2-nav .h2-nav__horizonTool"); const switchLeft = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick"); const switchRight = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick"); var horizonToolIndex = parseInt(horizonTool.css("--nav-horizonTool-show-block")); const totalSwitches = $(".h2-nav .h2-nav__horizonTool [class^='h2-nav__horizonToolSwitch']").length - 1; if (direction == "left") { horizonToolIndex = Math.max(0, horizonToolIndex - 1); } else if (direction == "right") { horizonToolIndex = Math.min(totalSwitches, horizonToolIndex + 1); } horizonTool.css("--nav-horizonTool-show-block", horizonToolIndex); switchLeft.toggleClass("comp-disabled", horizonToolIndex <= 0); switchRight.toggleClass("comp-disabled", horizonToolIndex >= totalSwitches); } $(function() { /** * 插入头图 */ $('<div>', { class: 'banner-image' }).insertBefore('#content'); /** * 水平工具栏初始化按钮 */ const horizonToolIndex = parseInt($(".h2-nav .h2-nav__horizonTool").css("--nav-horizonTool-show-block")); const totalSwitches = $(".h2-nav .h2-nav__horizonTool [class^='h2-nav__horizonToolSwitch']").length - 1; $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick").toggleClass("comp-disabled", horizonToolIndex <= 0); $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick").toggleClass("comp-disabled", horizonToolIndex >= totalSwitches); $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick").on("click", function() { navHorizonTool("left"); }); $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick").on("click", function() { navHorizonTool("right"); }); /** * 显示服务器人数 */ const onlineStatus = $(".h2-header > .h2-header__toolbar .h2-header__serverStatus .header-serverStatus-onlineStatus"); const onlinePlayer = $(".h2-header > .h2-header__toolbar .h2-header__serverStatus .header-serverStatus-onlinePlayer"); const onlineStatusColor = { 0: "var(--header-serverStatus-status--0)", 1: "var(--header-serverStatus-status--1)", 2: "var(--header-serverStatus-status--2)", 3: "var(--header-serverStatus-status--3)", }; /** * 发送请求显示服务器人数的函数 * * @param {void} * @returns {void} */ function headerServerStatusRequest() { $.getJSON("https://api.hydcraft.cn/query/NitrogenStatus.php", function(data) { if (data.code == 200) { let onlinePlayerIndex; let onlineStatusText; if (data.status == 3) { if (data.players.now == -1 || data.players.max == -1) { onlinePlayerIndex = 2; onlineStatusText = `服崩了`; } else { onlinePlayerIndex = 3; onlineStatusText = `${data.players.now}/${data.players.max}`; } } else if (data.status == 2) { onlinePlayerIndex = 2; onlineStatusText = `正在开`; } else if (data.status == 1) { onlinePlayerIndex = 2; onlineStatusText = `正在关`; } else if (data.status == 0) { onlinePlayerIndex = 1; onlineStatusText = `服没开`; } onlineStatus.css("background", onlineStatusColor[onlinePlayerIndex]); onlinePlayer.text(onlineStatusText); } else { onlineStatus.css("background", onlineStatusColor[0]); onlinePlayer.text(`API 炸了`); } }) .fail(function (xhr) { onlineStatus.css("background", onlineStatusColor[0]); onlinePlayer.text(`查不到`); }); } headerServerStatusRequest() setInterval(headerServerStatusRequest, 60 * 1000); }) } });
返回
MediaWiki:Mainpage.js
。
为了让您的浏览体验更加高效、方便和个性化,遵照《中华人民共和国网络安全法》和《信息安全技术个人信息安全规范》,我们需要您允许本站使用Cookies。在某些情况下,Cookies是使网站正常运行的必要条件。
了解并同意