<?php
|
include_once "/Common/Logging.php";
|
include_once "/Account/User.php";
|
include_once "/language/lang.php";
|
|
\Logging\CreateLogging("playerlv.php");
|
$Permission = \User\Permission::P_PlayerLV;
|
|
$alertMsg = "";
|
$channel = $_SESSION['spid'];
|
$UserAccount = $_SESSION['UserAccount'];
|
$user = new \User\User($UserAccount);
|
if (!$user->HavePermission($Permission)) {
|
exit;
|
}
|
|
$serversArray = $user->GetServers();
|
|
// 设置默认数据,开界面默认查选中服
|
$_POST["eventType"] = "PlayerLVInfo";
|
\CommFunc\QueryEventData($user, $retInfo);
|
|
// echo "_POST:", print_r($retInfo, true), "<br/>";
|
|
?>
|
|
<!DOCTYPE html>
|
<html>
|
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<title>
|
<?php echo \Lang\gettext("等级分布"); ?>
|
</title>
|
<link rel="gettext" type="application/x-po"
|
href="../language/<?php echo \Lang\getLang(); ?>/LC_MESSAGES/<?php echo \Lang\getjspodomain(); ?>.po" />
|
</head>
|
|
<body>
|
<center>
|
<p><b>
|
<?php echo \Lang\gettext("等级分布"); ?>
|
</b></P>
|
</center>
|
<form id="online" action="playerlv.php" method="post">
|
<input type="submit" value="<?php echo \Lang\gettext("查询本服"); ?>" onclick="onCurSubmit()" />
|
<input type="button" value="<?php echo \Lang\gettext("复制数据"); ?>" onclick="onCopyData()" />
|
注:本数据仅为物理服数据,如果是合服则为合服数据,不包含合服后被删除的角色
|
<div id="OnlinePlayerInfo"></div>
|
<hr />
|
<?php
|
include_once "/Common/SelectServer.php";
|
?>
|
<input type="submit" name="submit" id="submit" value="<?php echo \Lang\gettext("查询多服"); ?>"
|
onclick="return checkMultiSubmit()" />
|
<br />
|
<br />
|
</form>
|
</body>
|
<script type='text/javascript' src='/language/gettext.js'></script>
|
<script type='text/javascript' src="/js/calendar.js"></script>
|
<script type='text/javascript' src="/js/common.js"></script>
|
<script type='text/javascript' src="/Common/selectserver.js"></script>
|
<script type='text/javascript' src="/js/chart.min.js"></script>
|
<script type="text/javascript">
|
window.onload = function () {
|
var retInfo = '<?php echo json_encode($retInfo); ?>';
|
if (retInfo == 'null') {
|
return;
|
}
|
retInfo = JSON.parse(retInfo);
|
|
let chartNum = 0;
|
let insHtml, info;
|
for (const serverName in retInfo) {
|
let chartID;
|
insHtml = "";
|
insHtml += "<hr />";
|
info = retInfo[serverName];
|
console.log(serverName, info);
|
if (info && info["OK"]) {
|
chartID = "myChart" + chartNum;
|
chartNum += 1;
|
// insHtml += "<center>" + serverName + "</center>" + "<br/>";
|
insHtml += "<canvas id=\"" + chartID + "\" ></canvas>"; // 插入画布
|
} else {
|
insHtml += serverName + " : " + info + "<br/>";
|
}
|
document.getElementById("OnlinePlayerInfo").insertAdjacentHTML("beforeEnd", insHtml);
|
if (chartID) {
|
drawChartLine(chartID, serverName, info["Data"]);
|
}
|
}
|
}
|
|
function drawChartLine(chartID, serverName, drData) {
|
|
var lvList = [];
|
for (const key in drData) {
|
lvList.push(parseInt(key));
|
}
|
lvList.sort(function (a, b) { return a - b });
|
console.log("lvList", lvList);
|
|
var labels = [];
|
var datasets = [];
|
|
let playerCountList = [];
|
for (let index = 0; index < lvList.length; index++) {
|
const lvStr = lvList[index] + "";
|
labels.push(lvStr);
|
playerCountList.push(drData[lvStr]);
|
}
|
|
datasets.push({
|
label: "人数",
|
data: playerCountList,
|
backgroundColor: 'rgba(79, 66, 255, 0.2)',
|
borderColor: 'rgba(79, 66, 255, 1)',
|
borderWidth: 1,
|
lineTension: 0.5,
|
pointRadius: 1
|
});
|
|
var ctx = document.getElementById(chartID);
|
ctx.width = 400;
|
ctx.height = 100;
|
var myLineChart = new Chart(ctx, {
|
type: "line",
|
data: {
|
labels: labels,
|
datasets: datasets
|
},
|
options: {
|
plugins: {
|
title: {
|
display: true,
|
text: serverName
|
}
|
},
|
scales: {
|
x: {
|
title: {
|
display: true,
|
text: "等级"
|
}
|
},
|
y: {
|
title: {
|
display: true,
|
text: "人数"
|
},
|
beginAtZero: true,
|
ticks: {
|
stepSize: 1, // 刻度间隔1
|
}
|
}
|
}
|
}
|
});
|
}
|
|
function onCurSubmit() {
|
document.getElementById("MultiServer").value = 0;
|
return true;
|
}
|
|
function checkMultiSubmit() {
|
|
if (!checkHaveServerSelected()) {
|
return false;
|
}
|
|
if (!setSubmitQuerying("submit")) {
|
return false;
|
}
|
|
return true;
|
}
|
|
function onCopyData() {
|
var retInfo = '<?php echo json_encode($retInfo); ?>';
|
if (retInfo == 'null') {
|
return;
|
}
|
retInfo = JSON.parse(retInfo);
|
|
var copydata = "";
|
for (const serverName in retInfo) {
|
info = retInfo[serverName];
|
if (!info || !info["OK"]) {
|
continue;
|
}
|
drData = info["Data"];
|
var lvList = [];
|
for (const key in drData) {
|
lvList.push(parseInt(key));
|
}
|
lvList.sort(function(a, b) {
|
return a - b
|
});
|
|
copydata += "<table>";
|
copydata += "<tr><td>服务器: " + serverName + "</td></tr>";
|
copydata += "<tr><td>等级</td><td>人数</td></tr>";
|
for (let index = 0; index < lvList.length; index++) {
|
const lv = lvList[index];
|
const playerCount = drData[lv];
|
copydata += "<tr><td>" + lv + "</td><td>" + playerCount + "</td></tr>";
|
}
|
copydata += "<tr></tr>";
|
copydata += "</table>";
|
}
|
if (!copydata) {
|
alert("没有数据");
|
return
|
}
|
copyToClipboard(copydata);
|
alert("表格复制成功,可直接粘贴到Excel工作表!");
|
}
|
|
function copyToClipboard(text) {
|
var textarea = document.createElement('textarea');
|
textarea.style.position = 'fixed';
|
textarea.style.opacity = 0;
|
textarea.value = text;
|
document.body.appendChild(textarea);
|
textarea.select();
|
document.execCommand('copy');
|
document.body.removeChild(textarea);
|
}
|
</script>
|
|
</html>
|