mirror of
https://github.com/BeamMP/BeamMP-Website.git
synced 2026-02-16 10:40:51 +00:00
145 lines
4.6 KiB
Plaintext
145 lines
4.6 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
<meta name="description" content="" />
|
|
<meta name="author" content="" />
|
|
<title>BeamNG-MP-Statistics</title>
|
|
<link href="css/servers-styles.css" rel="stylesheet" />
|
|
<link href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" rel="stylesheet" crossorigin="anonymous" />
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/js/all.min.js" crossorigin="anonymous"></script>
|
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-160071688-1"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
|
|
<script>
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
|
|
gtag('config', 'UA-160071688-1');
|
|
</script>
|
|
</head>
|
|
<body class="sb-nav-fixed">
|
|
<nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
|
|
<%- include('includes/nav.ejs') %>
|
|
</nav>
|
|
<div id="layoutSidenav_content">
|
|
<main>
|
|
<br>
|
|
<br>
|
|
<div class="container-fluid">
|
|
<h1 class="mt-4"><i class="fas fa-server mr-1"></i>BeamMP Statistics <span id="LivePlayerCount"></span></h1>
|
|
<div style="height: 800px;">
|
|
<canvas id="myChart" width="400" height="770"></canvas>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<footer class="py-4 bg-light mt-auto">
|
|
<div class="container-fluid">
|
|
<div class="d-flex align-items-center justify-content-between small">
|
|
<div class="text-muted">Copyright © BeamNG-MP Development Team 2020</div>
|
|
<div>
|
|
<a href="#">Privacy Policy</a>
|
|
·
|
|
<a href="#">Terms & Conditions</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</div>
|
|
<script src="https://code.jquery.com/jquery-3.4.1.min.js" crossorigin="anonymous"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
|
|
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>
|
|
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js" crossorigin="anonymous"></script>
|
|
<script type="text/javascript">
|
|
var chartData = {};
|
|
|
|
var GetChartData = function () {
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/stats',
|
|
data: {
|
|
period: 'today',
|
|
},
|
|
dataType: 'json',
|
|
success: function (d) {
|
|
var Data = {}
|
|
Data.Players = []
|
|
Data.Servers = []
|
|
Data.Labels = []
|
|
console.log(d.history)
|
|
d.history.forEach(function(item, index) {
|
|
Data.Players.push(item.players)
|
|
Data.Servers.push(item.servers)
|
|
Data.Labels.push(item.datetime)
|
|
});
|
|
console.log(Data)
|
|
var ctx = document.getElementById('myChart').getContext('2d');
|
|
ctx.height = 770;
|
|
var myChart = new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: Data.Labels,
|
|
datasets: [{
|
|
label: 'Servers',
|
|
backgroundColor: 'rgba(255,0,0,0.1)',
|
|
borderColor: 'rgba(255,0,0,0.4)',
|
|
data: Data.Servers,
|
|
fill: false,
|
|
}, {
|
|
label: 'Players',
|
|
fill: false,
|
|
backgroundColor: 'rgba(0,0,255,0.1)',
|
|
borderColor: 'rgba(0,0,255,0.4)',
|
|
data: Data.Players,
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
title: {
|
|
display: true,
|
|
text: 'BeamNG-MP Statistics'
|
|
},
|
|
tooltips: {
|
|
mode: 'index',
|
|
intersect: false,
|
|
},
|
|
hover: {
|
|
mode: 'nearest',
|
|
intersect: true
|
|
},
|
|
scales: {
|
|
x: {
|
|
display: true,
|
|
scaleLabel: {
|
|
display: true,
|
|
labelString: 'Time'
|
|
}
|
|
},
|
|
y: {
|
|
display: true,
|
|
scaleLabel: {
|
|
display: true,
|
|
labelString: 'Count'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
});
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
GetChartData();
|
|
});
|
|
|
|
//const socket = io('./stats');
|
|
</script>
|
|
</body>
|
|
</html>
|