MediaWiki:Mainpage.js:修订间差异

MediaWiki界面页面
无编辑摘要
无编辑摘要
 
(未显示同一用户的23个中间版本)
第1行: 第1行:
$(function() {
var mainpageModule = (function() {
    /*  获取服务器人数 信息 */
    /**
    function getServerStatus() {
   配置 信息
      if ($("#live-player-status").length > 0) {
   */
$("#live-info-start").css("display" , "none");
    var config = {
$("#live-info-stop").css("display" , "none");
      apiUrl: "https://api.hydcraft.cn/wiki/info/mainpage",
    
     onlineStatusColor: {
        $.getJSON("https://api.hydcraft.cn/query/NitrogenStatus.php", function(data) {
       0: "var(--header-serverStatus-status--0)",
        if (data.code == 200) {
       1: "var(--header-serverStatus-status--1)",
          if (data.status == 3) {
       2: "var(--header-serverStatus-status--2)",
            $("#live-info-start").css("display" , "block");
       3: "var(--header-serverStatus-status--3)"
            var curPlayers = data.players.now;
     },
            var maxPlayers = data.players.max;
     tendersBlockIcons: {
            var width = curPlayers / maxPlayers;
       10: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/e/ee/Mainpage-Exchange.svg',
        11: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/3/35/Mainpage-Handshake.svg',
       12: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/5/5f/Mainpage-Construct.svg',
       13: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/d/d5/Mainpage-Done.svg'
     }
   };
 
 
 
   /**
   * 创建并返回一个招标信息的 HTML 字符串。
   *
   * @param {Object} tender - 招标信息对象。
   * @param {number} tender.prefix_id - 招标状态ID。
   * @param {string} tender.view_url - 招标详情页面的 URL。
   * @param {string} tender.title - 招标标题。
   * @param {string} tender.post_date - 招标发布日期。
   * @param {string} tender.user_view_url - 发布用户的页面 URL。
   * @param {string} [tender.user_avatar] - 发布用户的头像 URL。
   * @param {string} tender.username - 发布用户的用户名。
   * @returns {string} 招标信息的 HTML 字符串。
   */
   function createTenderBlock(tender) {
     var tendersBlockPrefixMap = {
        10: '招标中',
       11: '已中标',
       12: '开工中',
       13: '已交付'
     };
 
     var tendersBlockTemplate = `
       <div class="nav-tenders-block">
          <div class="nav-tenders-block__top">
           <div class="nav-tenders-block__prefix">${tendersBlockPrefixMap[tender.prefix_id]}</div>
            <div class="nav-tenders-block__icon"><img src="${config.tendersBlockIcons[tender.prefix_id]}"></div>
         </div>
         <div class="nav-tenders-block__bottom">
            <div class="nav-tenders-block__title"><a class="nav-tenders-block__link" href="${tender.view_url}">${tender.title}</a></div>
            <div class="nav-tenders-block__user">
             <div class="nav-tenders-block__time">${tender.post_date}</div>
             <a class="nav-tenders-block__username" href="${tender.user_view_url}"><img src="${tender.user_avatar ? tender.user_avatar : ''}">${tender.username}</a>
            </div>
         </div>
       </div>
     `;
 
     return tendersBlockTemplate;
   }


           var statusText = curPlayers + " / " + maxPlayers;


           $("#live-player-progress").css("background-color" , "#096dd9");


           $("#live-player-status").html(statusText + " (" + (width * 100).toFixed(1) + "%)");
   /**
           $("#live-player-progress").width(width * 100 + '%');
   * 根据API返回的数据更新在线状态显示。
         } else if (data.status == 2) {
   *
           $("#live-info-stop").css("display" , "block");
   * @param {Object} data - 从API获取的数据对象。
           var statusText = "服务器启动中";
   * @param {Object} data.server_status - 服务器状态对象。
           $("#live-player-status").html(statusText);
   * @param {Object} data.server_status.nitrogen - 特定服务器的状态信息。
           $("#live-player-progress").width(0 + '%')
   */
         } else if (data.status == 1) {
   function updateOnlineStatus(data) {
           $("#live-info-stop").css("display" , "block");
     var onlineStatus = $(".h2-header > .h2-header__toolbar .h2-header__serverStatus .header-serverStatus-onlineStatus");
           var statusText = "服务器关闭中";
     var onlinePlayer = $(".h2-header > .h2-header__toolbar .h2-header__serverStatus .header-serverStatus-onlinePlayer");
           $("#live-player-status").html(statusText);
     var onlinePlayerIndex;
           $("#live-player-progress").width(0 + '%');
     var onlineStatusText;
          } else if (data.status == 0) {
    
            $("#live-info-stop").css("display" , "block");
     if (data.server_status.nitrogen.code == 200) {
            var statusText = " 务器未启动";
       if (data.server_status.nitrogen.status == 3) {
            $("#live-player-status").html(statusText);
          if (data.server_status.nitrogen.players.now == -1 || data.server_status.nitrogen.max == -1) {
            $("#live-player-progress").width(0 + '%')
            onlinePlayerIndex = 2;
            onlineStatusText = ` 崩了`;
         } else {
            onlinePlayerIndex = 3;
            onlineStatusText = `${data.server_status.nitrogen.players.now}/${data.server_status.nitrogen.players.max}`;
          }
          }
        } else {
        } else if (data.server_status.nitrogen.status == 2) {
          $("#live-info-stop").css("display" , "block");
         onlinePlayerIndex = 2;
         var statusText = "API 无法连接服务器";
         onlineStatusText = `正在开`;
         $("#live-player-status").html(statusText);
       } else if (data.server_status.nitrogen.status == 1) {
         $("#live-player-progress").width(0 + '%'); 
          onlinePlayerIndex = 2;
         onlineStatusText = `正在关`;
       } else if (data.server_status.nitrogen.status == 0) {
         onlinePlayerIndex = 1;
         onlineStatusText = `服没开`;
       }
     } else if (data.server_status.nitrogen.code !== 200) {
       onlinePlayerIndex = 1;
       onlineStatusText = `机子炸了`;
     } else {
       onlinePlayerIndex = 0;
       onlineStatusText = `API 炸了`;
     }
 
     onlineStatus.css("background", config.onlineStatusColor[onlinePlayerIndex]);
     onlinePlayer.text(onlineStatusText);
   }
 
 
 
   /**
   * 根据API返回的数据更新招标信息显示。
   *
   * @param {Object} data - 包含招标信息的数据对象。
   */
   function updateTendersInfo(data) {
     var tendersWrapper = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__tenders .nav-tenders-content");
     var tendersCount = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__tenders .nav-tenders-header .nav-tenders-header__count .nav-tenders-header__countvalue");
 
     var formattedToday = new Date().toISOString().split('T')[0];
     let tendersMonthlyCount = 0;
     tendersWrapper.empty();
     $.each(data.server_community.server_tenders, function (index, tender) {
       if (tender.post_date.split(' ')[0] == formattedToday) {
         tendersMonthlyCount++;
        }
        }
        })
        var tenderBlock = createTenderBlock(tender);
       tendersWrapper.append(tenderBlock);
     });
     tendersCount.text(tendersMonthlyCount);
   }
 
 
 
   /**
   * 根据API返回的数据更新统计信息显示。
   *
   * @param {Object} data - 包含统计信息的数据对象。
   */
   function updateStatistics(data) {
     var statisticsPlayerTotal = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__playerTotal .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
     var statisticsEntTotal = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__entTotal .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
     var statisticsLauncherCurrent = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__launcherCurrent .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
     var statisticsTimeago = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__timeago .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
  
     statisticsPlayerTotal.text(data.server_count.player_total);
     statisticsEntTotal.text(data.server_count.enterprise_total);
     statisticsLauncherCurrent.text(data.server_count.launcher_current.nitrogen);
  
     var startDate = new Date(2018, 8, 1);
     var currentDate = new Date();
     var timeDiff = Math.abs(currentDate.getTime() - startDate.getTime());
     var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
  
     statisticsTimeago.text(diffDays);
   }
 
 
 
   /**
   * 请求主页信息,并更新页面上的在线状态、招标信息和统计信息。
   *
   * @param {void}
   */
   function mainpageInfoRequest() {
     $.getJSON(config.apiUrl, function (response) {
       updateOnlineStatus(response.data);
       updateTendersInfo(response.data);
       updateStatistics(response.data);
     })
     .fail(function () {
       updateOnlineStatus({ server_status: { nitrogen: { code: 0 } } });
     });
   }
 
 
 
   /**
   * 控制水平工具栏的移动方向。
   *
   * @param {string} direction - 移动方向,可以是 "left" 或 "right"。
   */
   function navHorizonTool(direction) {
     var horizonTool = $(".h2-nav .h2-nav__horizonTool");
     var switchLeft = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick");
     var switchRight = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick");
     var horizonIndexNow = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountNow");
     var horizonIndexMax = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountMax");
 
     var horizonToolIndex = parseInt(horizonTool.css("--nav-horizonTool-show-block"), 10);
     var totalSwitches = $(".h2-nav .h2-nav__horizonTool [class^='nav-horizonTool-block']").length - 1;


       .fail(function (xhr) {
     if (direction === "left") {
         $("#live-player-status").html("无法获取服务器信息");
       horizonToolIndex = Math.max(0, horizonToolIndex - 1);
         $("#live-player-progress").width(100 + '%');
     } else if (direction === "right") {
         $("#live-player-progress").css("background-color" , "#ff0000");
       horizonToolIndex = Math.min(totalSwitches, horizonToolIndex + 1);
       });
      }
      }
     horizonTool.css("--nav-horizonTool-show-block", horizonToolIndex);
     switchLeft.toggleClass("comp-disabled", horizonToolIndex <= 0);
     switchRight.toggleClass("comp-disabled", horizonToolIndex >= totalSwitches);
     horizonIndexNow.text(horizonToolIndex + 1);
     horizonIndexMax.text(totalSwitches + 1);
    }
    }


   getServerStatus();
   setInterval(getServerStatus, 60000);


   var interval = setInterval(function() {
     if (typeof sakanaLoaded !== 'undefined' && sakanaLoaded) {
       clearInterval(interval);
       animate();
     }
   }, 100);


    /*  获取海报 */
    /**
if ($('body.page-首页').length) {
   初始化。
var newDiv = $('<div>', {
   */
'class': 'header-image',
   $(function() {
'html': '<div class="header-image></div>'
     mainpageInfoRequest();
});
     setInterval(mainpageInfoRequest, 60 * 1000);
$('#content').before(newDiv);
   });
}
 
 
 
   return {
     navHorizonTool: navHorizonTool
   };
})();


    /* Sakana */
(function() {
    addCssFile("https://api.hydcraft.cn/h2wiki/assets/sakana.min.css");
    /**
importScript( 'MediaWiki:Sakana.js' );
   * 插入头图。
   */
    $('<div>').addClass('banner-image').insertBefore('#content');


    /*  字体动画 */
    $(function() {
   function animate() {
     /**
      return new Promise(resolve => {
     水平工具栏初始化按钮。
       let textBox = $('#title');
     */
       let ani_index = 0;
     const horizonToolIndex = parseInt($(".h2-nav .h2-nav__horizonTool").css("--nav-horizonTool-show-block"));
       let str = 'Welcome to HydCraft Wiki! :D';
      const totalSwitches = $(".h2-nav .h2-nav__horizonTool [class^='nav-horizonTool-block']").length - 1;
       let len = str.length;
     const horizonIndexNow = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountNow");
     const horizonIndexMax = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountMax");
  
     $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick").toggleClass("comp-disabled", horizonToolIndex <= 0);
     $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick").toggleClass("comp-disabled", horizonToolIndex >= totalSwitches);
      
      
       function input() {
     $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick").on("click", function() {
         textBox.html(str.substr(0, ani_index) + '<span class="animate">|</span>');
       mainpageModule.navHorizonTool("left");
         setTimeout(function() {
     });
           ani_index++;
  
           if (ani_index === len + 1) {
     $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick").on("click", function() {
           $('.animate').addClass('on');
        mainpageModule.navHorizonTool("right");
           resolve(); // 动画执行完成后,调用 resolve() 以解析 Promise
           return;
           }
           input();
         }, Math.random() * 600);
        }
    
       input();
      });
      });
    }
    
    animate();
     horizonIndexNow.text(horizonToolIndex + 1);
}());
     horizonIndexMax.text(totalSwitches + 1);
    });
})();

