1300 lines
43 KiB
HTML
1300 lines
43 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Timer Leaderboard</title>
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', sans-serif;
|
|
background: #0a0a0f;
|
|
color: #ffffff;
|
|
min-height: 100vh;
|
|
background-image:
|
|
radial-gradient(circle at 20% 80%, #1a1a2e 0%, transparent 50%),
|
|
radial-gradient(circle at 80% 20%, #16213e 0%, transparent 50%),
|
|
radial-gradient(circle at 40% 40%, #0f3460 0%, transparent 50%);
|
|
}
|
|
|
|
.main-container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
padding: 2rem;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.header-section {
|
|
text-align: center;
|
|
margin-bottom: 3rem;
|
|
}
|
|
|
|
.main-title {
|
|
font-size: 4rem;
|
|
font-weight: 700;
|
|
background: linear-gradient(135deg, #00d4ff, #ff6b35, #ffd700);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
margin-bottom: 0.5rem;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
|
|
.tagline {
|
|
font-size: 1.2rem;
|
|
color: #8892b0;
|
|
font-weight: 300;
|
|
}
|
|
|
|
.dashboard-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 2fr;
|
|
gap: 2rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.control-panel {
|
|
background: rgba(15, 23, 42, 0.8);
|
|
border: 1px solid #1e293b;
|
|
border-radius: 1rem;
|
|
padding: 2rem;
|
|
backdrop-filter: blur(20px);
|
|
}
|
|
|
|
.control-group {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.control-label {
|
|
display: block;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 0.9rem;
|
|
font-weight: 500;
|
|
color: #cbd5e1;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.custom-select {
|
|
width: 100%;
|
|
padding: 1rem;
|
|
background: #1e293b;
|
|
border: 2px solid #334155;
|
|
border-radius: 0.75rem;
|
|
color: #ffffff;
|
|
font-size: 1rem;
|
|
font-family: inherit;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.custom-select:focus {
|
|
outline: none;
|
|
border-color: #00d4ff;
|
|
box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
|
|
}
|
|
|
|
/* Location Control Layout */
|
|
.location-control {
|
|
display: flex;
|
|
gap: 0.75rem;
|
|
align-items: center;
|
|
}
|
|
|
|
.location-select {
|
|
flex: 1;
|
|
}
|
|
|
|
.location-btn {
|
|
padding: 1rem 1.5rem;
|
|
background: linear-gradient(135deg, #10b981, #059669);
|
|
border: none;
|
|
border-radius: 0.75rem;
|
|
color: white;
|
|
font-weight: 600;
|
|
font-size: 0.9rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
white-space: nowrap;
|
|
min-width: 140px;
|
|
}
|
|
|
|
.location-btn:hover {
|
|
background: linear-gradient(135deg, #059669, #047857);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
|
|
}
|
|
|
|
.location-btn:disabled {
|
|
background: #374151;
|
|
color: #9ca3af;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.location-btn.loading {
|
|
background: linear-gradient(135deg, #6366f1, #4f46e5);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.location-btn.loading::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: -100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
|
|
animation: loading-sweep 1.5s infinite;
|
|
}
|
|
|
|
@keyframes loading-sweep {
|
|
0% { left: -100%; }
|
|
100% { left: 100%; }
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.location-control {
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.location-btn {
|
|
width: 100%;
|
|
min-width: auto;
|
|
}
|
|
}
|
|
|
|
/* Horizontal Time Tabs */
|
|
.time-tabs {
|
|
display: flex;
|
|
background: #1e293b;
|
|
border: 2px solid #334155;
|
|
border-radius: 0.75rem;
|
|
padding: 0.25rem;
|
|
gap: 0.25rem;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.time-tab {
|
|
flex: 1;
|
|
min-width: 0;
|
|
padding: 0.75rem 1rem;
|
|
background: transparent;
|
|
border: none;
|
|
border-radius: 0.5rem;
|
|
color: #94a3b8;
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.5rem;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.time-tab:hover {
|
|
background: #334155;
|
|
color: #e2e8f0;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.time-tab.active {
|
|
background: linear-gradient(135deg, #00d4ff, #0891b2);
|
|
color: white;
|
|
box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
|
|
}
|
|
|
|
.time-tab.active:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 6px 16px rgba(0, 212, 255, 0.4);
|
|
}
|
|
|
|
.tab-icon {
|
|
font-size: 1rem;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.tab-text {
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
/* Mobile responsive tabs */
|
|
@media (max-width: 768px) {
|
|
.time-tabs {
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
padding: 0.5rem;
|
|
}
|
|
|
|
.time-tab {
|
|
padding: 1rem;
|
|
justify-content: flex-start;
|
|
border-radius: 0.75rem;
|
|
}
|
|
|
|
.tab-text {
|
|
font-size: 1rem;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.time-tabs {
|
|
flex-direction: row;
|
|
overflow-x: auto;
|
|
padding: 0.25rem;
|
|
gap: 0.25rem;
|
|
}
|
|
|
|
.time-tab {
|
|
min-width: 80px;
|
|
padding: 0.5rem 0.75rem;
|
|
flex-direction: column;
|
|
gap: 0.25rem;
|
|
}
|
|
|
|
.tab-icon {
|
|
font-size: 1.2rem;
|
|
}
|
|
|
|
.tab-text {
|
|
font-size: 0.75rem;
|
|
}
|
|
}
|
|
|
|
.refresh-btn {
|
|
width: 100%;
|
|
padding: 1rem;
|
|
background: linear-gradient(135deg, #00d4ff, #0891b2);
|
|
border: none;
|
|
border-radius: 0.75rem;
|
|
color: white;
|
|
font-weight: 600;
|
|
font-size: 1rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.refresh-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 10px 25px rgba(0, 212, 255, 0.3);
|
|
}
|
|
|
|
.stats-panel {
|
|
background: rgba(15, 23, 42, 0.8);
|
|
border: 1px solid #1e293b;
|
|
border-radius: 1rem;
|
|
padding: 2rem;
|
|
backdrop-filter: blur(20px);
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 1.5rem;
|
|
height: 100%;
|
|
}
|
|
|
|
.stat-card {
|
|
text-align: center;
|
|
padding: 1rem;
|
|
background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(255, 107, 53, 0.1));
|
|
border-radius: 0.75rem;
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 2.5rem;
|
|
font-weight: 700;
|
|
color: #00d4ff;
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 0.8rem;
|
|
color: #8892b0;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.leaderboard-container {
|
|
background: rgba(15, 23, 42, 0.8);
|
|
border: 1px solid #1e293b;
|
|
border-radius: 1rem;
|
|
backdrop-filter: blur(20px);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.leaderboard-header {
|
|
padding: 2rem;
|
|
background: linear-gradient(135deg, #1e293b, #0f172a);
|
|
border-bottom: 1px solid #334155;
|
|
}
|
|
|
|
.active-filters {
|
|
font-size: 1.5rem;
|
|
font-weight: 600;
|
|
color: #ffffff;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.last-sync {
|
|
font-size: 0.9rem;
|
|
color: #64748b;
|
|
}
|
|
|
|
.rankings-list {
|
|
max-height: 600px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.rankings-list::-webkit-scrollbar {
|
|
width: 6px;
|
|
}
|
|
|
|
.rankings-list::-webkit-scrollbar-track {
|
|
background: #1e293b;
|
|
}
|
|
|
|
.rankings-list::-webkit-scrollbar-thumb {
|
|
background: #475569;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.rank-entry {
|
|
display: grid;
|
|
grid-template-columns: 80px 1fr auto auto;
|
|
align-items: center;
|
|
padding: 1.5rem 2rem;
|
|
border-bottom: 1px solid rgba(51, 65, 85, 0.5);
|
|
transition: all 0.2s ease;
|
|
position: relative;
|
|
}
|
|
|
|
.rank-entry:hover {
|
|
background: rgba(0, 212, 255, 0.05);
|
|
border-left: 4px solid #00d4ff;
|
|
}
|
|
|
|
.rank-entry:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.position {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
text-align: center;
|
|
}
|
|
|
|
.position.gold {
|
|
color: #ffd700;
|
|
text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
|
|
}
|
|
|
|
.position.silver {
|
|
color: #c0c0c0;
|
|
text-shadow: 0 0 20px rgba(192, 192, 192, 0.3);
|
|
}
|
|
|
|
.position.bronze {
|
|
color: #cd7f32;
|
|
text-shadow: 0 0 20px rgba(205, 127, 50, 0.3);
|
|
}
|
|
|
|
.player-data {
|
|
padding-left: 1rem;
|
|
}
|
|
|
|
.player-name {
|
|
font-size: 1.3rem;
|
|
font-weight: 600;
|
|
color: #ffffff;
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
.player-meta {
|
|
font-size: 0.9rem;
|
|
color: #8892b0;
|
|
display: flex;
|
|
gap: 1rem;
|
|
align-items: center;
|
|
}
|
|
|
|
.location-tag {
|
|
background: rgba(0, 212, 255, 0.2);
|
|
color: #00d4ff;
|
|
padding: 0.25rem 0.5rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.8rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.time-result {
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 2.5rem;
|
|
font-weight: 700;
|
|
color: #ffffff;
|
|
text-align: right;
|
|
}
|
|
|
|
.trophy-icon {
|
|
font-size: 2rem;
|
|
margin-left: 1rem;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 4rem 2rem;
|
|
color: #64748b;
|
|
}
|
|
|
|
.empty-icon {
|
|
font-size: 4rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.empty-title {
|
|
font-size: 1.5rem;
|
|
font-weight: 600;
|
|
margin-bottom: 0.5rem;
|
|
color: #8892b0;
|
|
}
|
|
|
|
.empty-description {
|
|
font-size: 1rem;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
/* Admin Login Button */
|
|
.admin-login-btn {
|
|
position: fixed;
|
|
top: 2rem;
|
|
right: 2rem;
|
|
padding: 0.75rem 1.5rem;
|
|
background: linear-gradient(135deg, #ff6b35, #f7931e);
|
|
border: none;
|
|
border-radius: 0.75rem;
|
|
color: white;
|
|
font-weight: 600;
|
|
font-size: 0.9rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.admin-login-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 10px 25px rgba(255, 107, 53, 0.3);
|
|
}
|
|
|
|
.dashboard-btn {
|
|
position: fixed;
|
|
top: 2rem;
|
|
right: 2rem;
|
|
padding: 0.75rem 1.5rem;
|
|
background: linear-gradient(135deg, #00d4ff, #0891b2);
|
|
border: none;
|
|
border-radius: 0.75rem;
|
|
color: white;
|
|
font-weight: 600;
|
|
font-size: 0.9rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.dashboard-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 10px 25px rgba(0, 212, 255, 0.3);
|
|
}
|
|
|
|
.logout-btn {
|
|
position: fixed;
|
|
top: 2rem;
|
|
right: 12rem;
|
|
padding: 0.75rem 1.5rem;
|
|
background: linear-gradient(135deg, #dc3545, #c82333);
|
|
border: none;
|
|
border-radius: 0.75rem;
|
|
color: white;
|
|
font-weight: 600;
|
|
font-size: 0.9rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.logout-btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 10px 25px rgba(220, 53, 69, 0.3);
|
|
}
|
|
|
|
@media (max-width: 1024px) {
|
|
.dashboard-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.stats-grid {
|
|
grid-template-columns: repeat(3, 1fr);
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.main-title {
|
|
font-size: 2.5rem;
|
|
}
|
|
|
|
.rank-entry {
|
|
grid-template-columns: 60px 1fr auto;
|
|
padding: 1rem;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.trophy-icon {
|
|
display: none;
|
|
}
|
|
|
|
.time-result {
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
.stats-grid {
|
|
grid-template-columns: 1fr;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.player-meta {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.admin-login-btn, .dashboard-btn, .logout-btn {
|
|
top: 1rem;
|
|
right: 1rem;
|
|
padding: 0.5rem 1rem;
|
|
font-size: 0.8rem;
|
|
}
|
|
|
|
.logout-btn {
|
|
right: 8rem;
|
|
}
|
|
}
|
|
|
|
.pulse-animation {
|
|
animation: pulse 2s infinite;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0% { opacity: 1; }
|
|
50% { opacity: 0.7; }
|
|
100% { opacity: 1; }
|
|
}
|
|
|
|
/* Notification Bubble Styles */
|
|
.notification-bubble {
|
|
position: fixed;
|
|
top: 2rem;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background: linear-gradient(135deg, #00d4ff, #0891b2);
|
|
color: white;
|
|
padding: 1rem 2rem;
|
|
border-radius: 1rem;
|
|
box-shadow: 0 10px 25px rgba(0, 212, 255, 0.3);
|
|
z-index: 2000;
|
|
opacity: 0;
|
|
transform: translateX(-50%) translateY(-20px);
|
|
transition: all 0.3s ease;
|
|
backdrop-filter: blur(20px);
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
max-width: 400px;
|
|
text-align: center;
|
|
}
|
|
|
|
.notification-bubble.show {
|
|
opacity: 1;
|
|
transform: translateX(-50%) translateY(0);
|
|
}
|
|
|
|
.notification-bubble.hide {
|
|
opacity: 0;
|
|
transform: translateX(-50%) translateY(-20px);
|
|
}
|
|
|
|
.notification-content {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.notification-icon {
|
|
font-size: 1.5rem;
|
|
animation: bounce 0.6s ease-in-out;
|
|
}
|
|
|
|
.notification-text {
|
|
flex: 1;
|
|
}
|
|
|
|
.notification-title {
|
|
font-weight: 600;
|
|
font-size: 1rem;
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
.notification-subtitle {
|
|
font-size: 0.85rem;
|
|
opacity: 0.9;
|
|
}
|
|
|
|
@keyframes bounce {
|
|
0%, 20%, 50%, 80%, 100% {
|
|
transform: translateY(0);
|
|
}
|
|
40% {
|
|
transform: translateY(-10px);
|
|
}
|
|
60% {
|
|
transform: translateY(-5px);
|
|
}
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateX(-50%) translateY(-20px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateX(-50%) translateY(0);
|
|
}
|
|
}
|
|
|
|
@keyframes slideOut {
|
|
from {
|
|
opacity: 1;
|
|
transform: translateX(-50%) translateY(0);
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
transform: translateX(-50%) translateY(-20px);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- Notification Bubble -->
|
|
<div class="notification-bubble" id="notificationBubble">
|
|
<div class="notification-content">
|
|
<div class="notification-icon">🏁</div>
|
|
<div class="notification-text">
|
|
<div class="notification-title" id="notificationTitle">Neue Zeit!</div>
|
|
<div class="notification-subtitle" id="notificationSubtitle">Ein neuer Rekord wurde erstellt</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="main-container">
|
|
<!-- Admin Login Button -->
|
|
<a href="/login" class="admin-login-btn" id="adminLoginBtn">🔐 Login</a>
|
|
<a href="/dashboard" class="dashboard-btn" id="dashboardBtn" style="display: none;">📊 Dashboard</a>
|
|
<button class="logout-btn" id="logoutBtn" onclick="logout()" style="display: none;">🚪 Logout</button>
|
|
|
|
<div class="header-section">
|
|
<h1 class="main-title">NINJACROSS LEADERBOARD</h1>
|
|
<p class="tagline">Die ultimative NinjaCross-Rangliste</p>
|
|
</div>
|
|
|
|
<div class="dashboard-grid">
|
|
<div class="control-panel">
|
|
<div class="control-group">
|
|
<label class="control-label">Standort</label>
|
|
<div class="location-control">
|
|
<select class="custom-select location-select" id="locationSelect">
|
|
<option value="all">🌍 Alle Standorte</option>
|
|
<!-- Standorte werden dynamisch geladen -->
|
|
</select>
|
|
<button class="location-btn" id="findLocationBtn" onclick="findNearestLocation()" title="Nächstgelegenen Standort finden">
|
|
📍 Mein Standort
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<label class="control-label">Zeitraum</label>
|
|
<div class="time-tabs">
|
|
<button class="time-tab active" data-period="today">
|
|
<span class="tab-icon">📅</span>
|
|
<span class="tab-text">Heute</span>
|
|
</button>
|
|
<button class="time-tab" data-period="week">
|
|
<span class="tab-icon">📊</span>
|
|
<span class="tab-text">Diese Woche</span>
|
|
</button>
|
|
<button class="time-tab" data-period="month">
|
|
<span class="tab-icon">📈</span>
|
|
<span class="tab-text">Dieser Monat</span>
|
|
</button>
|
|
<button class="time-tab" data-period="all">
|
|
<span class="tab-icon">♾️</span>
|
|
<span class="tab-text">Alle Zeiten</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<button class="refresh-btn pulse-animation" onclick="loadData()">
|
|
⚡ Live Update
|
|
</button>
|
|
</div>
|
|
|
|
<div class="stats-panel">
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<div class="stat-value" id="totalPlayers">0</div>
|
|
<div class="stat-label">Teilnehmer</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" id="bestTime">--:--</div>
|
|
<div class="stat-label">Rekordzeit</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" id="totalRecords">0</div>
|
|
<div class="stat-label">Läufe</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="leaderboard-container">
|
|
<div class="leaderboard-header">
|
|
<div class="active-filters" id="currentSelection">
|
|
🌍 Alle Standorte • 📅 Heute
|
|
</div>
|
|
<div class="last-sync" id="lastUpdated">
|
|
Letzter Sync: Loading...
|
|
</div>
|
|
</div>
|
|
|
|
<div class="rankings-list" id="rankingList">
|
|
<!-- Rankings werden hier eingefügt -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Supabase CDN -->
|
|
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
|
|
<!-- Socket.IO CDN -->
|
|
<script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
|
|
|
|
<script>
|
|
// Supabase configuration
|
|
const SUPABASE_URL = 'https://lfxlplnypzvjrhftaoog.supabase.co';
|
|
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImxmeGxwbG55cHp2anJoZnRhb29nIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkyMTQ3NzIsImV4cCI6MjA2NDc5MDc3Mn0.XR4preBqWAQ1rT4PFbpkmRdz57BTwIusBI89fIxDHM8';
|
|
|
|
// Initialize Supabase client
|
|
const supabase = window.supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
|
|
|
// Initialize Socket.IO connection
|
|
const socket = io();
|
|
|
|
// WebSocket Event Handlers
|
|
socket.on('connect', () => {
|
|
console.log('🔌 WebSocket verbunden');
|
|
});
|
|
|
|
socket.on('disconnect', () => {
|
|
console.log('🔌 WebSocket getrennt');
|
|
});
|
|
|
|
socket.on('newTime', (data) => {
|
|
console.log('🏁 Neue Zeit empfangen:', data);
|
|
showNotification(data);
|
|
// Reload data to show the new time
|
|
loadData();
|
|
});
|
|
|
|
// Notification Functions
|
|
function showNotification(timeData) {
|
|
const notificationBubble = document.getElementById('notificationBubble');
|
|
const notificationTitle = document.getElementById('notificationTitle');
|
|
const notificationSubtitle = document.getElementById('notificationSubtitle');
|
|
|
|
// Format the time data
|
|
const playerName = timeData.player_name || 'Unbekannter Spieler';
|
|
const locationName = timeData.location_name || 'Unbekannter Standort';
|
|
const timeString = timeData.recorded_time || '--:--';
|
|
|
|
// Update notification content
|
|
notificationTitle.textContent = `🏁 Neue Zeit von ${playerName}!`;
|
|
notificationSubtitle.textContent = `${timeString} • ${locationName}`;
|
|
|
|
// Show notification
|
|
notificationBubble.classList.remove('hide');
|
|
notificationBubble.classList.add('show');
|
|
|
|
// Auto-hide after 5 seconds
|
|
setTimeout(() => {
|
|
hideNotification();
|
|
}, 5000);
|
|
}
|
|
|
|
function hideNotification() {
|
|
const notificationBubble = document.getElementById('notificationBubble');
|
|
notificationBubble.classList.remove('show');
|
|
notificationBubble.classList.add('hide');
|
|
|
|
// Remove hide class after animation
|
|
setTimeout(() => {
|
|
notificationBubble.classList.remove('hide');
|
|
}, 300);
|
|
}
|
|
|
|
// Check authentication status
|
|
async function checkAuth() {
|
|
try {
|
|
const { data: { session } } = await supabase.auth.getSession();
|
|
|
|
if (session) {
|
|
// User is logged in, show dashboard button
|
|
document.getElementById('adminLoginBtn').style.display = 'none';
|
|
document.getElementById('dashboardBtn').style.display = 'inline-block';
|
|
document.getElementById('logoutBtn').style.display = 'inline-block';
|
|
} else {
|
|
// User is not logged in, show admin login button
|
|
document.getElementById('adminLoginBtn').style.display = 'inline-block';
|
|
document.getElementById('dashboardBtn').style.display = 'none';
|
|
document.getElementById('logoutBtn').style.display = 'none';
|
|
}
|
|
} catch (error) {
|
|
console.error('Error checking auth:', error);
|
|
// Fallback: show login button if auth check fails
|
|
document.getElementById('adminLoginBtn').style.display = 'inline-block';
|
|
document.getElementById('dashboardBtn').style.display = 'none';
|
|
document.getElementById('logoutBtn').style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Logout function
|
|
async function logout() {
|
|
try {
|
|
const { error } = await supabase.auth.signOut();
|
|
if (error) {
|
|
console.error('Error logging out:', error);
|
|
} else {
|
|
window.location.reload();
|
|
}
|
|
} catch (error) {
|
|
console.error('Error during logout:', error);
|
|
window.location.reload();
|
|
}
|
|
}
|
|
|
|
// Global variable to store locations with coordinates
|
|
let locationsData = [];
|
|
|
|
// Load locations from database
|
|
async function loadLocations() {
|
|
try {
|
|
const response = await fetch('/public-api/locations');
|
|
if (!response.ok) {
|
|
throw new Error('Failed to fetch locations');
|
|
}
|
|
|
|
const responseData = await response.json();
|
|
const locations = responseData.data || responseData; // Handle both formats
|
|
const locationSelect = document.getElementById('locationSelect');
|
|
|
|
// Store locations globally for distance calculations
|
|
locationsData = locations;
|
|
|
|
// Clear existing options except "Alle Standorte"
|
|
locationSelect.innerHTML = '<option value="all">🌍 Alle Standorte</option>';
|
|
|
|
// Add locations from database
|
|
locations.forEach(location => {
|
|
const option = document.createElement('option');
|
|
option.value = location.name;
|
|
option.textContent = `📍 ${location.name}`;
|
|
locationSelect.appendChild(option);
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('Error loading locations:', error);
|
|
}
|
|
}
|
|
|
|
// Calculate distance between two points using Haversine formula
|
|
function calculateDistance(lat1, lon1, lat2, lon2) {
|
|
const R = 6371; // Earth's radius in kilometers
|
|
const dLat = toRadians(lat2 - lat1);
|
|
const dLon = toRadians(lon2 - lon1);
|
|
|
|
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) *
|
|
Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
|
|
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
const distance = R * c; // Distance in kilometers
|
|
|
|
return distance;
|
|
}
|
|
|
|
function toRadians(degrees) {
|
|
return degrees * (Math.PI / 180);
|
|
}
|
|
|
|
// Find nearest location based on user's current position
|
|
async function findNearestLocation() {
|
|
const btn = document.getElementById('findLocationBtn');
|
|
const locationSelect = document.getElementById('locationSelect');
|
|
|
|
// Check if geolocation is supported
|
|
if (!navigator.geolocation) {
|
|
showLocationError('Geolocation wird von diesem Browser nicht unterstützt.');
|
|
return;
|
|
}
|
|
|
|
// Update button state to loading
|
|
btn.disabled = true;
|
|
btn.classList.add('loading');
|
|
btn.textContent = '🔍 Suche...';
|
|
|
|
try {
|
|
// Get user's current position
|
|
const position = await new Promise((resolve, reject) => {
|
|
navigator.geolocation.getCurrentPosition(
|
|
resolve,
|
|
reject,
|
|
{
|
|
enableHighAccuracy: true,
|
|
timeout: 10000,
|
|
maximumAge: 300000 // 5 minutes
|
|
}
|
|
);
|
|
});
|
|
|
|
const userLat = position.coords.latitude;
|
|
const userLon = position.coords.longitude;
|
|
|
|
// Calculate distances to all locations
|
|
const locationsWithDistance = locationsData.map(location => ({
|
|
...location,
|
|
distance: calculateDistance(
|
|
userLat,
|
|
userLon,
|
|
parseFloat(location.latitude),
|
|
parseFloat(location.longitude)
|
|
)
|
|
}));
|
|
|
|
// Find the nearest location
|
|
const nearestLocation = locationsWithDistance.reduce((nearest, current) => {
|
|
return current.distance < nearest.distance ? current : nearest;
|
|
});
|
|
|
|
// Select the nearest location in the dropdown
|
|
locationSelect.value = nearestLocation.name;
|
|
|
|
// Trigger change event to update the leaderboard
|
|
locationSelect.dispatchEvent(new Event('change'));
|
|
|
|
// Show success notification
|
|
showLocationSuccess(nearestLocation.name, nearestLocation.distance);
|
|
|
|
} catch (error) {
|
|
console.error('Error getting location:', error);
|
|
let errorMessage = 'Standort konnte nicht ermittelt werden.';
|
|
|
|
if (error.code) {
|
|
switch(error.code) {
|
|
case error.PERMISSION_DENIED:
|
|
errorMessage = 'Standortzugriff wurde verweigert. Bitte erlaube den Standortzugriff in den Browser-Einstellungen.';
|
|
break;
|
|
case error.POSITION_UNAVAILABLE:
|
|
errorMessage = 'Standortinformationen sind nicht verfügbar.';
|
|
break;
|
|
case error.TIMEOUT:
|
|
errorMessage = 'Zeitüberschreitung beim Abrufen des Standorts.';
|
|
break;
|
|
}
|
|
}
|
|
|
|
showLocationError(errorMessage);
|
|
} finally {
|
|
// Reset button state
|
|
btn.disabled = false;
|
|
btn.classList.remove('loading');
|
|
btn.textContent = '📍 Mein Standort';
|
|
}
|
|
}
|
|
|
|
// Show success notification for location finding
|
|
function showLocationSuccess(locationName, distance) {
|
|
const notificationBubble = document.getElementById('notificationBubble');
|
|
const notificationTitle = document.getElementById('notificationTitle');
|
|
const notificationSubtitle = document.getElementById('notificationSubtitle');
|
|
|
|
// Update notification content
|
|
notificationTitle.textContent = `📍 Standort gefunden!`;
|
|
notificationSubtitle.textContent = `${locationName} (${distance.toFixed(1)} km entfernt)`;
|
|
|
|
// Show notification
|
|
notificationBubble.classList.remove('hide');
|
|
notificationBubble.classList.add('show');
|
|
|
|
// Auto-hide after 4 seconds
|
|
setTimeout(() => {
|
|
hideNotification();
|
|
}, 4000);
|
|
}
|
|
|
|
// Show error notification for location finding
|
|
function showLocationError(message) {
|
|
const notificationBubble = document.getElementById('notificationBubble');
|
|
const notificationTitle = document.getElementById('notificationTitle');
|
|
const notificationSubtitle = document.getElementById('notificationSubtitle');
|
|
|
|
// Change notification style to error
|
|
notificationBubble.style.background = 'linear-gradient(135deg, #dc3545, #c82333)';
|
|
|
|
// Update notification content
|
|
notificationTitle.textContent = '❌ Fehler';
|
|
notificationSubtitle.textContent = message;
|
|
|
|
// Show notification
|
|
notificationBubble.classList.remove('hide');
|
|
notificationBubble.classList.add('show');
|
|
|
|
// Auto-hide after 6 seconds
|
|
setTimeout(() => {
|
|
hideNotification();
|
|
// Reset notification style
|
|
notificationBubble.style.background = 'linear-gradient(135deg, #00d4ff, #0891b2)';
|
|
}, 6000);
|
|
}
|
|
|
|
// Load data from local database via MCP
|
|
async function loadData() {
|
|
try {
|
|
const location = document.getElementById('locationSelect').value;
|
|
const period = document.querySelector('.time-tab.active').dataset.period;
|
|
|
|
// Build query parameters
|
|
const params = new URLSearchParams();
|
|
if (location && location !== 'all') {
|
|
params.append('location', location);
|
|
}
|
|
if (period && period !== 'all') {
|
|
params.append('period', period);
|
|
}
|
|
|
|
// Fetch times with player and location data from local database
|
|
const response = await fetch(`/public-api/times-with-details?${params.toString()}`);
|
|
if (!response.ok) {
|
|
throw new Error('Failed to fetch times');
|
|
}
|
|
|
|
const times = await response.json();
|
|
|
|
// Convert to the format expected by the leaderboard
|
|
const leaderboardData = times.map(time => {
|
|
const { minutes, seconds, milliseconds } = time.recorded_time;
|
|
const timeString = `${minutes}:${seconds.toString().padStart(2, '0')}.${milliseconds}`;
|
|
const playerName = time.player ?
|
|
`${time.player.firstname} ${time.player.lastname}` :
|
|
'Unknown Player';
|
|
const locationName = time.location ? time.location.name : 'Unknown Location';
|
|
const date = new Date(time.created_at).toISOString().split('T')[0];
|
|
|
|
return {
|
|
name: playerName,
|
|
time: timeString,
|
|
date: date,
|
|
location: locationName
|
|
};
|
|
});
|
|
|
|
// Sort by time (fastest first)
|
|
leaderboardData.sort((a, b) => {
|
|
const timeA = timeToSeconds(a.time);
|
|
const timeB = timeToSeconds(b.time);
|
|
return timeA - timeB;
|
|
});
|
|
|
|
updateLeaderboard(leaderboardData);
|
|
updateStats(leaderboardData);
|
|
updateCurrentSelection();
|
|
|
|
} catch (error) {
|
|
console.error('Error loading data:', error);
|
|
// Fallback to sample data if API fails
|
|
loadSampleData();
|
|
}
|
|
}
|
|
|
|
// Fallback sample data based on real database data
|
|
function loadSampleData() {
|
|
const sampleData = [
|
|
{ name: "Carsten Graf", time: "01:28.945", date: "2025-08-30", location: "Ulm Donaubad" },
|
|
{ name: "Carsten Graf", time: "01:30.945", date: "2025-08-30", location: "Ulm Donaubad" },
|
|
{ name: "Max Mustermann", time: "01:50.945", date: "2025-08-30", location: "Ulm Donaubad" },
|
|
{ name: "Carsten Graf", time: "02:50.945", date: "2025-08-31", location: "Test" },
|
|
{ name: "Max Mustermann", time: "02:50.945", date: "2025-08-31", location: "Test" },
|
|
{ name: "Carsten Graf", time: "01:10.945", date: "2025-09-02", location: "Test" },
|
|
{ name: "Carsten Graf", time: "01:11.945", date: "2025-09-02", location: "Test" },
|
|
{ name: "Carsten Graf", time: "01:11.945", date: "2025-09-02", location: "Ulm Donaubad" }
|
|
];
|
|
|
|
updateLeaderboard(sampleData);
|
|
updateStats(sampleData);
|
|
updateCurrentSelection();
|
|
}
|
|
|
|
function timeToSeconds(timeStr) {
|
|
const [minutes, seconds] = timeStr.split(':');
|
|
return parseFloat(minutes) * 60 + parseFloat(seconds);
|
|
}
|
|
|
|
function updateStats(data) {
|
|
const totalPlayers = new Set(data.map(item => item.name)).size;
|
|
const bestTime = data.length > 0 ? data[0].time : '--:--';
|
|
const totalRecords = data.length;
|
|
|
|
document.getElementById('totalPlayers').textContent = totalPlayers;
|
|
document.getElementById('bestTime').textContent = bestTime;
|
|
document.getElementById('totalRecords').textContent = totalRecords;
|
|
}
|
|
|
|
function updateCurrentSelection() {
|
|
const location = document.getElementById('locationSelect').value;
|
|
const period = document.querySelector('.time-tab.active').dataset.period;
|
|
|
|
// Get the display text from the selected option
|
|
const locationSelect = document.getElementById('locationSelect');
|
|
const selectedLocationOption = locationSelect.options[locationSelect.selectedIndex];
|
|
const locationDisplay = selectedLocationOption ? selectedLocationOption.textContent : '🌍 Alle Standorte';
|
|
|
|
const periodIcons = {
|
|
'today': '📅 Heute',
|
|
'week': '📊 Diese Woche',
|
|
'month': '📈 Dieser Monat',
|
|
'all': '♾️ Alle Zeiten'
|
|
};
|
|
|
|
document.getElementById('currentSelection').textContent =
|
|
`${locationDisplay} • ${periodIcons[period]}`;
|
|
|
|
document.getElementById('lastUpdated').textContent =
|
|
`Letzter Sync: ${new Date().toLocaleTimeString('de-DE')}`;
|
|
}
|
|
|
|
function updateLeaderboard(data) {
|
|
const rankingList = document.getElementById('rankingList');
|
|
|
|
if (data.length === 0) {
|
|
rankingList.innerHTML = `
|
|
<div class="empty-state">
|
|
<div class="empty-icon">🏁</div>
|
|
<div class="empty-title">Keine Rekorde gefunden</div>
|
|
<div class="empty-description">
|
|
Für diese Filtereinstellungen liegen noch keine Zeiten vor.<br>
|
|
Versuche es mit einem anderen Zeitraum oder Standort.
|
|
</div>
|
|
</div>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
rankingList.innerHTML = data.map((player, index) => {
|
|
const rank = index + 1;
|
|
let positionClass = '';
|
|
let trophy = '';
|
|
|
|
if (rank === 1) {
|
|
positionClass = 'gold';
|
|
trophy = '👑';
|
|
} else if (rank === 2) {
|
|
positionClass = 'silver';
|
|
trophy = '🥈';
|
|
} else if (rank === 3) {
|
|
positionClass = 'bronze';
|
|
trophy = '🥉';
|
|
} else if (rank <= 10) {
|
|
trophy = '⭐';
|
|
}
|
|
|
|
const formatDate = new Date(player.date).toLocaleDateString('de-DE', {
|
|
day: '2-digit',
|
|
month: 'short'
|
|
});
|
|
|
|
return `
|
|
<div class="rank-entry">
|
|
<div class="position ${positionClass}">#${rank}</div>
|
|
<div class="player-data">
|
|
<div class="player-name">${player.name}</div>
|
|
<div class="player-meta">
|
|
<span class="location-tag">${player.location}</span>
|
|
<span>🗓️ ${formatDate}</span>
|
|
</div>
|
|
</div>
|
|
<div class="time-result">${player.time}</div>
|
|
${trophy ? `<div class="trophy-icon">${trophy}</div>` : '<div class="trophy-icon"></div>'}
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// Event Listeners
|
|
document.getElementById('locationSelect').addEventListener('change', loadData);
|
|
|
|
// Time tab event listeners
|
|
document.querySelectorAll('.time-tab').forEach(tab => {
|
|
tab.addEventListener('click', function() {
|
|
// Remove active class from all tabs
|
|
document.querySelectorAll('.time-tab').forEach(t => t.classList.remove('active'));
|
|
// Add active class to clicked tab
|
|
this.classList.add('active');
|
|
// Load data with new period
|
|
loadData();
|
|
});
|
|
});
|
|
|
|
// Initialize page
|
|
async function init() {
|
|
await checkAuth();
|
|
await loadLocations();
|
|
await loadData();
|
|
}
|
|
|
|
// Start the application
|
|
init();
|
|
|
|
// Auto-refresh
|
|
setInterval(loadData, 45000);
|
|
|
|
// Smooth scroll für bessere UX
|
|
document.querySelector('.rankings-list').style.scrollBehavior = 'smooth';
|
|
</script>
|
|
</body>
|
|
</html> |