180 lines
6.9 KiB
HTML
180 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<title>Shikigrid: Leaderboard</title>
|
|
<meta charset="UTF-8">
|
|
|
|
|
|
<script src="/static/js/dist.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/static/css/main.css">
|
|
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
|
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous">
|
|
</script>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
<script>
|
|
$(document).ready(function () {
|
|
|
|
$.get("https://grid-api.toshiki.dev/api/v1/total/aps", function (data2) {
|
|
document.getElementById("totalApsReported").innerText = `${data2.total} APs reported in total`;
|
|
//console.log(data2)
|
|
});
|
|
|
|
$.get("https://grid-api.toshiki.dev/api/statistics/leaders?units=3", function (data) {
|
|
for (let i = 0; i < 3; i++) {
|
|
//data[i].data = JSON.parse(data[i].data)
|
|
let leaderList = document.getElementById("leaders");
|
|
let regionNames = new Intl.DisplayNames(['en'], {
|
|
type: 'region'
|
|
});
|
|
|
|
let leaderListItem = document.createElement("li")
|
|
let aHref = `<a href="/search/${data[i].identity}">${data[i].name}</a>`
|
|
|
|
if (data[i].data && data[i].data.advertisement) {
|
|
leaderListItem.innerHTML =
|
|
`${data[i].data.advertisement.face} <b> ${aHref} </b> from <i> ${regionNames.of(data[i].country)} </i> has a total of <b> ${data[i].amount} </b> reported APs` //create string format of recently added devices
|
|
leaderList.appendChild(leaderListItem)
|
|
} else {
|
|
leaderListItem.innerHTML =
|
|
`<b> ${aHref} </b> from <i> ${regionNames.of(data[i].country)} </i> has a total of <b> ${data[i].amount} </b> reported APs` //create string format of recently added devices
|
|
leaderList.appendChild(leaderListItem)
|
|
}
|
|
}
|
|
});
|
|
|
|
$.get(`https://grid-api.toshiki.dev/api/statistics/leaders?units=50`, function (data) {
|
|
const LeadersChart = document.getElementById('LeadersChart');
|
|
//FORMAT DATA
|
|
unit = []
|
|
amount = []
|
|
colour = []
|
|
data.forEach(element => {
|
|
unit.push(element.name)
|
|
amount.push(element.amount)
|
|
|
|
colour.push("#" + element.identity.slice(0, 3) + element.identity.slice(-3))
|
|
});
|
|
//console.log(colour)
|
|
new Chart(LeadersChart, {
|
|
type: 'bar',
|
|
data: {
|
|
labels: unit,
|
|
datasets: [{
|
|
label: '# of APs reported by users',
|
|
data: amount,
|
|
backgroundColor: colour,
|
|
borderWidth: 1
|
|
}]
|
|
},
|
|
options: {
|
|
scales: {
|
|
y: {
|
|
beginAtZero: true
|
|
}
|
|
},
|
|
barPercentage:1
|
|
}
|
|
});
|
|
|
|
})
|
|
});
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<!-- Top navbar -->
|
|
<nav class="navbar navbar-expand-lg bg-dark navbar-dark">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="#">Shikigrid</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
|
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/">Home</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/convert">Convert</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/search/">Search</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" aria-current="page" href="/leaderboard">Leaderboard</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/statistics">Statistics</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<form id="search-form" class="form-inline" style="margin-block-end: 0em;">
|
|
<div class="input-group">
|
|
<input type="text" id="search-input" class="form-control" placeholder="Search by fingerprint...">
|
|
<button type="button" id="search-button" class="btn btn-primary">Search</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Main content container -->
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col">
|
|
<h1>
|
|
Top 3 units with the most reports
|
|
</h1>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<ol id="leaders">
|
|
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<canvas id="LeadersChart"></canvas>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<h4 id="totalApsReported"></h2>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<footer>
|
|
<script>
|
|
// Get references to the input and button elements
|
|
const searchInput = document.getElementById('search-input');
|
|
const searchButton = document.getElementById('search-button');
|
|
|
|
// Add a click event listener to the button
|
|
searchButton.addEventListener('click', function () {
|
|
// Get the text from the input
|
|
const searchText = searchInput.value.trim();
|
|
|
|
// Check if the input is not empty
|
|
if (searchText) {
|
|
// Redirect to /search/ with the search query appended
|
|
window.location.href = `/search/${encodeURIComponent(searchText)}`;
|
|
}
|
|
});
|
|
</script>
|
|
</footer>
|
|
|
|
</html> |