2024年4月5日 (五) 17:24的最新版本

var mainpageModule = (function() {
    /**
     * 配置信息
     */
    var config = {
        apiUrl: "https://api.hydcraft.cn/wiki/info/mainpage",
        onlineStatusColor: {
            0: "var(--header-serverStatus-status--0)",
            1: "var(--header-serverStatus-status--1)",
            2: "var(--header-serverStatus-status--2)",
            3: "var(--header-serverStatus-status--3)"
        },
        tendersBlockIcons: {
            10: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/e/ee/Mainpage-Exchange.svg',
            11: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/3/35/Mainpage-Handshake.svg',
            12: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/5/5f/Mainpage-Construct.svg',
            13: 'https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/d/d5/Mainpage-Done.svg'
        }
    };



    /**
     * 创建并返回一个招标信息的 HTML 字符串。
     * 
     * @param {Object} tender - 招标信息对象。
     * @param {number} tender.prefix_id - 招标状态ID。
     * @param {string} tender.view_url - 招标详情页面的 URL。
     * @param {string} tender.title - 招标标题。
     * @param {string} tender.post_date - 招标发布日期。
     * @param {string} tender.user_view_url - 发布用户的页面 URL。
     * @param {string} [tender.user_avatar] - 发布用户的头像 URL。
     * @param {string} tender.username - 发布用户的用户名。
     * @returns {string} 招标信息的 HTML 字符串。
     */
    function createTenderBlock(tender) {
        var tendersBlockPrefixMap = {
            10: '招标中',
            11: '已中标',
            12: '开工中',
            13: '已交付'
        };

        var tendersBlockTemplate = `
            <div class="nav-tenders-block">
                <div class="nav-tenders-block__top">
                    <div class="nav-tenders-block__prefix">${tendersBlockPrefixMap[tender.prefix_id]}</div>
                    <div class="nav-tenders-block__icon"><img src="${config.tendersBlockIcons[tender.prefix_id]}"></div>
                </div>
                <div class="nav-tenders-block__bottom">
                    <div class="nav-tenders-block__title"><a class="nav-tenders-block__link" href="${tender.view_url}">${tender.title}</a></div>
                    <div class="nav-tenders-block__user">
                        <div class="nav-tenders-block__time">${tender.post_date}</div>
                        <a class="nav-tenders-block__username" href="${tender.user_view_url}"><img src="${tender.user_avatar ? tender.user_avatar : ''}">${tender.username}</a>
                    </div>
                </div>
            </div>
        `;

        return tendersBlockTemplate;
    }



    /**
     * 根据API返回的数据更新在线状态显示。
     * 
     * @param {Object} data - 从API获取的数据对象。
     * @param {Object} data.server_status - 服务器状态对象。
     * @param {Object} data.server_status.nitrogen - 特定服务器的状态信息。
     */
    function updateOnlineStatus(data) {
        var onlineStatus = $(".h2-header > .h2-header__toolbar .h2-header__serverStatus .header-serverStatus-onlineStatus");
        var onlinePlayer = $(".h2-header > .h2-header__toolbar .h2-header__serverStatus .header-serverStatus-onlinePlayer");
        var onlinePlayerIndex;
        var onlineStatusText;
        
        if (data.server_status.nitrogen.code == 200) {
            if (data.server_status.nitrogen.status == 3) {
                if (data.server_status.nitrogen.players.now == -1 || data.server_status.nitrogen.max == -1) {
                    onlinePlayerIndex = 2;
                    onlineStatusText = `服崩了`;
                } else {
                    onlinePlayerIndex = 3;
                    onlineStatusText = `${data.server_status.nitrogen.players.now}/${data.server_status.nitrogen.players.max}`;
                }
            } else if (data.server_status.nitrogen.status == 2) {
                onlinePlayerIndex = 2;
                onlineStatusText = `正在开`;
            } else if (data.server_status.nitrogen.status == 1) {
                onlinePlayerIndex = 2;
                onlineStatusText = `正在关`;
            } else if (data.server_status.nitrogen.status == 0) {
                onlinePlayerIndex = 1;
                onlineStatusText = `服没开`;
            }
        } else if (data.server_status.nitrogen.code !== 200) {
            onlinePlayerIndex = 1;
            onlineStatusText = `机子炸了`;
        } else {
            onlinePlayerIndex = 0;
            onlineStatusText = `API 炸了`;
        }

        onlineStatus.css("background", config.onlineStatusColor[onlinePlayerIndex]);
        onlinePlayer.text(onlineStatusText);
    }



    /**
     * 根据API返回的数据更新招标信息显示。
     * 
     * @param {Object} data - 包含招标信息的数据对象。
     */
    function updateTendersInfo(data) {
        var tendersWrapper = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__tenders .nav-tenders-content");
        var tendersCount = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__tenders .nav-tenders-header .nav-tenders-header__count .nav-tenders-header__countvalue");

        var formattedToday = new Date().toISOString().split('T')[0];
        let tendersMonthlyCount = 0;
        tendersWrapper.empty();
        $.each(data.server_community.server_tenders, function (index, tender) {
            if (tender.post_date.split(' ')[0] == formattedToday) {
                tendersMonthlyCount++;
            }
            var tenderBlock = createTenderBlock(tender);
            tendersWrapper.append(tenderBlock);
        });
        tendersCount.text(tendersMonthlyCount);
    }



    /**
     * 根据API返回的数据更新统计信息显示。
     * 
     * @param {Object} data - 包含统计信息的数据对象。
     */
    function updateStatistics(data) {
        var statisticsPlayerTotal = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__playerTotal .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
        var statisticsEntTotal = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__entTotal .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
        var statisticsLauncherCurrent = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__launcherCurrent .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
        var statisticsTimeago = $(".h2-nav .h2-nav__horizonTool .nav-horizonTool-block--1 > .h2-nav__statistics .nav-horizon-block--statistics__cardWrapper .nav-horizon-block--statistics__timeago .nav-horizon-block--statistics__content .nav-horizon-block--statistics__count");
    
        statisticsPlayerTotal.text(data.server_count.player_total);
        statisticsEntTotal.text(data.server_count.enterprise_total);
        statisticsLauncherCurrent.text(data.server_count.launcher_current.nitrogen);
    
        var startDate = new Date(2018, 8, 1);
        var currentDate = new Date();
        var timeDiff = Math.abs(currentDate.getTime() - startDate.getTime());
        var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); 
    
        statisticsTimeago.text(diffDays);
    }



    /**
     * 请求主页信息,并更新页面上的在线状态、招标信息和统计信息。
     * 
     * @param {void}
     */
    function mainpageInfoRequest() {
        $.getJSON(config.apiUrl, function (response) {
            updateOnlineStatus(response.data);
            updateTendersInfo(response.data);
            updateStatistics(response.data);
        })
        .fail(function () {
            updateOnlineStatus({ server_status: { nitrogen: { code: 0 } } });
        });
    }



    /**
     * 控制水平工具栏的移动方向。
     * 
     * @param {string} direction - 移动方向,可以是 "left" 或 "right"。
     */
    function navHorizonTool(direction) {
        var horizonTool = $(".h2-nav .h2-nav__horizonTool");
        var switchLeft = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick");
        var switchRight = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick");
        var horizonIndexNow = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountNow");
        var horizonIndexMax = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountMax");

        var horizonToolIndex = parseInt(horizonTool.css("--nav-horizonTool-show-block"), 10);
        var totalSwitches = $(".h2-nav .h2-nav__horizonTool [class^='nav-horizonTool-block']").length - 1;

        if (direction === "left") {
            horizonToolIndex = Math.max(0, horizonToolIndex - 1);
        } else if (direction === "right") {
            horizonToolIndex = Math.min(totalSwitches, horizonToolIndex + 1);
        }

        horizonTool.css("--nav-horizonTool-show-block", horizonToolIndex);
        switchLeft.toggleClass("comp-disabled", horizonToolIndex <= 0);
        switchRight.toggleClass("comp-disabled", horizonToolIndex >= totalSwitches);
        horizonIndexNow.text(horizonToolIndex + 1);
        horizonIndexMax.text(totalSwitches + 1);
    }



    /**
     * 初始化。
     */
    $(function() {
        mainpageInfoRequest();
        setInterval(mainpageInfoRequest, 60 * 1000);
    });



    return {
        navHorizonTool: navHorizonTool
    };
})();

