MediaWiki:Common.js:修订间差异

MediaWiki界面页面
无编辑摘要
标签已被回退
(撤销Aurora Lemon讨论)的版本6871)
标签撤销
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
  $(function() {
$(function() {


    if ($("#live-player-status").length > 0) {
    if ($("#live-player-status").length > 0) {
    $.getJSON("https://he-api.hydcraft.cn/")
    .done(function (data) {
     var curPlayers = data.current_players;
     var maxPlayers = data.max_players;
     var width = curPlayers / maxPlayers;


      var statusText = "服务器在线人数" + data.current_players + " / " + data.max_players;
   $.ajax({
 
     type: "GET",
     $("#live-player-status").html(statusText);
     url: "https://he-api.hydcraft.cn/",
     $("#live-player-progress").width(width + '%'); 
     dataType: "jsonp",
    })
     jsonp: "callback",
   
      success: function (data) {
    .fail(function (xhr) {
       var curPlayers = data.current_players;
     if (xhr.status == 502) {
       var maxPlayers = data.max_players;
      $("#live-player-status").html("服务端未启动。");
       var width = curPlayers / maxPlayers;
     } else {
  
      $("#live-player-status").html("无法获取信息,错误值:" + xhr.status + "。");
       var statusText = "服务器在线人数" + data.current_players + " / " + data.max_players;
      $("#live-player-progress").width(100 + '%'); 
  
      $("#live-player-progress").css("background-color" , "#ff0000"); 
       $("#live-player-status").html(statusText);
       $("#live-player-progress").width(width + '%'); 
     },
     error: function (xhr) {
       if (xhr.status == 502) {
         $("#live-player-status").html("服务端未启动。");
       } else {
         $("#live-player-status").html("无法获取信息,错误值:" + xhr.status + "。");
         $("#live-player-progress").width(100 + '%'); 
         $("#live-player-progress").css("background-color" , "#ff0000"); 
       }
      }
      }
    });
     });
 
    }
    }
 
}());
   }());

2023年1月7日 (六) 23:46的版本

/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
$(function() {

    if ($("#live-player-status").length > 0) {

    $.ajax({
        type: "GET",
        url: "https://he-api.hydcraft.cn/",
        dataType: "jsonp",
        jsonp: "callback",
        success: function (data) {
            var curPlayers = data.current_players;
            var maxPlayers = data.max_players;
            var width = curPlayers / maxPlayers;
    
            var statusText = "服务器在线人数" + data.current_players + " / " + data.max_players;
    
            $("#live-player-status").html(statusText);
            $("#live-player-progress").width(width + '%'); 
        },
        error: function (xhr) {
            if (xhr.status == 502) {
                $("#live-player-status").html("服务端未启动。");
            } else {
                $("#live-player-status").html("无法获取信息,错误值:" + xhr.status + "。");
                $("#live-player-progress").width(100 + '%'); 
                $("#live-player-progress").css("background-color" , "#ff0000"); 
            }
        }
        });
    }
}());
为了让您的浏览体验更加高效、方便和个性化,遵照《中华人民共和国网络安全法》和《信息安全技术个人信息安全规范》,我们需要您允许本站使用Cookies。在某些情况下,Cookies是使网站正常运行的必要条件。