224 lines
6.9 KiB
HTML
224 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>AdGuard Home Leaderboard</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
background: #0f0f1a;
|
|
color: #e2e8f0;
|
|
font-family: 'Segoe UI', sans-serif;
|
|
min-height: 100vh;
|
|
padding: 2rem;
|
|
}
|
|
|
|
h1 {
|
|
text-align: center;
|
|
font-size: 2rem;
|
|
margin-bottom: 0.5rem;
|
|
color: #a78bfa;
|
|
text-shadow: 0 0 20px #a78bfa88;
|
|
}
|
|
|
|
.subtitle {
|
|
text-align: center;
|
|
color: #94a3b8;
|
|
margin-bottom: 2rem;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
#error-msg {
|
|
text-align: center;
|
|
color: #f87171;
|
|
margin-bottom: 1rem;
|
|
display: none;
|
|
}
|
|
|
|
.grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
gap: 1.5rem;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.card {
|
|
background: #1e1e2e;
|
|
border-radius: 12px;
|
|
padding: 1.25rem;
|
|
text-align: center;
|
|
border: 2px solid transparent;
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card:hover {
|
|
transform: translateY(-4px);
|
|
box-shadow: 0 8px 24px rgba(0,0,0,0.4);
|
|
}
|
|
|
|
.card-rank {
|
|
position: absolute;
|
|
top: 8px;
|
|
left: 12px;
|
|
font-size: 0.75rem;
|
|
color: #94a3b8;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.card-img {
|
|
width: 100px;
|
|
height: 100px;
|
|
object-fit: contain;
|
|
margin: 0.5rem auto 0.75rem;
|
|
display: block;
|
|
}
|
|
|
|
.card-name {
|
|
font-size: 1rem;
|
|
font-weight: 700;
|
|
margin-bottom: 0.25rem;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.card-tier-label {
|
|
font-size: 0.8rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
margin-bottom: 0.2rem;
|
|
}
|
|
|
|
.card-desc {
|
|
font-size: 0.75rem;
|
|
color: #94a3b8;
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
|
|
.card-count {
|
|
font-size: 1.4rem;
|
|
font-weight: 800;
|
|
}
|
|
|
|
.card-count-label {
|
|
font-size: 0.7rem;
|
|
color: #64748b;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
color: #94a3b8;
|
|
padding: 4rem;
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
.refresh-btn {
|
|
display: block;
|
|
margin: 2rem auto 0;
|
|
padding: 0.6rem 1.5rem;
|
|
background: #4f46e5;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 0.9rem;
|
|
cursor: pointer;
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
.refresh-btn:hover { background: #4338ca; }
|
|
|
|
.last-updated {
|
|
text-align: center;
|
|
color: #475569;
|
|
font-size: 0.75rem;
|
|
margin-top: 1rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>AdGuard Home Leaderboard</h1>
|
|
<p class="subtitle">Who's been out there in these internet streets?</p>
|
|
<p id="error-msg"></p>
|
|
<div id="grid-container" class="loading">Loading client data...</div>
|
|
<button class="refresh-btn" onclick="loadClients()">Refresh</button>
|
|
<p class="last-updated" id="last-updated"></p>
|
|
|
|
<script>
|
|
const TIER_CHARS = {
|
|
1: ['tier1_1.png', 'tier1_2.png', 'tier1_3.png', 'tier1_4.png', 'tier1_5.png'],
|
|
2: ['tier2_1.png', 'tier2_2.png', 'tier2_3.png', 'tier2_4.png', 'tier2_5.png'],
|
|
3: ['tier3_1.png', 'tier3_2.png', 'tier3_3.png', 'tier3_4.png', 'tier3_5.png'],
|
|
4: ['tier4_1.png', 'tier4_2.png', 'tier4_3.png', 'tier4_4.png', 'tier4_5.png'],
|
|
5: ['tier5_1.png']
|
|
};
|
|
|
|
function randomChar(tier) {
|
|
const options = TIER_CHARS[tier] || ['tier1_1.png'];
|
|
const pick = options[Math.floor(Math.random() * options.length)];
|
|
return `/static/characters/${pick}`;
|
|
}
|
|
|
|
async function loadClients() {
|
|
const container = document.getElementById('grid-container');
|
|
const errorMsg = document.getElementById('error-msg');
|
|
container.innerHTML = '<p class="loading">Loading client data...</p>';
|
|
container.className = 'loading';
|
|
errorMsg.style.display = 'none';
|
|
|
|
try {
|
|
const resp = await fetch('/api/clients');
|
|
const data = await resp.json();
|
|
|
|
if (data.error) {
|
|
errorMsg.textContent = `Error: ${data.error}`;
|
|
errorMsg.style.display = 'block';
|
|
}
|
|
|
|
if (!data.clients || data.clients.length === 0) {
|
|
container.innerHTML = '<p class="loading">No client data available.</p>';
|
|
return;
|
|
}
|
|
|
|
container.className = 'grid';
|
|
container.innerHTML = data.clients.map((client, i) => `
|
|
<div class="card" style="border-color: ${client.color}; box-shadow: 0 0 12px ${client.color}44;">
|
|
<span class="card-rank">#${i + 1}</span>
|
|
<img
|
|
class="card-img"
|
|
src="${randomChar(client.tier)}"
|
|
alt="${client.label}"
|
|
onerror="this.style.display='none'"
|
|
/>
|
|
<div class="card-name" title="${client.name}">${client.name}</div>
|
|
<div class="card-tier-label" style="color: ${client.color};">${client.label}</div>
|
|
<div class="card-desc">${client.desc}</div>
|
|
<div class="card-count" style="color: ${client.color};">${client.blocks.toLocaleString()}</div>
|
|
<div class="card-count-label">queries</div>
|
|
</div>
|
|
`).join('');
|
|
|
|
document.getElementById('last-updated').textContent =
|
|
`Last updated: ${new Date().toLocaleTimeString()}`;
|
|
|
|
} catch (err) {
|
|
errorMsg.textContent = `Failed to fetch data: ${err.message}`;
|
|
errorMsg.style.display = 'block';
|
|
container.innerHTML = '';
|
|
container.className = '';
|
|
}
|
|
}
|
|
|
|
loadClients();
|
|
// Auto-refresh every 5 minutes
|
|
setInterval(loadClients, 300000);
|
|
</script>
|
|
</body>
|
|
</html> |