|
|
(未显示同一用户的5个中间版本) |
第1行: |
第1行: |
| $(function() {
| | addJsFile("https://api.hydcraft.cn/h2wiki/libraries/Playerlist.js"); |
| $.getJSON('https://h2-1254268741.cos.ap-shanghai.myqcloud.com/api/playerlist.json', function(data) {
| |
| /* 获取表格 */
| |
| var tbody = $('#player-list tbody');
| |
| tbody.empty();
| |
| $.each(data.player, function(i, player) {
| |
| var typeText = player.type === 0 ? '参与成员' : '成员';
| |
| var contactHtml = '';
| |
| if (player.contact_hidden === true) {
| |
| contactHtml = '<td id="none">已隐藏</td>';
| |
| } else {
| |
| for (var j = 0; j < player.contact.length; j++) {
| |
| var contactType = player.contact_type[j];
| |
| var contact = player.contact[j];
| |
| var contactImg = '';
| |
| if (contactType === 0) {
| |
| contactImg = '<img alt="QQ Logo Blue.svg" src="https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/thumb/9/97/Qq_logo.png/64px-Qq_logo.png" height="14" style="padding-right: 10px;">';
| |
| } else if (contactType === 1) {
| |
| contactImg = '<img alt="WeChat logo.png" src="https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/thumb/1/17/WeChat_logo.png/134px-WeChat_logo.png" height="14" style="padding-right: 10px;">';
| |
| } else if (contactType === 2) {
| |
| contactImg = '<img alt="Bilibili Logo Blue.svg" src="https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/b/bd/Bilibili_Logo_Blue.svg" height="14" style="padding-right: 10px;">';
| |
| } else if (contactType === 3) {
| |
| contactImg = '<img alt="Email.svg" src="https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/7/72/Email.svg" height="14" style="padding-right: 10px;">';
| |
| }
| |
| var contactLine = contactImg + contact;
| |
| if (j < player.contact.length - 1) {
| |
| contactLine += '<br>';
| |
| }
| |
| contactHtml += contactLine;
| |
| }
| |
| contactHtml = '<td>' + contactHtml + '</td>';
| |
| }
| |
| var noteText = player.note !== null ? player.note : '无';
| |
| var noteId = (player.note !== null && player.status !== 0) ? '' : 'none';
| |
| var rowHtml = "<tr";
| |
| if (player.status === 1) {
| |
| rowHtml += " id='hibernate'";
| |
| noteText = noteText == "无" ? '' : noteText;
| |
| noteId = '';
| |
| noteText = "冬眠计划玩家。" + "<br/>" + noteText;
| |
| } else if (player.status === 2) {
| |
| rowHtml += " id='leave'";
| |
| noteText = noteText == "无" ? '' : noteText;
| |
| noteId = '';
| |
| noteText = "已离开玩家。" + "<br/>" + noteText;
| |
| } else if (player.status === 3) {
| |
| rowHtml += " id='kick'";
| |
| noteText = noteText == "无" ? '' : noteText;
| |
| noteId = '';
| |
| noteText = "被移出的玩家。" + "<br/>" + noteText;
| |
| } else if (player.status === 0 && player.note !== null) {
| |
| noteId = '';
| |
| }
| |
| | |
| rowHtml += ">" +
| |
| "<td>" + player.id + "</td>" +
| |
| "<td><a href='/Player:" + player.nick + "' class='mw-redirect' title='" + player.nick + "'>" + player.nick + "</a></td>" +
| |
| contactHtml +
| |
| "<td>" + typeText + "</td>" +
| |
| "<td>" + player.jointime + "</td>" +
| |
| "<td id='" + noteId + "'>" + noteText + "</td>" +
| |
| "</tr>";
| |
| tbody.append(rowHtml);
| |
| // setTimeout(function() {
| |
| // tbody.append(rowHtml);
| |
| // }, (Math.random() * 100));
| |
| });
| |
|
| |
| /* 玩家数量 */
| |
| var count = 0;
| |
| for (var i = 0; i < data.player.length; i++) {
| |
| var status = data.player[i].status;
| |
| if (status === 0 || status === 1) {
| |
| count++;
| |
| }
| |
| }
| |
| player_count = count;
| |
| $("#playerCount").html(player_count); //总数
| |
| $("#allPlayerCount").html(data.player.length); //所有
| |
| $("#pageEditTime").html("更新于 " + data.time); //时间
| |
| var count = 0;
| |
| for (var i = 0; i < data.player.length; i++) {
| |
| var type = data.player[i].type;
| |
| if (type === 0) {
| |
| count++;
| |
| }
| |
| }
| |
| $("#partMembers").html(count); //参与成员
| |
| $("#allMembers").html(player_count - count); //普通成员
| |
| $("#active-player").html(((count / player_count)* 100).toFixed(1) + "%"); //参与成员占比
| |
| | |
| | |
| /* 获取 usernamecache */
| |
| $.getJSON("https://h2-1254268741.cos.ap-shanghai.myqcloud.com/api/usernamecache.json", function(user) {
| |
| var count = 0;
| |
| $.each(user, function() {
| |
| count++;
| |
| });
| |
| $("#reg-player").html(count);
| |
| | |
| /* 核对玩家数量 */
| |
| var loginCount = 0;
| |
| for (var i = 0; i < data.player.length; i++) {
| |
| var playerId = data.player[i].id;
| |
| $.each(user, function(_key, value) {
| |
| if (value === playerId) {
| |
| loginCount++;
| |
| }
| |
| });
| |
| }
| |
| $("#login-player").html(((loginCount / data.player.length)* 100).toFixed(1) + "%");
| |
| $("#loginPlayerCount").html(loginCount);
| |
| });
| |
| });
| |
|
| |
| if (window.innerWidth < 500) {
| |
| const message = `<div class="tips home-card home-card__label" style="box-shadow: none; background:var(--color-surface-2);"><p style="margin-bottom:0px;margin-right: auto; margin-left: auto;"><span class="tips-icon"><img alt="Alert.svg" src="https://h2-wiki-1254268741.cos.ap-shanghai.myqcloud.com/8/8f/Alert.svg" decoding="async" width="16" height="16"></span> 本页面已适配移动端,表格信息可左右滑动查看。</p></div>`;
| |
| document.querySelector('.playerlist').insertAdjacentHTML('beforebegin', message);
| |
| }
| |
| });
| |