注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- 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() {
function getServerStatus(){
const apiUrl = "https://wiki.shangxiaoguan.top/api.php?action=lindongrequest&address=ld.cmsy.xyz&port=19132&format=json";
$.get(apiUrl)
.done(function(data) {
if (data.lindongrequest.status == "online") {
const { online, max } = data.lindongrequest;
$("#online-player").text(`${online}/${max}`);
$("#online-ver").text('Ver ' + data.lindongrequest.version);
$("#online-desc").text('服务器已启动。延迟 ' + data.lindongrequest.delay + ' 毫秒。');
} else {
$("#online-player").text("-/-");
$("#online-desc").text('服务器未启动。');
}
})
.fail(function(error) {
$("#online-player").text("-/-");
$("#online-desc").text('无法发送请求,请检查当前设备网络。');
});
}
getServerStatus();
setInterval(getServerStatus, 3 * 60 * 1000);
}());