417 lines
No EOL
18 KiB
HTML
417 lines
No EOL
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="it">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Report Giocatori - TetraQ</title>
|
|
|
|
<script defer src="/__/firebase/10.8.0/firebase-app-compat.js"></script>
|
|
<script defer src="/__/firebase/10.8.0/firebase-firestore-compat.js"></script>
|
|
<script defer src="/__/firebase/init.js"></script>
|
|
|
|
<style>
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
background-color: #f8f9fa;
|
|
color: #2c3e50;
|
|
padding: 20px;
|
|
margin: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
/* --- STILI LOGIN --- */
|
|
#login-view {
|
|
background-color: #34495e;
|
|
position: fixed;
|
|
top: 0; left: 0; width: 100%; height: 100vh;
|
|
display: flex; justify-content: center; align-items: center;
|
|
z-index: 1000; padding: 20px; box-sizing: border-box;
|
|
}
|
|
.login-box {
|
|
background: white; padding: 40px; border-radius: 12px;
|
|
box-shadow: 0 10px 25px rgba(0,0,0,0.1); text-align: center;
|
|
width: 100%; max-width: 350px; box-sizing: border-box;
|
|
}
|
|
.login-box h2 { color: #2c3e50; margin-top: 0; font-weight: 800; letter-spacing: 1px;}
|
|
.login-box input {
|
|
width: 100%; padding: 12px; margin: 10px 0 20px 0;
|
|
border: 1px solid #e1e5eb; border-radius: 8px; box-sizing: border-box;
|
|
font-size: 16px; outline: none; transition: border-color 0.2s;
|
|
}
|
|
.login-box input:focus { border-color: #3498db; }
|
|
.login-box button {
|
|
width: 100%; background-color: #e74c3c; color: white;
|
|
border: none; padding: 12px; font-size: 16px; border-radius: 8px;
|
|
cursor: pointer; font-weight: bold; transition: background-color 0.2s;
|
|
}
|
|
.login-box button:hover { background-color: #c0392b; }
|
|
.error { color: #e74c3c; font-weight: bold; font-size: 14px; margin-top: -5px; margin-bottom: 15px; }
|
|
|
|
/* --- STILI DASHBOARD --- */
|
|
#dashboard-view { display: none; }
|
|
.container {
|
|
max-width: 1200px; margin: 0 auto; background: white;
|
|
padding: 30px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.05);
|
|
box-sizing: border-box;
|
|
}
|
|
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
h1 { color: #2c3e50; margin: 0; font-size: 26px; font-weight: 800;}
|
|
.btn-logout {
|
|
background-color: transparent; color: #95a5a6; padding: 8px 15px;
|
|
border-radius: 5px; font-weight: bold; font-size: 14px;
|
|
border: 1px solid #ecf0f1; cursor: pointer; transition: 0.2s;
|
|
}
|
|
.btn-logout:hover { background-color: #f9f9f9; color: #e74c3c; border-color: #e74c3c; }
|
|
|
|
/* --- FILTRI --- */
|
|
.filter-section {
|
|
background: #f8f9fa; padding: 20px; border-radius: 8px; margin-bottom: 30px;
|
|
display: flex; flex-wrap: wrap; gap: 15px; align-items: flex-end;
|
|
border: 1px solid #e1e5eb;
|
|
}
|
|
.form-group { display: flex; flex-direction: column; flex: 1; min-width: 150px; }
|
|
.form-group label { font-size: 12px; font-weight: bold; color: #7f8c8d; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px;}
|
|
.form-group input, .form-group select {
|
|
padding: 10px; border: 1px solid #bdc3c7; border-radius: 6px;
|
|
font-size: 14px; outline: none; box-sizing: border-box; width: 100%;
|
|
}
|
|
.form-group input:focus, .form-group select:focus { border-color: #3498db; }
|
|
.btn-filtra {
|
|
background-color: #3498db; color: white; padding: 10px 20px; border: none;
|
|
border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 14px;
|
|
transition: 0.2s; height: 40px;
|
|
}
|
|
.btn-filtra:hover { background-color: #2980b9; }
|
|
.btn-reset {
|
|
background-color: #95a5a6; color: white; padding: 0 15px; border: none;
|
|
border-radius: 6px; cursor: pointer; font-size: 14px; height: 40px;
|
|
line-height: 40px; text-align: center;
|
|
}
|
|
.btn-reset:hover { background-color: #7f8c8d; }
|
|
|
|
/* --- CARDS RIASSUNTIVE --- */
|
|
.dashboard { display: flex; justify-content: space-between; margin-bottom: 30px; gap: 20px; text-align: center; flex-wrap: wrap; }
|
|
.card {
|
|
flex: 1; min-width: 150px; background: white; padding: 20px;
|
|
border-radius: 8px; border-left: 5px solid #3498db; box-sizing: border-box;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.05); border: 1px solid #e1e5eb; border-left-width: 5px;
|
|
}
|
|
.card.ios { border-left-color: #e74c3c; }
|
|
.card.android { border-left-color: #2ecc71; }
|
|
.card h3 { margin: 0 0 10px 0; font-size: 12px; color: #7f8c8d; text-transform: uppercase; letter-spacing: 0.5px;}
|
|
.card p { margin: 0; font-size: 28px; font-weight: 800; color: #2c3e50; }
|
|
|
|
/* --- TABELLA --- */
|
|
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; table-layout: fixed; }
|
|
th, td { padding: 16px 20px; text-align: left; vertical-align: top;}
|
|
th {
|
|
background-color: #34495e; color: white; font-weight: 700;
|
|
font-size: 13px; letter-spacing: 0.5px;
|
|
}
|
|
th:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
|
|
th:last-child { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
|
|
td { border-bottom: 1px solid #ecf0f1; color: #2c3e50; }
|
|
tr:hover td { background-color: #fbfcfc; }
|
|
|
|
th:nth-child(1) { width: 15%; } /* Accesso */
|
|
th:nth-child(2) { width: 25%; } /* Giocatore */
|
|
th:nth-child(3) { width: 15%; } /* Statistiche (Nuova) */
|
|
th:nth-child(4) { width: 25%; } /* Connessione */
|
|
th:nth-child(5) { width: 20%; } /* Dispositivo */
|
|
|
|
/* Tipografia Specifica Tabella */
|
|
.player-name { font-weight: 800; color: #2c3e50; font-size: 15px; }
|
|
.player-level { font-weight: normal; color: #e74c3c; } /* Rosso come nell'app */
|
|
.sub-text { display: block; font-size: 12px; color: #95a5a6; margin-top: 4px; font-weight: 500; }
|
|
.data-text { font-weight: 500; color: #2c3e50; font-size: 14px; }
|
|
.stat-value { font-weight: bold; color: #3498db; }
|
|
|
|
/* Badge Sistema Operativo */
|
|
.badge {
|
|
padding: 4px 8px; border-radius: 4px; color: white;
|
|
font-weight: 800; font-size: 11px; text-transform: uppercase;
|
|
letter-spacing: 0.5px; display: inline-block; margin-bottom: 5px;
|
|
}
|
|
.badge-ios { background-color: #e74c3c; }
|
|
.badge-android { background-color: #2ecc71; }
|
|
.badge-desktop { background-color: #95a5a6; }
|
|
|
|
.empty { text-align: center; padding: 40px; color: #95a5a6; font-weight: 500; }
|
|
|
|
/* MOBILE */
|
|
@media (max-width: 768px) {
|
|
body { padding: 10px; }
|
|
.container { padding: 15px; }
|
|
.header-top { flex-direction: column; text-align: center; gap: 15px; }
|
|
.filter-section { flex-direction: column; align-items: stretch; gap: 10px; padding: 15px;}
|
|
.form-group { min-width: 100%; }
|
|
.btn-filtra, .btn-reset { width: 100%; margin-top: 5px; height: auto; padding: 12px;}
|
|
.dashboard { flex-direction: column; gap: 15px; }
|
|
.card { min-width: 100%; }
|
|
table, thead, tbody, th, td, tr { display: block; width: 100%; box-sizing: border-box; }
|
|
thead { display: none; }
|
|
tr { margin-bottom: 15px; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
|
|
td { display: flex; flex-direction: column; text-align: left; border-bottom: 1px solid #eee; padding: 12px 15px; position: relative; width: 100%; }
|
|
td::before { content: attr(data-label); font-weight: bold; margin-bottom: 5px; color: #34495e; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
|
|
td:last-child { border-bottom: none; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="login-view">
|
|
<div class="login-box">
|
|
<h2>Area Riservata</h2>
|
|
<div id="login-error" class="error"></div>
|
|
<form id="login-form">
|
|
<input type="text" id="username" autocomplete="username" required>
|
|
<input type="password" id="password" placeholder="Password" autocomplete="current-password" required>
|
|
<button type="submit">Accedi al Database</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="dashboard-view">
|
|
<div class="container">
|
|
<div class="header-top">
|
|
<h1>Dettaglio Giocatori</h1>
|
|
<button class="btn-logout" onclick="logout()">Disconnetti</button>
|
|
</div>
|
|
|
|
<form class="filter-section" id="filter-form">
|
|
<div class="form-group">
|
|
<label for="data_da">Ultimo Accesso Da:</label>
|
|
<input type="date" id="data_da">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="data_a">Ultimo Accesso A:</label>
|
|
<input type="date" id="data_a">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="os">Sistema Operativo:</label>
|
|
<select id="os">
|
|
<option value="">Tutti i sistemi</option>
|
|
<option value="iOS">Apple iOS</option>
|
|
<option value="Android">Google Android</option>
|
|
<option value="Desktop">Desktop (Mac/Win)</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="loc">Cerca Giocatore/Città:</label>
|
|
<input type="text" id="loc" placeholder="Digita...">
|
|
</div>
|
|
<button type="submit" class="btn-filtra">🔍 Applica</button>
|
|
<button type="button" class="btn-reset" onclick="resetFilters()">Reset</button>
|
|
</form>
|
|
|
|
<div class="dashboard">
|
|
<div class="card">
|
|
<h3>Totale Giocatori</h3>
|
|
<p id="totale-text">0</p>
|
|
</div>
|
|
<div class="card ios">
|
|
<h3>Apple iOS</h3>
|
|
<p id="ios-text">0</p>
|
|
</div>
|
|
<div class="card android">
|
|
<h3>Google Android</h3>
|
|
<p id="android-text">0</p>
|
|
</div>
|
|
<div class="card">
|
|
<h3>Desktop / Mac</h3>
|
|
<p id="desktop-text">0</p>
|
|
</div>
|
|
</div>
|
|
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Ultimo Accesso</th>
|
|
<th>Giocatore</th>
|
|
<th>Statistiche</th>
|
|
<th>Connessione</th>
|
|
<th>Dispositivo</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="table-body">
|
|
<tr><td colspan="5" class="empty">Caricamento dati dal database in corso...</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// --- CONFIGURAZIONE SICUREZZA ---
|
|
const PASSWORD_SEGRETA = "!!TetraQ!!";
|
|
const UTENTE_SEGRETO = "io";
|
|
let allData = [];
|
|
|
|
// --- FUNZIONI DI UTILITÀ ---
|
|
function formatTime(seconds) {
|
|
if (!seconds || seconds <= 0) return "00:00";
|
|
const h = Math.floor(seconds / 3600);
|
|
const m = Math.floor((seconds % 3600) / 60);
|
|
return `${h.toString().padStart(2, '0')}h ${m.toString().padStart(2, '0')}m`;
|
|
}
|
|
|
|
function formatDate(dateObj) {
|
|
if (!dateObj) return "N/D";
|
|
const options = { year: 'numeric', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' };
|
|
return dateObj.toLocaleDateString('it-IT', options).replace(',', '');
|
|
}
|
|
|
|
function formatDateShort(dateObj) {
|
|
if (!dateObj) return "N/D";
|
|
return dateObj.toLocaleDateString('it-IT', { year: 'numeric', month: '2-digit', day: '2-digit' });
|
|
}
|
|
|
|
// --- GESTIONE LOGIN ---
|
|
document.getElementById('login-form').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
const user = document.getElementById('username').value.trim().toLowerCase();
|
|
const pwd = document.getElementById('password').value;
|
|
|
|
if (user === UTENTE_SEGRETO && pwd === PASSWORD_SEGRETA) {
|
|
document.getElementById('login-view').style.display = 'none';
|
|
document.getElementById('dashboard-view').style.display = 'block';
|
|
loadFirebaseData();
|
|
} else {
|
|
document.getElementById('login-error').innerText = "Credenziali errate! Riprova.";
|
|
}
|
|
});
|
|
|
|
function logout() {
|
|
document.getElementById('password').value = '';
|
|
document.getElementById('login-error').innerText = '';
|
|
document.getElementById('dashboard-view').style.display = 'none';
|
|
document.getElementById('login-view').style.display = 'flex';
|
|
document.getElementById('table-body').innerHTML = '<tr><td colspan="5" class="empty">Caricamento dati dal database...</td></tr>';
|
|
allData = [];
|
|
}
|
|
|
|
// --- CONNESSIONE A FIREBASE ---
|
|
function loadFirebaseData() {
|
|
const db = firebase.firestore();
|
|
db.collection('leaderboard').orderBy('lastActive', 'desc').onSnapshot((snapshot) => {
|
|
allData = [];
|
|
snapshot.forEach(doc => {
|
|
let data = doc.data();
|
|
|
|
// Gestione Date Firebase
|
|
if (data.lastActive) {
|
|
data.dateObj = data.lastActive.toDate();
|
|
data.dateStr = data.dateObj.toISOString().substring(0, 10);
|
|
} else {
|
|
data.dateStr = "2000-01-01";
|
|
}
|
|
|
|
if (data.accountCreated) {
|
|
data.createdObj = data.accountCreated.toDate();
|
|
}
|
|
|
|
// Nascondi account sviluppatore se necessario
|
|
if ((data.name || '').toUpperCase() !== 'PIPPO') {
|
|
allData.push(data);
|
|
}
|
|
});
|
|
applyFilters();
|
|
}, error => {
|
|
console.error("Errore lettura database:", error);
|
|
document.getElementById('table-body').innerHTML = '<tr><td colspan="5" class="empty" style="color:#e74c3c;">Errore di connessione a Firebase. Riprova.</td></tr>';
|
|
});
|
|
}
|
|
|
|
// --- GESTIONE FILTRI ---
|
|
document.getElementById('filter-form').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
applyFilters();
|
|
});
|
|
|
|
function resetFilters() {
|
|
document.getElementById('data_da').value = '';
|
|
document.getElementById('data_a').value = '';
|
|
document.getElementById('os').value = '';
|
|
document.getElementById('loc').value = '';
|
|
applyFilters();
|
|
}
|
|
|
|
function applyFilters() {
|
|
const fDa = document.getElementById('data_da').value;
|
|
const fA = document.getElementById('data_a').value;
|
|
const fOs = document.getElementById('os').value;
|
|
const fLoc = document.getElementById('loc').value.toLowerCase();
|
|
|
|
let tot = 0, ios = 0, android = 0, desktop = 0;
|
|
let html = '';
|
|
|
|
allData.forEach(row => {
|
|
let mostra = true;
|
|
|
|
let platform = row.platform || 'Sconosciuta';
|
|
let city = (row.city || '').toLowerCase();
|
|
let name = (row.name || 'Sconosciuto').toLowerCase();
|
|
|
|
// Filtri Logica
|
|
if (fDa !== '' && row.dateStr < fDa) mostra = false;
|
|
if (fA !== '' && row.dateStr > fA) mostra = false;
|
|
|
|
if (fOs !== '') {
|
|
if (fOs === 'Desktop' && (platform === 'iOS' || platform === 'Android')) mostra = false;
|
|
if (fOs !== 'Desktop' && platform !== fOs) mostra = false;
|
|
}
|
|
|
|
if (fLoc !== '' && !city.includes(fLoc) && !name.includes(fLoc)) mostra = false;
|
|
|
|
if (mostra) {
|
|
tot++;
|
|
let badgeClass = 'badge-desktop';
|
|
let platformDisplay = platform;
|
|
|
|
if (platform === 'iOS' || platform === 'macOS') { ios++; badgeClass = 'badge-ios'; }
|
|
else if (platform === 'Android') { android++; badgeClass = 'badge-android'; }
|
|
else { desktop++; platformDisplay = 'Desktop'; }
|
|
|
|
// Costruzione Riga Tabella
|
|
html += `
|
|
<tr>
|
|
<td data-label="Ultimo Accesso">
|
|
<span class="data-text">${formatDate(row.dateObj)}</span>
|
|
</td>
|
|
<td data-label="Giocatore">
|
|
<span class="player-name">${(row.name || 'GUEST').toUpperCase()}</span>
|
|
<span class="player-level">(Liv. ${row.level || 1})</span>
|
|
<span class="sub-text">Iscritto il: ${formatDateShort(row.createdObj)}</span>
|
|
</td>
|
|
<td data-label="Statistiche">
|
|
<span class="sub-text">XP: <span class="stat-value">${row.xp || 0}</span></span>
|
|
<span class="sub-text">Vittorie: <span class="stat-value" style="color:#2ecc71;">${row.wins || 0}</span></span>
|
|
<span class="sub-text">Tempo: <span class="stat-value" style="color:#2c3e50;">${formatTime(row.playtime)}</span></span>
|
|
</td>
|
|
<td data-label="Connessione">
|
|
<span class="badge ${badgeClass}">${platformDisplay}</span>
|
|
<span class="loc-text" style="display:block; margin-top:2px;">${row.city || 'N/D'}</span>
|
|
<span class="sub-text">IP: ${row.ip || 'N/D'}</span>
|
|
</td>
|
|
<td data-label="Dispositivo" style="font-size: 13px; color: #7f8c8d;">
|
|
<strong>${row.deviceModel || 'N/D'}</strong>
|
|
<span class="sub-text">App v. ${row.appVersion || 'N/D'}</span>
|
|
</td>
|
|
</tr>
|
|
`;
|
|
}
|
|
});
|
|
|
|
if (tot === 0) {
|
|
html = '<tr><td colspan="5" class="empty">Nessun giocatore corrisponde ai filtri selezionati.</td></tr>';
|
|
}
|
|
|
|
// Aggiorna la vista
|
|
document.getElementById('table-body').innerHTML = html;
|
|
document.getElementById('totale-text').innerText = tot;
|
|
document.getElementById('ios-text').innerText = ios;
|
|
document.getElementById('android-text').innerText = android;
|
|
document.getElementById('desktop-text').innerText = desktop;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |