MediaWiki:Mainpage.js

MediaWiki系统消息页面
AurLemonCN讨论 | 贡献2023年9月29日 (五) 20:44的版本 (创建页面,内容为“$(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('服务器已…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-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);
}());