1
mirror of https://github.com/jakejarvis/npqueue.git synced 2025-11-04 12:40:09 -05:00

host everything on heroku

This commit is contained in:
2019-06-24 17:29:00 -04:00
parent a9f902ba30
commit ad5d6aee2d
9 changed files with 4 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -1,80 +0,0 @@
document.addEventListener("DOMContentLoaded", updateData, false);
async function fetchData() {
let request = await fetch("https://hidden-depths-42970.herokuapp.com/api/list");
if(request.status == 200) {
console.log("New JSON successfully fetched!");
let data = await request.json();
return data;
}
throw new Error(request.status);
}
function updateData() {
fetchData().then(data => updateTable(data)).catch(data => console.log(data));
// Re-fetch data every 1 minute
setTimeout(updateData, 60000);
}
function updateTable(data) {
active = document.getElementById("active");
active.innerText = `Active Players: ${data.currentPlayers} / 60`;
queue = document.getElementById("queue");
queue.innerText = `In Queue: ${data.currentQueue}`;
table = document.getElementsByTagName("table")[0].getElementsByTagName("tbody")[0];
table.innerHTML = "";
data.players = data.players.sort((a, b) => (a.id > b.id) ? 1 : ((b.id > a.id) ? -1 : 0));
data.players.forEach(function(player, i) {
newRow = table.insertRow(table.rows.length);
newCell = newRow.insertCell(0);
newText = document.createTextNode(`${i+1}`)
newCell.appendChild(newText);
newCell = newRow.insertCell(1);
newText = document.createTextNode(`${player.id}`)
newCell.appendChild(newText);
newCell = newRow.insertCell(2);
a = document.createElement('a');
a.setAttribute('href', `https://www.twitch.tv/${player.identifiers[3]}`);
a.setAttribute('target', '_blank');
a.setAttribute('rel', 'noopener noreferrer nofollow');
a.innerHTML = player.identifiers[3];
newCell.appendChild(a);
newCell = newRow.insertCell(3);
a = document.createElement('a');
a.setAttribute('href', `https://www.nopixel.net/upload/index.php?members/${player.identifiers[4]}`);
a.setAttribute('target', '_blank');
a.setAttribute('rel', 'noopener noreferrer nofollow');
a.innerHTML = player.identifiers[0];
newCell.appendChild(a);
newCell = newRow.insertCell(4);
a = document.createElement('a');
a.setAttribute('href', `https://steamcommunity.com/profiles/${player.identifiers[2]}`);
a.setAttribute('target', '_blank');
a.setAttribute('rel', 'noopener noreferrer nofollow');
a.innerHTML = player.name;
newCell.appendChild(a);
newCell = newRow.insertCell(5);
newText = document.createTextNode(`${player.identifiers[1]}`)
newCell.appendChild(newText);
newCell = newRow.insertCell(6);
newText = document.createTextNode(`${player.identifiers[2]}`)
newCell.appendChild(newText);
newCell = newRow.insertCell(7);
newText = document.createTextNode(`${player.ping} ms`)
newCell.appendChild(newText);
});
}

View File

@@ -1,36 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NoPixel GTA5 RP Online Players</title>
<link rel="dns-prefetch" href="https://hidden-depths-42970.herokuapp.com">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 id="title">NoPixel Players 👾</h1>
<h2 id="active">Active Players:</h2>
<h2 id="queue">In Queue:</h2>
<p>Please report missing or inaccurate <a href="https://github.com/jakejarvis/npqueue/issues/new" target="_blank" rel="noopener noreferrer nofollow">on GitHub</a> or <a href="mailto:nopixellist@gmail.com">via email</a>.</p>
<table id="players">
<thead>
<tr>
<th>#</th>
<th>Session ID</th>
<th>Twitch</th>
<th>NoPixel Forums</th>
<th>Steam Name</th>
<th>Steam ID</th>
<th>Steam64 ID</th>
<th>Ping</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<p>Updates every 1 minute.</p>
<script src="fetch.js"></script>
</body>
</html>

View File

@@ -1,35 +0,0 @@
body {
font-size: 1em;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
"Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
"Droid Sans", "Helvetica Neue", sans-serif,
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
text-align: center;
}
a {
color: #59289b;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h1 {
font-size: 2.4em;
}
h2 {
line-height: 0.6em;
}
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid #000;
padding: 5px;
}