Refactor UI/views, rework Docker build, untrack local data

- Views umstrukturiert: einstellungen.ejs -> bewerbung.ejs, neues
  partials/head.ejs, header/footer/index angepasst
- CSS umbenannt: style.css -> styles.css
- server.js und public/js/main.js ueberarbeitet
- Dockerfile auf schlankes Multi-Stage-Setup umgestellt;
  docker-compose.yml und .dockerignore entfernt
- npm-Scripts docker:build/push/deploy ergaenzt
- SQLite-DB und .idea aus Git entfernt und via .gitignore ignoriert

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 04:01:37 +02:00
parent 34cfcecc1e
commit c2a629e2c0
25 changed files with 3693 additions and 1886 deletions
-822
View File
@@ -1,822 +0,0 @@
/* ── Bewerbungs-Tracker — Design System ──────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');
/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
--bg: #f3f5fb;
--surface: #ffffff;
--surface-2: #edf0f7;
--surface-3: #e4e9f4;
--border: #dde2ef;
--border-2: #cad2e4;
--text: #18202f;
--text-2: #4a556b;
--text-muted: #8896b0;
--accent: #e07b00;
--accent-dim: rgba(224,123,0,0.1);
--accent-hover: #c96e00;
--green: #16a34a;
--green-dim: rgba(22,163,74,0.1);
--red: #dc2626;
--red-dim: rgba(220,38,38,0.1);
--amber: #d97706;
--amber-dim: rgba(217,119,6,0.1);
--blue: #2563eb;
--blue-dim: rgba(37,99,235,0.1);
--purple: #7c3aed;
--purple-dim: rgba(124,58,237,0.1);
--shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
--shadow: 0 4px 16px rgba(0,0,0,0.08);
--shadow-xl: 0 20px 60px rgba(0,0,0,0.14);
--radius: 6px;
--radius-lg: 10px;
--radius-xl: 14px;
--font-sans: 'DM Sans', system-ui, -apple-system, sans-serif;
--font-display: 'Barlow Semi Condensed', system-ui, sans-serif;
--font-mono: 'DM Mono', 'Fira Mono', monospace;
}
html.dark {
--bg: #0c0e14;
--surface: #131720;
--surface-2: #192030;
--surface-3: #1f2840;
--border: #232d42;
--border-2: #2c3a56;
--text: #d0d9ea;
--text-2: #7d8ea8;
--text-muted: #435069;
--accent: #f08c00;
--accent-dim: rgba(240,140,0,0.12);
--accent-hover: #e07b00;
--green: #22c55e;
--green-dim: rgba(34,197,94,0.12);
--red: #f87171;
--red-dim: rgba(248,113,113,0.12);
--amber: #fbbf24;
--amber-dim: rgba(251,191,36,0.12);
--blue: #60a5fa;
--blue-dim: rgba(96,165,250,0.12);
--purple: #a78bfa;
--purple-dim: rgba(167,139,250,0.12);
--shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
--shadow: 0 4px 16px rgba(0,0,0,0.5);
--shadow-xl: 0 20px 60px rgba(0,0,0,0.7);
}
/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
/* ── Base ────────────────────────────────────────────────────────────────── */
body {
font-family: var(--font-sans);
background: var(--bg);
color: var(--text);
min-height: 100vh;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transition: background 0.2s, color 0.2s;
}
/* Ambient gradient for dark mode */
html.dark body::before {
content: '';
position: fixed;
inset: 0;
z-index: 0;
pointer-events: none;
background:
radial-gradient(ellipse 70% 50% at 5% 0%, rgba(240,140,0,0.05) 0%, transparent 65%),
radial-gradient(ellipse 50% 40% at 95% 100%, rgba(96,165,250,0.04) 0%, transparent 65%);
}
/* ── Navigation ──────────────────────────────────────────────────────────── */
.app-nav {
position: sticky;
top: 0;
z-index: 40;
height: 56px;
display: flex;
align-items: center;
padding: 0 1.5rem;
gap: 1.5rem;
background: var(--surface);
border-bottom: 1px solid var(--border);
}
.nav-brand {
display: flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
font-family: var(--font-display);
font-weight: 700;
font-size: 1.05rem;
letter-spacing: 0.01em;
color: var(--text);
flex-shrink: 0;
}
/* Animated dot */
.brand-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
flex-shrink: 0;
animation: pulse-dot 3s ease-in-out infinite;
}
@keyframes pulse-dot {
0%, 100% { box-shadow: 0 0 0 0 var(--accent-dim); }
50% { box-shadow: 0 0 0 5px transparent; }
}
.nav-links {
display: flex;
align-items: center;
gap: 2px;
flex: 1;
}
.nav-link {
padding: 0.3125rem 0.6875rem;
border-radius: var(--radius);
font-size: 0.875rem;
font-weight: 500;
color: var(--text-2);
text-decoration: none;
transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }
/* Pill toggle for dark mode */
.dark-toggle {
position: relative;
width: 42px;
height: 24px;
border-radius: 12px;
background: var(--surface-3);
border: 1px solid var(--border-2);
cursor: pointer;
transition: background 0.2s, border-color 0.2s;
flex-shrink: 0;
padding: 0;
outline: none;
}
.dark-toggle:focus-visible {
box-shadow: 0 0 0 2px var(--accent);
}
.dark-toggle::after {
content: '';
position: absolute;
top: 3px;
left: 3px;
width: 16px;
height: 16px;
border-radius: 50%;
background: var(--text-muted);
transition: transform 0.22s cubic-bezier(0.4,0,0.2,1), background 0.2s;
}
html.dark .dark-toggle { background: var(--accent-dim); border-color: var(--accent); }
html.dark .dark-toggle::after {
transform: translateX(18px);
background: var(--accent);
}
/* ── Page wrapper ────────────────────────────────────────────────────────── */
.page-wrapper {
position: relative;
z-index: 1;
max-width: 88rem;
margin: 0 auto;
padding: 2rem 1.5rem 3rem;
}
/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1.75rem;
}
.page-title {
font-family: var(--font-display);
font-weight: 700;
font-size: 1.875rem;
letter-spacing: 0.01em;
line-height: 1.15;
color: var(--text);
}
.page-meta {
font-size: 0.8125rem;
color: var(--text-muted);
margin-top: 0.3rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.page-meta .sep { opacity: 0.4; }
.page-meta .tag {
font-family: var(--font-mono);
font-size: 0.7rem;
background: var(--surface-2);
border: 1px solid var(--border);
padding: 0.1rem 0.5rem;
border-radius: 4px;
color: var(--text-2);
}
/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
display: flex;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
}
/* ── Stats ───────────────────────────────────────────────────────────────── */
.stats-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0.875rem;
margin-bottom: 1.5rem;
}
@media (min-width: 560px) {
.stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
padding: 1.125rem 1.25rem 1rem;
position: relative;
overflow: hidden;
animation: fadeUp 0.45s cubic-bezier(0.22,1,0.36,1) both;
}
.stat-card:nth-child(1) { animation-delay: 0.04s; }
.stat-card:nth-child(2) { animation-delay: 0.09s; }
.stat-card:nth-child(3) { animation-delay: 0.14s; }
.stat-card:nth-child(4) { animation-delay: 0.19s; }
/* Bottom color strip */
.stat-card::after {
content: '';
position: absolute;
bottom: 0; left: 0; right: 0;
height: 2px;
border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.stat-card.s-total::after { background: var(--accent); }
.stat-card.s-positiv::after { background: var(--green); }
.stat-card.s-absage::after { background: var(--red); }
.stat-card.s-pending::after { background: var(--amber); }
.stat-label {
font-size: 0.65rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--text-muted);
margin-bottom: 0.375rem;
}
.stat-value {
font-family: var(--font-display);
font-weight: 800;
font-size: 2.5rem;
line-height: 1;
letter-spacing: 0.01em;
color: var(--text);
font-variant-numeric: tabular-nums;
}
.stat-card.s-total .stat-value { color: var(--accent); }
.stat-card.s-positiv .stat-value { color: var(--green); }
.stat-card.s-absage .stat-value { color: var(--red); }
.stat-card.s-pending .stat-value { color: var(--amber); }
/* ── Action bar ──────────────────────────────────────────────────────────── */
.action-bar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.75rem;
}
.entry-count {
font-size: 0.6875rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--text-muted);
}
/* ── Data card ───────────────────────────────────────────────────────────── */
.data-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
overflow: hidden;
animation: fadeUp 0.45s 0.24s cubic-bezier(0.22,1,0.36,1) both;
}
/* ── Table ───────────────────────────────────────────────────────────────── */
.data-table {
width: 100%;
border-collapse: collapse;
}
.data-table thead th {
padding: 0.6875rem 1rem;
text-align: left;
font-size: 0.65rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--text-muted);
background: var(--surface-2);
border-bottom: 1px solid var(--border);
white-space: nowrap;
}
.data-table thead th:first-child { border-radius: 0; }
.data-table tbody tr {
border-bottom: 1px solid var(--border);
transition: background 0.1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
/* Row actions: only visible on hover */
.data-table tbody tr .row-actions { opacity: 0; transition: opacity 0.15s; }
.data-table tbody tr:hover .row-actions { opacity: 1; }
.data-table td {
padding: 0.8125rem 1rem;
font-size: 0.875rem;
vertical-align: middle;
}
.td-date {
font-family: var(--font-mono);
font-size: 0.75rem;
color: var(--text-muted);
white-space: nowrap;
letter-spacing: 0.02em;
}
.td-firma { font-weight: 600; color: var(--text); }
.td-stelle { color: var(--text-2); }
.td-art {
font-family: var(--font-mono);
font-size: 0.7rem;
color: var(--text-muted);
}
.td-notizen {
max-width: 14rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 0.75rem;
color: var(--text-muted);
}
/* ── Status chip ─────────────────────────────────────────────────────────── */
.status-chip {
display: inline-flex;
align-items: center;
gap: 0.375rem;
font-size: 0.8rem;
font-weight: 500;
white-space: nowrap;
}
.status-chip::before {
content: '';
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0;
}
.st-gesendet { color: var(--blue); }
.st-gesendet::before { background: var(--blue); }
.st-eingang { color: var(--amber); }
.st-eingang::before { background: var(--amber); }
.st-vorstellung { color: var(--purple); }
.st-vorstellung::before { background: var(--purple); }
.st-absage { color: var(--red); }
.st-absage::before { background: var(--red); }
.st-einstellung { color: var(--green); }
.st-einstellung::before { background: var(--green); box-shadow: 0 0 5px var(--green); }
.st-keine { color: var(--text-muted); }
.st-keine::before { background: var(--text-muted); }
/* ── Row action buttons ──────────────────────────────────────────────────── */
.row-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 30px;
height: 30px;
border-radius: var(--radius);
border: none;
background: transparent;
cursor: pointer;
transition: background 0.12s, color 0.12s;
color: var(--text-muted);
}
.row-btn:hover { background: var(--surface-3); color: var(--text); }
.row-btn.btn-edit:hover { background: var(--blue-dim); color: var(--blue); }
.row-btn.btn-del:hover { background: var(--red-dim); color: var(--red); }
/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 5rem 2rem;
text-align: center;
}
.empty-icon {
width: 52px;
height: 52px;
border-radius: 50%;
background: var(--surface-2);
border: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 1.125rem;
color: var(--text-muted);
}
.empty-title { font-weight: 600; color: var(--text-2); margin-bottom: 0.3rem; font-size: 0.9375rem; }
.empty-sub { font-size: 0.8125rem; color: var(--text-muted); }
/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.375rem;
padding: 0.5rem 1rem;
border-radius: var(--radius);
font-family: var(--font-sans);
font-size: 0.875rem;
font-weight: 600;
line-height: 1;
cursor: pointer;
border: 1px solid transparent;
transition: background 0.13s, border-color 0.13s, color 0.13s, opacity 0.13s, transform 0.1s;
text-decoration: none;
white-space: nowrap;
user-select: none;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }
.btn-primary {
background: var(--accent);
color: #0d0d0d;
border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
background: var(--accent-hover);
border-color: var(--accent-hover);
}
.btn-secondary {
background: var(--surface-2);
color: var(--text-2);
border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
background: var(--surface-3);
border-color: var(--border-2);
}
.btn-danger {
background: var(--red-dim);
color: var(--red);
border-color: transparent;
}
.btn-danger:hover:not(:disabled) {
background: var(--red);
color: #fff;
}
.btn-sm {
padding: 0.375rem 0.75rem;
font-size: 0.8125rem;
}
/* ── Form controls ───────────────────────────────────────────────────────── */
.form-group {
display: flex;
flex-direction: column;
gap: 0.375rem;
}
.form-label {
font-size: 0.8125rem;
font-weight: 600;
color: var(--text-2);
letter-spacing: -0.01em;
}
.form-label .req { color: var(--red); margin-left: 2px; }
.form-hint {
font-size: 0.75rem;
color: var(--text-muted);
margin-top: 0.2rem;
}
.form-input,
.form-select,
.form-textarea {
width: 100%;
padding: 0.5625rem 0.75rem;
font-family: var(--font-sans);
font-size: 0.875rem;
line-height: 1.5;
color: var(--text);
background: var(--surface);
border: 1px solid var(--border-2);
border-radius: var(--radius);
outline: none;
transition: border-color 0.15s, box-shadow 0.15s;
-webkit-appearance: none;
-moz-appearance: none;
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-select {
cursor: pointer;
padding-right: 2.25rem;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%237d8ea8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 0.625rem center;
background-size: 1em;
}
.form-textarea { resize: none; line-height: 1.65; }
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 500px) {
.form-grid { grid-template-columns: 1fr; }
.form-grid .span-2 { grid-column: span 1; }
}
/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
position: fixed;
inset: 0;
z-index: 50;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
background: rgba(0, 0, 0, 0);
backdrop-filter: blur(0px);
visibility: hidden;
opacity: 0;
transition:
background 0.22s ease,
backdrop-filter 0.22s ease,
opacity 0.22s ease,
visibility 0s 0.22s;
}
.modal-backdrop.is-open {
background: rgba(0,0,0,0.72);
backdrop-filter: blur(5px);
visibility: visible;
opacity: 1;
transition:
background 0.22s ease,
backdrop-filter 0.22s ease,
opacity 0.22s ease,
visibility 0s 0s;
}
.modal-box {
width: 100%;
max-width: 36rem;
background: var(--surface);
border: 1px solid var(--border-2);
border-radius: var(--radius-xl);
box-shadow: var(--shadow-xl);
display: flex;
flex-direction: column;
max-height: 90vh;
overflow-y: auto;
transform: scale(0.94) translateY(14px);
opacity: 0;
transition: transform 0.28s cubic-bezier(0.32,0.72,0,1), opacity 0.22s ease;
}
.modal-backdrop.is-open .modal-box {
transform: scale(1) translateY(0);
opacity: 1;
}
.modal-box.compact { max-width: 26rem; }
.modal-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1.25rem 1.5rem 1.125rem;
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
.modal-title {
font-family: var(--font-display);
font-weight: 700;
font-size: 1.125rem;
letter-spacing: 0.01em;
color: var(--text);
}
.modal-body { padding: 1.25rem 1.5rem; }
.modal-foot {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 0.625rem;
padding: 1rem 1.5rem;
border-top: 1px solid var(--border);
flex-shrink: 0;
}
.modal-close {
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--radius);
background: transparent;
border: none;
cursor: pointer;
color: var(--text-muted);
transition: background 0.12s, color 0.12s;
padding: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
/* ── Alert ───────────────────────────────────────────────────────────────── */
.alert {
display: flex;
align-items: center;
gap: 0.625rem;
padding: 0.75rem 1rem;
border-radius: var(--radius-lg);
font-size: 0.875rem;
margin-bottom: 1.25rem;
animation: fadeUp 0.3s ease-out both;
}
.alert-error {
background: var(--red-dim);
border: 1px solid rgba(248,113,113,0.25);
color: var(--red);
}
.alert-success {
background: var(--green-dim);
border: 1px solid rgba(34,197,94,0.25);
color: var(--green);
}
/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
padding: 2rem 2rem 1.75rem;
animation: fadeUp 0.4s ease-out both;
}
.settings-form > * + * { margin-top: 1.25rem; }
.info-box {
padding: 1rem 1.125rem;
border-radius: var(--radius-lg);
background: var(--blue-dim);
border: 1px solid rgba(96,165,250,0.2);
font-size: 0.8125rem;
color: var(--blue);
animation: fadeUp 0.4s 0.1s ease-out both;
}
html:not(.dark) .info-box {
background: rgba(37,99,235,0.06);
border-color: rgba(37,99,235,0.18);
color: var(--blue);
}
.info-box strong {
display: block;
font-weight: 600;
margin-bottom: 0.3rem;
font-size: 0.875rem;
}
/* ── Footer ──────────────────────────────────────────────────────────────── */
.app-footer {
position: relative;
text-align: center;
padding: 1.5rem;
font-size: 0.75rem;
color: var(--text-muted);
border-top: 1px solid var(--border);
}
/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeUp {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* ── Scrollbar (webkit) ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
/* ── Selection ───────────────────────────────────────────────────────────── */
::selection { background: var(--accent-dim); color: var(--text); }
+231
View File
@@ -0,0 +1,231 @@
/* ============================================
Bewerbungs-Tracker - Custom Styles
============================================ */
/* Base styles */
* {
box-sizing: border-box;
}
/* Smooth scrolling */
html {
scroll-behavior: smooth;
}
/* Custom scrollbar for dark mode */
.dark ::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.dark ::-webkit-scrollbar-track {
background: #374151;
}
.dark ::-webkit-scrollbar-thumb {
background: #6b7280;
border-radius: 4px;
}
.dark ::-webkit-scrollbar-thumb:hover {
background: #8b94a3;
}
/* Light mode scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #a1a1a1;
}
/* Modal backdrop animation */
.fixed.inset-0.bg-black.bg-opacity-50 {
animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Modal content animation */
.fixed.inset-0 > div > div {
animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Table hover effect */
.tbody tr:hover {
transition: background-color 0.15s ease;
}
/* Focus styles for inputs */
input:focus,
textarea:focus,
select:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}
/* Dark mode focus */
.dark input:focus,
.dark textarea:focus,
.dark select:focus {
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}
/* Button focus */
button:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}
/* Loading spinner for buttons */
button.loading {
position: relative;
pointer-events: none;
}
button.loading::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 16px;
height: 16px;
border: 2px solid transparent;
border-top-color: currentColor;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: translate(-50%, -50%) rotate(360deg);
}
}
/* Status badges */
.status-badge {
display: inline-block;
padding: 4px 8px;
border-radius: 9999px;
font-size: 12px;
font-weight: 500;
}
/* Table cell wrapping */
.table-cell-wrap {
white-space: normal;
word-wrap: break-word;
}
/* Responsive adjustments */
@media (max-width: 768px) {
/* Make filter section stack on mobile */
#filterForm {
flex-direction: column;
align-items: stretch;
}
#filterForm > div {
margin-bottom: 1rem;
}
/* Adjust buttons on mobile */
#filterForm .flex.space-x-2,
#filterForm .ml-auto,
#filterForm > div:last-child {
margin-bottom: 0 !important;
}
/* Make table scroll horizontally on mobile */
.overflow-hidden {
overflow-x: auto;
}
table {
min-width: 768px;
}
/* Adjust modal width on mobile */
.max-w-lg {
max-width: 90vw;
margin: 0 5vw;
}
.max-w-md {
max-width: 90vw;
margin: 0 5vw;
}
}
/* Print styles */
@media print {
.no-print {
display: none !important;
}
body {
background: white;
color: black;
}
.dark body {
background: white;
color: black;
}
}
/* Header shadow */
header {
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
/* Card shadows */
.bg-white,
.bg-gray-800 {
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}
/* Utility classes */
.truncate-2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.truncate-3 {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
+609 -252
View File
@@ -1,267 +1,624 @@
'use strict';
// ============================================
// Bewerbungs-Tracker - Client-side JavaScript
// ============================================
// ── Dark mode toggle ──────────────────────────────────────────────────────────
// DOM Elements
const body = document.getElementById('body');
const darkModeToggle = document.getElementById('darkModeToggle');
const sunIcon = document.getElementById('sunIcon');
const moonIcon = document.getElementById('moonIcon');
document.getElementById('darkModeToggle').addEventListener('click', () => {
const isDark = document.documentElement.classList.toggle('dark');
localStorage.setItem('darkMode', isDark ? 'true' : 'false');
});
// Modal Elements
const settingsModal = document.getElementById('settingsModal');
const applicationModal = document.getElementById('applicationModal');
const deleteModal = document.getElementById('deleteModal');
const pdfExportModal = document.getElementById('pdfExportModal');
// ── Stat counter animation ────────────────────────────────────────────────────
// Form Elements
const settingsForm = document.getElementById('settingsForm');
const applicationForm = document.getElementById('applicationForm');
const pdfExportForm = document.getElementById('pdfExportForm');
const filterForm = document.getElementById('filterForm');
(function animateStats() {
const DURATION = 700;
// Button Elements
const settingsBtn = document.getElementById('settingsBtn');
const addApplicationBtn = document.getElementById('addApplicationBtn');
const exportPdfBtn = document.getElementById('exportPdfBtn');
document.querySelectorAll('.stat-value[data-count]').forEach((el, i) => {
const target = parseInt(el.dataset.count, 10) || 0;
if (target === 0) return;
// Close Modal Buttons
const closeSettingsModal = document.getElementById('closeSettingsModal');
const closeApplicationModal = document.getElementById('closeApplicationModal');
const closeDeleteModal = document.getElementById('closeDeleteModal');
const closePdfModal = document.getElementById('closePdfModal');
const delay = 80 + i * 60;
setTimeout(() => {
const start = performance.now();
const tick = (now) => {
const p = Math.min((now - start) / DURATION, 1);
// ease-out expo
const eased = p === 1 ? 1 : 1 - Math.pow(2, -10 * p);
el.textContent = Math.round(eased * target);
if (p < 1) requestAnimationFrame(tick);
};
requestAnimationFrame(tick);
}, delay);
});
})();
const cancelSettings = document.getElementById('cancelSettings');
const cancelApplication = document.getElementById('cancelApplication');
const cancelDelete = document.getElementById('cancelDelete');
const cancelPdfExport = document.getElementById('cancelPdfExport');
const confirmDelete = document.getElementById('confirmDelete');
// ── Load bewerbungen from embedded JSON ───────────────────────────────────────
// Global variables
let currentApplicationId = null;
let currentDeleteId = null;
let pdfLibrariesLoaded = false;
let BEWERBUNGEN = [];
const dataEl = document.getElementById('bewerbungenData');
if (dataEl) {
try { BEWERBUNGEN = JSON.parse(dataEl.textContent); } catch (_) {}
}
// ============================================
// Dark Mode
// ============================================
// ── Modal system ──────────────────────────────────────────────────────────────
function openModal(id) {
const el = document.getElementById(id);
el.classList.add('is-open');
document.body.style.overflow = 'hidden';
setTimeout(() => {
const first = el.querySelector(
'input[type="date"], input[type="text"]:not([type="hidden"]), select, textarea'
);
if (first) first.focus();
}, 60);
}
function closeModal(id) {
const el = document.getElementById(id);
el.classList.remove('is-open');
document.body.style.overflow = '';
}
function closeOnBackdrop(event, id) {
if (event.target === event.currentTarget) closeModal(id);
}
document.addEventListener('keydown', (e) => {
if (e.key !== 'Escape') return;
['bewerbungModal', 'deleteModal'].forEach(id => {
const el = document.getElementById(id);
if (el && el.classList.contains('is-open')) closeModal(id);
});
});
// ── Add modal ─────────────────────────────────────────────────────────────────
function openAddModal() {
const form = document.getElementById('bewerbungForm');
form.reset();
form.action = '/bewerbungen';
document.getElementById('modalTitle').textContent = 'Neue Bewerbung';
document.getElementById('datum').value = todayISO();
openModal('bewerbungModal');
}
// ── Edit modal ────────────────────────────────────────────────────────────────
function openEditModal(id) {
const b = BEWERBUNGEN.find(x => x.id === id);
if (!b) return;
const form = document.getElementById('bewerbungForm');
form.action = `/bewerbungen/${id}?_method=PUT`;
document.getElementById('modalTitle').textContent = 'Bewerbung bearbeiten';
document.getElementById('datum').value = b.datum || '';
document.getElementById('firma').value = b.firma || '';
document.getElementById('stelle').value = b.stelle || '';
document.getElementById('art').value = b.art || '';
document.getElementById('status').value = b.status || '';
document.getElementById('notizen').value = b.notizen || '';
openModal('bewerbungModal');
}
// ── Delete modal ──────────────────────────────────────────────────────────────
function openDeleteModal(id, firma, stelle) {
document.getElementById('deleteInfo').textContent = `${firma} ${stelle}`;
document.getElementById('deleteForm').action = `/bewerbungen/${id}?_method=DELETE`;
openModal('deleteModal');
}
// ── PDF generation ────────────────────────────────────────────────────────────
async function generatePDF(monat, jahr) {
const btn = event.currentTarget;
const saved = btn.innerHTML;
btn.disabled = true;
btn.innerHTML = '<span style="opacity:.7">Wird erstellt …</span>';
try {
const res = await fetch(`/api/pdf-daten?monat=${monat}&jahr=${jahr}`);
if (!res.ok) throw new Error(`Server ${res.status}`);
buildPDF(await res.json(), monat, jahr);
} catch (err) {
alert('PDF-Erstellung fehlgeschlagen:\n' + err.message);
} finally {
btn.disabled = false;
btn.innerHTML = saved;
}
}
function buildPDF({ bewerbungen, settings }, monat, jahr) {
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' });
const PW = doc.internal.pageSize.getWidth(); // 210 mm
const PH = doc.internal.pageSize.getHeight(); // 297 mm
const monatName = MONATE_DE[monat - 1];
const count = bewerbungen.length;
// Accent stripe
doc.setFillColor(224, 123, 0);
doc.rect(0, 0, PW, 2.5, 'F');
// ── User info (top right) ──────────────────────────────────────────────────
doc.setFontSize(9);
doc.setTextColor(120, 120, 120);
let uy = 10;
const ux = PW - 12;
if (settings?.name) {
doc.setFont('helvetica', 'bold');
doc.text(settings.name, ux, uy, { align: 'right' });
uy += 5;
doc.setFont('helvetica', 'normal');
}
if (settings?.adresse) {
settings.adresse.split('\n').forEach(line => {
doc.text(line.trim(), ux, uy, { align: 'right' });
uy += 4.5;
});
}
if (settings?.kundennummer) {
uy += 1;
doc.text(`Kundennr.: ${settings.kundennummer}`, ux, uy, { align: 'right' });
}
// ── Title ──────────────────────────────────────────────────────────────────
doc.setFontSize(17);
doc.setFont('helvetica', 'bold');
doc.setTextColor(24, 32, 47);
const titleText = `Bewerbungsaktivitäten ${monatName} ${jahr}`;
doc.text(titleText, 12, 14);
// Divider — only under the title, never touching the address block on the right
const titleWidth = doc.getTextWidth(titleText);
doc.setDrawColor(220, 226, 237);
doc.setLineWidth(0.35);
doc.line(12, 18.5, 12 + titleWidth + 6, 18.5);
// ── Summary ────────────────────────────────────────────────────────────────
doc.setFontSize(10);
doc.setFont('helvetica', 'normal');
doc.setTextColor(74, 85, 107);
const pl = count !== 1 ? 'n' : '';
doc.text(
`Im Monat ${monatName} ${jahr} habe ich mich insgesamt auf ${count} Stelle${pl} beworben.`,
12, 25
);
// ── Table ──────────────────────────────────────────────────────────────────
doc.autoTable({
startY: 31,
head: [['Datum', 'Firma / Unternehmen', 'Stelle / Position', 'Art', 'Status', 'Notizen']],
body: bewerbungen.map(b => [
formatDateDE(b.datum),
b.firma || '',
b.stelle || '',
b.art || '',
b.status || '',
b.notizen ? b.notizen.slice(0, 120) : ''
]),
margin: { left: 12, right: 12 },
styles: {
fontSize: 7,
cellPadding: 2.8,
textColor: [24, 32, 47],
lineColor: [221, 226, 239],
lineWidth: 0.25,
font: 'helvetica'
},
headStyles: {
fillColor: [224, 123, 0],
textColor: [255, 255, 255],
fontStyle: 'bold',
halign: 'left',
fontSize: 7
},
alternateRowStyles: { fillColor: [248, 250, 254] },
columnStyles: {
0: { cellWidth: 26, overflow: 'hidden' },
1: { cellWidth: 38 },
2: { cellWidth: 38 },
3: { cellWidth: 28 },
4: { cellWidth: 32 },
5: { cellWidth: 'auto' }
},
didDrawPage: ({ pageNumber }) => {
doc.setFontSize(7.5);
doc.setTextColor(160, 170, 185);
doc.text(`Seite ${pageNumber}`, PW / 2, PH - 4.5, { align: 'center' });
function initializeDarkMode() {
// Check localStorage for dark mode preference
const darkMode = localStorage.getItem('darkMode');
if (darkMode === 'enabled' || (!darkMode && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
body.classList.add('dark');
sunIcon.classList.add('hidden');
moonIcon.classList.remove('hidden');
} else {
body.classList.remove('dark');
sunIcon.classList.remove('hidden');
moonIcon.classList.add('hidden');
}
});
// ── Declaration line ───────────────────────────────────────────────────────
const finalY = doc.lastAutoTable.finalY;
const declY = finalY + 10;
doc.setFontSize(8.5);
doc.setTextColor(100, 110, 130);
doc.setFont('helvetica', 'italic');
doc.text(
'Ich erkläre hiermit, dass die vorstehenden Angaben vollständig und wahrheitsgemäß sind.',
12, declY
);
doc.save(`Bewerbungen_${monatName}_${jahr}.pdf`);
}
// ── Utilities ─────────────────────────────────────────────────────────────────
function todayISO() {
const d = new Date();
return [
d.getFullYear(),
String(d.getMonth() + 1).padStart(2, '0'),
String(d.getDate()).padStart(2, '0')
].join('-');
function toggleDarkMode() {
body.classList.toggle('dark');
sunIcon.classList.toggle('hidden');
moonIcon.classList.toggle('hidden');
// Save preference to localStorage
if (body.classList.contains('dark')) {
localStorage.setItem('darkMode', 'enabled');
} else {
localStorage.setItem('darkMode', 'disabled');
}
}
function formatDateDE(s) {
if (!s) return '';
const p = s.split('-');
return p.length === 3 ? `${p[2]}.${p[1]}.${p[0]}` : s;
// ============================================
// Modal Functions
// ============================================
function showModal(modal) {
modal.classList.remove('hidden');
body.style.overflow = 'hidden';
}
function hideModal(modal) {
modal.classList.add('hidden');
body.style.overflow = '';
}
function resetApplicationForm() {
applicationForm.reset();
document.getElementById('modalTitle').textContent = 'Bewerbung hinzufügen';
currentApplicationId = null;
}
// ============================================
// Settings Management
// ============================================
function loadSettings() {
fetch('/api/settings')
.then(response => response.json())
.then(settings => {
if (settings) {
document.getElementById('userName').value = settings.name || '';
document.getElementById('userAddress').value = settings.adresse || '';
document.getElementById('customerNumber').value = settings.kundennummer || '';
}
})
.catch(error => console.error('Error loading settings:', error));
}
function saveSettings(event) {
event.preventDefault();
const formData = new FormData(settingsForm);
const settings = {
name: formData.get('name'),
adresse: formData.get('adresse'),
kundennummer: formData.get('kundennummer')
};
fetch('/api/settings', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(settings)
})
.then(response => response.json())
.then(data => {
if (data.success) {
hideModal(settingsModal);
// Refresh page to update settings in header
location.reload();
}
})
.catch(error => console.error('Error saving settings:', error));
}
// ============================================
// Application Management (CRUD)
// ============================================
function openAddApplicationModal() {
resetApplicationForm();
// Set default date to today
const today = new Date().toISOString().split('T')[0];
document.getElementById('applicationDatum').value = today;
showModal(applicationModal);
}
function openEditApplicationModal(id) {
// Fetch application data
fetch(`/api/bewerbungen/${id}`)
.then(response => response.json())
.then(application => {
currentApplicationId = application.id;
document.getElementById('modalTitle').textContent = 'Bewerbung bearbeiten';
document.getElementById('applicationId').value = application.id;
document.getElementById('applicationDatum').value = application.datum;
document.getElementById('applicationFirma').value = application.firma;
document.getElementById('applicationStelle').value = application.stelle;
document.getElementById('applicationArt').value = application.art || '';
document.getElementById('applicationStatus').value = application.status || '';
document.getElementById('applicationNotizen').value = application.notizen || '';
showModal(applicationModal);
})
.catch(error => console.error('Error loading application:', error));
}
function saveApplication(event) {
event.preventDefault();
const formData = new FormData(applicationForm);
const application = {
datum: formData.get('datum'),
firma: formData.get('firma'),
stelle: formData.get('stelle'),
art: formData.get('art'),
status: formData.get('status'),
notizen: formData.get('notizen'),
interne_notizen: formData.get('interne_notizen'),
kommentar: formData.get('kommentar')
};
let url = '/api/bewerbungen';
let method = 'POST';
if (currentApplicationId) {
url = `/api/bewerbungen/${currentApplicationId}`;
method = 'PUT';
}
fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(application)
})
.then(response => response.json())
.then(data => {
if (data.success) {
hideModal(applicationModal);
resetApplicationForm();
// Refresh the page to show updated data
location.reload();
}
})
.catch(error => console.error('Error saving application:', error));
}
function openDeleteModal(id) {
currentDeleteId = id;
showModal(deleteModal);
}
function deleteApplication() {
if (!currentDeleteId) return;
fetch(`/api/bewerbungen/${currentDeleteId}`, {
method: 'DELETE'
})
.then(response => response.json())
.then(data => {
if (data.success) {
hideModal(deleteModal);
currentDeleteId = null;
// Refresh the page
location.reload();
}
})
.catch(error => console.error('Error deleting application:', error));
}
// ============================================
// PDF Export
// ============================================
function openPdfExportModal() {
// Load PDF libraries if not already loaded
loadPdfLibraries().then(() => {
showModal(pdfExportModal);
});
}
function generatePDF(event) {
event.preventDefault();
const month = document.getElementById('pdfMonth').value;
const year = document.getElementById('pdfYear').value;
// Fetch data for PDF
let url = '/api/export?';
const params = [];
if (month) params.push(`month=${month}`);
if (year) params.push(`year=${year}`);
if (params.length > 0) {
url += params.join('&') + '&';
}
Promise.all([
fetch('/api/settings').then(res => res.json()),
fetch(url).then(res => res.json())
])
.then(([settings, applications]) => {
generatePdfDocument(settings, applications, month, year);
hideModal(pdfExportModal);
})
.catch(error => console.error('Error generating PDF:', error));
}
// PDF Generation with jsPDF
function generatePdfDocument(settings, applications, month, year) {
// Check if jsPDF is loaded
if (typeof jsPDF === 'undefined') {
console.error('jsPDF not loaded, please wait for libraries to load');
alert('Bitte warten Sie einen Moment und versuchen Sie es erneut.');
return;
}
const doc = new jsPDF({
orientation: 'portrait',
unit: 'mm',
format: 'a4'
});
const monthNames = ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni',
'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'];
const monthName = month ? monthNames[parseInt(month) - 1] : 'alle';
const title = `Bewerbungsaktivitäten - ${monthName} ${year || 'Jahre'}`;
const dateStr = new Date().toLocaleDateString('de-DE');
// Page geometry
const pageWidth = doc.internal.pageSize.getWidth(); // 210 mm
const pageHeight = doc.internal.pageSize.getHeight(); // 297 mm
const margin = 15;
const contentWidth = pageWidth - margin * 2; // 180 mm
const bottomLimit = pageHeight - margin;
let yPos = 20;
// Start a new page if the next block would not fit
function ensureSpace(needed) {
if (yPos + needed > bottomLimit) {
doc.addPage();
yPos = margin;
}
}
// Header with user data
doc.setFont('helvetica', 'bold');
doc.setFontSize(16);
doc.text(title, pageWidth / 2, yPos, { align: 'center' });
yPos += 12;
// User information
doc.setFontSize(12);
doc.setFont('helvetica', 'normal');
if (settings && settings.name) {
doc.text(`Name: ${settings.name}`, margin, yPos);
yPos += 7;
}
if (settings && settings.adresse) {
doc.text(`Adresse: ${settings.adresse}`, margin, yPos);
yPos += 7;
}
if (settings && settings.kundennummer) {
doc.text(`Kundennummer: ${settings.kundennummer}`, margin, yPos);
yPos += 7;
}
yPos += 5;
// Summary text
const totalApplications = applications.length;
const summaryText = year
? `Im Monat ${monthName} ${year} habe ich mich insgesamt auf ${totalApplications} Stellen beworben.`
: `Insgesamt habe ich mich auf ${totalApplications} Stellen beworben.`;
doc.setFont('helvetica', 'bold');
doc.text(summaryText, pageWidth / 2, yPos, { align: 'center' });
yPos += 12;
// Group entries by status (keep this order in sync with views/index.ejs)
const statusOrder = ['Gesendet', 'Eingangsbestätigung', 'Vorstellungsgespräch',
'Einstellung', 'Absage', 'Keine Rückmeldung'];
const groups = {};
applications.forEach((app) => {
const key = (app.status && app.status.trim()) ? app.status.trim() : 'Ohne Status';
(groups[key] = groups[key] || []).push(app);
});
const orderedKeys = [
...statusOrder.filter((s) => groups[s]),
...Object.keys(groups).filter((k) => !statusOrder.includes(k))
];
// One block per application — no table, so the note (which documents the
// full Verlauf) gets the entire page width and is shown completely.
orderedKeys.forEach((statusKey) => {
const group = groups[statusKey];
// Status group heading (dark bar), kept together with its first entry
ensureSpace(40);
doc.setFillColor(55, 65, 81);
doc.rect(margin, yPos, contentWidth, 10, 'F');
doc.setFont('helvetica', 'bold');
doc.setFontSize(12);
doc.setTextColor(255, 255, 255);
doc.text(`${statusKey} (${group.length})`, margin + 3, yPos + 6.8);
yPos += 14;
doc.setTextColor(0, 0, 0);
group.forEach((app) => {
const datum = new Date(app.datum).toLocaleDateString('de-DE');
const firma = app.firma || '—';
const stelle = app.stelle || '—';
const art = app.art || '—';
const notizen = (app.notizen || '').trim();
// Keep the heading together with the start of its content
ensureSpace(28);
// Heading bar: Firma Stelle (left), Datum (right)
doc.setFillColor(225, 232, 240);
doc.rect(margin, yPos, contentWidth, 9, 'F');
doc.setFont('helvetica', 'bold');
doc.setFontSize(11);
doc.setTextColor(20, 20, 20);
const heading = doc.splitTextToSize(`${firma} ${stelle}`, contentWidth - 40)[0];
doc.text(heading, margin + 2, yPos + 6);
doc.text(datum, pageWidth - margin - 2, yPos + 6, { align: 'right' });
yPos += 9;
// Meta line: Art
doc.setFont('helvetica', 'normal');
doc.setFontSize(9);
doc.setTextColor(90, 90, 90);
doc.text(`Art: ${art}`, margin + 2, yPos + 5);
yPos += 9;
// Status-Verlauf timeline (chronological status changes with comments)
const verlauf = Array.isArray(app.verlauf) ? app.verlauf : [];
if (verlauf.length) {
doc.setFont('helvetica', 'bold');
doc.setFontSize(10);
doc.setTextColor(20, 20, 20);
ensureSpace(6);
doc.text('Status-Verlauf:', margin + 2, yPos + 4);
yPos += 6;
doc.setFontSize(9);
verlauf.forEach((v) => {
const vDatum = new Date(v.datum).toLocaleDateString('de-DE');
doc.setFont('helvetica', 'bold');
doc.setTextColor(50, 50, 50);
ensureSpace(5);
doc.text(`${vDatum}${v.status || ''}`, margin + 5, yPos + 4);
yPos += 5;
const kommentar = (v.kommentar || '').trim();
if (kommentar) {
doc.setFont('helvetica', 'normal');
doc.setTextColor(0, 0, 0);
kommentar.split(/\r?\n/).forEach((paragraph) => {
const lines = doc.splitTextToSize(paragraph.length ? paragraph : ' ', contentWidth - 12);
lines.forEach((line) => {
ensureSpace(4.5);
doc.text(line, margin + 9, yPos + 3.5);
yPos += 4.5;
});
});
}
});
yPos += 3;
}
// Notizen label
doc.setFont('helvetica', 'bold');
doc.setFontSize(10);
doc.setTextColor(20, 20, 20);
doc.text('Notizen:', margin + 2, yPos + 4);
yPos += 6;
// Notizen body — full width, complete, with page breaks line by line
doc.setFont('helvetica', 'normal');
doc.setFontSize(10);
doc.setTextColor(0, 0, 0);
const lineHeight = 5;
const noteText = notizen || '(keine Notizen)';
noteText.split(/\r?\n/).forEach((paragraph) => {
const lines = doc.splitTextToSize(paragraph.length ? paragraph : ' ', contentWidth - 4);
lines.forEach((line) => {
ensureSpace(lineHeight);
doc.text(line, margin + 2, yPos + 4);
yPos += lineHeight;
});
});
// Separator before the next entry
yPos += 4;
ensureSpace(6);
doc.setDrawColor(210, 210, 210);
doc.line(margin, yPos, pageWidth - margin, yPos);
yPos += 8;
});
// Extra spacing after a status group
yPos += 4;
});
// Footer with confirmation
ensureSpace(20);
yPos += 6;
doc.setFont('helvetica', 'italic');
doc.setFontSize(10);
doc.setTextColor(0, 0, 0);
doc.text('Ich versichere, dass die oben genannten Angaben der Wahrheit entsprechen.', pageWidth / 2, yPos, { align: 'center' });
yPos += 7;
doc.text(`Datum: ${dateStr}`, pageWidth / 2, yPos, { align: 'center' });
// Save the PDF
const fileName = `Bewerbungsaktivitaeten_${monthName}_${year || 'alle'}.pdf`;
doc.save(fileName);
}
// Load PDF libraries dynamically
function loadPdfLibraries() {
return new Promise((resolve) => {
if (pdfLibrariesLoaded) {
resolve();
return;
}
// Check if already loading
if (document.getElementById('jspdf-script')) {
const checkLoaded = setInterval(() => {
if (typeof jsPDF !== 'undefined') {
clearInterval(checkLoaded);
pdfLibrariesLoaded = true;
resolve();
}
}, 100);
return;
}
// Load jsPDF from CDN
const script1 = document.createElement('script');
script1.id = 'jspdf-script';
script1.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js';
script1.onload = () => {
const script2 = document.createElement('script');
script2.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.8.2/jspdf.plugin.autotable.min.js';
script2.onload = () => {
pdfLibrariesLoaded = true;
resolve();
};
document.head.appendChild(script2);
};
document.head.appendChild(script1);
});
}
// ============================================
// Event Listeners
// ============================================
// Dark Mode Toggle
darkModeToggle.addEventListener('click', toggleDarkMode);
// Settings Modal
settingsBtn.addEventListener('click', () => {
loadSettings();
showModal(settingsModal);
});
closeSettingsModal.addEventListener('click', () => hideModal(settingsModal));
cancelSettings.addEventListener('click', () => hideModal(settingsModal));
settingsForm.addEventListener('submit', saveSettings);
// Application Modal
addApplicationBtn.addEventListener('click', openAddApplicationModal);
closeApplicationModal.addEventListener('click', () => {
hideModal(applicationModal);
resetApplicationForm();
});
cancelApplication.addEventListener('click', () => {
hideModal(applicationModal);
resetApplicationForm();
});
applicationForm.addEventListener('submit', saveApplication);
// Delete Modal
closeDeleteModal.addEventListener('click', () => hideModal(deleteModal));
cancelDelete.addEventListener('click', () => hideModal(deleteModal));
confirmDelete.addEventListener('click', deleteApplication);
// PDF Export Modal
exportPdfBtn.addEventListener('click', openPdfExportModal);
closePdfModal.addEventListener('click', () => hideModal(pdfExportModal));
cancelPdfExport.addEventListener('click', () => hideModal(pdfExportModal));
pdfExportForm.addEventListener('submit', generatePDF);
// Filter Form
document.getElementById('filterForm').addEventListener('submit', function(e) {
e.preventDefault();
const month = document.getElementById('filterMonth').value;
const year = document.getElementById('filterYear').value;
let url = '/';
if (month || year) {
url += '?';
if (month) url += `month=${month}&`;
if (year) url += `year=${year}&`;
}
window.location.href = url;
});
// Delete buttons (event delegation). Editing opens its own page (/bewerbung/:id).
document.addEventListener('click', (e) => {
if (e.target.closest('.delete-btn')) {
const id = e.target.closest('.delete-btn').dataset.id;
openDeleteModal(id);
}
});
// Close modals when clicking outside
document.addEventListener('click', (e) => {
if (e.target === settingsModal) hideModal(settingsModal);
if (e.target === applicationModal) {
hideModal(applicationModal);
resetApplicationForm();
}
if (e.target === deleteModal) hideModal(deleteModal);
if (e.target === pdfExportModal) hideModal(pdfExportModal);
});
// Close modals with Escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
if (!settingsModal.classList.contains('hidden')) hideModal(settingsModal);
if (!applicationModal.classList.contains('hidden')) {
hideModal(applicationModal);
resetApplicationForm();
}
if (!deleteModal.classList.contains('hidden')) hideModal(deleteModal);
if (!pdfExportModal.classList.contains('hidden')) hideModal(pdfExportModal);
}
});
// Set current year in footer
document.getElementById('currentYear').textContent = new Date().getFullYear();
// ============================================
// Initialize
// ============================================
// Initialize dark mode
initializeDarkMode();
console.log('Bewerbungs-Tracker initialized');