无编辑摘要 |
无编辑摘要 |
||
第15行: | 第15行: | ||
checkbox.dispatchEvent( event ); | checkbox.dispatchEvent( event ); | ||
}); | }); | ||
// Load header poster | |||
var newDiv = $('<div>', { | |||
'class': 'header-image', | |||
'html': '<div class="header-image></div>' | |||
}); | |||
$('#content').before(newDiv); | |||
// Get server status | // Get server status |
2023年10月5日 (四) 02:16的最新版本
$(function() {
// Calculate days TEMPORARY
const today = new Date();
const targetDate = new Date('2023-12-31');
const timeDifference = targetDate - today;
const daysRemaining = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
const countdownValue = document.querySelector('#count-down .countdown__value');
countdownValue.textContent = `${daysRemaining} 天`;
// Load earch trigger
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 );
});
// Load header poster
var newDiv = $('<div>', {
'class': 'header-image',
'html': '<div class="header-image></div>'
});
$('#content').before(newDiv);
// Get server status
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);
}());