eaa718f09d
- Statische Nginx website - index.html, error pages - CHANGELOG.md en .gitignore
1871 lines
95 KiB
HTML
1871 lines
95 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="nl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Padel Planner</title>
|
|
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
|
|
<meta http-equiv="pragma" content="no-cache">
|
|
<meta http-equiv="expires" content="0">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
|
|
<style>
|
|
/* ══════════════════════════════════════════════════════════════
|
|
DESIGN TOKENS — shadcn-inspired dark theme
|
|
══════════════════════════════════════════════════════════════ */
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
:root {
|
|
/* Colors */
|
|
--bg: #09090b;
|
|
--surface: #111114;
|
|
--surface-2: #1a1a1f;
|
|
--surface-3: #242429;
|
|
--border: #2a2a30;
|
|
--border-light: #38383f;
|
|
--primary: #a78bfa;
|
|
--primary-hover: #b89dfc;
|
|
--primary-dim: rgba(167,139,250,0.12);
|
|
--primary-glow: rgba(167,139,250,0.25);
|
|
--accent: #34d399;
|
|
--accent-dim: rgba(52,211,153,0.12);
|
|
--text: #fafafa;
|
|
--text-secondary: #c0c0c8;
|
|
--muted: #8888a0;
|
|
--danger: #f87171;
|
|
--warning: #fbbf24;
|
|
--live: #22c55e;
|
|
|
|
/* Typography */
|
|
--font: 'Inter', system-ui, -apple-system, sans-serif;
|
|
--radius-sm: 8px;
|
|
--radius: 12px;
|
|
--radius-lg: 16px;
|
|
--radius-xl: 20px;
|
|
|
|
/* Shadows — depth layers */
|
|
--shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
|
|
--shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 0 1px var(--border);
|
|
--shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
|
|
--shadow-lg: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px var(--border);
|
|
--shadow-glow: 0 0 20px var(--primary-glow), 0 0 0 1px var(--border);
|
|
|
|
/* Transitions */
|
|
--ease: cubic-bezier(0.4, 0, 0.2, 1);
|
|
--ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
}
|
|
|
|
html { font-family: var(--font); background: var(--bg); color: var(--text); height: 100%; scroll-behavior: smooth; }
|
|
body { min-height: 100%; display: flex; flex-direction: column; overflow-x: hidden; }
|
|
|
|
/* ── Subtle grid bg texture ── */
|
|
body::before {
|
|
content: '';
|
|
position: fixed; inset: 0;
|
|
background-image:
|
|
radial-gradient(circle at 50% 0%, rgba(167,139,250,0.03) 0%, transparent 50%),
|
|
linear-gradient(rgba(255,255,255,0.01) 1px, transparent 1px),
|
|
linear-gradient(90deg, rgba(255,255,255,0.01) 1px, transparent 1px);
|
|
background-size: 100% 100%, 40px 40px, 40px 40px;
|
|
pointer-events: none; z-index: 0;
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
LAYOUT — desktop sidebar + mobile bottom nav
|
|
══════════════════════════════════════════════════════════════ */
|
|
@media (min-width: 768px) {
|
|
body { flex-direction: row; }
|
|
.sidebar {
|
|
width: 256px; flex-shrink: 0;
|
|
border-right: 1px solid var(--border);
|
|
display: flex; flex-direction: column;
|
|
position: sticky; top: 0; height: 100vh;
|
|
overflow: hidden;
|
|
background: var(--surface);
|
|
backdrop-filter: blur(20px) saturate(180%);
|
|
}
|
|
.main-area { flex: 1; display: flex; flex-direction: column; min-height: 100vh; position: relative; z-index: 1; }
|
|
.topbar-desktop { display: flex; }
|
|
.content-area { flex: 1; overflow-y: auto; padding: 32px 40px; }
|
|
.bottom-nav { display: none !important; }
|
|
}
|
|
|
|
@media (max-width: 767px) {
|
|
.sidebar { display: none; }
|
|
.topbar-desktop { display: none; }
|
|
body { background: var(--bg); }
|
|
.content-area { padding: 12px 12px 80px; flex: 1; position: relative; z-index: 1; }
|
|
.view { max-width: 100%; }
|
|
.bottom-nav { display: flex !important; }
|
|
.card-pad { padding: 14px 14px; }
|
|
.view-head { padding-bottom: 14px; }
|
|
.view-head h1 { font-size: 18px; }
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
SVG ICONS — inline, consistent, no emoji
|
|
══════════════════════════════════════════════════════════════ */
|
|
.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
|
|
.ic svg { width: 1em; height: 1em; }
|
|
.ic-lg svg { width: 20px; height: 20px; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
SIDEBAR
|
|
══════════════════════════════════════════════════════════════ */
|
|
.sidebar-header {
|
|
padding: 20px 16px 16px;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
.sidebar-logo {
|
|
display: flex; align-items: center; gap: 10px;
|
|
font-size: 15px; font-weight: 700; letter-spacing: -0.2px;
|
|
}
|
|
.sidebar-logo-icon {
|
|
width: 34px; height: 34px; border-radius: var(--radius);
|
|
background: linear-gradient(135deg, #5b21b6, #7c3aed 50%, #a78bfa);
|
|
display: flex; align-items: center; justify-content: center;
|
|
box-shadow: 0 2px 8px rgba(124,58,237,0.4);
|
|
}
|
|
.sidebar-logo-icon svg { width: 18px; height: 18px; }
|
|
|
|
.sidebar-date { padding: 10px 16px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); }
|
|
|
|
.sidebar-nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
|
|
|
|
.sidebar-nav-item {
|
|
display: flex; align-items: center; gap: 10px;
|
|
padding: 9px 10px; border-radius: var(--radius);
|
|
font-size: 13.5px; font-weight: 500;
|
|
color: var(--muted); cursor: pointer;
|
|
transition: all 0.15s var(--ease);
|
|
border: none; background: transparent; width: 100%; text-align: left;
|
|
position: relative; overflow: hidden;
|
|
}
|
|
.sidebar-nav-item::before {
|
|
content: '';
|
|
position: absolute; left: 0; top: 50%; transform: translateY(-50%);
|
|
width: 3px; height: 0; border-radius: 0 3px 3px 0;
|
|
background: var(--primary); opacity: 0;
|
|
transition: height 0.2s var(--ease), opacity 0.2s var(--ease);
|
|
}
|
|
.sidebar-nav-item:hover { background: var(--surface-2); color: var(--text-secondary); }
|
|
.sidebar-nav-item.active { background: var(--primary-dim); color: var(--primary); }
|
|
.sidebar-nav-item.active::before { height: 60%; opacity: 1; }
|
|
.sidebar-nav-item .ic svg { opacity: 0.7; }
|
|
.sidebar-nav-item.active .ic svg { opacity: 1; }
|
|
|
|
.sidebar-nav-badge {
|
|
margin-left: auto; font-size: 10px; font-weight: 700;
|
|
background: var(--primary-dim); color: var(--primary);
|
|
padding: 2px 7px; border-radius: 99px;
|
|
border: 1px solid var(--primary-glow);
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
TOPBAR DESKTOP
|
|
══════════════════════════════════════════════════════════════ */
|
|
.topbar-desktop {
|
|
padding: 14px 40px;
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex; align-items: center; gap: 12px;
|
|
background: rgba(9,9,11,0.8);
|
|
backdrop-filter: blur(12px);
|
|
position: sticky; top: 0; z-index: 20;
|
|
}
|
|
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; letter-spacing: -0.2px; }
|
|
.topbar-date { font-size: 12px; color: var(--muted); }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
BOTTOM NAV (mobile)
|
|
══════════════════════════════════════════════════════════════ */
|
|
.bottom-nav {
|
|
position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
|
|
background: rgba(17,17,20,0.85);
|
|
border-top: 1px solid var(--border);
|
|
backdrop-filter: blur(24px) saturate(180%);
|
|
padding: 6px 0 max(6px, env(safe-area-inset-bottom));
|
|
display: flex; justify-content: space-around;
|
|
box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
|
|
}
|
|
.bottom-nav-item {
|
|
display: flex; flex-direction: column; align-items: center; gap: 3px;
|
|
padding: 6px 14px; border-radius: var(--radius);
|
|
font-size: 9.5px; font-weight: 700; letter-spacing: 0.3px;
|
|
color: var(--muted); cursor: pointer; border: none;
|
|
background: transparent; transition: all 0.2s var(--ease);
|
|
text-transform: uppercase; -webkit-tap-highlight-color: transparent;
|
|
}
|
|
.bottom-nav-item svg { width: 20px; height: 20px; transition: transform 0.2s var(--ease-spring); }
|
|
.bottom-nav-item.active { color: var(--primary); }
|
|
.bottom-nav-item.active svg { transform: scale(1.15); }
|
|
.bottom-nav-item:active { transform: scale(0.92); }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
CARDS
|
|
══════════════════════════════════════════════════════════════ */
|
|
.card {
|
|
background: var(--surface);
|
|
border-radius: var(--radius-lg);
|
|
box-shadow: var(--shadow-md);
|
|
overflow: hidden;
|
|
transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
|
|
}
|
|
.card:hover { box-shadow: var(--shadow-lg); }
|
|
.card-pad { padding: 18px 20px; }
|
|
.card-title {
|
|
font-size: 10.5px; font-weight: 700; letter-spacing: 1px;
|
|
text-transform: uppercase; color: var(--muted); margin-bottom: 12px;
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
BUTTONS
|
|
══════════════════════════════════════════════════════════════ */
|
|
.btn {
|
|
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
padding: 9px 16px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600;
|
|
cursor: pointer; border: none; transition: all 0.18s var(--ease);
|
|
font-family: var(--font); position: relative; overflow: hidden;
|
|
-webkit-tap-highlight-color: transparent;
|
|
}
|
|
.btn::after {
|
|
content: '';
|
|
position: absolute; inset: 0;
|
|
background: rgba(255,255,255,0.08);
|
|
opacity: 0; transition: opacity 0.15s;
|
|
}
|
|
.btn:hover::after { opacity: 1; }
|
|
.btn:active { transform: scale(0.97); }
|
|
.btn:disabled { opacity: 0.35; pointer-events: none; }
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, #5b21b6, #7c3aed);
|
|
color: #fff;
|
|
box-shadow: 0 2px 12px rgba(124,58,237,0.35);
|
|
}
|
|
.btn-primary:hover { box-shadow: 0 4px 20px rgba(124,58,237,0.5); }
|
|
.btn-secondary {
|
|
background: var(--surface-2); color: var(--text);
|
|
border: 1px solid var(--border);
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
.btn-secondary:hover { border-color: var(--border-light); background: var(--surface-3); }
|
|
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
|
|
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }
|
|
.btn-danger { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
|
|
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: var(--radius-sm); }
|
|
.btn-full { width: 100%; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
FORM ELEMENTS
|
|
══════════════════════════════════════════════════════════════ */
|
|
.form-group { margin-bottom: 14px; }
|
|
.form-label {
|
|
display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
|
|
letter-spacing: 0.8px; color: var(--muted); margin-bottom: 6px;
|
|
}
|
|
.form-input {
|
|
width: 100%; padding: 9px 13px;
|
|
background: var(--surface-2); border: 1px solid var(--border);
|
|
border-radius: var(--radius); color: var(--text); font-size: 13.5px; font-family: var(--font);
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
}
|
|
.form-input:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px var(--primary-dim);
|
|
}
|
|
.form-input::placeholder { color: var(--muted); }
|
|
select.form-input { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
AVATAR
|
|
══════════════════════════════════════════════════════════════ */
|
|
.av {
|
|
border-radius: 50%;
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-weight: 700; color: #fff; flex-shrink: 0;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
STATUS BADGES
|
|
══════════════════════════════════════════════════════════════ */
|
|
.badge {
|
|
display: inline-flex; align-items: center; gap: 5px;
|
|
padding: 3px 9px; border-radius: 99px;
|
|
font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
|
|
border: 1px solid transparent;
|
|
}
|
|
.badge-live {
|
|
background: rgba(34,197,94,0.15); color: var(--live);
|
|
border-color: rgba(34,197,94,0.3);
|
|
}
|
|
.badge-live .dot {
|
|
width: 6px; height: 6px; border-radius: 50%;
|
|
background: var(--live);
|
|
animation: pulse-live 1.5s ease-in-out infinite;
|
|
}
|
|
.badge-upcoming {
|
|
background: var(--primary-dim); color: var(--primary);
|
|
border-color: var(--primary-glow);
|
|
}
|
|
.badge-done { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
|
|
.badge-canceled { background: rgba(239,68,68,0.1); color: var(--danger); border-color: rgba(239,68,68,0.25); }
|
|
.badge-group { background: var(--primary-dim); color: var(--primary); border-color: var(--primary-glow); font-size: 10px; padding: 2px 8px; }
|
|
|
|
@keyframes pulse-live {
|
|
0%, 100% { opacity: 1; transform: scale(1); }
|
|
50% { opacity: 0.5; transform: scale(0.85); }
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
STAT CHIPS
|
|
══════════════════════════════════════════════════════════════ */
|
|
.stat-chip {
|
|
border-radius: var(--radius-lg); padding: 14px 16px;
|
|
display: flex; flex-direction: column; align-items: center; gap: 4px;
|
|
border: 1px solid transparent;
|
|
transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease);
|
|
}
|
|
.stat-chip:hover { transform: translateY(-2px); }
|
|
.stat-chip .val { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
|
|
.stat-chip .lbl { font-size: 9.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
PLAYER CHIPS & SELECTOR
|
|
══════════════════════════════════════════════════════════════ */
|
|
.player-chip {
|
|
display: inline-flex; align-items: center; gap: 7px;
|
|
padding: 5px 10px 5px 5px; border-radius: 99px;
|
|
border: 1px solid var(--border); font-size: 12px; font-weight: 500;
|
|
background: var(--surface-2);
|
|
transition: border-color 0.15s;
|
|
}
|
|
.player-chip:hover { border-color: var(--border-light); }
|
|
|
|
.player-selector-item {
|
|
display: flex; align-items: center; gap: 12px;
|
|
padding: 12px 14px; border-radius: var(--radius-lg);
|
|
border: 1px solid var(--border); background: var(--surface);
|
|
cursor: pointer; transition: all 0.18s var(--ease);
|
|
margin-bottom: 7px;
|
|
}
|
|
.player-selector-item:hover { border-color: var(--primary); background: var(--primary-dim); }
|
|
.player-selector-item.selected {
|
|
border-color: var(--primary);
|
|
background: var(--primary-dim);
|
|
box-shadow: 0 0 0 3px var(--primary-dim);
|
|
}
|
|
.player-selector-item .check {
|
|
width: 20px; height: 20px; border-radius: 50%;
|
|
border: 2px solid var(--border-light); flex-shrink: 0;
|
|
display: flex; align-items: center; justify-content: center;
|
|
transition: all 0.18s var(--ease-spring);
|
|
background: transparent;
|
|
}
|
|
.player-selector-item.selected .check {
|
|
background: var(--primary); border-color: var(--primary);
|
|
}
|
|
.player-selector-item.selected .check svg { opacity: 1; }
|
|
.player-selector-item .av { width: 40px; height: 40px; font-size: 13px; }
|
|
.player-selector-item .name { font-size: 14px; font-weight: 600; }
|
|
.player-selector-item .meta { font-size: 11px; color: var(--muted); }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
TIME PRESET PILLS
|
|
══════════════════════════════════════════════════════════════ */
|
|
.time-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
|
|
.time-preset {
|
|
padding: 5px 12px; border-radius: 99px;
|
|
font-size: 11.5px; font-weight: 600;
|
|
border: 1px solid var(--border); background: var(--surface-2);
|
|
color: var(--text-secondary); cursor: pointer;
|
|
transition: all 0.15s var(--ease);
|
|
}
|
|
.time-preset:hover { border-color: var(--primary); color: var(--text); }
|
|
.time-preset.selected { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
GROUP MEMBER PILL
|
|
══════════════════════════════════════════════════════════════ */
|
|
.member-pill {
|
|
display: inline-flex; align-items: center; gap: 5px;
|
|
padding: 4px 10px 4px 4px; border-radius: 99px;
|
|
border: 1px solid var(--border); font-size: 11px; font-weight: 600;
|
|
background: var(--surface-2);
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
BAR CHART
|
|
══════════════════════════════════════════════════════════════ */
|
|
.bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 80px; }
|
|
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
|
|
.bar-fill {
|
|
width: 100%; border-radius: 4px 4px 0 0;
|
|
background: linear-gradient(to top, #5b21b6, var(--primary));
|
|
min-height: 4px; transition: height 0.4s var(--ease-spring);
|
|
}
|
|
.bar-lbl { font-size: 9.5px; color: var(--muted); font-weight: 600; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
SECTION TITLE
|
|
══════════════════════════════════════════════════════════════ */
|
|
.section-title {
|
|
font-size: 10.5px; font-weight: 700; text-transform: uppercase;
|
|
letter-spacing: 0.9px; color: var(--muted); margin-bottom: 10px;
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
VIEW HEAD
|
|
══════════════════════════════════════════════════════════════ */
|
|
.view-head { margin-bottom: 22px; }
|
|
.view-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
|
|
.view-head p { font-size: 13px; color: var(--muted); margin-top: 3px; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
TOAST
|
|
══════════════════════════════════════════════════════════════ */
|
|
#toast {
|
|
position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(20px);
|
|
background: var(--surface-3); border: 1px solid var(--border-light);
|
|
color: var(--text); padding: 10px 18px; border-radius: var(--radius-lg);
|
|
font-size: 13px; font-weight: 600; z-index: 999;
|
|
opacity: 0; pointer-events: none;
|
|
box-shadow: var(--shadow-lg);
|
|
transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
|
|
white-space: nowrap;
|
|
backdrop-filter: blur(12px);
|
|
}
|
|
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
DIALOG OVERLAY
|
|
══════════════════════════════════════════════════════════════ */
|
|
#dialog-overlay {
|
|
position: fixed; inset: 0; background: rgba(0,0,0,0.65);
|
|
backdrop-filter: blur(6px); z-index: 100;
|
|
display: none; align-items: center; justify-content: center; padding: 16px;
|
|
transition: opacity 0.2s var(--ease);
|
|
}
|
|
#dialog-overlay.open { display: flex; }
|
|
.dialog-box {
|
|
background: var(--surface); border: 1px solid var(--border-light);
|
|
border-radius: var(--radius-xl); width: 100%; max-width: 420px;
|
|
padding: 24px; max-height: 88vh; overflow-y: auto;
|
|
box-shadow: var(--shadow-lg);
|
|
transform: scale(0.95) translateY(10px);
|
|
transition: transform 0.25s var(--ease-spring);
|
|
}
|
|
#dialog-overlay.open .dialog-box { transform: scale(1) translateY(0); }
|
|
.dialog-head { margin-bottom: 18px; }
|
|
.dialog-head h2 { font-size: 17px; font-weight: 800; }
|
|
.dialog-head p { font-size: 12px; color: var(--muted); margin-top: 3px; }
|
|
.dialog-close {
|
|
float: right; background: var(--surface-2); border: 1px solid var(--border);
|
|
color: var(--muted); width: 28px; height: 28px;
|
|
border-radius: var(--radius-sm); cursor: pointer;
|
|
display: flex; align-items: center; justify-content: center;
|
|
transition: all 0.15s;
|
|
}
|
|
.dialog-close:hover { color: var(--text); border-color: var(--border-light); }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
LOADING SKELETON
|
|
══════════════════════════════════════════════════════════════ */
|
|
.skeleton {
|
|
background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
|
|
background-size: 200% 100%;
|
|
animation: shimmer 1.4s ease-in-out infinite;
|
|
border-radius: var(--radius);
|
|
}
|
|
@keyframes shimmer { to { background-position: -200% 0; } }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
VIEWS — page transitions
|
|
══════════════════════════════════════════════════════════════ */
|
|
.view { display: none; }
|
|
.view.active { display: block; animation: viewIn 0.25s var(--ease); }
|
|
@keyframes viewIn {
|
|
from { opacity: 0; transform: translateY(10px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
STAT BIG NUMBER
|
|
══════════════════════════════════════════════════════════════ */
|
|
.stat-big-num {
|
|
font-size: 54px; font-weight: 900; letter-spacing: -3px;
|
|
background: linear-gradient(135deg, var(--primary), var(--accent));
|
|
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
|
|
background-clip: text; line-height: 1;
|
|
}
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
GROUP CARD
|
|
══════════════════════════════════════════════════════════════ */
|
|
.group-card {
|
|
background: var(--surface); border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 12px;
|
|
box-shadow: var(--shadow);
|
|
transition: box-shadow 0.2s, transform 0.2s;
|
|
}
|
|
.group-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
|
|
.group-card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
RANKING ROW
|
|
══════════════════════════════════════════════════════════════ */
|
|
.rank-row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); transition: background 0.15s; }
|
|
.rank-row:last-child { border-bottom: none; }
|
|
.rank-row:hover { background: var(--surface-2); margin: 0 -20px; padding-left: 20px; padding-right: 20px; border-radius: var(--radius); }
|
|
.rank-num { width: 28px; text-align: center; font-size: 13px; font-weight: 800; color: var(--muted); }
|
|
.rank-hours { margin-left: auto; font-size: 14px; font-weight: 800; font-family: monospace; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
SCROLL AREA
|
|
══════════════════════════════════════════════════════════════ */
|
|
.scroll-area { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-light) transparent; }
|
|
.scroll-area::-webkit-scrollbar { width: 4px; }
|
|
.scroll-area::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
EMPTY STATE
|
|
══════════════════════════════════════════════════════════════ */
|
|
.empty-state { text-align: center; padding: 36px 20px; }
|
|
.empty-state svg { margin-bottom: 14px; opacity: 0.4; }
|
|
.empty-state h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
|
|
.empty-state p { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
UTILITIES
|
|
══════════════════════════════════════════════════════════════ */
|
|
.flex { display: flex; }
|
|
.flex-col { display: flex; flex-direction: column; }
|
|
.gap8 { gap: 8px; }
|
|
.gap12 { gap: 12px; }
|
|
.items-center { align-items: center; }
|
|
.items-start { align-items: flex-start; }
|
|
.justify-between { justify-content: space-between; }
|
|
.flex-1 { flex: 1; }
|
|
.mt8 { margin-top: 8px; }
|
|
.mt12 { margin-top: 12px; }
|
|
.mt16 { margin-top: 16px; }
|
|
.mb12 { margin-bottom: 12px; }
|
|
.mb16 { margin-bottom: 16px; }
|
|
.mb20 { margin-bottom: 20px; }
|
|
.mb24 { margin-bottom: 24px; }
|
|
.text-muted { color: var(--muted); }
|
|
.text-sm { font-size: 13px; }
|
|
.text-xs { font-size: 11px; }
|
|
.font-bold { font-weight: 700; }
|
|
.text-center { text-align: center; }
|
|
.font-mono { font-family: monospace; }
|
|
.opacity-0 { opacity: 0; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
LOGIN OVERLAY
|
|
══════════════════════════════════════════════════════════════ */
|
|
#login-overlay {
|
|
position: fixed; inset: 0; z-index: 9999;
|
|
display: flex; align-items: center; justify-content: center;
|
|
background: rgba(0,0,0,0.7);
|
|
backdrop-filter: blur(8px);
|
|
animation: fadeIn 0.3s ease;
|
|
}
|
|
#login-box {
|
|
background: var(--surface); border: 1px solid var(--border);
|
|
border-radius: 16px; padding: 36px 28px 28px;
|
|
width: 360px; max-width: 92vw;
|
|
box-shadow: 0 24px 80px rgba(0,0,0,0.5);
|
|
text-align: center;
|
|
animation: scaleIn 0.3s ease;
|
|
}
|
|
#login-box .login-icon {
|
|
width: 56px; height: 56px; margin: 0 auto 16px;
|
|
background: linear-gradient(135deg, #5b21b6, #7c3aed);
|
|
border-radius: 50%; display: flex; align-items: center; justify-content: center;
|
|
box-shadow: 0 0 20px rgba(124,58,237,0.35);
|
|
}
|
|
#login-box h2 { margin-bottom: 4px; }
|
|
#login-box p { color: var(--muted); font-size: 14px; margin-bottom: 20px; line-height: 1.5; }
|
|
.pin-inputs {
|
|
display: flex; gap: 8px; justify-content: center; margin-bottom: 20px;
|
|
}
|
|
.pin-inputs input {
|
|
width: 48px; height: 56px;
|
|
background: var(--surface-2); border: 1px solid var(--border);
|
|
border-radius: 10px; color: var(--text);
|
|
font-size: 24px; font-weight: 700; text-align: center;
|
|
font-family: var(--font);
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
caret-color: var(--primary);
|
|
}
|
|
.pin-inputs input:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px var(--primary-dim);
|
|
}
|
|
.pin-inputs input::-webkit-outer-spin-button,
|
|
.pin-inputs input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
|
.pin-inputs input[type=number] { -moz-appearance: textfield; }
|
|
.login-meta { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.6; }
|
|
.login-meta a { color: var(--primary); text-decoration: none; }
|
|
.login-meta a:hover { text-decoration: underline; }
|
|
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 20px; }
|
|
|
|
/* ══════════════════════════════════════════════════════════════
|
|
AVAILABILITY GRID
|
|
══════════════════════════════════════════════════════════════ */
|
|
/* Mobile-first avail-grid: horizontale swipe per dag */
|
|
.avail-grid { overflow: hidden; position: relative; }
|
|
|
|
.avail-day-nav {
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
margin-bottom: 12px; gap: 8px;
|
|
}
|
|
.avail-day-nav button {
|
|
background: var(--surface-2); border: 1px solid var(--border);
|
|
border-radius: 8px; padding: 8px 12px; cursor: pointer;
|
|
color: var(--text); font-size: 16px; line-height: 1;
|
|
min-width: 40px; display: flex; align-items: center; justify-content: center;
|
|
}
|
|
.avail-day-nav button:active { background: var(--primary-dim); }
|
|
.avail-day-label {
|
|
font-size: 14px; font-weight: 700; text-align: center; flex: 1;
|
|
}
|
|
.avail-day-label small { font-weight: 400; color: var(--muted); font-size: 12px; }
|
|
|
|
.avail-slots {
|
|
display: flex; flex-direction: column; gap: 6px;
|
|
max-height: 400px; overflow-y: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
}
|
|
.avail-slot {
|
|
display: flex; align-items: center; gap: 10px;
|
|
background: var(--surface-2); border: 1px solid var(--border);
|
|
border-radius: 10px; padding: 10px 14px;
|
|
cursor: pointer; transition: all 0.15s ease;
|
|
user-select: none; -webkit-tap-highlight-color: transparent;
|
|
}
|
|
.avail-slot:active { transform: scale(0.97); }
|
|
.avail-slot.active {
|
|
background: var(--primary-dim); border-color: var(--primary);
|
|
box-shadow: 0 0 12px var(--primary-glow);
|
|
}
|
|
.avail-slot-time {
|
|
font-size: 15px; font-weight: 700; color: var(--text);
|
|
min-width: 80px;
|
|
}
|
|
.avail-slot.active .avail-slot-time { color: var(--primary); }
|
|
.avail-slot-dur {
|
|
font-size: 11px; color: var(--muted);
|
|
}
|
|
.avail-slot-indicator {
|
|
margin-left: auto; width: 22px; height: 22px;
|
|
border-radius: 50%; border: 2px solid var(--border);
|
|
display: flex; align-items: center; justify-content: center;
|
|
flex-shrink: 0; transition: all 0.15s ease;
|
|
}
|
|
.avail-slot.active .avail-slot-indicator {
|
|
background: var(--primary); border-color: var(--primary);
|
|
}
|
|
.avail-slot-indicator svg { width: 12px; height: 12px; stroke: white; stroke-width: 3; opacity: 0; transition: opacity 0.15s; }
|
|
.avail-slot.active .avail-slot-indicator svg { opacity: 1; }
|
|
|
|
@media (min-width: 768px) {
|
|
.avail-slots { max-height: 600px; }
|
|
}
|
|
|
|
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
@keyframes scaleIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- ════════════════════════════════════ SVG SPRITE ════════════════════════════════════ -->
|
|
<svg xmlns="http://www.w3.org/2000/svg" style="display:none">
|
|
<symbol id="ico-logo" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>
|
|
</symbol>
|
|
<symbol id="ico-dashboard" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/>
|
|
</symbol>
|
|
<symbol id="ico-calendar" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18"/>
|
|
</symbol>
|
|
<symbol id="ico-users" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"/>
|
|
</symbol>
|
|
<symbol id="ico-group" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 1 3-3.87M16 3.13a4 4 0 0 1 0 7.75"/>
|
|
<line x1="12" y1="11" x2="12" y2="17"/><line x1="9" y1="14" x2="15" y2="14"/>
|
|
</symbol>
|
|
<symbol id="ico-stats" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/>
|
|
</symbol>
|
|
<symbol id="ico-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="20 6 9 17 4 12"/>
|
|
</symbol>
|
|
<symbol id="ico-x" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
</symbol>
|
|
<symbol id="ico-plus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
|
|
</symbol>
|
|
<symbol id="ico-trash" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
|
|
</symbol>
|
|
<symbol id="ico-edit" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
</symbol>
|
|
<symbol id="ico-court" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<rect x="2" y="7" width="20" height="14" rx="2"/><path d="M12 7V3M2 11h20M2 17h20M2 21h20"/>
|
|
</symbol>
|
|
<symbol id="ico-padel" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><path d="M8 12h8M12 8v8"/>
|
|
</symbol>
|
|
<symbol id="ico-clock" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/>
|
|
</symbol>
|
|
</svg>
|
|
|
|
<!-- ════════════════════════════════════ SIDEBAR ════════════════════════════════════ -->
|
|
<aside class="sidebar" id="sidebar">
|
|
<div class="sidebar-header">
|
|
<div class="sidebar-logo">
|
|
<div class="sidebar-logo-icon">
|
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><path d="M8 12h8M12 8v8"/>
|
|
</svg>
|
|
</div>
|
|
<span>Padel Planner</span>
|
|
</div>
|
|
</div>
|
|
<div class="sidebar-date" id="sidebar-date"></div>
|
|
|
|
<nav class="sidebar-nav scroll-area">
|
|
<button class="sidebar-nav-item active" data-nav="availability">
|
|
<span class="ic ic-lg"><svg><use href="#ico-clock"/></svg></span>
|
|
Beschikbaarheid
|
|
</button>
|
|
<button class="sidebar-nav-item" data-nav="competition">
|
|
<span class="ic ic-lg"><svg><use href="#ico-stats"/></svg></span>
|
|
Competitie
|
|
</button>
|
|
<button class="sidebar-nav-item" data-nav="settings">
|
|
<span class="ic ic-lg"><svg><use href="#ico-edit"/></svg></span>
|
|
Instellingen
|
|
</button>
|
|
<span class="ic ic-lg"><svg><use href="#ico-stats"/></svg></span>
|
|
Competitie
|
|
</button>
|
|
</nav>
|
|
</aside>
|
|
|
|
<!-- ════════════════════════════════════ MAIN AREA ════════════════════════════════════ -->
|
|
<div class="main-area">
|
|
<div class="topbar-desktop" id="topbar-desktop">
|
|
<div class="topbar-title" id="topbar-title">Beschikbaarheid</div>
|
|
<div class="topbar-date" id="topbar-date"></div>
|
|
</div>
|
|
|
|
<div class="content-area scroll-area" id="content">
|
|
|
|
<!-- BESCHIKBAARHEID (standaard) -->
|
|
<div class="view active" id="view-availability">
|
|
<div class="view-head">
|
|
<h1>Beschikbaarheid</h1>
|
|
<p>Geef aan wanneer je kunt spelen</p>
|
|
</div>
|
|
|
|
<!-- User card + logout -->
|
|
<div class="card card-pad mb16" id="profile-card">
|
|
<div style="display:flex;align-items:center;gap:14px;">
|
|
<div id="profile-avatar"></div>
|
|
<div style="flex:1;">
|
|
<div style="font-size:17px;font-weight:700;" id="profile-name"></div>
|
|
<div style="font-size:13px;color:var(--muted);margin-top:2px;" id="profile-meta"></div>
|
|
</div>
|
|
<button class="btn btn-secondary btn-sm" id="btn-settings" title="Instellingen">
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>
|
|
</svg>
|
|
</button>
|
|
<button class="btn btn-ghost btn-sm" id="btn-logout" style="color:var(--danger);">Uitloggen</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Mode toggle -->
|
|
<div class="card card-pad mb16">
|
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;">
|
|
<div style="font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--muted);">Beschikbaarheid</div>
|
|
<div style="display:flex;gap:6px;">
|
|
<button class="btn btn-sm" id="btn-mode-flex" style="border:1px solid var(--primary);color:var(--primary);">Flexibel</button>
|
|
<button class="btn btn-sm btn-ghost" id="btn-mode-weekly">Wekelijks</button>
|
|
</div>
|
|
</div>
|
|
<div class="avail-grid" id="avail-grid"></div>
|
|
<div style="margin-top:14px;display:flex;gap:8px;">
|
|
<button class="btn btn-primary btn-full" id="btn-save-avail">
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="margin-right:4px;"><polyline points="20 6 9 17 4 12"/></svg>
|
|
Opslaan
|
|
</button>
|
|
<button class="btn btn-secondary" id="btn-reset-avail">Reset</button>
|
|
</div>
|
|
<div id="save-status" style="font-size:12px;color:var(--accent);margin-top:8px;text-align:center;min-height:18px;"></div>
|
|
</div>
|
|
|
|
<!-- Recent matches -->
|
|
<div class="card card-pad">
|
|
<div style="font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--muted);margin-bottom:10px;">Mijn Matches</div>
|
|
<div id="profile-matches" style="font-size:13px;color:var(--muted);">Geen matches</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- OVERVIEW (alle spelers) -->
|
|
<div class="view" id="view-overview">
|
|
<div class="view-head">
|
|
<h1>Overzicht</h1>
|
|
<p>Alle spelers en beschikbaarheid</p>
|
|
</div>
|
|
<div id="players-avail-list"></div>
|
|
</div>
|
|
|
|
<!-- COMPETITIE -->
|
|
<div class="view" id="view-competition">
|
|
<div class="view-head">
|
|
<h1>Competitie</h1>
|
|
<p>Scores, ranking en historie</p>
|
|
</div>
|
|
<div id="ranking-section" class="card card-pad mb16">
|
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
|
|
<div style="font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--muted);">Ranking</div>
|
|
<select id="season-select" style="background:var(--surface-2);color:var(--text);border:1px solid var(--border);border-radius:6px;padding:4px 8px;font-size:12px;"></select>
|
|
</div>
|
|
<div id="ranking-list">Laden...</div>
|
|
</div>
|
|
<div id="pending-scores-section" class="card card-pad mb16">
|
|
<div style="font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--muted);margin-bottom:12px;">Openstaande Scores</div>
|
|
<div id="pending-scores-list" style="font-size:13px;color:var(--muted);">Geen openstaande scores</div>
|
|
</div>
|
|
<div class="card card-pad mb16" id="score-entry-section">
|
|
<div style="font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--muted);margin-bottom:12px;">Score Invoeren</div>
|
|
<div id="score-entry-form"></div>
|
|
</div>
|
|
<div class="card card-pad">
|
|
<div style="font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--muted);margin-bottom:12px;">Wedstrijd Historie</div>
|
|
<div id="match-history" style="font-size:13px;color:var(--muted);">Laden...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- INSTELLINGEN -->
|
|
<div class="view" id="view-settings">
|
|
<div class="view-head">
|
|
<h1>Instellingen</h1>
|
|
<p>Je profiel aanpassen</p>
|
|
</div>
|
|
|
|
<div class="card card-pad mb16">
|
|
<div class="form-group">
|
|
<label class="form-label">Naam</label>
|
|
<input type="text" class="form-input" id="set-name">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Speelniveau (1-10)</label>
|
|
<input type="number" class="form-input" id="set-level" min="1" max="10">
|
|
</div>
|
|
<div class="form-group" style="margin-bottom:20px;">
|
|
<label class="form-label">Voorkeurspositie</label>
|
|
<select class="form-input" id="set-position">
|
|
<option value="links">Links</option>
|
|
<option value="rechts">Rechts</option>
|
|
<option value="beide">Beide</option>
|
|
<option value="onbekend">Onbekend</option>
|
|
</select>
|
|
</div>
|
|
<button class="btn btn-primary btn-full" id="btn-save-settings-tab">Opslaan</button>
|
|
<div id="settings-tab-status" style="font-size:12px;margin-top:10px;text-align:center;color:var(--accent);min-height:18px;"></div>
|
|
</div>
|
|
|
|
<div class="card card-pad">
|
|
<div style="font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--muted);margin-bottom:10px;">Account</div>
|
|
<div style="font-size:13px;color:var(--muted);margin-bottom:14px;">
|
|
Je PIN: <strong id="settings-pin">****</strong><br>
|
|
Geregistreerd via Telegram: <span id="settings-telegram">-</span>
|
|
</div>
|
|
<button class="btn btn-danger btn-full" id="btn-logout-settings" style="background:var(--danger);color:white;border:none;padding:10px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;">Uitloggen</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ════════════════════════════════════ BOTTOM NAV ════════════════════════════════════ -->
|
|
<nav class="bottom-nav" id="bottom-nav">
|
|
<button class="bottom-nav-item active" data-nav="availability">
|
|
<svg><use href="#ico-clock"/></svg>
|
|
<span>Mijn</span>
|
|
</button>
|
|
<button class="bottom-nav-item" data-nav="competition">
|
|
<svg><use href="#ico-stats"/></svg>
|
|
<span>Comp.</span>
|
|
</button>
|
|
<button class="bottom-nav-item" data-nav="settings">
|
|
<svg><use href="#ico-edit"/></svg>
|
|
<span>Inst.</span>
|
|
</button>
|
|
<button class="bottom-nav-item" data-nav="overview">
|
|
<svg><use href="#ico-users"/></svg>
|
|
<span>Spelers</span>
|
|
</button>
|
|
</nav>
|
|
|
|
<!-- ════════════════════════════════════ DIALOG ════════════════════════════════════ -->
|
|
<div id="dialog-overlay">
|
|
<div class="dialog-box" id="dialog-box">
|
|
<button class="dialog-close" onclick="closeDialog()">
|
|
<svg width="12" height="12"><use href="#ico-x"/></svg>
|
|
</button>
|
|
<div class="dialog-head">
|
|
<h2 id="dialog-title"></h2>
|
|
<p id="dialog-desc"></p>
|
|
</div>
|
|
<div id="dialog-content"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ════════════════════════════════════ TOAST ════════════════════════════════════ -->
|
|
<div id="toast"></div>
|
|
|
|
<script>
|
|
const API = '/api';
|
|
|
|
let players = [], sessions = [], matches = [];
|
|
let _loggedInUser = null;
|
|
let _availData = {}, _availMode = 'flex';
|
|
|
|
/* ── Helpers ── */
|
|
function initials(name) { return name.split(' ').map(w=>w[0]).join('').toUpperCase().slice(0,2); }
|
|
|
|
const GRADS = [
|
|
['#5b21b6','#7c3aed'],['#0e7490','#06b6d4'],['#065f46','#10b981'],
|
|
['#b91c1c','#ef4444'],['#6d28d9','#a78bfa'],['#0f766e','#14b8a6'],
|
|
['#a16207','#eab308'],['#1e40af','#3b82f6'],['#9a3412','#f97316'],
|
|
['#831843','#ec4899']
|
|
];
|
|
|
|
function mkAv(name, id, sz=40, fs=13) {
|
|
const g = GRADS[(id||name.length) % GRADS.length];
|
|
return `<div style="width:${sz}px;height:${sz}px;border-radius:50%;background:linear-gradient(135deg,${g[0]},${g[1]});display:flex;align-items:center;justify-content:center;font-size:${fs}px;font-weight:700;color:white;flex-shrink:0;">${initials(name)}</div>`;
|
|
}
|
|
|
|
let toastTimer;
|
|
function toast(msg) {
|
|
const t = document.getElementById('toast');
|
|
if (!t) return;
|
|
clearTimeout(toastTimer);
|
|
t.textContent = msg; t.classList.add('visible');
|
|
toastTimer = setTimeout(() => t.classList.remove('visible'), 2500);
|
|
}
|
|
|
|
/* ── API ── */
|
|
async function api(method, path, body) {
|
|
const opts = { method, headers: {} };
|
|
if (body) { opts.headers['Content-Type'] = 'application/json'; opts.body = JSON.stringify(body); }
|
|
const r = await fetch(API + path, opts);
|
|
if (!r.ok) { const txt = await r.text(); throw new Error(txt); }
|
|
const ct = r.headers.get('content-type') || '';
|
|
if (ct.includes('application/json')) return r.json();
|
|
return r.text();
|
|
}
|
|
|
|
async function loadData() {
|
|
try {
|
|
players = await api('GET', '/players');
|
|
if (!Array.isArray(players)) players = players ? [players] : [];
|
|
} catch(e) { players = []; }
|
|
try {
|
|
const m = await api('GET', '/matches');
|
|
matches = Array.isArray(m) ? m : [];
|
|
} catch(_) { matches = []; }
|
|
try {
|
|
const s = await api('GET', '/sessions');
|
|
sessions = Array.isArray(s) ? s : [];
|
|
} catch(_) { sessions = []; }
|
|
}
|
|
|
|
/* ── Navigation ── */
|
|
function switchView(view) {
|
|
document.querySelectorAll('.view').forEach(el => el.classList.remove('active'));
|
|
const v = document.getElementById('view-' + view);
|
|
if (v) v.classList.add('active');
|
|
document.querySelectorAll(`[data-nav="${view}"]`).forEach(el => el.classList.add('active'));
|
|
document.querySelectorAll(`[data-nav]:not([data-nav="${view}"])`).forEach(el => el.classList.remove('active'));
|
|
const titles = { availability:'Beschikbaarheid', overview:'Spelers', competition:'Competitie', settings:'Instellingen' };
|
|
const t = document.getElementById('topbar-title');
|
|
if (t) t.textContent = titles[view] || view;
|
|
}
|
|
|
|
document.querySelectorAll('[data-nav]').forEach(el => {
|
|
el.addEventListener('click', () => {
|
|
const v = el.dataset.nav;
|
|
if (v === 'competition') {
|
|
_loadRankings();
|
|
_loadPendingScores();
|
|
_loadMatchHistory();
|
|
_buildScoreEntry();
|
|
}
|
|
if (v === 'overview') { _renderOverview(); }
|
|
if (v === 'settings') { _initSettingsTab(); }
|
|
switchView(v);
|
|
});
|
|
});
|
|
|
|
/* ── Login Overlay ── */
|
|
let _loginAttempts = 0, _loginBlocked = false;
|
|
|
|
function _buildLoginOverlay() {
|
|
const existing = document.getElementById('login-overlay');
|
|
if (existing) existing.remove();
|
|
const overlay = document.createElement('div');
|
|
overlay.id = 'login-overlay';
|
|
overlay.style.cssText = 'position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.7);backdrop-filter:blur(12px);animation:fadeIn 0.3s ease;';
|
|
overlay.innerHTML = `
|
|
<div style="background:var(--surface);max-width:380px;width:90%;border-radius:16px;padding:32px 28px;border:1px solid var(--border);animation:scaleIn 0.3s ease;box-shadow:0 25px 50px rgba(0,0,0,0.5);">
|
|
<div style="text-align:center;margin-bottom:24px;">
|
|
<div style="width:48px;height:48px;border-radius:14px;background:linear-gradient(135deg,#7c3aed,#06b6d4);display:flex;align-items:center;justify-content:center;margin:0 auto 14px;">
|
|
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><path d="M8 12h8M12 8v8"/>
|
|
</svg>
|
|
</div>
|
|
<h2 style="margin:0 0 4px;font-size:20px;">Padel Planner</h2>
|
|
<p style="margin:0;font-size:13px;color:var(--muted);">Log in met je Telegram naam en PIN</p>
|
|
</div>
|
|
<div id="login-error" class="login-error"></div>
|
|
<div class="form-group">
|
|
<label class="form-label">Naam</label>
|
|
<input type="text" class="form-input" id="login-name" placeholder="Je naam" autocomplete="off">
|
|
</div>
|
|
<div class="form-group" style="margin-bottom:20px;">
|
|
<label class="form-label">PIN-code</label>
|
|
<input type="password" class="form-input" id="login-pin" placeholder="0000" maxlength="4" inputmode="numeric" pattern="[0-9]*">
|
|
</div>
|
|
<button class="btn btn-primary btn-full" id="btn-login">Inloggen</button>
|
|
<p style="text-align:center;font-size:12px;color:var(--muted);margin-top:16px;">
|
|
Nog niet geregistreerd?<br>
|
|
Stuur <strong>/start</strong> naar <a href="https://t.me/padel_nl_bot" target="_blank" style="color:var(--primary);text-decoration:none;">@padel_nl_bot</a> op Telegram
|
|
</p>
|
|
</div>`;
|
|
document.body.appendChild(overlay);
|
|
document.getElementById('btn-login').addEventListener('click', _doLogin);
|
|
['keydown','keyup'].forEach(ev => document.getElementById('login-pin').addEventListener(ev, e => {
|
|
if (e.key === 'Enter') _doLogin();
|
|
}));
|
|
document.getElementById('login-name').addEventListener('keydown', e => {
|
|
if (e.key === 'Enter') document.getElementById('login-pin').focus();
|
|
});
|
|
setTimeout(() => document.getElementById('login-name').focus(), 100);
|
|
}
|
|
|
|
async function _doLogin() {
|
|
if (_loginBlocked) { document.getElementById('login-error').textContent = 'Te veel pogingen. Wacht 30s.'; return; }
|
|
const name = document.getElementById('login-name').value.trim();
|
|
const pin = document.getElementById('login-pin').value.trim();
|
|
if (!name || !pin || pin.length !== 4) {
|
|
document.getElementById('login-error').textContent = 'Voer je naam en 4-cijferige PIN in.';
|
|
return;
|
|
}
|
|
document.getElementById('login-error').textContent = '';
|
|
try {
|
|
const user = await api('POST', '/login', { name, pin });
|
|
if (user && user.id) {
|
|
_loggedInUser = user;
|
|
localStorage.setItem('padel_pin', user.pin);
|
|
localStorage.setItem('padel_name', user.name);
|
|
_loginAttempts = 0;
|
|
document.getElementById('login-overlay')?.remove();
|
|
_initApp();
|
|
} else {
|
|
_loginAttempts++;
|
|
if (_loginAttempts >= 5) {
|
|
_loginBlocked = true;
|
|
document.getElementById('login-error').textContent = 'Te veel pogingen. Wacht 30s.';
|
|
setTimeout(() => { _loginBlocked = false; _loginAttempts = 0; }, 30000);
|
|
} else {
|
|
document.getElementById('login-error').textContent = 'Ongeldige naam of PIN.';
|
|
}
|
|
}
|
|
} catch(e) {
|
|
document.getElementById('login-error').textContent = 'Fout: ongeldige combinatie.';
|
|
}
|
|
}
|
|
|
|
async function _loginByPin(pin) {
|
|
const name = localStorage.getItem('padel_name') || '';
|
|
if (!name) return null;
|
|
try { return await api('POST', '/login', { name, pin }); }
|
|
catch(_) { return null; }
|
|
}
|
|
|
|
/* ── Profile info ── */
|
|
function _renderProfile() {
|
|
const u = _loggedInUser;
|
|
if (!u) return;
|
|
document.getElementById('profile-avatar').innerHTML = mkAv(u.name, u.id, 44, 15);
|
|
document.getElementById('profile-name').textContent = u.name;
|
|
const posMap = { links:'Links', rechts:'Rechts', beide:'Beide', onbekend:'?' };
|
|
document.getElementById('profile-meta').textContent = `Level ${u.level || '?'} · ${posMap[u.position?.toLowerCase()] || u.position || '?'} · PIN: ${u.pin}`;
|
|
}
|
|
|
|
/* ── Settings Dialog ── */
|
|
function _openSettings() {
|
|
const u = _loggedInUser;
|
|
const overlay = document.createElement('div');
|
|
overlay.style.cssText = 'position:fixed;inset:0;z-index:9998;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.6);backdrop-filter:blur(8px);animation:fadeIn 0.2s ease;';
|
|
overlay.id = 'settings-overlay';
|
|
overlay.innerHTML = `
|
|
<div style="background:var(--surface);max-width:380px;width:90%;border-radius:16px;padding:28px;border:1px solid var(--border);animation:scaleIn 0.2s ease;">
|
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;">
|
|
<h3 style="margin:0;font-size:16px;">Instellingen</h3>
|
|
<button class="btn btn-ghost btn-sm" id="close-settings" style="padding:4px;"><svg width="16" height="16"><use href="#ico-x"/></svg></button>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Naam</label>
|
|
<input type="text" class="form-input" id="set-name" value="${u.name}">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Level (1-10)</label>
|
|
<input type="number" class="form-input" id="set-level" value="${u.level||5}" min="1" max="10">
|
|
</div>
|
|
<div class="form-group" style="margin-bottom:20px;">
|
|
<label class="form-label">Positie</label>
|
|
<select class="form-input" id="set-position">
|
|
${['Links','Rechts','Beide','Onbekend'].map(p => `<option value="${p.toLowerCase()}" ${(u.position||'').toLowerCase()===p.toLowerCase()?'selected':''}>${p}</option>`).join('')}
|
|
</select>
|
|
</div>
|
|
<button class="btn btn-primary btn-full" id="btn-save-settings">Opslaan</button>
|
|
<div id="settings-status" style="font-size:12px;margin-top:10px;text-align:center;color:var(--accent);min-height:18px;"></div>
|
|
</div>`;
|
|
document.body.appendChild(overlay);
|
|
document.getElementById('close-settings').onclick = () => overlay.remove();
|
|
overlay.addEventListener('click', e => { if (e.target === overlay) overlay.remove(); });
|
|
document.getElementById('btn-save-settings').addEventListener('click', async () => {
|
|
const name = document.getElementById('set-name').value.trim();
|
|
const level = parseInt(document.getElementById('set-level').value) || 5;
|
|
const position = document.getElementById('set-position').value;
|
|
if (!name) { document.getElementById('settings-status').textContent = 'Naam is verplicht.'; return; }
|
|
try {
|
|
await api('PUT', `/players/${u.id}`, { name, level, position });
|
|
_loggedInUser.name = name; _loggedInUser.level = level; _loggedInUser.position = position;
|
|
localStorage.setItem('padel_name', name);
|
|
try { _renderProfile(); } catch(e) { console.error("Profile error:", e); }
|
|
overlay.remove();
|
|
toast('Profiel bijgewerkt');
|
|
await _runMatchCheck();
|
|
} catch(e) { document.getElementById('settings-status').textContent = 'Fout: ' + e.message; }
|
|
});
|
|
}
|
|
|
|
/* ── Availability ── */
|
|
function _genSlots() {
|
|
const slots = [];
|
|
for (let h = 6; h < 23; h++) {
|
|
for (let m = 0; m < 60; m += 30) {
|
|
slots.push(`${String(h).padStart(2,'0')}:${String(m).padStart(2,'0')}`);
|
|
}
|
|
}
|
|
return slots;
|
|
}
|
|
|
|
function _getWeekNumber(d) {
|
|
const start = new Date(d.getFullYear(), 0, 1);
|
|
const diff = (d - start + (start.getTimezoneOffset() - d.getTimezoneOffset()) * 60000) / 86400000;
|
|
return Math.ceil((diff + start.getDay() + 1) / 7);
|
|
}
|
|
|
|
function _renderAvailGrid(user) {
|
|
const grid = document.getElementById('avail-grid');
|
|
if (!grid) return;
|
|
_availData = JSON.parse(JSON.stringify(user.availability || {}));
|
|
_availMode = user.avail_mode || 'flex';
|
|
|
|
const days = ['maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag','zondag'];
|
|
const daysShort = ['Ma','Di','Wo','Do','Vr','Za','Zo'];
|
|
const slots = _genSlots();
|
|
let weekOffset = 0;
|
|
let curDay = 0;
|
|
let dirty = JSON.parse(JSON.stringify(_availData));
|
|
|
|
function getWD(off) {
|
|
const t = new Date();
|
|
const mon = new Date(t);
|
|
mon.setDate(t.getDate() - ((t.getDay() + 6) % 7) + off * 7);
|
|
const res = [];
|
|
for (let i = 0; i < 7; i++) { const d = new Date(mon); d.setDate(mon.getDate() + i); res.push(d); }
|
|
return res;
|
|
}
|
|
function wn(d) {
|
|
const s = new Date(d.getFullYear(), 0, 1);
|
|
const di = (d - s + (s.getTimezoneOffset() - d.getTimezoneOffset()) * 60000) / 86400000;
|
|
return Math.ceil((di + s.getDay() + 1) / 7);
|
|
}
|
|
|
|
// Set mode buttons
|
|
const flexBtn = document.getElementById('btn-mode-flex');
|
|
const weeklyBtn = document.getElementById('btn-mode-weekly');
|
|
if (flexBtn) flexBtn.style.cssText = _availMode === 'flex' ? 'border:1px solid var(--primary);color:var(--primary);' : '';
|
|
if (weeklyBtn) weeklyBtn.style.cssText = _availMode === 'weekly' ? 'border:1px solid var(--primary);color:var(--primary);' : '';
|
|
if (flexBtn) flexBtn.className = _availMode === 'flex' ? 'btn btn-sm' : 'btn btn-sm btn-ghost';
|
|
if (weeklyBtn) weeklyBtn.className = _availMode === 'weekly' ? 'btn btn-sm' : 'btn btn-sm btn-ghost';
|
|
|
|
function render() {
|
|
var isWeekly = (_availMode === 'weekly');
|
|
var wd = getWD(weekOffset);
|
|
var wc = wd[curDay];
|
|
var day = days[curDay];
|
|
var dayLabel = daysShort[curDay] + ' ' + wc.getDate() + '/' + (wc.getMonth()+1);
|
|
|
|
var html = '';
|
|
if (isWeekly) {
|
|
// In weekly mode: toon alleen dag-navigatie (geen week-pijltjes)
|
|
html += '<div style="display:flex;align-items:center;gap:8px;margin-bottom:10px;padding:4px 0;justify-content:center;">';
|
|
html += '<div style="font-size:12px;color:var(--muted);font-weight:600;">Vast weekschema</div>';
|
|
html += '</div>';
|
|
} else {
|
|
// Flex mode: week pijltjes
|
|
html += '<div style="display:flex;align-items:center;gap:8px;margin-bottom:10px;padding:4px 0;">';
|
|
html += '<button onclick="void 0" class="week-nav-btn" id="wk-prev"' + (weekOffset <= 0 ? ' style="opacity:0.3"' : '') + ' style="background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:8px 12px;cursor:pointer;color:var(--text);font-size:14px;">←</button>';
|
|
html += '<div style="flex:1;text-align:center;font-size:12px;color:var(--muted);font-weight:600;">Week ' + wn(wd[0]) + '<br><span style="font-size:10px;font-weight:400;">' + wd[0].getDate() + '/' + (wd[0].getMonth()+1) + ' - ' + wd[6].getDate() + '/' + (wd[6].getMonth()+1) + '</span></div>';
|
|
html += '<button onclick="void 0" class="week-nav-btn" id="wk-next" style="background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:8px 12px;cursor:pointer;color:var(--text);font-size:14px;">→</button>';
|
|
html += '</div>';
|
|
}
|
|
if (isWeekly) {
|
|
// Weekly: toon alle 7 dagen, geen navigatie
|
|
var dayNamesLong = ['maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag','zondag'];
|
|
var dayShort = ['Ma','Di','Wo','Do','Vr','Za','Zo'];
|
|
html += '<div style="font-size:11px;color:var(--muted);margin-bottom:8px;text-align:center;font-weight:600;">Vast weekschema — zet aan/uit per dag</div>';
|
|
for (var di = 0; di < 7; di++) {
|
|
var dName = dayNamesLong[di];
|
|
var dLabel = dayShort[di];
|
|
var dSlots = dirty[dName] || [];
|
|
html += '<div style="font-size:13px;font-weight:700;margin:12px 0 4px;color:var(--text);">' + dLabel + '</div>';
|
|
html += '<div class="avail-weekly-day" data-weekly-day="' + dName + '">';
|
|
for (var si = 0; si < slots.length - 1; si++) {
|
|
var s = slots[si], e = slots[si+1];
|
|
var on = dSlots.some(function(sl) { return sl.start === s; });
|
|
html += '<div class="avail-slot' + (on ? ' active' : '') + '" data-day="' + dName + '" data-start="' + s + '" data-end="' + e + '">';
|
|
html += '<span class="avail-slot-time">' + s + '</span>';
|
|
html += '<span class="avail-slot-dur">90 min</span>';
|
|
html += '<span class="avail-slot-indicator"><svg><polyline points="20 6 9 17 4 12"/></svg></span></div>';
|
|
}
|
|
html += '</div>';
|
|
}
|
|
grid.innerHTML = html;
|
|
grid.querySelectorAll('.avail-slot').forEach(function(el) {
|
|
el.addEventListener('click', function() {
|
|
var d = this.dataset.day;
|
|
var st = this.dataset.start;
|
|
if (!dirty[d]) dirty[d] = [];
|
|
var idx = -1;
|
|
for (var k = 0; k < dirty[d].length; k++) { if (dirty[d][k].start === st) { idx = k; break; } }
|
|
if (idx >= 0) { dirty[d].splice(idx, 1); if (dirty[d].length === 0) delete dirty[d]; this.classList.remove('active'); }
|
|
else { dirty[d].push({ start: st, end: this.dataset.end, duration: 90 }); this.classList.add('active'); }
|
|
});
|
|
});
|
|
return;
|
|
}
|
|
html += '<div class="avail-day-nav">';
|
|
html += '<button onclick="void 0" id="day-prev"' + (curDay <= 0 && weekOffset <= 0 ? ' style="opacity:0.3;background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:8px 12px;cursor:pointer;color:var(--text);font-size:18px;"' : ' style="background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:8px 12px;cursor:pointer;color:var(--text);font-size:18px;"') + '>←</button>';
|
|
html += '<div class="avail-day-label">' + dayLabel + ' <small>week ' + wn(wd[0]) + '</small></div>';
|
|
html += '<button onclick="void 0" id="day-next" style="background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:8px 12px;cursor:pointer;color:var(--text);font-size:18px;">→</button>';
|
|
html += '</div><div class="avail-slots">';
|
|
for (let i = 0; i < slots.length - 1; i++) {
|
|
const s = slots[i], e = slots[i+1];
|
|
const on = (dirty[day] || []).some(function(sl) { return sl.start === s; });
|
|
html += '<div class="avail-slot' + (on ? ' active' : '') + '" data-day="' + day + '" data-start="' + s + '" data-end="' + e + '">';
|
|
html += '<span class="avail-slot-time">' + s + '</span>';
|
|
html += '<span class="avail-slot-dur">90 min</span>';
|
|
html += '<span class="avail-slot-indicator"><svg><polyline points="20 6 9 17 4 12"/></svg></span></div>';
|
|
}
|
|
html += '</div>';
|
|
grid.innerHTML = html;
|
|
|
|
// Click handlers
|
|
document.getElementById('wk-prev')?.addEventListener('click', function() { if (weekOffset > 0) { weekOffset--; curDay = 0; render(); } });
|
|
document.getElementById('wk-next')?.addEventListener('click', function() { weekOffset++; curDay = 0; render(); });
|
|
document.getElementById('day-prev')?.addEventListener('click', function() {
|
|
if (curDay > 0) { curDay--; render(); }
|
|
else if (weekOffset > 0) { weekOffset--; curDay = 6; render(); }
|
|
});
|
|
document.getElementById('day-next')?.addEventListener('click', function() {
|
|
if (curDay < 6) { curDay++; render(); }
|
|
else { weekOffset++; curDay = 0; render(); }
|
|
});
|
|
|
|
grid.querySelectorAll('.avail-slot').forEach(function(el) {
|
|
el.addEventListener('click', function() {
|
|
var d = this.dataset.day;
|
|
var st = this.dataset.start;
|
|
if (!dirty[d]) dirty[d] = [];
|
|
var idx = -1;
|
|
for (var k = 0; k < dirty[d].length; k++) { if (dirty[d][k].start === st) { idx = k; break; } }
|
|
if (idx >= 0) {
|
|
dirty[d].splice(idx, 1);
|
|
if (dirty[d].length === 0) delete dirty[d];
|
|
this.classList.remove('active');
|
|
} else {
|
|
dirty[d].push({ start: st, end: this.dataset.end, duration: 90 });
|
|
this.classList.add('active');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
render();
|
|
|
|
// Mode buttons
|
|
// Mode buttons + gedrag
|
|
document.getElementById('btn-mode-flex')?.addEventListener('click', function() {
|
|
_availMode = 'flex';
|
|
document.getElementById('btn-mode-flex').style.cssText = 'border:1px solid var(--primary);color:var(--primary);';
|
|
document.getElementById('btn-mode-weekly').style.cssText = '';
|
|
document.getElementById('btn-mode-weekly').className = 'btn btn-sm btn-ghost';
|
|
document.getElementById('btn-mode-flex').className = 'btn btn-sm';
|
|
dirty = JSON.parse(JSON.stringify(_availData));
|
|
weekOffset = 0; curDay = 0;
|
|
render();
|
|
});
|
|
document.getElementById('btn-mode-weekly')?.addEventListener('click', function() {
|
|
_availMode = 'weekly';
|
|
document.getElementById('btn-mode-weekly').style.cssText = 'border:1px solid var(--primary);color:var(--primary);';
|
|
document.getElementById('btn-mode-flex').style.cssText = '';
|
|
document.getElementById('btn-mode-flex').className = 'btn btn-sm btn-ghost';
|
|
document.getElementById('btn-mode-weekly').className = 'btn btn-sm';
|
|
var ws = _loggedInUser.weekly_schedule || {};
|
|
dirty = JSON.parse(JSON.stringify(ws));
|
|
weekOffset = 0; curDay = 0;
|
|
render();
|
|
});
|
|
document.getElementById('btn-save-avail')?.addEventListener('click', async function() {
|
|
var status = document.getElementById('save-status');
|
|
status.textContent = 'Bezig met opslaan...';
|
|
try {
|
|
if (_availMode === 'weekly') {
|
|
await api('PUT', '/players/' + _loggedInUser.id, { weekly_schedule: dirty, avail_mode: 'weekly' });
|
|
_loggedInUser.weekly_schedule = JSON.parse(JSON.stringify(dirty));
|
|
_loggedInUser.avail_mode = 'weekly';
|
|
status.textContent = 'Weekschema opgeslagen';
|
|
} else {
|
|
await api('PUT', '/players/' + _loggedInUser.id + '/availability', { availability: dirty, avail_mode: 'flex' });
|
|
_loggedInUser.availability = JSON.parse(JSON.stringify(dirty));
|
|
_loggedInUser.avail_mode = 'flex';
|
|
_availData = JSON.parse(JSON.stringify(dirty));
|
|
status.textContent = 'Opgeslagen';
|
|
}
|
|
setTimeout(function() { status.textContent = ''; }, 2000);
|
|
toast('Beschikbaarheid opgeslagen');
|
|
if (typeof _runMatchCheck === 'function') _runMatchCheck();
|
|
} catch(e) { status.textContent = 'Fout: ' + e.message; }
|
|
});
|
|
document.getElementById('btn-reset-avail')?.addEventListener('click', function() {
|
|
dirty = {};
|
|
render();
|
|
});
|
|
}
|
|
|
|
async function _runMatchCheck() {
|
|
// Check if 4+ players have overlapping availability in next 7 days
|
|
try {
|
|
const allPlayers = await api('GET', '/players');
|
|
if (!Array.isArray(allPlayers) || allPlayers.length < 4) return;
|
|
|
|
const days = ['maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag','zondag'];
|
|
const today = new Date();
|
|
const dayNames = ['zondag','maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag'];
|
|
|
|
// For each day in next 7 days
|
|
for (let d = 0; d < 7; d++) {
|
|
const date = new Date(today);
|
|
date.setDate(date.getDate() + d);
|
|
const dayName = dayNames[date.getDay()];
|
|
|
|
// Check availability: flex per week of vast weekschema
|
|
const available = allPlayers.filter(p => {
|
|
var avail = null;
|
|
if (p.avail_mode === 'weekly' && p.weekly_schedule) {
|
|
avail = p.weekly_schedule;
|
|
} else {
|
|
avail = p.availability || {};
|
|
}
|
|
return avail[dayName] && avail[dayName].length > 0;
|
|
});
|
|
|
|
if (available.length < 4) continue;
|
|
|
|
// Group by time slot overlap (90min minimum)
|
|
const slotGroups = {};
|
|
for (const p of available) {
|
|
var avail = null;
|
|
if (p.avail_mode === 'weekly' && p.weekly_schedule) {
|
|
avail = p.weekly_schedule;
|
|
} else {
|
|
avail = p.availability || {};
|
|
}
|
|
for (const slot of (avail[dayName] || [])) {
|
|
if (!slotGroups[slot.start]) slotGroups[slot.start] = [];
|
|
slotGroups[slot.start].push(p);
|
|
}
|
|
}
|
|
|
|
// Find slots with 4+ players
|
|
for (const [start, ps] of Object.entries(slotGroups)) {
|
|
if (ps.length >= 4) {
|
|
// Check if match already exists for this date+time
|
|
const dateStr = date.toISOString().split('T')[0];
|
|
const existing = matches.filter(m => m.date === dateStr && m.start === start);
|
|
if (existing.length > 0) continue;
|
|
|
|
// Create match proposal
|
|
const playerIds = ps.map(p => p.id);
|
|
const match = await api('POST', '/matches', {
|
|
date: dateStr,
|
|
start,
|
|
players: playerIds,
|
|
status: 'proposed'
|
|
});
|
|
matches.push(match);
|
|
toast(`✅ Match gevonden op ${dateStr} om ${start}!`);
|
|
}
|
|
}
|
|
}
|
|
_renderMatches();
|
|
} catch(e) {
|
|
console.error('Match check error:', e);
|
|
}
|
|
}
|
|
|
|
function _renderMatches() {
|
|
const el = document.getElementById('profile-matches');
|
|
if (!el) return;
|
|
if (!_loggedInUser) { el.textContent = 'Log in om matches te zien'; return; }
|
|
const myMatches = matches.filter(m => m.players && m.players.includes(_loggedInUser.id));
|
|
if (!myMatches.length) { el.textContent = 'Geen matches'; return; }
|
|
el.innerHTML = myMatches.slice(-10).reverse().map(m => {
|
|
const names = (m.players||[]).map(pid => (players.find(p=>p.id===pid)||{}).name || '?').join(', ');
|
|
return `<div style="padding:6px 0;border-bottom:1px solid var(--border);font-size:13px;">📅 ${m.date} ${m.start} · ${names}</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
/* ── Overview tab ── */
|
|
function _renderOverview() {
|
|
const el = document.getElementById('players-avail-list');
|
|
if (!el) return;
|
|
const days = ['maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag','zondag'];
|
|
const dayShort = ['ma','di','wo','do','vr','za','zo'];
|
|
if (!players.length) { el.innerHTML = '<div class="card card-pad text-center" style="color:var(--muted);font-size:14px;">Geen spelers gevonden</div>'; return; }
|
|
|
|
const todayIdx = new Date().getDay();
|
|
const todayName = days[(todayIdx + 6) % 7];
|
|
const todayShort = dayShort[(todayIdx + 6) % 7];
|
|
|
|
let html = '';
|
|
|
|
// Stats cards
|
|
const registered = players.filter(p => p.telegram_id).length;
|
|
const availToday = players.filter(p => {
|
|
const a = p.availability || {};
|
|
return a[todayName] && a[todayName].length > 0;
|
|
}).length;
|
|
|
|
html += '<div style="display:flex;gap:8px;margin-bottom:16px;">' +
|
|
'<div class="card card-pad" style="flex:1;text-align:center;padding:12px;">' +
|
|
'<div style="font-size:20px;font-weight:800;color:var(--primary);">' + players.length + '</div>' +
|
|
'<div style="font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:1px;">Spelers</div>' +
|
|
'</div>' +
|
|
'<div class="card card-pad" style="flex:1;text-align:center;padding:12px;">' +
|
|
'<div style="font-size:20px;font-weight:800;color:var(--accent);">' + registered + '</div>' +
|
|
'<div style="font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:1px;">Via Telegram</div>' +
|
|
'</div>' +
|
|
'<div class="card card-pad" style="flex:1;text-align:center;padding:12px;">' +
|
|
'<div style="font-size:20px;font-weight:800;color:' + (availToday > 0 ? 'var(--success)' : 'var(--muted)') + ';">' + availToday + '</div>' +
|
|
'<div style="font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:1px;">Vandaag beschikbaar</div>' +
|
|
'</div>' +
|
|
'</div>';
|
|
|
|
// Vandaag matches
|
|
const todayStr = new Date().toISOString().split('T')[0];
|
|
const todayMatches = (matches || []).filter(function(m) {
|
|
return m.date === todayStr && m.status === 'confirmed';
|
|
});
|
|
|
|
for (const m of todayMatches) {
|
|
const names = (m.players||[]).map(function(pid) {
|
|
const p = players.find(pl => pl.id === pid);
|
|
return p ? p.name : '?';
|
|
}).join(', ');
|
|
html += '<div class="card card-pad mb12" style="border-left:3px solid var(--primary);padding:10px 12px;">' +
|
|
'<div style="font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:1px;color:var(--primary);margin-bottom:4px;">Vandaag \uD83C\uDFBE</div>' +
|
|
'<div style="font-size:14px;font-weight:600;">' + m.start + '-' + m.end + '</div>' +
|
|
'<div style="font-size:12px;color:var(--muted);">' + names + '</div>' +
|
|
'</div>';
|
|
}
|
|
|
|
// Spelers
|
|
for (const p of players) {
|
|
const avail = p.availability || {};
|
|
const availDays = days.filter(d => avail[d] && avail[d].length > 0);
|
|
const hasTelegram = !!p.telegram_id;
|
|
const todaySlots = avail[todayName] || [];
|
|
const todayTag = todaySlots.length ? '<span style="background:var(--success-dim);color:var(--success);font-size:10px;padding:1px 6px;border-radius:4px;font-weight:600;margin-left:6px;">Vandaag</span>' : '';
|
|
const dayStr = availDays.length ? availDays.map(function(d) {
|
|
const times = (avail[d]||[]).map(function(s) { return s.start; }).join(', ');
|
|
const idx = days.indexOf(d);
|
|
const isToday = d === todayName;
|
|
var bg = isToday ? 'var(--success-dim)' : 'var(--primary-dim)';
|
|
var cl = isToday ? 'var(--success)' : 'var(--primary)';
|
|
return '<span style="display:inline-block;background:' + bg + ';color:' + cl + ';padding:2px 6px;border-radius:4px;font-size:10px;margin:2px;">' + dayShort[idx] + ' ' + times + '</span>';
|
|
}).join(' ') : '<span style="color:var(--muted);font-size:11px;">Nog niet ingesteld</span>';
|
|
|
|
const posMap = { links:'Links', rechts:'Rechts', beide:'Beide', onbekend:'?' };
|
|
const pos = posMap[p.position?.toLowerCase()] || p.position || '?';
|
|
const tgIcon = hasTelegram ? '\u2705' : '\u274C';
|
|
|
|
html += '<div class="card card-pad mb10" style="display:flex;align-items:center;gap:10px;padding:12px;">' +
|
|
mkAv(p.name, p.id, 38, 13) +
|
|
'<div style="flex:1;min-width:0;">' +
|
|
'<div style="font-weight:600;font-size:14px;">' + p.name + todayTag + '</div>' +
|
|
'<div style="font-size:11px;color:var(--muted);margin-top:2px;">Lv.' + (p.level||'?') + ' \u00B7 ' + pos + ' \u00B7 Telegram ' + tgIcon + '</div>' +
|
|
'</div>' +
|
|
'<div style="flex:1.5;text-align:right;">' + dayStr + '</div>' +
|
|
'</div>';
|
|
}
|
|
el.innerHTML = html;
|
|
}
|
|
|
|
|
|
/* ── Competition / Scores ── */
|
|
async function _loadRankings() {
|
|
const el = document.getElementById('ranking-list');
|
|
if (!el) return;
|
|
const season = document.getElementById('season-select')?.value || '';
|
|
try {
|
|
const resp = await api('/rankings' + (season ? '?season='+season : ''));
|
|
let rankings = resp.rankings || [];
|
|
const seasons = resp.seasons || [];
|
|
const current = resp.currentSeason || '';
|
|
|
|
// Update season dropdown
|
|
const sel = document.getElementById('season-select');
|
|
if (sel && seasons.length) {
|
|
sel.innerHTML = seasons.map(s => `<option value="${s}" ${s===current||s===season?'selected':''}>${s}</option>`).join('');
|
|
sel.onchange = () => { _loadRankings(); _loadMatchHistory(); };
|
|
}
|
|
|
|
if (!rankings.length) {
|
|
el.innerHTML = '<div style="color:var(--muted);text-align:center;padding:12px;">Nog geen wedstrijden dit seizoen</div>';
|
|
return;
|
|
}
|
|
el.innerHTML = rankings.map((r, i) => {
|
|
const medal = i === 0 ? '🥇' : i === 1 ? '🥈' : i === 2 ? '🥉' : `#${i+1}`;
|
|
const barWidth = r.games > 0 ? Math.min(100, (r.winrate / 100) * 100) : 0;
|
|
const levelBadge = r.level ? `<span style="display:inline-block;background:var(--primary-dim);color:var(--primary);padding:0 6px;border-radius:4px;font-size:10px;margin-left:6px;">Lv.${r.level}</span>` : '';
|
|
return `<div style="display:flex;align-items:center;gap:10px;padding:8px 0;border-bottom:1px solid var(--border);">
|
|
${mkAv(r.name, r.id, 32, 11)}
|
|
<div style="flex:1;min-width:0;">
|
|
<div style="display:flex;justify-content:space-between;align-items:center;">
|
|
<strong style="font-size:13px;">${r.name}${levelBadge}</strong>
|
|
<span style="font-size:13px;font-weight:700;color:var(--primary);">${r.points}</span>
|
|
</div>
|
|
<div style="font-size:11px;color:var(--muted);margin-top:2px;">${r.wins}W - ${r.losses}L (${r.winrate}%)</div>
|
|
<div style="margin-top:4px;height:4px;background:var(--surface-2);border-radius:2px;overflow:hidden;">
|
|
<div style="width:${barWidth}%;height:100%;background:linear-gradient(90deg,var(--primary),var(--accent));border-radius:2px;transition:width 0.3s;"></div>
|
|
</div>
|
|
</div>
|
|
<div style="text-align:right;font-size:10px;color:var(--muted);">${medal}</div>
|
|
</div>`;
|
|
}).join('');
|
|
} catch(e) {
|
|
el.innerHTML = '<div style="color:var(--danger);padding:8px;">Fout bij laden ranking</div>';
|
|
}
|
|
}
|
|
async function _loadPendingScores() {
|
|
const el = document.getElementById('pending-scores-list');
|
|
if (!el) return;
|
|
try {
|
|
const matches = await api('GET', '/matches');
|
|
const pending = (Array.isArray(matches) ? matches : []).filter(m => m.score && m.score.status !== 'confirmed');
|
|
if (!pending.length) {
|
|
el.innerHTML = '<div style="color:var(--muted);padding:4px;">Geen openstaande scores</div>';
|
|
return;
|
|
}
|
|
el.innerHTML = pending.map(m => {
|
|
const t1 = (m.score.team1||[]).map(pid => players.find(p=>p.id==pid)?.name||'?').join(' & ');
|
|
const t2 = (m.score.team2||[]).map(pid => players.find(p=>p.id==pid)?.name||'?').join(' & ');
|
|
const canVerify = _loggedInUser && m.score.verified_by && !m.score.verified_by.includes(_loggedInUser.id) && m.score.team2.includes(_loggedInUser.id);
|
|
return `<div style="display:flex;justify-content:space-between;align-items:center;padding:8px 0;border-bottom:1px solid var(--border);font-size:13px;">
|
|
<div>
|
|
<strong>${m.date}</strong> ${m.start}<br>
|
|
<span style="font-size:12px;color:var(--muted);">${t1} vs ${t2}</span><br>
|
|
<span style="font-size:12px;">Score: ${m.score.score}</span>
|
|
<span style="font-size:11px;color:${m.score.status==='partial'?'var(--warning)':'var(--muted)'};margin-left:6px;">
|
|
(${m.score.status==='pending'?'wacht op verificatie':m.score.status==='partial'?'1 van 2 geverifieerd':'bevestigd'})
|
|
</span>
|
|
</div>
|
|
<div>
|
|
${canVerify ? `<button class="btn btn-primary btn-sm" onclick="_verifyScore(${m.id})">Check</button>` : ''}
|
|
</div>
|
|
</div>`;
|
|
}).join('');
|
|
} catch(e) {
|
|
el.innerHTML = '<div style="color:var(--muted);">Fout bij laden</div>';
|
|
}
|
|
}
|
|
|
|
async function _verifyScore(matchId) {
|
|
try {
|
|
await api('POST', `/matches/${matchId}/verify`, { player_id: _loggedInUser.id });
|
|
toast('✅ Score geverifieerd!');
|
|
_loadPendingScores();
|
|
_loadRankings();
|
|
_loadMatchHistory();
|
|
} catch(e) {
|
|
toast('Fout bij verificatie: ' + e.message);
|
|
}
|
|
}
|
|
|
|
function _buildScoreEntry() {
|
|
const el = document.getElementById("score-entry-form");
|
|
if (!el) return;
|
|
|
|
api("GET", "/matches").then(matches => {
|
|
const allMatches = Array.isArray(matches) ? matches : [];
|
|
const unscored = allMatches.filter(m => (m.status === "completed" || m.status === "confirmed") && (!m.score || m.score.status !== "confirmed"));
|
|
|
|
if (!unscored.length) {
|
|
el.innerHTML = '<div style="color:var(--muted);font-size:13px;padding:8px;text-align:center;">Nog geen afgeronde matches om scores in te vullen</div>';
|
|
return;
|
|
}
|
|
|
|
const days = ['zondag','maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag'];
|
|
el.innerHTML = `\
|
|
<div class="form-group">\
|
|
<label class="form-label">Match</label>\
|
|
<select class="form-input" id="score-match-select">\
|
|
<option value="">Kies een match...</option>\
|
|
${unscored.map(m => {
|
|
const names = (m.players||[]).map(pid => players.find(p=>p.id==pid)?.name||'?').join(', ');
|
|
const date = new Date(m.date);
|
|
const dayLabel = isNaN(date.getTime()) ? m.day : days[date.getDay()];
|
|
return `<option value="${m.id}">${dayLabel} ${m.date} ${m.start}-${m.end} — ${names}</option>`;
|
|
}).join('')}
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Team 1</label>
|
|
<select class="form-input" id="score-team1-p1">${_playerOptions()}</select>
|
|
<select class="form-input" id="score-team1-p2" style="margin-top:6px;">${_playerOptions()}</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Team 2</label>
|
|
<select class="form-input" id="score-team2-p1">${_playerOptions()}</select>
|
|
<select class="form-input" id="score-team2-p2" style="margin-top:6px;">${_playerOptions()}</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Sets (bv 6-4, 3-6, 6-3)</label>
|
|
<input class="form-input" id="score-sets" placeholder="6-4, 3-6, 6-3">
|
|
</div>
|
|
<button class="btn btn-primary btn-full" onclick="_submitScore()">Score Opslaan</button>
|
|
<div id="score-status" style="font-size:12px;margin-top:8px;text-align:center;color:var(--accent);min-height:18px;"></div>
|
|
`;
|
|
}).catch(e => {
|
|
el.innerHTML = '<div style="color:var(--danger);">Fout bij laden: ' + e.message + '</div>';
|
|
});
|
|
}
|
|
function _playerOptions(excludeId) {
|
|
return players.map(p => `<option value="${p.id}" ${p.id === excludeId ? 'disabled' : ''}>${p.name}</option>`).join('');
|
|
}
|
|
|
|
async function _submitScore() {
|
|
const status = document.getElementById('score-status');
|
|
const matchId = document.getElementById('score-match-select')?.value;
|
|
const team1_1 = parseInt(document.getElementById('score-team1-p1')?.value);
|
|
const team1_2 = parseInt(document.getElementById('score-team1-p2')?.value);
|
|
const team2_1 = parseInt(document.getElementById('score-team2-p1')?.value);
|
|
const team2_2 = parseInt(document.getElementById('score-team2-p2')?.value);
|
|
const score = document.getElementById('score-sets')?.value.trim();
|
|
|
|
if (!matchId) { status.textContent = 'Kies een match.'; return; }
|
|
if (!team1_1 || !team1_2 || !team2_1 || !team2_2) { status.textContent = 'Selecteer alle 4 spelers.'; return; }
|
|
if (team1_1 === team1_2 || team2_1 === team2_2 || team1_1 === team2_1 || team1_2 === team2_2) { status.textContent = 'Een speler kan niet in beide teams.'; return; }
|
|
if (!score) { status.textContent = 'Voer een score in (bijv. 6-3, 7-5).'; return; }
|
|
|
|
status.textContent = 'Bezig...';
|
|
try {
|
|
const body = {
|
|
team1: [team1_1, team1_2],
|
|
team2: [team2_1, team2_2],
|
|
score,
|
|
submitted_by: _loggedInUser.id
|
|
};
|
|
await api('POST', `/matches/${matchId}/score`, body);
|
|
status.textContent = '✅ Score opgeslagen! Tegenstander moet verifiëren.';
|
|
toast('Score opgeslagen - wacht op verificatie');
|
|
_loadPendingScores();
|
|
_loadRankings();
|
|
_loadMatchHistory();
|
|
_buildScoreEntry();
|
|
} catch(e) {
|
|
status.textContent = '❌ Fout: ' + e.message;
|
|
}
|
|
}
|
|
|
|
async function _loadMatchHistory() {
|
|
const el = document.getElementById('match-history');
|
|
if (!el) return;
|
|
const season = document.getElementById('season-select')?.value || '';
|
|
try {
|
|
const history = await api('/matches/history' + (season ? '?season='+season : ''));
|
|
if (!Array.isArray(history) || !history.length) {
|
|
el.innerHTML = '<div style="color:var(--muted);padding:4px;">Nog geen afgeronde wedstrijden dit seizoen</div>';
|
|
return;
|
|
}
|
|
el.innerHTML = history.map(function(h) {
|
|
var setStr = '';
|
|
if (h.sets && Array.isArray(h.sets) && h.sets.length) {
|
|
setStr = h.sets.map(function(s, i) {
|
|
return '<span style="font-weight:' + (s.team1 > s.team2 ? '700' : '400') + ';color:' + (s.team1 > s.team2 ? 'var(--primary)' : 'var(--text)') + '">' + s.team1 + '</span>-<span style="font-weight:' + (s.team2 > s.team1 ? '700' : '400') + ';color:' + (s.team2 > s.team1 ? 'var(--danger)' : 'var(--text)') + '">' + s.team2 + '</span>';
|
|
}).join(' , ');
|
|
} else {
|
|
setStr = h.score || '?';
|
|
}
|
|
|
|
// Maak datum mooi
|
|
var dateStr = h.date || '?';
|
|
try {
|
|
var d = new Date(h.date);
|
|
if (!isNaN(d.getTime())) {
|
|
var dayNames = ['zo','ma','di','wo','do','vr','za'];
|
|
dateStr = dayNames[d.getDay()] + ' ' + d.getDate() + '/' + (d.getMonth()+1);
|
|
}
|
|
} catch(e) {}
|
|
|
|
return '<div style="padding:10px 0;border-bottom:1px solid var(--border);">' +
|
|
'<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px;">' +
|
|
'<span style="font-size:11px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:0.5px;">' + dateStr + ' ' + (h.start||'') + '</span>' +
|
|
'<span style="font-size:10px;color:var(--muted-dim);">' + (h.season||'') + '</span>' +
|
|
'</div>' +
|
|
'<div style="display:flex;align-items:center;gap:8px;font-size:14px;">' +
|
|
'<span style="font-weight:600;">' + (h.team1||[]).join(' & ') + '</span>' +
|
|
'<span style="color:var(--muted);font-size:12px;">vs</span>' +
|
|
'<span style="font-weight:600;">' + (h.team2||[]).join(' & ') + '</span>' +
|
|
'</div>' +
|
|
'<div style="margin-top:4px;font-size:12px;color:var(--muted);">' + setStr + '</div>' +
|
|
'</div>';
|
|
}).join('');
|
|
} catch(e) {
|
|
el.innerHTML = '<div style="color:var(--muted);">Fout bij laden historie</div>';
|
|
}
|
|
}
|
|
function _initSettingsTab() {
|
|
const u = _loggedInUser;
|
|
if (!u) return;
|
|
const nameEl = document.getElementById('set-name');
|
|
const levelEl = document.getElementById('set-level');
|
|
const posEl = document.getElementById('set-position');
|
|
const pinEl = document.getElementById('settings-pin');
|
|
const tgEl = document.getElementById('settings-telegram');
|
|
if (nameEl) nameEl.value = u.name || '';
|
|
if (levelEl) levelEl.value = u.level || 5;
|
|
if (posEl) posEl.value = (u.position || 'onbekend').toLowerCase();
|
|
if (pinEl) pinEl.textContent = u.pin || '****';
|
|
if (tgEl) tgEl.textContent = u.telegram_id ? '✅ Ja' : '❌ Nee';
|
|
|
|
document.getElementById('btn-save-settings-tab')?.addEventListener('click', async () => {
|
|
const name = document.getElementById('set-name')?.value.trim();
|
|
const level = parseInt(document.getElementById('set-level')?.value) || 5;
|
|
const position = document.getElementById('set-position')?.value;
|
|
const status = document.getElementById('settings-tab-status');
|
|
if (!name) { if(status) status.textContent = 'Naam is verplicht.'; return; }
|
|
try {
|
|
await api('PUT', `/players/${u.id}`, { name, level, position });
|
|
_loggedInUser.name = name; _loggedInUser.level = level; _loggedInUser.position = position;
|
|
localStorage.setItem('padel_name', name);
|
|
try { _renderProfile(); } catch(e) { console.error("Profile error:", e); }
|
|
if(status) status.textContent = '✅ Opgeslagen';
|
|
setTimeout(() => { if(status) status.textContent = ''; }, 2000);
|
|
toast('Profiel bijgewerkt');
|
|
} catch(e) { if(status) status.textContent = '❌ Fout: ' + e.message; }
|
|
});
|
|
|
|
document.getElementById('btn-logout-settings')?.addEventListener('click', () => {
|
|
_loggedInUser = null;
|
|
localStorage.removeItem('padel_pin');
|
|
localStorage.removeItem('padel_name');
|
|
_buildLoginOverlay();
|
|
});
|
|
}
|
|
|
|
/* ── Init ── */
|
|
function _initApp() {
|
|
try { _renderProfile(); } catch(e) { console.error("Profile error:", e); }
|
|
try { _renderAvailGrid(_loggedInUser); } catch(e) { console.error("AvailGrid error:", e); document.getElementById("avail-grid") && (document.getElementById("avail-grid").innerHTML = "<div style=\"color:var(--danger);padding:20px;text-align:center;\">Fout bij laden: " + e.message + "</div>"); }
|
|
_renderMatches();
|
|
_buildScoreEntry();
|
|
_initSettingsTab();
|
|
|
|
// Wire up score submit
|
|
document.addEventListener('click', function(e) {
|
|
if (e.target && e.target.id === 'btn-submit-score') _submitScore();
|
|
});
|
|
|
|
document.getElementById('btn-logout')?.addEventListener('click', () => {
|
|
_loggedInUser = null;
|
|
localStorage.removeItem('padel_pin');
|
|
localStorage.removeItem('padel_name');
|
|
_buildLoginOverlay();
|
|
});
|
|
|
|
document.getElementById('btn-settings')?.addEventListener('click', () => switchView('settings'));
|
|
|
|
// Settings tab init on load
|
|
_initSettingsTab();
|
|
|
|
// Load data for overview
|
|
loadData().then(() => {
|
|
_renderOverview();
|
|
_renderMatches();
|
|
_loadRankings();
|
|
_loadPendingScores();
|
|
_loadMatchHistory();
|
|
});
|
|
}
|
|
|
|
/* ── Auto-login ── */
|
|
(function() {
|
|
const ver = localStorage.getItem('padel_ver');
|
|
if (ver !== 'v4') {
|
|
localStorage.removeItem('padel_pin');
|
|
localStorage.removeItem('padel_name');
|
|
localStorage.setItem('padel_ver', 'v4');
|
|
}
|
|
|
|
const savedPin = localStorage.getItem('padel_pin');
|
|
const savedName = localStorage.getItem('padel_name');
|
|
if (savedPin && savedName) {
|
|
_loginByPin(savedPin).then(user => {
|
|
if (user && user.name.toLowerCase() === savedName.toLowerCase()) {
|
|
_loggedInUser = user;
|
|
_initApp();
|
|
} else {
|
|
localStorage.removeItem('padel_pin');
|
|
localStorage.removeItem('padel_name');
|
|
_buildLoginOverlay();
|
|
}
|
|
}).catch(() => _buildLoginOverlay());
|
|
} else {
|
|
_buildLoginOverlay();
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |