注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- 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() {
document.getElementById( 'skin-citizen-search-trigger' ).addEventListener( 'click', function() {
var event = new Event( 'input', { bubbles: true, composed: true } ),
checkbox = document.getElementById( 'citizen-search__checkbox' );
checkbox.checked = true;
checkbox.dispatchEvent( event );
});
function getServerStatus(type) {
const apiUrlMap = {
"total": "https://mcapi.us/server/status?ip=mc.fetarute.org",
"survival": "https://mcapi.us/server/status?ip=survival.fetarute.org",
"creative": "https://mcapi.us/server/status?ip=creative.fetarute.org"
}
$.get(apiUrlMap[type])
.done(function(data) {
const serverBlock = $("#" + type);
if (data.online) {
const { players: { now, max } } = data;
serverBlock.find(".current-info").text(`服务器已启动`);
serverBlock.find(".current-player").text(`${now}/${max}`);
serverBlock.find(".progress-scroll").css("width", (now / max) * 100 + "%");
} else {
serverBlock.find(".current-info").text(`服务器未启动`);
serverBlock.find(".current-player").text(`-/-`);
serverBlock.find(".progress-scroll").css("width", "0%");
}
})
.fail(function(error) {
const serverBlock = $("#" + type);
serverBlock.find(".current-info").text(`无法发送请求,请检查网络。`);
serverBlock.find(".current-player").text(`-/-`);
serverBlock.find(".progress-scroll").css("width", "0%");
});
}
getServerStatus("total");
getServerStatus("survival");
getServerStatus("creative");
setInterval(function() {
getServerStatus("total");
getServerStatus("survival");
getServerStatus("creative");
}, 60 * 1000);
}());