434 lines
19 KiB
HTML
434 lines
19 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<title>Shikigrid: Search</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://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
<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>
|
|
$(document).ready(function () {
|
|
const params = new URLSearchParams(document.location.search);
|
|
|
|
|
|
// sets countries on adv search
|
|
$.get("https://grid-api.toshiki.dev/api/v1/units/countries",function (data) {
|
|
let regionNames = new Intl.DisplayNames(['en'], {
|
|
type: 'region'
|
|
});
|
|
data.forEach(element => {
|
|
let sel = ""
|
|
if (params.get("c") == element) {
|
|
sel = "selected"
|
|
}
|
|
let template = `<option value="${element}"${sel}>${regionNames.of(element)}</option>`
|
|
document.getElementById("sByCountrySel").insertAdjacentHTML('beforeend', template)
|
|
})
|
|
})
|
|
//if (params.get("c")) {
|
|
// selectElement('sByCountrySel', );
|
|
//}
|
|
|
|
|
|
|
|
if (params.get("n")){
|
|
document.getElementById("sByNameData").value = params.get("n")
|
|
searchforName()
|
|
}
|
|
|
|
function searchforName() {
|
|
const NameTableBd = document.getElementById("sUnitsFound")
|
|
// called when search by name button is pressed, handles creation of table elements
|
|
let name = document.getElementById("sByNameData").value
|
|
url = "https://grid-api.toshiki.dev/api/v1/search/byName/" + name
|
|
params.set("n", name)
|
|
NameTableBd.innerHTML = ""
|
|
$.get(url,
|
|
function (data) {
|
|
data.forEach(element => {
|
|
let template = `<tr><td><a href="/search/${element.identity}">${element.name}</a></td><td>${element.identity}</td><td>${element.country}</td></tr>`
|
|
NameTableBd.insertAdjacentHTML('beforeend', template)
|
|
})
|
|
})
|
|
};
|
|
document.getElementById("sByNameBtn").onclick = searchforName
|
|
|
|
|
|
document.getElementById("sByCountryBtn").onclick = function () {
|
|
const NameTableBd = document.getElementById("sUnitsFound")
|
|
let country = document.getElementById("sByCountrySel").value
|
|
params.set("c",country)
|
|
// called when search by name button is pressed, handles creation of table elements
|
|
url = "https://grid-api.toshiki.dev/api/v1/units/byCountry/" + document.getElementById("sByNameData").value + "?country=" + country
|
|
NameTableBd.innerHTML = ""
|
|
$.get(url,
|
|
function (data) {
|
|
data.forEach(element => {
|
|
let template = `<tr><td><a href="/search/${element.identity}">${element.name}</a></td><td>${element.identity}</td><td>${element.country}</td></tr>`
|
|
NameTableBd.insertAdjacentHTML('beforeend', template)
|
|
})
|
|
})
|
|
};
|
|
|
|
|
|
unitBox = document.querySelector("#unitBox")
|
|
searchBox = document.querySelector("#advSearchElements")
|
|
fingerprint = window.location.pathname.split("/search/")[1]
|
|
if (fingerprint) {
|
|
|
|
url = `https://grid-api.toshiki.dev/api/v1/search/byID/${fingerprint}`
|
|
$.get(url,
|
|
function (data) {
|
|
if (!data.error) {
|
|
let body = document.getElementById("body");
|
|
let regionNames = new Intl.DisplayNames(['en'], {
|
|
type: 'region'
|
|
});
|
|
|
|
//set face and name
|
|
document.getElementById("userStringName").innerText = `${getFaceStr(data,false)}`
|
|
|
|
|
|
//set created at
|
|
let dateCreated = new Date(data.created_at);
|
|
let MsCreatedAt = dateCreated.getTime()
|
|
let now = new Date()
|
|
let timeNow = now.getTime()
|
|
document.getElementById("createdAt").innerText =
|
|
`${timeDifference(timeNow, MsCreatedAt)}`;
|
|
document.getElementById("countryOfOrigin").innerText =
|
|
`${regionNames.of(data.country)}`;
|
|
document.getElementById("pwnedNetworks").innerText = `${data.amount}`;
|
|
|
|
// set updated at
|
|
if (data.updated_at) {
|
|
let dateUpdated = new Date(data.updated_at);
|
|
let MsUpdatedAt = dateUpdated.getTime()
|
|
document.getElementById("updatedAt").innerText =
|
|
`${timeDifference(timeNow, MsUpdatedAt)}`;
|
|
}
|
|
|
|
// set ai data
|
|
if (data.data.ai == false) {
|
|
document.getElementById("aiEpochsLived").innerText =`AI Disabled`;
|
|
document.getElementById("aiEpochsTrained").innerText =`AI Disabled`;
|
|
} else {
|
|
if (data.data.brain) {
|
|
document.getElementById("aiEpochsLived").innerText =`${data.data.brain.epochs_lived}`;
|
|
document.getElementById("aiEpochsTrained").innerText =`${data.data.brain.epochs_trained}`;
|
|
}
|
|
}
|
|
|
|
//set session data
|
|
if (data.data.session) {
|
|
document.getElementById("duration").innerText =
|
|
`${data.data.session.duration}`;
|
|
document.getElementById("peers").innerText =
|
|
`${data.data.session.peers}`;
|
|
document.getElementById("associated").innerText =
|
|
`${data.data.session.associated}`;
|
|
document.getElementById("deauthed").innerText =
|
|
`${data.data.session.deauthed}`;
|
|
document.getElementById("handshakes").innerText =
|
|
`${data.data.session.handshakes}`;
|
|
document.getElementById("min_reward").innerText =
|
|
`${data.data.session.min_reward}`;
|
|
document.getElementById("max_reward").innerText =
|
|
`${data.data.session.max_reward}`;
|
|
document.getElementById("avg_reward").innerText =
|
|
`${data.data.session.avg_reward}`;
|
|
|
|
|
|
}
|
|
//build data
|
|
document.getElementById("version").innerText =
|
|
`${data.data.version}`;
|
|
if (data.data.build) {
|
|
document.getElementById("build").innerText =
|
|
`${data.data.build}`;
|
|
}
|
|
if (data.data.uname) {
|
|
document.getElementById("uname").innerText =
|
|
`${data.data.uname}`;
|
|
}
|
|
|
|
document.getElementById("contactStringID").innerHTML = `${data.identity}`
|
|
} else {
|
|
document.getElementById("container").innerHTML =
|
|
"<h1>This unit does not exist</h1>";
|
|
}
|
|
});
|
|
searchBox.style.display = "none";
|
|
unitBox.style.display = "block";
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body id="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 active" aria-current="page"
|
|
href="/search/">Search</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" 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>
|
|
<div id="advSearchElements" class="container" style="margin-top: 1rem;">
|
|
<div class="row">
|
|
<h1>Advanced Search</h1>
|
|
<div class="col" id="sByFingerprint" >
|
|
<form id="search-form" class="form-inline"
|
|
style="margin-block-end: 0em;">
|
|
<div class="input-group">
|
|
<select name="" class="form-select" id="sByCountrySel"></select>
|
|
<button type="button" id="sByCountryBtn"
|
|
class="btn btn-primary">Search</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col" id="sByName"style="margin-top: 1rem;" >
|
|
<form id="search-form" class="form-inline"
|
|
style="margin-block-end: 0em;">
|
|
<div class="input-group">
|
|
<input type="text" id="sByNameData"
|
|
class="form-control"
|
|
placeholder="Search by name...">
|
|
<button type="button" id="sByNameBtn"
|
|
class="btn btn-primary">Search</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
<div class="row" style="margin-top: 1rem;">
|
|
<h2>Units Found</h2>
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
Name
|
|
</th>
|
|
<th>
|
|
Fingerprint
|
|
</th>
|
|
<th>
|
|
Country
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="sUnitsFound">
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<!-- Splitter between adv search and unit-->
|
|
<!-- Main content container -->
|
|
<div class="container" id="unitBox" style="margin-top: 1rem; display: none;">
|
|
<!-- First row, just the username and if available, his face -->
|
|
<div class="row">
|
|
<div class="col">
|
|
<h1 id="userStringName"></h1>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Second row, table with details -->
|
|
<div class="row">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
Created at
|
|
</th>
|
|
<th>
|
|
Updated at
|
|
</th>
|
|
<th>
|
|
Country of origin
|
|
</th>
|
|
<th>
|
|
Pwned networks
|
|
</th>
|
|
<th>
|
|
AI - Epochs lived
|
|
</th>
|
|
<th>
|
|
AI - Epochs trained
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td id="createdAt"></td>
|
|
<td id="updatedAt"></td>
|
|
<td id="countryOfOrigin"></td>
|
|
<td id="pwnedNetworks"></td>
|
|
<td id="aiEpochsLived">Not available</td>
|
|
<td id="aiEpochsTrained">Not available</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- forth row, table with last session -->
|
|
<div class="row" style="top:10px;">
|
|
<div id="session">
|
|
<h3>Last Session</h3>
|
|
<table width="100%" class="table">
|
|
<tbody>
|
|
<tr>
|
|
<th width="20%">Duration</th>
|
|
<td id="duration">00:00:00</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Peers Met</th>
|
|
<td id="peers">0</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Associations</th>
|
|
<td id="associated">0</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Deauths</th>
|
|
<td id="deauthed">0</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Handshakes</th>
|
|
<td id="handshakes">0</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Min Reward</th>
|
|
<td id="min_reward">0.0</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Max Reward</th>
|
|
<td id="max_reward">0.0</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Average Reward</th>
|
|
<td id="avg_reward">0.0</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Thirs row, contact card -->
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
Contact info
|
|
</div>
|
|
<div class="card-body">
|
|
<h5 class="card-title">You can contact this
|
|
Pwnagotchi at</h5>
|
|
<pre class="card-text" id="contactStringID"></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<h1></h1>
|
|
<!-- forth row, table with build info -->
|
|
<div class="row build-info" style>
|
|
<div id="session">
|
|
<h4>Build Info</h4>
|
|
<table width="100%" class="table">
|
|
<tbody>
|
|
<tr>
|
|
<th width="20%">Version</th>
|
|
<td id="version">0.0.0</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Build</th>
|
|
<td id="build">Not available</td>
|
|
</tr>
|
|
<tr>
|
|
<th>uname</th>
|
|
<td id="uname">Not available</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</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();
|
|
// console.log(searchText);
|
|
|
|
// 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> |