Extract inline CSS/JS, add EJS templates with shared layout

- Extract CSS into public/css/{shared,players,courses}.css
- Extract JS into public/js/{chart,tooltips,progress,players,courses}.js
- Consolidate 5 duplicated tooltip blocks into setupTooltip() helper
- Add EJS view engine with layout partial and nav partial
- Convert HTML pages to EJS templates (index.ejs, courses.ejs)
- Add /courses route with redirect from /courses.html
- Remove old monolithic HTML files (1478 + 612 lines)
This commit is contained in:
Samuel Enocsson
2026-02-18 22:32:03 +01:00
parent 33a962e6b8
commit 20bbdbbfcf
18 changed files with 2010 additions and 2094 deletions
+144
View File
@@ -0,0 +1,144 @@
/* Course page styles */
.container {
max-width: 1000px;
}
.nav-links {
text-align: center;
margin-bottom: 20px;
}
.nav-links a {
margin: 0 15px;
color: #007bff;
text-decoration: none;
font-weight: bold;
}
.nav-links a:hover {
text-decoration: underline;
}
.controls {
text-align: right;
margin-bottom: 20px;
}
.btn {
margin-left: 10px;
}
.search-container {
margin-bottom: 20px;
text-align: center;
}
.search-input {
width: 100%;
max-width: 400px;
padding: 10px 15px;
font-size: 16px;
border: 2px solid #ddd;
border-radius: 4px;
outline: none;
transition: border-color 0.2s;
}
.search-input:focus {
border-color: #007bff;
}
.search-results-info {
text-align: center;
margin: 10px 0;
color: #666;
font-size: 14px;
}
.layouts-container {
padding: 15px;
}
.layout-item {
padding: 10px;
margin: 5px 0;
background-color: white;
border-radius: 4px;
border: 1px solid #dee2e6;
display: flex;
justify-content: space-between;
align-items: center;
}
.layout-name {
font-weight: bold;
color: #333;
}
.layout-par {
color: #007bff;
font-weight: bold;
}
.no-layouts {
text-align: center;
color: #999;
font-style: italic;
padding: 20px;
}
.inactive-layouts-accordion {
margin-top: 15px;
border: 1px solid #dee2e6;
border-radius: 4px;
background-color: #f8f9fa;
}
.accordion-header {
padding: 12px 15px;
cursor: pointer;
user-select: none;
display: flex;
justify-content: space-between;
align-items: center;
background-color: #e9ecef;
border-radius: 4px;
transition: background-color 0.2s;
}
.accordion-header:hover {
background-color: #dee2e6;
}
.accordion-header-text {
font-weight: 600;
color: #6c757d;
font-size: 14px;
}
.accordion-icon {
transition: transform 0.3s;
color: #6c757d;
}
.accordion-icon.expanded {
transform: rotate(180deg);
}
.accordion-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
padding: 0 10px;
}
.accordion-content.expanded {
max-height: 2000px;
padding: 10px;
transition: max-height 0.5s ease-in;
}
.layout-item.inactive {
opacity: 0.7;
}
+348
View File
@@ -0,0 +1,348 @@
/* Player ratings page styles */
.progress-container {
width: 100%;
background-color: #f0f0f0;
border-radius: 10px;
padding: 3px;
margin: 20px 0;
}
.progress-bar {
width: 0%;
height: 30px;
background-color: #007bff;
border-radius: 8px;
text-align: center;
line-height: 30px;
color: white;
font-weight: bold;
transition: width 0.3s ease;
}
.progress-text {
text-align: center;
margin: 10px 0;
font-size: 16px;
color: #666;
}
.mobile-only {
display: none;
}
@media (max-width: 768px) {
.mobile-only {
display: block;
}
.player-name {
font-weight: bold;
}
.chart-container {
height: 250px;
margin: 5px 0;
}
.chart-title {
font-size: 14px;
}
}
.chart-container {
width: 100%;
height: 300px;
margin: 10px 0;
border: 1px solid #ddd;
border-radius: 4px;
background: white;
}
.chart-title {
text-align: center;
font-weight: bold;
margin-bottom: 10px;
color: #333;
}
.loading-chart {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
color: #666;
}
.chart-tooltip {
position: fixed;
background-color: rgba(0, 0, 0, 0.9);
color: white;
padding: 8px 12px;
border-radius: 4px;
font-size: 12px;
pointer-events: none;
z-index: 10000;
display: none;
white-space: nowrap;
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
border: 1px solid rgba(255,255,255,0.2);
}
.rating {
font-weight: bold;
color: #007bff;
}
.std-dev-tooltip {
position: absolute;
background-color: rgba(0, 0, 0, 0.9);
color: white;
padding: 8px 12px;
border-radius: 4px;
font-size: 12px;
pointer-events: none;
z-index: 10000;
display: none;
white-space: nowrap;
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
border: 1px solid rgba(255,255,255,0.2);
font-weight: normal;
}
.predicted-value {
position: relative;
display: inline-block;
}
.pdga-number {
color: #6c757d;
font-size: 14px;
}
.difference {
font-weight: bold;
}
.positive {
color: #28a745;
}
.negative {
color: #dc3545;
}
.neutral {
color: #6c757d;
}
.rating-change {
font-weight: bold;
font-size: 14px;
}
.refresh-section {
display: inline-flex;
align-items: center;
}
.debug-icon:hover {
opacity: 1 !important;
color: #007bff !important;
transform: scale(1.1);
}
.debug-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 10001;
display: none;
justify-content: center;
align-items: center;
}
.debug-content {
background: white;
border-radius: 8px;
padding: 20px;
max-width: 600px;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.debug-header {
font-weight: bold;
font-size: 18px;
margin-bottom: 15px;
color: #333;
border-bottom: 2px solid #007bff;
padding-bottom: 10px;
}
.debug-log {
font-family: 'Courier New', monospace;
background-color: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 4px;
padding: 15px;
font-size: 12px;
line-height: 1.4;
white-space: pre-line;
color: #495057;
}
.debug-close {
position: absolute;
top: 10px;
right: 15px;
font-size: 24px;
color: #999;
cursor: pointer;
background: none;
border: none;
}
.debug-close:hover {
color: #333;
}
.add-player-section {
background-color: #f8f9fa;
border: 2px solid #007bff;
border-radius: 8px;
padding: 20px;
margin-bottom: 30px;
text-align: center;
}
.add-player-section h3 {
margin-top: 0;
margin-bottom: 15px;
color: #333;
font-size: 18px;
}
.add-player-form {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.pdga-input {
padding: 10px 15px;
font-size: 16px;
border: 2px solid #ddd;
border-radius: 4px;
outline: none;
width: 250px;
transition: border-color 0.2s;
}
.pdga-input:focus {
border-color: #007bff;
}
.btn-add {
background-color: #28a745;
}
.btn-add:hover {
background-color: #218838;
}
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 10001;
display: none;
justify-content: center;
align-items: center;
}
.modal-content {
background: white;
border-radius: 8px;
padding: 0;
max-width: 500px;
width: 90%;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
position: relative;
}
.modal-header {
font-weight: bold;
font-size: 20px;
padding: 20px;
color: #333;
border-bottom: 2px solid #007bff;
}
.modal-body {
padding: 20px;
font-size: 16px;
color: #495057;
line-height: 1.6;
}
.modal-footer {
padding: 15px 20px;
border-top: 1px solid #e9ecef;
display: flex;
justify-content: flex-end;
gap: 10px;
}
.modal-close {
position: absolute;
top: 10px;
right: 15px;
font-size: 28px;
color: #999;
cursor: pointer;
background: none;
border: none;
line-height: 1;
}
.modal-close:hover {
color: #333;
}
.btn-cancel {
background-color: #6c757d;
}
.btn-cancel:hover {
background-color: #5a6268;
}
.btn-confirm {
background-color: #28a745;
}
.btn-confirm:hover {
background-color: #218838;
}
@media (max-width: 768px) {
.add-player-section {
padding: 15px;
}
.add-player-form {
flex-direction: column;
}
.pdga-input {
width: 100%;
}
}
+163
View File
@@ -0,0 +1,163 @@
/* Shared styles for PDGA Ratings app */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
}
@media (max-width: 768px) {
body {
padding: 10px;
}
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
overflow-x: auto;
}
@media (max-width: 768px) {
.container {
padding: 15px;
border-radius: 0;
box-shadow: none;
}
}
h1 {
color: #333;
text-align: center;
margin-bottom: 30px;
}
@media (max-width: 768px) {
h1 {
font-size: 24px;
margin-bottom: 20px;
}
}
.loading {
text-align: center;
padding: 20px;
font-size: 18px;
color: #666;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
font-size: 14px;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
@media (max-width: 768px) {
table {
font-size: 12px;
}
th, td {
padding: 8px 4px;
}
.mobile-hide {
display: none;
}
}
th {
background-color: #f8f9fa;
font-weight: bold;
color: #495057;
}
tr:hover {
background-color: #f5f5f5;
}
.expandable-row {
cursor: pointer;
}
.expandable-row:hover {
background-color: #e3f2fd;
}
.expanded-content {
display: none;
background-color: #f8f9fa;
border-top: 2px solid #007bff;
}
.expanded-content td {
padding: 20px;
}
a {
color: #007bff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.btn {
padding: 8px 16px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
.btn:hover {
background-color: #0056b3;
}
.btn:disabled {
background-color: #6c757d;
cursor: not-allowed;
}
.refresh-icon {
cursor: pointer;
opacity: 0.6;
margin-left: 8px;
font-size: 13px;
color: #6c757d;
transition: all 0.2s ease;
padding: 2px;
border-radius: 3px;
}
.refresh-icon:hover {
opacity: 1;
color: #007bff;
background-color: rgba(0, 123, 255, 0.1);
transform: scale(1.1);
}
.refresh-icon.spinning {
animation: spin 1s linear infinite;
color: #007bff;
opacity: 1;
background-color: rgba(0, 123, 255, 0.1);
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}