(function() {
    /**
     * 插入头图。
     */
    $('<div>').addClass('banner-image').insertBefore('#content');

    $(function() {
        /**
         * 水平工具栏初始化按钮。
         */
        const horizonToolIndex = parseInt($(".h2-nav .h2-nav__horizonTool").css("--nav-horizonTool-show-block"));
        const totalSwitches = $(".h2-nav .h2-nav__horizonTool [class^='nav-horizonTool-block']").length - 1;
        const horizonIndexNow = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountNow");
        const horizonIndexMax = $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonTool-title .h2-nav__horizonTool-blockcount .h2-nav__horizonTool-blockcountMax");
    
        $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick").toggleClass("comp-disabled", horizonToolIndex <= 0);
        $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick").toggleClass("comp-disabled", horizonToolIndex >= totalSwitches);
        
        $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchLeft .h2-comp-buttonClick").on("click", function() {
            mainpageModule.navHorizonTool("left");
        });
    
        $(".h2-nav .h2-nav__horizonTool .h2-nav__horizonToolSwitchRight .h2-comp-buttonClick").on("click", function() {
            mainpageModule.navHorizonTool("right");
        });
    
        horizonIndexNow.text(horizonToolIndex + 1);
        horizonIndexMax.text(totalSwitches + 1);
    });
})();
为了让您的浏览体验更加高效、方便和个性化,遵照《中华人民共和国网络安全法》和《信息安全技术个人信息安全规范》,我们需要您允许本站使用Cookies。在某些情况下,Cookies是使网站正常运行的必要条件。