Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f3e33a5ea | |||
| c7fb4a7068 | |||
| 27ffa096e4 | |||
| 5198a1c0f4 | |||
| 7297c0a16b | |||
| ada2dcb4ae | |||
| 5ece854340 | |||
| 2ef7de4e58 | |||
| 16c045e7cc | |||
| 8ee5cc3861 | |||
| 2561ee12ef | |||
| 0d2f0fa3a8 | |||
| ec3ae872da | |||
| a90f2d0e86 | |||
| f8233960d2 | |||
| 98a6c6be2e | |||
| 9138299ae0 | |||
| 3275241aa7 | |||
| 6faddc6232 | |||
| cad14def56 | |||
| 75b2360e96 | |||
| 2035ae0efc | |||
| 88396c9220 | |||
| 9cb78c9c98 | |||
| f2e30c62aa | |||
| 4bbf6d9728 | |||
| 0beeb98002 | |||
| f4c5e963d2 | |||
| 27d1bef8dd | |||
| 088e283dcf | |||
| 5791d8e34f | |||
| 1ff768e2fa | |||
| c3fb850de3 | |||
| c69efa469e | |||
| e21e6f2ef0 | |||
| 141dc90db7 | |||
| b4d9305550 | |||
| e900b86e69 | |||
| 4dc429b961 | |||
| 4bcf83d267 | |||
| 7ab16994c5 | |||
| b51c47dc4c | |||
| cc9d8eb4cd |
@@ -0,0 +1,91 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
# Auto-tagging baserat på conventional commits sedan senaste taggen.
|
||||||
|
# feat: → minor bump (1.2.9 → 1.3.0)
|
||||||
|
# fix: → patch bump (1.2.9 → 1.2.10)
|
||||||
|
# "!:" eller "BREAKING CHANGE" → major bump (1.2.9 → 2.0.0)
|
||||||
|
# Andra prefix (chore:, docs:, ci:, refactor:, style:, test:) bumpar inte.
|
||||||
|
# Skippas tyst när inga releaseable commits hittas — t.ex. när workflow:n själv pushar version-commiten.
|
||||||
|
# Push av tag triggar deploy.yml (PACKAGES_TOKEN är en PAT så cross-workflow-triggers funkar).
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "Release Bot"
|
||||||
|
git config user.email "noreply@shcizo.se"
|
||||||
|
|
||||||
|
- name: Determine version bump
|
||||||
|
id: bump
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
LAST_TAG=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || echo "")
|
||||||
|
if [ -z "$LAST_TAG" ]; then
|
||||||
|
RANGE=""
|
||||||
|
echo "No previous v* tag found — scanning all commits."
|
||||||
|
else
|
||||||
|
RANGE="${LAST_TAG}..HEAD"
|
||||||
|
echo "Scanning commits since ${LAST_TAG}."
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUMP="none"
|
||||||
|
while IFS= read -r subject; do
|
||||||
|
[ -z "$subject" ] && continue
|
||||||
|
if echo "$subject" | grep -qE "^[a-z]+(\([^)]+\))?!:|BREAKING[ -]CHANGE"; then
|
||||||
|
BUMP="major"
|
||||||
|
break
|
||||||
|
elif echo "$subject" | grep -qE "^feat(\([^)]+\))?:"; then
|
||||||
|
[ "$BUMP" != "major" ] && BUMP="minor"
|
||||||
|
elif echo "$subject" | grep -qE "^fix(\([^)]+\))?:"; then
|
||||||
|
[ "$BUMP" = "none" ] && BUMP="patch"
|
||||||
|
fi
|
||||||
|
done < <(git log ${RANGE} --no-merges --pretty=format:%s)
|
||||||
|
|
||||||
|
echo "Determined bump: ${BUMP}"
|
||||||
|
echo "bump=${BUMP}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Compute new version
|
||||||
|
if: steps.bump.outputs.bump != 'none'
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
CURRENT=$(node -p "require('./package.json').version")
|
||||||
|
IFS=. read -r MAJ MIN PAT <<< "$CURRENT"
|
||||||
|
case "${{ steps.bump.outputs.bump }}" in
|
||||||
|
major) NEW="$((MAJ+1)).0.0" ;;
|
||||||
|
minor) NEW="${MAJ}.$((MIN+1)).0" ;;
|
||||||
|
patch) NEW="${MAJ}.${MIN}.$((PAT+1))" ;;
|
||||||
|
esac
|
||||||
|
echo "Bumping ${CURRENT} → ${NEW}"
|
||||||
|
echo "new=${NEW}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Update files, commit, tag, push
|
||||||
|
if: steps.bump.outputs.bump != 'none'
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
NEW="${{ steps.version.outputs.new }}"
|
||||||
|
|
||||||
|
npm version "$NEW" --no-git-tag-version
|
||||||
|
|
||||||
|
git add package.json package-lock.json
|
||||||
|
git commit -m "$NEW"
|
||||||
|
git tag "v${NEW}"
|
||||||
|
git push origin main "v${NEW}"
|
||||||
|
|
||||||
|
- name: No-op summary
|
||||||
|
if: steps.bump.outputs.bump == 'none'
|
||||||
|
run: echo "No feat/fix/breaking commits since last tag — no release."
|
||||||
@@ -46,7 +46,7 @@ public/
|
|||||||
- **Logging:** Use `require('./logger')` (or relative path). Never use `console.log/error` in backend code. Use appropriate Pino levels: `debug` for verbose/diagnostic data, `info` for operational status, `warn` for retries/degraded state, `error` for failures, `fatal` for startup crashes.
|
- **Logging:** Use `require('./logger')` (or relative path). Never use `console.log/error` in backend code. Use appropriate Pino levels: `debug` for verbose/diagnostic data, `info` for operational status, `warn` for retries/degraded state, `error` for failures, `fatal` for startup crashes.
|
||||||
- **Frontend JS:** `console.error` is fine in `public/js/` — runs in browser, no Pino.
|
- **Frontend JS:** `console.error` is fine in `public/js/` — runs in browser, no Pino.
|
||||||
- **Commits:** Conventional commits (`feat:`, `fix:`, `refactor:`, `chore:`, `ci:`).
|
- **Commits:** Conventional commits (`feat:`, `fix:`, `refactor:`, `chore:`, `ci:`).
|
||||||
- **Releases:** Manual version bump — edit `version` in `package.json` + `package-lock.json`, commit as `<version>`, tag `v<version>`, push commit + tag (`git push origin main v<version>`). Triggers `.gitea/workflows/deploy.yml` which (1) builds and pushes the image to `gitea.shcizo.se/shcizo/pdga-rating:<tag>` + `:latest`, then (2) calls `package-updater-action` against `updater.shcizo.se/update` to roll out the new image. Required secrets: `PACKAGES_TOKEN` (PAT with `write:package`, for registry auth — the auto-injected `GITEA_TOKEN` does not have effective registry access) and `UPDATER_API_KEY` (for the updater endpoint). The action repo `shcizo/package-updater-action` is referenced via full Gitea URL (`https://gitea.shcizo.se/...`) since `uses:` defaults to GitHub.
|
- **Releases:** Automated via `.gitea/workflows/release.yml` on push to `main`. Workflow scans conventional commits sedan senaste `v*`-taggen och bumpar strikt semver: `feat:` → minor, `fix:` → patch, `!:`/`BREAKING CHANGE` → major. Andra prefix (`chore:`, `docs:`, `ci:`, `refactor:`, `style:`, `test:`) bumpar inte. Workflow:n uppdaterar `package.json` + `package-lock.json`, committar som `<version>`, taggar `v<version>` och pushar. Tag-pushen triggar `.gitea/workflows/deploy.yml` som (1) bygger + pushar image till `gitea.shcizo.se/shcizo/pdga-rating:<tag>` + `:latest`, sen (2) anropar `package-updater-action` mot `updater.shcizo.se/update`. Required secrets: `PACKAGES_TOKEN` (PAT med `write:package` + repo-push-scope — används av både release.yml för att pusha main/tag och deploy.yml för registry-auth; auto-injicerade `GITEA_TOKEN` triggar inte cross-workflows och saknar effective registry-access) och `UPDATER_API_KEY` (för updater-endpointen). Action-repot `shcizo/package-updater-action` refereras via full Gitea-URL (`https://gitea.shcizo.se/...`) eftersom `uses:` defaultar till GitHub. **Manuell tag** är fortfarande möjlig om release-workflow:n skippas eller behöver kringgås — pusha bara `v<version>`-tag direkt.
|
||||||
- **Scraping:** Two strategies per entity: direct HTTP (fast, preferred) with Puppeteer fallback (stealth plugin for anti-bot). Rate limiting must be respected.
|
- **Scraping:** Two strategies per entity: direct HTTP (fast, preferred) with Puppeteer fallback (stealth plugin for anti-bot). Rate limiting must be respected.
|
||||||
- **Database:** Migrations run automatically on startup in `db.js`. Schema changes go there.
|
- **Database:** Migrations run automatically on startup in `db.js`. Schema changes go there.
|
||||||
- **Templates:** EJS with shared layout in `views/partials/`. Pages use HTMX for dynamic content loading.
|
- **Templates:** EJS with shared layout in `views/partials/`. Pages use HTMX for dynamic content loading.
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "pdga-ratings",
|
"name": "pdga-ratings",
|
||||||
"version": "1.2.8",
|
"version": "1.4.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pdga-ratings",
|
"name": "pdga-ratings",
|
||||||
"version": "1.2.8",
|
"version": "1.4.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ejs": "^4.0.1",
|
"ejs": "^4.0.1",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pdga-ratings",
|
"name": "pdga-ratings",
|
||||||
"version": "1.2.8",
|
"version": "1.4.2",
|
||||||
"description": "PDGA rating scraper and display",
|
"description": "PDGA rating scraper and display",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+427
-99
@@ -2,133 +2,461 @@
|
|||||||
Courses Page
|
Courses Page
|
||||||
═══════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════ */
|
||||||
|
|
||||||
/* ── Controls ─────────────────────────────────── */
|
/* ── Action Card (tabs + inputs) ─────────────────── */
|
||||||
|
|
||||||
.controls {
|
.action-card {
|
||||||
|
background: var(--paper);
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-card-tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
border-bottom: 1px solid var(--line-2);
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Search ───────────────────────────────────── */
|
.action-tab {
|
||||||
|
padding: 12px 18px;
|
||||||
.search-results-info {
|
background: transparent;
|
||||||
text-align: center;
|
border: 0;
|
||||||
margin: 10px 0;
|
color: var(--ink-2);
|
||||||
color: var(--text-muted);
|
font: 600 14px/1.2 var(--font-sans);
|
||||||
font-size: 13px;
|
cursor: pointer;
|
||||||
|
transition: color 120ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Layouts ──────────────────────────────────── */
|
.action-tab:hover {
|
||||||
|
color: var(--ink);
|
||||||
.layouts-container {
|
|
||||||
padding: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.layouts-container h4 {
|
.action-tab.is-active {
|
||||||
margin: 0 0 12px 0;
|
color: var(--ink);
|
||||||
font-size: 13px;
|
box-shadow: inset 0 -2px 0 var(--accent);
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.04em;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-item {
|
.action-card-body {
|
||||||
padding: 12px 14px;
|
padding: 16px 20px;
|
||||||
margin: 4px 0;
|
}
|
||||||
background: var(--surface-1);
|
|
||||||
|
.action-pane[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-card-body input[type=text] {
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
padding: 0 14px;
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
border-radius: var(--radius-sm);
|
border-radius: var(--radius-sm);
|
||||||
border: 1px solid var(--border);
|
background: var(--paper-2);
|
||||||
|
font: 14px/1.2 var(--font-sans);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-card-body input[type=text]:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--accent);
|
||||||
|
box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 14%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-hint {
|
||||||
|
margin: 8px 0 0;
|
||||||
|
font-size: 11.5px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tjing-search-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
gap: 10px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
transition: border-color var(--transition), box-shadow var(--transition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-item:hover {
|
.tjing-search-row input[type=text] {
|
||||||
border-color: var(--accent-border);
|
flex: 1;
|
||||||
box-shadow: var(--shadow-sm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-name {
|
/* ── Buttons ──────────────────────────────────────── */
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.layout-par {
|
/* .btn-primary is defined in shared.css — no override needed here */
|
||||||
color: var(--accent);
|
|
||||||
font-weight: 700;
|
.btn-pill {
|
||||||
font-size: 14px;
|
padding: 6px 12px;
|
||||||
font-variant-numeric: tabular-nums;
|
background: var(--accent);
|
||||||
|
color: #fff;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 999px;
|
||||||
|
font: 600 12.5px/1 var(--font-sans);
|
||||||
|
cursor: pointer;
|
||||||
|
height: 28px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-pill:disabled {
|
||||||
|
opacity: .6;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Results bar ─────────────────────────────────── */
|
||||||
|
|
||||||
|
.results-bar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 12px 4px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-count {
|
||||||
|
color: var(--ink-2);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-count strong {
|
||||||
|
color: var(--ink);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-link {
|
||||||
|
color: var(--accent);
|
||||||
|
text-decoration: none;
|
||||||
|
font: 500 13.5px/1.2 var(--font-sans);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Course grid ─────────────────────────────────── */
|
||||||
|
|
||||||
|
.course-grid {
|
||||||
|
background: var(--paper);
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(280px, 2fr) minmax(140px, 1fr) minmax(140px, 0.9fr) 72px;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
padding: 14px 20px;
|
||||||
|
border-bottom: 1px solid var(--line-2);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 120ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row:hover {
|
||||||
|
background: var(--paper-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row.row-open {
|
||||||
|
background: var(--paper-2);
|
||||||
|
box-shadow: inset 3px 0 0 var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row[hidden],
|
||||||
|
.expanded-content[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row.row-open .icon-chev i {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row--header {
|
||||||
|
height: 48px;
|
||||||
|
padding: 0 20px;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row--header:hover {
|
||||||
|
background: var(--paper-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-header-cell {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-cell {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-name {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
letter-spacing: -0.005em;
|
||||||
|
color: var(--ink);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-row:hover .course-name,
|
||||||
|
.course-row.row-open .course-name {
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-meta {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-city {
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-updated {
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-feature-settings: "tnum", "zero";
|
||||||
|
font-size: 12.5px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Expanded layout panel ───────────────────────── */
|
||||||
|
|
||||||
|
.expanded-content {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expanded-content.is-open {
|
||||||
|
display: block;
|
||||||
|
animation: expandIn .2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expanded-cell {
|
||||||
|
padding: 22px 28px 28px;
|
||||||
|
background: color-mix(in oklch, var(--accent) 4%, var(--paper-2));
|
||||||
|
border-bottom: 1px solid var(--line-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Layout list ─────────────────────────────────── */
|
||||||
|
|
||||||
|
.layouts-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: baseline;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layouts-kicker {
|
||||||
|
font: 600 11px/1 var(--font-sans);
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.layouts-count {
|
||||||
|
font-size: 12.5px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-list {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-card {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 14px;
|
||||||
|
padding: 12px 18px;
|
||||||
|
background: var(--paper);
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
transition: border-color 120ms, box-shadow 120ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-card:hover {
|
||||||
|
border-color: var(--line);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-card--inactive {
|
||||||
|
background: transparent;
|
||||||
|
border-style: dashed;
|
||||||
|
opacity: 0.65;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-card--inactive .layout-name {
|
||||||
|
color: var(--ink-2);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 14px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-name {
|
||||||
|
font: 600 13.5px/1.2 var(--font-sans);
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-last-played {
|
||||||
|
font: 12.5px/1 var(--font-mono);
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-never-played {
|
||||||
|
font-size: 12.5px;
|
||||||
|
color: var(--down);
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-chips {
|
||||||
|
display: flex;
|
||||||
|
gap: 14px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font: 600 12.5px/1 var(--font-mono);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chip-par {
|
||||||
|
color: var(--accent);
|
||||||
|
background: color-mix(in oklch, var(--accent) 8%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chip-rating--green {
|
||||||
|
color: var(--rating-tier-high);
|
||||||
|
background: color-mix(in oklch, var(--rating-tier-high) 10%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chip-rating--amber {
|
||||||
|
color: var(--rating-tier-mid);
|
||||||
|
background: color-mix(in oklch, var(--rating-tier-mid) 10%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chip-rating--orange {
|
||||||
|
color: var(--rating-tier-low);
|
||||||
|
background: color-mix(in oklch, var(--rating-tier-low) 10%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Inactive layouts collapsible ────────────────── */
|
||||||
|
|
||||||
|
.inactive-layouts {
|
||||||
|
margin-top: 14px;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inactive-toggle {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px 16px;
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
font: 500 13.5px/1.2 var(--font-sans);
|
||||||
|
color: var(--ink-2);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inactive-toggle .icon-chev {
|
||||||
|
transition: transform 180ms;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inactive-toggle.is-open .icon-chev {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inactive-layouts-body {
|
||||||
|
padding: 0 12px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inactive-layouts-body[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ── Tjing results ───────────────────────────────── */
|
||||||
|
|
||||||
|
#tjing-results {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tjing-result {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-bottom: 1px solid var(--line-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tjing-result:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tjing-result-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tjing-result-name {
|
||||||
|
font: 600 14px/1.3 var(--font-sans);
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tjing-result-address {
|
||||||
|
font-size: 12.5px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tjing-error {
|
||||||
|
color: var(--down);
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── No-layouts message ──────────────────────────── */
|
||||||
|
|
||||||
.no-layouts {
|
.no-layouts {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: var(--text-muted);
|
color: var(--ink-3);
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Inactive Layouts Accordion ───────────────── */
|
/* ── Loading placeholder ─────────────────────────── */
|
||||||
|
|
||||||
.inactive-layouts-accordion {
|
.loading {
|
||||||
margin-top: 16px;
|
text-align: center;
|
||||||
border: 1px solid var(--border);
|
color: var(--ink-3);
|
||||||
border-radius: var(--radius-md);
|
|
||||||
background: var(--surface-2);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.accordion-header {
|
|
||||||
padding: 12px 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
background: var(--surface-3);
|
|
||||||
transition: background var(--transition);
|
|
||||||
}
|
|
||||||
|
|
||||||
.accordion-header:hover {
|
|
||||||
background: var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.accordion-header-text {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
padding: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion-icon {
|
|
||||||
transition: transform 0.3s ease;
|
|
||||||
color: var(--text-muted);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.accordion-icon.expanded {
|
|
||||||
transform: rotate(180deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.accordion-content {
|
|
||||||
max-height: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
transition: max-height 0.3s ease-out;
|
|
||||||
padding: 0 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.accordion-content.expanded {
|
|
||||||
max-height: 2000px;
|
|
||||||
padding: 12px;
|
|
||||||
transition: max-height 0.5s ease-in;
|
|
||||||
}
|
|
||||||
|
|
||||||
.layout-item.inactive {
|
|
||||||
opacity: 0.6;
|
|
||||||
border-style: dashed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,671 @@
|
|||||||
|
/* ═══════════════════════════════════════════════════
|
||||||
|
PDGA Ratings — Mobile Styles (≤ 880px)
|
||||||
|
All rules scoped inside @media (max-width: 880px)
|
||||||
|
unless marked "default hidden" (for elements that
|
||||||
|
must be display:none on desktop too).
|
||||||
|
═══════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
/* ── Default-hidden mobile elements ──────────────── */
|
||||||
|
/* Hidden on ALL viewports; mobile.css un-hides them */
|
||||||
|
|
||||||
|
.topbar__mobile { display: none; }
|
||||||
|
.mobile-list { display: none; }
|
||||||
|
.mobile-add-bar { display: none; }
|
||||||
|
.mobile-section-head { display: none; }
|
||||||
|
.m-tab-pill { display: none; }
|
||||||
|
.m-search-input { display: none; }
|
||||||
|
|
||||||
|
/* ═══════════════════════════════════════════════════ */
|
||||||
|
@media (max-width: 880px) {
|
||||||
|
|
||||||
|
/* ── Desktop elements → hide on mobile ─────────── */
|
||||||
|
|
||||||
|
.topbar__inner { display: none !important; }
|
||||||
|
.kpi-strip { display: none !important; }
|
||||||
|
.add-bar { display: none !important; }
|
||||||
|
.footnote { display: none !important; }
|
||||||
|
.table-toolbar { display: none !important; }
|
||||||
|
|
||||||
|
/* Hide desktop search card on mobile (mobile has .m-search-input instead) */
|
||||||
|
.card-section { display: none; }
|
||||||
|
|
||||||
|
/* ── Mobile course search input ─────────────────── */
|
||||||
|
|
||||||
|
.m-search-input {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 38px;
|
||||||
|
padding: 0 12px;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
border-radius: 10px;
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--ink);
|
||||||
|
outline: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transition: border-color 150ms ease, box-shadow 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-search-input::placeholder {
|
||||||
|
color: var(--ink-3);
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-search-input:focus {
|
||||||
|
border-color: var(--accent);
|
||||||
|
box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide desktop table but keep .table-card as wrapper */
|
||||||
|
.table-card > #ratings-table table,
|
||||||
|
#ratings-table table,
|
||||||
|
#courses-table table {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Container ──────────────────────────────────── */
|
||||||
|
|
||||||
|
.container {
|
||||||
|
--m-container-pad-bottom: 80px;
|
||||||
|
padding: 10px 12px var(--m-container-pad-bottom);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Topbar mobile ──────────────────────────────── */
|
||||||
|
|
||||||
|
.topbar__mobile {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-row1 {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px 16px 8px;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-brand {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-mark {
|
||||||
|
width: 26px;
|
||||||
|
height: 26px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 70%, black));
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #fff;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-mark svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-brand-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
line-height: 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-sub {
|
||||||
|
font-size: 9.5px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-refresh {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
background: var(--paper);
|
||||||
|
color: var(--ink);
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
transition: background 120ms ease, border-color 120ms ease;
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-refresh:hover:not(:disabled) {
|
||||||
|
background: var(--hover);
|
||||||
|
border-color: color-mix(in oklab, var(--line) 60%, var(--ink-3));
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-refresh:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-refresh .topbar__refresh-spinner {
|
||||||
|
display: none;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
border: 2px solid var(--line);
|
||||||
|
border-top-color: var(--accent);
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: topbar-spin 0.7s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-refresh.htmx-request .topbar__refresh-spinner {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-refresh.htmx-request .topbar__refresh-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-row2 {
|
||||||
|
padding: 0 16px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-nav {
|
||||||
|
display: flex;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 4px;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-nav a {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 1;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: 7px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ink-2);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: color 120ms ease, background 120ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-nav a:hover {
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.topbar__mobile-nav a.active {
|
||||||
|
background: var(--paper);
|
||||||
|
color: var(--ink);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Mobile section head ────────────────────────── */
|
||||||
|
|
||||||
|
.mobile-section-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 6px 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pill-button for "Trend chart" toggle in mobile section head */
|
||||||
|
.pill-button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
background: var(--paper-2);
|
||||||
|
color: var(--ink-2);
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pill-button:hover {
|
||||||
|
background: var(--hover);
|
||||||
|
border-color: var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pill-button[aria-pressed="true"] {
|
||||||
|
background: color-mix(in oklab, var(--accent) 10%, white);
|
||||||
|
border-color: color-mix(in oklab, var(--accent) 35%, var(--line-2));
|
||||||
|
color: var(--accent-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Mobile list wrapper ────────────────────────── */
|
||||||
|
|
||||||
|
.mobile-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
padding-bottom: 90px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Player card ────────────────────────────────── */
|
||||||
|
|
||||||
|
.m-card {
|
||||||
|
background: var(--paper);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 12px;
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 120ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card:hover {
|
||||||
|
background: var(--hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card__head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-rank-chip {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ink-3);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-rank-chip--first {
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--accent-text);
|
||||||
|
border-color: color-mix(in oklab, var(--accent) 25%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card__name-stack {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1px;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-player-name {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ink);
|
||||||
|
letter-spacing: -0.005em;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-pdga-num {
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-chevron {
|
||||||
|
color: var(--ink-3);
|
||||||
|
font-size: 14px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transition: transform 180ms ease;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card.is-open .m-chevron {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Refresh button: hidden by default, revealed only when the card is open.
|
||||||
|
Larger than the desktop icon to give a comfortable touch target (≥44px). */
|
||||||
|
.m-card__head .m-refresh-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card.is-open .m-card__head .m-refresh-icon {
|
||||||
|
display: grid;
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
margin-left: 0;
|
||||||
|
font-size: 15px;
|
||||||
|
opacity: 0.7;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card.is-open .m-card__head .m-refresh-icon:active {
|
||||||
|
opacity: 1;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Spin only the icon glyph, not the 44px button box — otherwise the button's
|
||||||
|
lingering touch-hover frame (background + border) rotates too, which looks odd. */
|
||||||
|
.m-card.is-open .m-card__head .m-refresh-icon.spinning {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card.is-open .m-card__head .m-refresh-icon.spinning i {
|
||||||
|
display: inline-block;
|
||||||
|
animation: spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card__body {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card__stats {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-stat-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-stat-label {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--ink-3);
|
||||||
|
width: 62px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-num {
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-feature-settings: "tnum", "zero";
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ink);
|
||||||
|
letter-spacing: -0.02em;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-num--predicted {
|
||||||
|
color: var(--ink-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Override delta-pill size inside mobile cards */
|
||||||
|
.m-card .delta-pill {
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 2px 7px 2px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card__sparkline {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-chart-spark {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Player card expand panel ───────────────────── */
|
||||||
|
|
||||||
|
.m-card__expand {
|
||||||
|
display: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
border-top: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-card.is-open .m-card__expand {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-chart {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 480px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-detail-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
margin: 10px 0 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-detail-grid > div {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 6px 0;
|
||||||
|
border-bottom: 1px dashed var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-detail-grid > div:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-detail-grid dt {
|
||||||
|
color: var(--ink-2);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 400;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-detail-grid dd {
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-feature-settings: "tnum", "zero";
|
||||||
|
margin: 0;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Courses mobile tab pill ────────────────────── */
|
||||||
|
|
||||||
|
.m-tab-pill {
|
||||||
|
display: flex;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 4px;
|
||||||
|
gap: 2px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-tab-pill__btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 1;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: 7px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
color: var(--ink-2);
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 120ms ease, background 120ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-tab-pill__btn--active {
|
||||||
|
background: var(--paper);
|
||||||
|
color: var(--ink);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-tab-pill__btn--disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Course card ────────────────────────────────── */
|
||||||
|
|
||||||
|
.m-course-card {
|
||||||
|
background: var(--paper);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 12px;
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 120ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-card:hover {
|
||||||
|
background: var(--hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-card__head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-card__name-stack {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-name-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-name {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--ink);
|
||||||
|
letter-spacing: -0.005em;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-layouts-pill {
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 2px 7px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
color: var(--ink-3);
|
||||||
|
white-space: nowrap;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-card__meta {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--ink-3);
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-card__expand {
|
||||||
|
display: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
border-top: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-card.is-open .m-course-card__expand {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-course-card.is-open .m-chevron {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Sticky mobile add-bar ──────────────────────── */
|
||||||
|
|
||||||
|
.mobile-add-bar {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) 12px;
|
||||||
|
background: color-mix(in oklab, var(--paper) 88%, transparent);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10px);
|
||||||
|
border-top: 1px solid var(--line);
|
||||||
|
position: sticky;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 10;
|
||||||
|
/* Negative margin to break out of container padding */
|
||||||
|
margin-left: -12px;
|
||||||
|
margin-right: -12px;
|
||||||
|
margin-bottom: calc(-1 * var(--m-container-pad-bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-add-bar input {
|
||||||
|
flex: 1;
|
||||||
|
height: 38px;
|
||||||
|
background: var(--paper-2);
|
||||||
|
border: 1px solid var(--line-2);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 0 14px;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--ink);
|
||||||
|
font-feature-settings: "tnum";
|
||||||
|
outline: none;
|
||||||
|
transition: border-color 150ms ease, box-shadow 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-add-bar input::placeholder {
|
||||||
|
color: var(--ink-3);
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-add-bar input:focus {
|
||||||
|
border-color: var(--accent);
|
||||||
|
box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-add-bar .btn-primary {
|
||||||
|
height: 38px;
|
||||||
|
padding: 0 18px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Table-card: remove overflow:hidden on mobile ─ */
|
||||||
|
/* so sticky add-bar can extend to bottom */
|
||||||
|
.table-card {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* end @media (max-width: 880px) */
|
||||||
@@ -10,16 +10,6 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.mobile-only {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.player-name {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Rating values ────────────────────────────── */
|
/* ── Rating values ────────────────────────────── */
|
||||||
|
|
||||||
.rating-value {
|
.rating-value {
|
||||||
@@ -104,100 +94,6 @@
|
|||||||
box-shadow: var(--shadow-lg);
|
box-shadow: var(--shadow-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Tooltips ─────────────────────────────────── */
|
|
||||||
|
|
||||||
.std-dev-tooltip {
|
|
||||||
position: absolute;
|
|
||||||
background: var(--navy-900);
|
|
||||||
color: var(--text-inverse);
|
|
||||||
padding: 6px 10px;
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
font-size: 12px;
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 10000;
|
|
||||||
display: none;
|
|
||||||
white-space: nowrap;
|
|
||||||
box-shadow: var(--shadow-lg);
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Debug Icon ───────────────────────────────── */
|
|
||||||
|
|
||||||
.debug-icon:hover {
|
|
||||||
opacity: 1 !important;
|
|
||||||
color: var(--accent) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Debug Modal ──────────────────────────────── */
|
|
||||||
|
|
||||||
.debug-modal {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: rgba(15, 23, 42, 0.5);
|
|
||||||
backdrop-filter: blur(4px);
|
|
||||||
z-index: 10001;
|
|
||||||
display: none;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.debug-content {
|
|
||||||
background: var(--surface-1);
|
|
||||||
border-radius: var(--radius-lg);
|
|
||||||
padding: 24px;
|
|
||||||
max-width: 640px;
|
|
||||||
width: 90%;
|
|
||||||
max-height: 80vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
box-shadow: var(--shadow-overlay);
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.debug-header {
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 16px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
padding-bottom: 12px;
|
|
||||||
border-bottom: 1px solid var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.debug-log {
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
background: var(--surface-2);
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
padding: 16px;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.6;
|
|
||||||
white-space: pre-line;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.debug-close {
|
|
||||||
position: absolute;
|
|
||||||
top: 12px;
|
|
||||||
right: 16px;
|
|
||||||
font-size: 22px;
|
|
||||||
color: var(--text-muted);
|
|
||||||
cursor: pointer;
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
padding: 4px;
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
transition: color var(--transition), background var(--transition);
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.debug-close:hover {
|
|
||||||
color: var(--text-primary);
|
|
||||||
background: var(--surface-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Add Player Modal ─────────────────────────── */
|
/* ── Add Player Modal ─────────────────────────── */
|
||||||
|
|
||||||
.modal {
|
.modal {
|
||||||
@@ -286,19 +182,6 @@
|
|||||||
background: #059669;
|
background: #059669;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Responsive ───────────────────────────────── */
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.chart-container {
|
|
||||||
height: 250px;
|
|
||||||
margin: 5px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chart-title {
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Target Rating Calculator ─────────────────── */
|
/* ── Target Rating Calculator ─────────────────── */
|
||||||
|
|
||||||
.target-rating-icon {
|
.target-rating-icon {
|
||||||
|
|||||||
+8
-34
@@ -34,6 +34,11 @@
|
|||||||
--font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
|
--font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
|
||||||
--font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
--font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
||||||
|
|
||||||
|
/* ── Rating tier tokens ───────────────────────── */
|
||||||
|
--rating-tier-high: oklch(0.55 0.15 150);
|
||||||
|
--rating-tier-mid: oklch(0.55 0.12 100);
|
||||||
|
--rating-tier-low: oklch(0.55 0.10 50);
|
||||||
|
|
||||||
/* legacy token aliases — remove as components migrate */
|
/* legacy token aliases — remove as components migrate */
|
||||||
--surface-0: var(--bg);
|
--surface-0: var(--bg);
|
||||||
--surface-1: var(--paper);
|
--surface-1: var(--paper);
|
||||||
@@ -708,21 +713,7 @@ a:hover {
|
|||||||
transform: translateY(1px);
|
transform: translateY(1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
/* add-bar responsive handled by mobile.css (≤880px hides it entirely) */
|
||||||
.add-bar {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.add-bar-controls {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-wrap {
|
|
||||||
flex: 1;
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Inputs ───────────────────────────────────── */
|
/* ── Inputs ───────────────────────────────────── */
|
||||||
|
|
||||||
@@ -778,26 +769,9 @@ a:hover {
|
|||||||
|
|
||||||
/* ── Responsive ───────────────────────────────── */
|
/* ── Responsive ───────────────────────────────── */
|
||||||
|
|
||||||
|
/* Responsive table/container tweaks handled by mobile.css (≤880px) */
|
||||||
|
|
||||||
@media (max-width: 880px) {
|
@media (max-width: 880px) {
|
||||||
.container {
|
|
||||||
padding: 18px 16px 40px;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
th, td {
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.col-rank { width: 40px; }
|
|
||||||
.col-actions { width: 40px; }
|
|
||||||
.col-predicted { display: none; }
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.mobile-hide {
|
.mobile-hide {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-9
@@ -1,4 +1,5 @@
|
|||||||
function createRatingChart(container, history) {
|
function createRatingChart(container, history, opts) {
|
||||||
|
opts = opts || {};
|
||||||
if (!history || history.length === 0) {
|
if (!history || history.length === 0) {
|
||||||
container.textContent = '';
|
container.textContent = '';
|
||||||
var empty = document.createElement('div');
|
var empty = document.createElement('div');
|
||||||
@@ -8,8 +9,13 @@ function createRatingChart(container, history) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var W = 880, H = 240;
|
var W = opts.w || 880;
|
||||||
var pad = { left: 44, right: 16, top: 20, bottom: 32 };
|
var H = opts.h || 240;
|
||||||
|
var pad = opts.padding || { left: 44, right: 16, top: 20, bottom: 32 };
|
||||||
|
var tickCount = opts.tickCount !== undefined ? opts.tickCount : 4;
|
||||||
|
var xLabelCount = opts.xLabelCount !== undefined ? opts.xLabelCount : 5;
|
||||||
|
var dotR = opts.dotR !== undefined ? opts.dotR : 3;
|
||||||
|
var lastDotR = opts.lastDotR !== undefined ? opts.lastDotR : 4;
|
||||||
var chartW = W - pad.left - pad.right;
|
var chartW = W - pad.left - pad.right;
|
||||||
var chartH = H - pad.top - pad.bottom;
|
var chartH = H - pad.top - pad.bottom;
|
||||||
|
|
||||||
@@ -61,8 +67,7 @@ function createRatingChart(container, history) {
|
|||||||
'aria-hidden': 'true'
|
'aria-hidden': 'true'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Grid lines + y-axis labels (4 ticks)
|
// Grid lines + y-axis labels
|
||||||
var tickCount = 4;
|
|
||||||
for (var i = 0; i <= tickCount; i++) {
|
for (var i = 0; i <= tickCount; i++) {
|
||||||
var gy = pad.top + (i / tickCount) * chartH;
|
var gy = pad.top + (i / tickCount) * chartH;
|
||||||
var gr = Math.round(maxR - (i / tickCount) * range);
|
var gr = Math.round(maxR - (i / tickCount) * range);
|
||||||
@@ -96,18 +101,18 @@ function createRatingChart(container, history) {
|
|||||||
if (isLast) {
|
if (isLast) {
|
||||||
svg.appendChild(el('circle', {
|
svg.appendChild(el('circle', {
|
||||||
cx: p.x.toFixed(1), cy: p.y.toFixed(1),
|
cx: p.x.toFixed(1), cy: p.y.toFixed(1),
|
||||||
r: '4', fill: 'var(--accent)', stroke: 'var(--paper)', 'stroke-width': '2'
|
r: String(lastDotR), fill: 'var(--accent)', stroke: 'var(--paper)', 'stroke-width': '2'
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
svg.appendChild(el('circle', {
|
svg.appendChild(el('circle', {
|
||||||
cx: p.x.toFixed(1), cy: p.y.toFixed(1),
|
cx: p.x.toFixed(1), cy: p.y.toFixed(1),
|
||||||
r: '3', fill: 'var(--accent)'
|
r: String(dotR), fill: 'var(--accent)'
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// X-axis labels (5 evenly spaced)
|
// X-axis labels (evenly spaced)
|
||||||
var labelCount = Math.min(5, history.length);
|
var labelCount = Math.min(xLabelCount, history.length);
|
||||||
var labelIndices = [];
|
var labelIndices = [];
|
||||||
if (labelCount <= 1) {
|
if (labelCount <= 1) {
|
||||||
labelIndices.push(0);
|
labelIndices.push(0);
|
||||||
|
|||||||
+295
-42
@@ -1,39 +1,155 @@
|
|||||||
function toggleAccordion(accordionId) {
|
// ── Tab switching ──────────────────────────────────
|
||||||
const content = document.getElementById(accordionId);
|
function initCourseTabs() {
|
||||||
const icon = document.getElementById(`${accordionId}-icon`);
|
const tabs = document.querySelectorAll('.action-tab');
|
||||||
|
tabs.forEach(function(tab) {
|
||||||
|
tab.addEventListener('click', function() {
|
||||||
|
tabs.forEach(function(t) {
|
||||||
|
t.classList.remove('is-active');
|
||||||
|
t.setAttribute('aria-selected', 'false');
|
||||||
|
});
|
||||||
|
tab.classList.add('is-active');
|
||||||
|
tab.setAttribute('aria-selected', 'true');
|
||||||
|
|
||||||
if (content.classList.contains('expanded')) {
|
document.querySelectorAll('.action-pane').forEach(function(pane) {
|
||||||
content.classList.remove('expanded');
|
pane.hidden = true;
|
||||||
icon.classList.remove('expanded');
|
pane.classList.remove('is-active');
|
||||||
} else {
|
});
|
||||||
content.classList.add('expanded');
|
|
||||||
icon.classList.add('expanded');
|
const targetId = 'tab-pane-' + tab.dataset.tab;
|
||||||
}
|
const pane = document.getElementById(targetId);
|
||||||
|
if (pane) {
|
||||||
|
pane.hidden = false;
|
||||||
|
pane.classList.add('is-active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Live filter ────────────────────────────────────
|
||||||
|
function initCourseLiveFilter() {
|
||||||
|
const input = document.getElementById('course-filter-input');
|
||||||
|
if (!input) return;
|
||||||
|
|
||||||
|
input.addEventListener('input', function() {
|
||||||
|
const q = input.value.toLowerCase().trim();
|
||||||
|
const rows = document.querySelectorAll('.course-row');
|
||||||
|
let visible = 0;
|
||||||
|
|
||||||
|
rows.forEach(function(row) {
|
||||||
|
const name = row.dataset.courseName || '';
|
||||||
|
const city = row.dataset.courseCity || '';
|
||||||
|
const match = !q || name.includes(q) || city.includes(q);
|
||||||
|
|
||||||
|
row.hidden = !match;
|
||||||
|
|
||||||
|
// Keep the expanded content sibling in sync
|
||||||
|
const next = row.nextElementSibling;
|
||||||
|
if (next && next.classList.contains('expanded-content')) {
|
||||||
|
next.hidden = !match;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match) visible++;
|
||||||
|
});
|
||||||
|
|
||||||
|
const visibleEl = document.getElementById('visible-count');
|
||||||
|
if (visibleEl) visibleEl.textContent = visible;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Count display ──────────────────────────────────
|
||||||
|
function initCourseCounts() {
|
||||||
|
const grid = document.querySelector('.course-grid');
|
||||||
|
const total = grid ? parseInt(grid.dataset.totalCount || '0', 10) : 0;
|
||||||
|
const rows = document.querySelectorAll('.course-row');
|
||||||
|
let visible = 0;
|
||||||
|
rows.forEach(function(r) { if (!r.hidden) visible++; });
|
||||||
|
|
||||||
|
const totalEl = document.getElementById('total-count');
|
||||||
|
const visibleEl = document.getElementById('visible-count');
|
||||||
|
if (totalEl) totalEl.textContent = total;
|
||||||
|
if (visibleEl) visibleEl.textContent = visible || total;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Course row expand/collapse ─────────────────────
|
||||||
function toggleCourseLayouts(courseId) {
|
function toggleCourseLayouts(courseId) {
|
||||||
const layoutsRow = document.getElementById(`layouts-${courseId}`);
|
const row = document.querySelector('.course-row[data-course-id="' + courseId + '"]');
|
||||||
const layoutsContainer = document.getElementById(`layouts-container-${courseId}`);
|
const content = document.getElementById('course-layouts-' + courseId);
|
||||||
|
if (!row || !content) return;
|
||||||
|
|
||||||
if (layoutsRow.style.display === 'table-row') {
|
const isOpen = content.classList.contains('is-open');
|
||||||
layoutsRow.style.display = 'none';
|
|
||||||
return;
|
if (isOpen) {
|
||||||
|
content.classList.remove('is-open');
|
||||||
|
row.classList.remove('row-open');
|
||||||
|
} else {
|
||||||
|
content.classList.add('is-open');
|
||||||
|
row.classList.add('row-open');
|
||||||
|
|
||||||
|
// Lazy-load layouts on first expand
|
||||||
|
const cell = content.querySelector('.expanded-cell');
|
||||||
|
if (cell && cell.dataset.loaded !== 'true') {
|
||||||
|
cell.dataset.loaded = 'true';
|
||||||
|
htmx.ajax('GET', '/partials/course-layouts/' + courseId, { target: cell, swap: 'innerHTML' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutsRow.style.display = 'table-row';
|
|
||||||
|
|
||||||
if (layoutsContainer.dataset.loaded === 'true') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
htmx.ajax('GET', `/partials/course-layouts/${courseId}`, {target: `#layouts-container-${courseId}`, swap: 'innerHTML'});
|
|
||||||
layoutsContainer.dataset.loaded = 'true';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Mobile course card toggle ──────────────────────
|
||||||
|
let openMobileCourseId = null;
|
||||||
|
|
||||||
|
function toggleMobileCourseLayouts(courseId) {
|
||||||
|
const card = document.getElementById('m-course-' + courseId);
|
||||||
|
if (!card) return;
|
||||||
|
|
||||||
|
const isOpen = card.classList.contains('is-open');
|
||||||
|
|
||||||
|
// Close previously open card
|
||||||
|
if (openMobileCourseId !== null && openMobileCourseId !== courseId) {
|
||||||
|
const prevCard = document.getElementById('m-course-' + openMobileCourseId);
|
||||||
|
if (prevCard) {
|
||||||
|
prevCard.classList.remove('is-open');
|
||||||
|
prevCard.setAttribute('aria-expanded', 'false');
|
||||||
|
}
|
||||||
|
openMobileCourseId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
card.classList.remove('is-open');
|
||||||
|
card.setAttribute('aria-expanded', 'false');
|
||||||
|
openMobileCourseId = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
card.classList.add('is-open');
|
||||||
|
card.setAttribute('aria-expanded', 'true');
|
||||||
|
openMobileCourseId = courseId;
|
||||||
|
|
||||||
|
// Lazy-load layouts on first expand
|
||||||
|
const container = document.getElementById('m-layouts-container-' + courseId);
|
||||||
|
if (container && container.dataset.loaded !== 'true') {
|
||||||
|
htmx.ajax('GET', '/partials/course-layouts/' + courseId, { target: '#m-layouts-container-' + courseId, swap: 'innerHTML' });
|
||||||
|
container.dataset.loaded = 'true';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Inactive layouts toggle ────────────────────────
|
||||||
|
function toggleInactiveLayouts(btn) {
|
||||||
|
const body = btn.nextElementSibling;
|
||||||
|
if (!body) return;
|
||||||
|
|
||||||
|
const isOpen = btn.classList.contains('is-open');
|
||||||
|
btn.classList.toggle('is-open', !isOpen);
|
||||||
|
btn.setAttribute('aria-expanded', String(!isOpen));
|
||||||
|
body.hidden = isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Scrape courses ─────────────────────────────────
|
||||||
async function scrapeCourses() {
|
async function scrapeCourses() {
|
||||||
const btn = document.getElementById('scrape-courses-btn');
|
const btn = document.getElementById('scrape-courses-btn');
|
||||||
btn.disabled = true;
|
if (btn) {
|
||||||
btn.textContent = 'Scraping...';
|
btn.disabled = true;
|
||||||
|
btn.textContent = 'Scraping...';
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/scrape-courses', { method: 'POST' });
|
const response = await fetch('/api/scrape-courses', { method: 'POST' });
|
||||||
@@ -41,7 +157,7 @@ async function scrapeCourses() {
|
|||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
alert(data.message);
|
alert(data.message);
|
||||||
htmx.ajax('GET', '/partials/course-table', '#courses-table');
|
htmx.trigger(document.body, 'refresh');
|
||||||
} else {
|
} else {
|
||||||
alert('Failed to scrape courses');
|
alert('Failed to scrape courses');
|
||||||
}
|
}
|
||||||
@@ -49,31 +165,33 @@ async function scrapeCourses() {
|
|||||||
console.error('Error scraping courses:', error);
|
console.error('Error scraping courses:', error);
|
||||||
alert('Error scraping courses');
|
alert('Error scraping courses');
|
||||||
} finally {
|
} finally {
|
||||||
btn.disabled = false;
|
if (btn) {
|
||||||
btn.textContent = 'Scrape Courses';
|
btn.disabled = false;
|
||||||
|
btn.textContent = 'Scrape Courses';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function scrapeLayouts(courseId, courseName) {
|
// ── Scrape layouts for a course ────────────────────
|
||||||
const icon = document.querySelector(`#row-${courseId} .refresh-icon`);
|
async function scrapeLayouts(courseId, btn) {
|
||||||
icon.classList.add('spinning');
|
if (btn) btn.classList.add('spinning');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/scrape-layouts/${courseId}`, { method: 'POST' });
|
const response = await fetch('/api/scrape-layouts/' + courseId, { method: 'POST' });
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (response.status === 409) {
|
if (response.status === 409) {
|
||||||
alert(data.message || 'Scrape already in progress for this course. Please wait.');
|
alert(data.message || 'Scrape already in progress for this course. Please wait.');
|
||||||
} else if (data.success) {
|
} else if (data.success) {
|
||||||
const layoutsContainer = document.getElementById(`layouts-container-${courseId}`);
|
// Reload expanded layout content if currently open
|
||||||
layoutsContainer.dataset.loaded = 'false';
|
const content = document.getElementById('course-layouts-' + courseId);
|
||||||
|
if (content && content.classList.contains('is-open')) {
|
||||||
const layoutsRow = document.getElementById(`layouts-${courseId}`);
|
const cell = content.querySelector('.expanded-cell');
|
||||||
if (layoutsRow.style.display === 'table-row') {
|
if (cell) {
|
||||||
htmx.ajax('GET', `/partials/course-layouts/${courseId}`, {target: `#layouts-container-${courseId}`, swap: 'innerHTML'});
|
cell.dataset.loaded = 'true';
|
||||||
layoutsContainer.dataset.loaded = 'true';
|
htmx.ajax('GET', '/partials/course-layouts/' + courseId, { target: cell, swap: 'innerHTML' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alert(data.message);
|
alert(data.message);
|
||||||
} else {
|
} else {
|
||||||
alert('Failed to scrape layouts');
|
alert('Failed to scrape layouts');
|
||||||
@@ -82,6 +200,141 @@ async function scrapeLayouts(courseId, courseName) {
|
|||||||
console.error('Error scraping layouts:', error);
|
console.error('Error scraping layouts:', error);
|
||||||
alert('Error scraping layouts');
|
alert('Error scraping layouts');
|
||||||
} finally {
|
} finally {
|
||||||
icon.classList.remove('spinning');
|
if (btn) btn.classList.remove('spinning');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Tjing search ───────────────────────────────────
|
||||||
|
async function searchTjing() {
|
||||||
|
const input = document.getElementById('tjing-search-input');
|
||||||
|
const btn = document.getElementById('tjing-search-btn');
|
||||||
|
const container = document.getElementById('tjing-results');
|
||||||
|
if (!input || !container) return;
|
||||||
|
|
||||||
|
const q = input.value.trim();
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
btn.disabled = true;
|
||||||
|
|
||||||
|
// Clear previous results safely
|
||||||
|
while (container.firstChild) {
|
||||||
|
container.removeChild(container.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/tjing/search?q=' + encodeURIComponent(q));
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = await response.json();
|
||||||
|
} catch (e) {
|
||||||
|
const errP = document.createElement('p');
|
||||||
|
errP.className = 'tjing-error';
|
||||||
|
errP.textContent = 'Invalid response from server.';
|
||||||
|
container.appendChild(errP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.ok || data.error) {
|
||||||
|
const errP2 = document.createElement('p');
|
||||||
|
errP2.className = 'tjing-error';
|
||||||
|
errP2.textContent = 'Error: ' + (data.error || 'Search failed');
|
||||||
|
container.appendChild(errP2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const results = data.results || [];
|
||||||
|
if (results.length === 0) {
|
||||||
|
const noResults = document.createElement('p');
|
||||||
|
noResults.className = 'tjing-error';
|
||||||
|
noResults.textContent = 'No courses found on Tjing.';
|
||||||
|
container.appendChild(noResults);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
results.forEach(function(course) {
|
||||||
|
const item = document.createElement('div');
|
||||||
|
item.className = 'tjing-result';
|
||||||
|
|
||||||
|
const info = document.createElement('div');
|
||||||
|
info.className = 'tjing-result-info';
|
||||||
|
|
||||||
|
const nameSpan = document.createElement('span');
|
||||||
|
nameSpan.className = 'tjing-result-name';
|
||||||
|
nameSpan.textContent = course.name || '';
|
||||||
|
|
||||||
|
const addrSpan = document.createElement('span');
|
||||||
|
addrSpan.className = 'tjing-result-address';
|
||||||
|
addrSpan.textContent = course.address || '';
|
||||||
|
|
||||||
|
info.appendChild(nameSpan);
|
||||||
|
info.appendChild(addrSpan);
|
||||||
|
|
||||||
|
const importBtn = document.createElement('button');
|
||||||
|
importBtn.className = 'btn-pill';
|
||||||
|
importBtn.textContent = 'Import';
|
||||||
|
(function(id, b) {
|
||||||
|
b.addEventListener('click', function() { importFromTjing(id, b); });
|
||||||
|
})(course.id, importBtn);
|
||||||
|
|
||||||
|
item.appendChild(info);
|
||||||
|
item.appendChild(importBtn);
|
||||||
|
container.appendChild(item);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error searching Tjing:', error);
|
||||||
|
const errFallback = document.createElement('p');
|
||||||
|
errFallback.className = 'tjing-error';
|
||||||
|
errFallback.textContent = 'Failed to search Tjing.';
|
||||||
|
container.appendChild(errFallback);
|
||||||
|
} finally {
|
||||||
|
btn.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Tjing import ───────────────────────────────────
|
||||||
|
async function importFromTjing(tjingId, btn) {
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.textContent = 'Importing…';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/tjing/import/' + encodeURIComponent(tjingId), { method: 'POST' });
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = await response.json();
|
||||||
|
} catch (e) {
|
||||||
|
btn.textContent = 'Error';
|
||||||
|
btn.disabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.ok || data.error) {
|
||||||
|
btn.textContent = 'Error: ' + (data.error || 'Import failed');
|
||||||
|
btn.disabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
btn.textContent = 'Imported ✓';
|
||||||
|
// Trigger table reload
|
||||||
|
htmx.trigger(document.body, 'refresh');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error importing from Tjing:', error);
|
||||||
|
btn.textContent = 'Failed';
|
||||||
|
btn.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Init ───────────────────────────────────────────
|
||||||
|
function initAll() {
|
||||||
|
initCourseTabs();
|
||||||
|
initCourseLiveFilter();
|
||||||
|
initCourseCounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', initAll);
|
||||||
|
|
||||||
|
document.addEventListener('htmx:afterSwap', function(evt) {
|
||||||
|
if (evt.detail && evt.detail.target && evt.detail.target.id === 'course-table-region') {
|
||||||
|
initCourseLiveFilter();
|
||||||
|
initCourseCounts();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
+124
-106
@@ -1,4 +1,3 @@
|
|||||||
const cachedDebugInfo = {};
|
|
||||||
let pendingPlayerData = null;
|
let pendingPlayerData = null;
|
||||||
let openPdgaNumber = null;
|
let openPdgaNumber = null;
|
||||||
|
|
||||||
@@ -32,7 +31,20 @@ function initChartsIn(rootEl) {
|
|||||||
if (!container.dataset.history) return;
|
if (!container.dataset.history) return;
|
||||||
try {
|
try {
|
||||||
const history = JSON.parse(container.dataset.history);
|
const history = JSON.parse(container.dataset.history);
|
||||||
createRatingChart(container, history);
|
const isMobile = container.dataset.variant === 'mobile';
|
||||||
|
if (isMobile) {
|
||||||
|
createRatingChart(container, history, {
|
||||||
|
w: 360,
|
||||||
|
h: 160,
|
||||||
|
padding: { left: 36, right: 12, top: 14, bottom: 24 },
|
||||||
|
tickCount: 3,
|
||||||
|
xLabelCount: 3,
|
||||||
|
dotR: 2,
|
||||||
|
lastDotR: 3
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createRatingChart(container, history);
|
||||||
|
}
|
||||||
container.dataset.charted = 'true';
|
container.dataset.charted = 'true';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error rendering chart:', e);
|
console.error('Error rendering chart:', e);
|
||||||
@@ -44,7 +56,6 @@ function setupAfterTableSwap() {
|
|||||||
document.body.addEventListener('htmx:afterSwap', function(event) {
|
document.body.addEventListener('htmx:afterSwap', function(event) {
|
||||||
const target = event.detail.target;
|
const target = event.detail.target;
|
||||||
if (target.id === 'ratings-table') {
|
if (target.id === 'ratings-table') {
|
||||||
initRatingsTooltips();
|
|
||||||
initChartsIn(target);
|
initChartsIn(target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -54,31 +65,6 @@ function setupAfterTableSwap() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initRatingsTooltips() {
|
|
||||||
document.querySelectorAll('.predicted-value').forEach(span => {
|
|
||||||
const pdgaNumber = span.dataset.pdga;
|
|
||||||
const stdDev = span.dataset.stddev;
|
|
||||||
const tooltip = document.getElementById(`tooltip-stddev-${pdgaNumber}`);
|
|
||||||
|
|
||||||
if (stdDev && tooltip) {
|
|
||||||
setupTooltip(span, tooltip, () => `Standard Deviation: \u00b1${stdDev}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelectorAll('.rating-value').forEach(span => {
|
|
||||||
const pdgaNumber = span.dataset.pdga;
|
|
||||||
const rating = parseInt(span.dataset.rating);
|
|
||||||
const stdDev = parseInt(span.dataset.stddev);
|
|
||||||
const tooltip = document.getElementById(`tooltip-rating-${pdgaNumber}`);
|
|
||||||
|
|
||||||
if (rating && stdDev && tooltip) {
|
|
||||||
const minRating = rating - stdDev;
|
|
||||||
const maxRating = rating + stdDev;
|
|
||||||
setupTooltip(span, tooltip, () => `Rating Range: ${minRating} - ${maxRating} (\u00b1${stdDev})`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function togglePlayerHistory(pdgaNumber) {
|
function togglePlayerHistory(pdgaNumber) {
|
||||||
const historyRow = document.getElementById('history-' + pdgaNumber);
|
const historyRow = document.getElementById('history-' + pdgaNumber);
|
||||||
const contentDiv = document.getElementById('history-content-' + pdgaNumber);
|
const contentDiv = document.getElementById('history-content-' + pdgaNumber);
|
||||||
@@ -145,10 +131,16 @@ async function clearCache() {
|
|||||||
// Refreshes both the current rating and the prediction in one click, then
|
// Refreshes both the current rating and the prediction in one click, then
|
||||||
// re-swaps the table so every derived value (deltas, pills, sparkline) reflects
|
// re-swaps the table so every derived value (deltas, pills, sparkline) reflects
|
||||||
// the new state. Cheaper than fine-grained DOM updates and guaranteed consistent
|
// the new state. Cheaper than fine-grained DOM updates and guaranteed consistent
|
||||||
// because the server renders the truth.
|
// because the server renders the truth. The mobile cards partial is included
|
||||||
|
// inside ratings-table, so swapping #ratings-table re-renders both views at once.
|
||||||
async function refreshPlayerData(pdgaNumber) {
|
async function refreshPlayerData(pdgaNumber) {
|
||||||
const icon = document.querySelector(`#row-${pdgaNumber} .cell-actions .refresh-icon`);
|
// The desktop row exists in the DOM even on mobile (hidden via CSS), so spin
|
||||||
if (icon) icon.classList.add('spinning');
|
// both possible icons; only the one visible in the active viewport is seen.
|
||||||
|
const icons = [
|
||||||
|
document.querySelector(`#row-${pdgaNumber} .cell-actions .refresh-icon`),
|
||||||
|
document.querySelector(`#m-card-${pdgaNumber} .m-refresh-icon`)
|
||||||
|
].filter(Boolean);
|
||||||
|
icons.forEach(icon => icon.classList.add('spinning'));
|
||||||
try {
|
try {
|
||||||
await Promise.allSettled([
|
await Promise.allSettled([
|
||||||
fetch(`/api/refresh-player/${pdgaNumber}`, { method: 'POST' }),
|
fetch(`/api/refresh-player/${pdgaNumber}`, { method: 'POST' }),
|
||||||
@@ -158,7 +150,7 @@ async function refreshPlayerData(pdgaNumber) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error refreshing player data:', error);
|
console.error('Error refreshing player data:', error);
|
||||||
} finally {
|
} finally {
|
||||||
if (icon) icon.classList.remove('spinning');
|
icons.forEach(icon => icon.classList.remove('spinning'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,16 +170,6 @@ async function refreshPlayer(pdgaNumber) {
|
|||||||
if (ratingValue) {
|
if (ratingValue) {
|
||||||
ratingValue.textContent = data.player.rating || 'N/A';
|
ratingValue.textContent = data.player.rating || 'N/A';
|
||||||
ratingValue.dataset.rating = data.player.rating || '';
|
ratingValue.dataset.rating = data.player.rating || '';
|
||||||
|
|
||||||
const stdDev = parseInt(ratingValue.dataset.stddev);
|
|
||||||
const rating = parseInt(data.player.rating);
|
|
||||||
const tooltip = document.getElementById(`tooltip-rating-${pdgaNumber}`);
|
|
||||||
|
|
||||||
if (rating && stdDev && tooltip) {
|
|
||||||
const minRating = rating - stdDev;
|
|
||||||
const maxRating = rating + stdDev;
|
|
||||||
replaceWithTooltip(ratingValue, tooltip, () => `Rating Range: ${minRating} - ${maxRating} (\u00b1${stdDev})`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const deltaMonthPill = ratingCell ? ratingCell.querySelector('.delta-pill') : null;
|
const deltaMonthPill = ratingCell ? ratingCell.querySelector('.delta-pill') : null;
|
||||||
@@ -209,21 +191,12 @@ async function refreshRoundHistory(pdgaNumber) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
if (data.debugLog) {
|
|
||||||
cachedDebugInfo[pdgaNumber] = data.debugLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
const predictedCell = document.getElementById(`predicted-${pdgaNumber}`);
|
const predictedCell = document.getElementById(`predicted-${pdgaNumber}`);
|
||||||
if (predictedCell) {
|
if (predictedCell) {
|
||||||
const predictedValue = predictedCell.querySelector('.predicted-value');
|
const predictedValue = predictedCell.querySelector('.predicted-value');
|
||||||
if (predictedValue) {
|
if (predictedValue) {
|
||||||
predictedValue.textContent = data.predictedRating || 'N/A';
|
predictedValue.textContent = data.predictedRating || 'N/A';
|
||||||
predictedValue.dataset.stddev = data.stdDev || '';
|
predictedValue.dataset.stddev = data.stdDev || '';
|
||||||
|
|
||||||
const tooltip = document.getElementById(`tooltip-stddev-${pdgaNumber}`);
|
|
||||||
if (data.stdDev && tooltip) {
|
|
||||||
replaceWithTooltip(predictedValue, tooltip, () => `Standard Deviation: \u00b1${data.stdDev}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,16 +205,6 @@ async function refreshRoundHistory(pdgaNumber) {
|
|||||||
const ratingValue = ratingCell ? ratingCell.querySelector('.rating-value') : null;
|
const ratingValue = ratingCell ? ratingCell.querySelector('.rating-value') : null;
|
||||||
if (ratingValue && data.stdDev) {
|
if (ratingValue && data.stdDev) {
|
||||||
ratingValue.dataset.stddev = data.stdDev;
|
ratingValue.dataset.stddev = data.stdDev;
|
||||||
|
|
||||||
const rating = parseInt(ratingValue.dataset.rating);
|
|
||||||
const stdDev = parseInt(data.stdDev);
|
|
||||||
const ratingTooltip = document.getElementById(`tooltip-rating-${pdgaNumber}`);
|
|
||||||
|
|
||||||
if (rating && stdDev && ratingTooltip) {
|
|
||||||
const minRating = rating - stdDev;
|
|
||||||
const maxRating = rating + stdDev;
|
|
||||||
replaceWithTooltip(ratingValue, ratingTooltip, () => `Rating Range: ${minRating} - ${maxRating} (\u00b1${stdDev})`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -272,43 +235,6 @@ async function refreshRatingHistory(pdgaNumber) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showDebugInfo(pdgaNumber) {
|
|
||||||
const modal = document.getElementById('debug-modal');
|
|
||||||
const header = document.getElementById('debug-header');
|
|
||||||
const log = document.getElementById('debug-log');
|
|
||||||
|
|
||||||
const playerNameElement = document.querySelector(`#row-${pdgaNumber} .player-name a`);
|
|
||||||
const playerName = playerNameElement ? playerNameElement.textContent : `PDGA #${pdgaNumber}`;
|
|
||||||
|
|
||||||
header.textContent = `Prediction Calculation Details - ${playerName}`;
|
|
||||||
log.textContent = 'Loading calculation details...';
|
|
||||||
modal.style.display = 'flex';
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (cachedDebugInfo[pdgaNumber]) {
|
|
||||||
log.textContent = cachedDebugInfo[pdgaNumber].join('\n');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(`/api/refresh-round-history/${pdgaNumber}`, { method: 'POST' });
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
if (data.success && data.debugLog) {
|
|
||||||
cachedDebugInfo[pdgaNumber] = data.debugLog;
|
|
||||||
log.textContent = data.debugLog.join('\n');
|
|
||||||
} else {
|
|
||||||
log.textContent = 'No debug information available. Try refreshing the prediction first.';
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching debug info:', error);
|
|
||||||
log.textContent = 'Error loading debug information. Please try again.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeDebugModal(event) {
|
|
||||||
document.getElementById('debug-modal').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
async function searchAndAddPlayer(event) {
|
async function searchAndAddPlayer(event) {
|
||||||
if (event) event.preventDefault();
|
if (event) event.preventDefault();
|
||||||
const input = document.getElementById('pdga-number-input');
|
const input = document.getElementById('pdga-number-input');
|
||||||
@@ -516,18 +442,34 @@ function closeAddPlayerModal(event) {
|
|||||||
|
|
||||||
// ── Sparkline toggle ───────────────────────────────
|
// ── Sparkline toggle ───────────────────────────────
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const btn = document.getElementById('trendchart-toggle');
|
const SPARKLINE_KEY = 'ratingtracker.sparklines';
|
||||||
if (!btn) return;
|
|
||||||
|
|
||||||
const state = localStorage.getItem('ratingtracker.sparklines') || 'on';
|
function syncSparklineButtons(state) {
|
||||||
|
const btns = document.querySelectorAll('#trendchart-toggle, #trendchart-toggle-mobile');
|
||||||
|
btns.forEach(function(b) {
|
||||||
|
b.setAttribute('aria-pressed', state === 'on' ? 'true' : 'false');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = localStorage.getItem(SPARKLINE_KEY) || 'on';
|
||||||
document.body.dataset.sparklines = state;
|
document.body.dataset.sparklines = state;
|
||||||
btn.setAttribute('aria-pressed', state === 'on' ? 'true' : 'false');
|
syncSparklineButtons(state);
|
||||||
|
|
||||||
btn.addEventListener('click', function() {
|
document.body.addEventListener('click', function(e) {
|
||||||
|
const target = e.target.closest('#trendchart-toggle, #trendchart-toggle-mobile');
|
||||||
|
if (!target) return;
|
||||||
const next = document.body.dataset.sparklines === 'on' ? 'off' : 'on';
|
const next = document.body.dataset.sparklines === 'on' ? 'off' : 'on';
|
||||||
document.body.dataset.sparklines = next;
|
document.body.dataset.sparklines = next;
|
||||||
btn.setAttribute('aria-pressed', next === 'on' ? 'true' : 'false');
|
localStorage.setItem(SPARKLINE_KEY, next);
|
||||||
localStorage.setItem('ratingtracker.sparklines', next);
|
syncSparklineButtons(next);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Re-sync after HTMX table swap (mobile button is inside the swapped partial)
|
||||||
|
document.body.addEventListener('htmx:afterSwap', function(event) {
|
||||||
|
const target = event.detail.target;
|
||||||
|
if (target.id === 'ratings-table') {
|
||||||
|
syncSparklineButtons(document.body.dataset.sparklines || 'on');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -734,7 +676,6 @@ async function refreshHistoryThenCalculate(pdgaNumber) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.debugLog) cachedDebugInfo[pdgaNumber] = data.debugLog;
|
|
||||||
const predictedCell = document.getElementById('predicted-' + pdgaNumber);
|
const predictedCell = document.getElementById('predicted-' + pdgaNumber);
|
||||||
if (predictedCell) {
|
if (predictedCell) {
|
||||||
const predictedValue = predictedCell.querySelector('.predicted-value');
|
const predictedValue = predictedCell.querySelector('.predicted-value');
|
||||||
@@ -751,3 +692,80 @@ async function refreshHistoryThenCalculate(pdgaNumber) {
|
|||||||
_targetResultMsg(result, 'error', 'Network error during refresh. Please try again.');
|
_targetResultMsg(result, 'error', 'Network error during refresh. Please try again.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Mobile player card toggle ──────────────────────
|
||||||
|
let openMobilePdgaNumber = null;
|
||||||
|
|
||||||
|
function toggleMobilePlayerCard(pdgaNumber) {
|
||||||
|
const card = document.getElementById('m-card-' + pdgaNumber);
|
||||||
|
if (!card) return;
|
||||||
|
|
||||||
|
const isOpen = card.classList.contains('is-open');
|
||||||
|
|
||||||
|
// Close previously open card
|
||||||
|
if (openMobilePdgaNumber !== null && openMobilePdgaNumber !== pdgaNumber) {
|
||||||
|
const prevCard = document.getElementById('m-card-' + openMobilePdgaNumber);
|
||||||
|
if (prevCard) {
|
||||||
|
prevCard.classList.remove('is-open');
|
||||||
|
prevCard.setAttribute('aria-expanded', 'false');
|
||||||
|
}
|
||||||
|
openMobilePdgaNumber = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
card.classList.remove('is-open');
|
||||||
|
card.setAttribute('aria-expanded', 'false');
|
||||||
|
openMobilePdgaNumber = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
card.classList.add('is-open');
|
||||||
|
card.setAttribute('aria-expanded', 'true');
|
||||||
|
openMobilePdgaNumber = pdgaNumber;
|
||||||
|
|
||||||
|
// Init charts inside the expand panel
|
||||||
|
const expand = card.querySelector('.m-card__expand');
|
||||||
|
if (expand) {
|
||||||
|
initChartsIn(expand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Mobile add player ──────────────────────────────
|
||||||
|
async function searchAndAddPlayerMobile(event) {
|
||||||
|
if (event) event.preventDefault();
|
||||||
|
const input = document.getElementById('pdga-number-input-mobile');
|
||||||
|
const pdgaNumber = input ? input.value.trim() : '';
|
||||||
|
|
||||||
|
if (!pdgaNumber) {
|
||||||
|
alert('Please enter a PDGA number');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const button = event && event.target ? event.target.querySelector('button[type="submit"]') : null;
|
||||||
|
if (button) { button.disabled = true; button.textContent = 'Searching...'; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/search-player/' + pdgaNumber);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
showErrorModal(data.error || 'Player not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.alreadyExists) {
|
||||||
|
showInfoModal(data.player.name + ' is already being tracked!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingPlayerData = data.player;
|
||||||
|
showConfirmationModal(data.player);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error searching for player:', error);
|
||||||
|
showErrorModal('Failed to search for player. Please try again.');
|
||||||
|
} finally {
|
||||||
|
if (button) { button.disabled = false; button.textContent = 'Add'; }
|
||||||
|
if (input) input.value = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ function initializeDatabase() {
|
|||||||
const hasLastRoundUpdate = columns.some(col => col.name === 'last_round_update');
|
const hasLastRoundUpdate = columns.some(col => col.name === 'last_round_update');
|
||||||
const hasPredictedRating = columns.some(col => col.name === 'predicted_rating');
|
const hasPredictedRating = columns.some(col => col.name === 'predicted_rating');
|
||||||
const hasStdDev = columns.some(col => col.name === 'std_dev');
|
const hasStdDev = columns.some(col => col.name === 'std_dev');
|
||||||
|
const hasExcludedRoundsCount = columns.some(col => col.name === 'excluded_rounds_count');
|
||||||
|
const hasCutoffRating = columns.some(col => col.name === 'cutoff_rating');
|
||||||
|
|
||||||
if (!hasLastRoundUpdate) {
|
if (!hasLastRoundUpdate) {
|
||||||
logger.info('Adding last_round_update column to players table...');
|
logger.info('Adding last_round_update column to players table...');
|
||||||
@@ -58,6 +60,32 @@ function initializeDatabase() {
|
|||||||
else logger.info('Successfully added std_dev column');
|
else logger.info('Successfully added std_dev column');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hasExcludedRoundsCount) {
|
||||||
|
logger.info('Adding excluded_rounds_count column to players table...');
|
||||||
|
db.run(`ALTER TABLE players ADD COLUMN excluded_rounds_count INTEGER DEFAULT NULL`, (err) => {
|
||||||
|
if (err) logger.error('Error adding excluded_rounds_count column:', err.message);
|
||||||
|
else logger.info('Successfully added excluded_rounds_count column');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasCutoffRating) {
|
||||||
|
logger.info('Adding cutoff_rating column to players table...');
|
||||||
|
db.run(`ALTER TABLE players ADD COLUMN cutoff_rating INTEGER DEFAULT NULL`, (err) => {
|
||||||
|
if (err) logger.error('Error adding cutoff_rating column:', err.message);
|
||||||
|
else logger.info('Successfully added cutoff_rating column');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasPredictedCalculatedAt = columns.some(col => col.name === 'predicted_calculated_at');
|
||||||
|
|
||||||
|
if (!hasPredictedCalculatedAt) {
|
||||||
|
logger.info('Adding predicted_calculated_at column to players table...');
|
||||||
|
db.run(`ALTER TABLE players ADD COLUMN predicted_calculated_at DATETIME DEFAULT NULL`, (err) => {
|
||||||
|
if (err) logger.error('Error adding predicted_calculated_at column:', err.message);
|
||||||
|
else logger.info('Successfully added predicted_calculated_at column');
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+31
-2
@@ -8,8 +8,14 @@ function saveCourseToDB(courseData) {
|
|||||||
ON CONFLICT(link) DO UPDATE SET name = excluded.name, city = excluded.city, last_updated = datetime('now')`,
|
ON CONFLICT(link) DO UPDATE SET name = excluded.name, city = excluded.city, last_updated = datetime('now')`,
|
||||||
[courseData.name, courseData.link, courseData.city],
|
[courseData.name, courseData.link, courseData.city],
|
||||||
function(err) {
|
function(err) {
|
||||||
if (err) reject(err);
|
if (err) return reject(err);
|
||||||
else resolve(this.lastID);
|
// node-sqlite3 leaves lastID = 0 when ON CONFLICT triggers an UPDATE.
|
||||||
|
// Fall back to a SELECT to get the real id in that case.
|
||||||
|
if (this.lastID !== 0) return resolve(this.lastID);
|
||||||
|
db.get('SELECT id FROM courses WHERE link = ?', [courseData.link], (err2, row) => {
|
||||||
|
if (err2) reject(err2);
|
||||||
|
else resolve(row ? row.id : 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -70,10 +76,33 @@ function updateLayoutRating(courseId, layoutName, par, meanRating, ratingCount,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOrCreateLayout(courseId, name, par) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
db.get(
|
||||||
|
'SELECT id FROM layouts WHERE course_id = ? AND name = ? AND par = ?',
|
||||||
|
[courseId, name, par],
|
||||||
|
(err, row) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
if (row) return resolve(row.id);
|
||||||
|
|
||||||
|
db.run(
|
||||||
|
'INSERT INTO layouts (course_id, name, par) VALUES (?, ?, ?)',
|
||||||
|
[courseId, name, par],
|
||||||
|
function(err) {
|
||||||
|
if (err) reject(err);
|
||||||
|
else resolve(this.lastID);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
saveCourseToDB,
|
saveCourseToDB,
|
||||||
getAllCoursesFromDB,
|
getAllCoursesFromDB,
|
||||||
saveLayoutToDB,
|
saveLayoutToDB,
|
||||||
getLayoutsForCourse,
|
getLayoutsForCourse,
|
||||||
|
getOrCreateLayout,
|
||||||
updateLayoutRating
|
updateLayoutRating
|
||||||
};
|
};
|
||||||
|
|||||||
+23
-7
@@ -17,12 +17,27 @@ function getPlayerFromDB(pdgaNumber) {
|
|||||||
function savePlayerToDB(playerData) {
|
function savePlayerToDB(playerData) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
db.run(
|
db.run(
|
||||||
`INSERT OR REPLACE INTO players (pdga_number, name, current_rating, rating_change, last_updated)
|
// UPSERT (not INSERT OR REPLACE): updating in place preserves columns not
|
||||||
VALUES (?, ?, ?, ?, datetime('now'))`,
|
// listed here — predicted_rating, std_dev, last_round_update,
|
||||||
|
// excluded_rounds_count, cutoff_rating. INSERT OR REPLACE would delete the
|
||||||
|
// existing row and reset those to their DEFAULT (NULL).
|
||||||
|
`INSERT INTO players (pdga_number, name, current_rating, rating_change, last_updated)
|
||||||
|
VALUES (?, ?, ?, ?, datetime('now'))
|
||||||
|
ON CONFLICT(pdga_number) DO UPDATE SET
|
||||||
|
name = excluded.name,
|
||||||
|
current_rating = excluded.current_rating,
|
||||||
|
rating_change = excluded.rating_change,
|
||||||
|
last_updated = excluded.last_updated`,
|
||||||
[playerData.pdgaNumber, playerData.name, playerData.rating, playerData.ratingChange],
|
[playerData.pdgaNumber, playerData.name, playerData.rating, playerData.ratingChange],
|
||||||
function(err) {
|
function(err) {
|
||||||
if (err) reject(err);
|
if (err) return reject(err);
|
||||||
else resolve(this.lastID);
|
// node-sqlite3 leaves lastID = 0 when ON CONFLICT triggers an UPDATE.
|
||||||
|
// Fall back to a SELECT to get the real id in that case.
|
||||||
|
if (this.lastID !== 0) return resolve(this.lastID);
|
||||||
|
db.get('SELECT id FROM players WHERE pdga_number = ?', [playerData.pdgaNumber], (err2, row) => {
|
||||||
|
if (err2) reject(err2);
|
||||||
|
else resolve(row ? row.id : 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -172,11 +187,12 @@ function saveRoundHistoryToDB(pdgaNumber, roundData, isIncremental = false) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function savePredictedRatingToDB(pdgaNumber, predictedRating, stdDev = null) {
|
function savePredictedRatingToDB(pdgaNumber, predictedRating, stdDev = null, excludedRoundsCount = null, cutoffRating = null, calculatedAt = null) {
|
||||||
|
const timestamp = calculatedAt || new Date().toISOString();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
db.run(
|
db.run(
|
||||||
'UPDATE players SET predicted_rating = ?, std_dev = ? WHERE pdga_number = ?',
|
'UPDATE players SET predicted_rating = ?, std_dev = ?, excluded_rounds_count = ?, cutoff_rating = ?, predicted_calculated_at = ? WHERE pdga_number = ?',
|
||||||
[predictedRating, stdDev, pdgaNumber],
|
[predictedRating, stdDev, excludedRoundsCount, cutoffRating, timestamp, pdgaNumber],
|
||||||
function(err) {
|
function(err) {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
else resolve();
|
else resolve();
|
||||||
|
|||||||
+76
-15
@@ -1,7 +1,8 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const { db } = require('../db');
|
const { db } = require('../db');
|
||||||
const { getAllCoursesFromDB, getLayoutsForCourse, updateLayoutRating } = require('../models/course');
|
const { getAllCoursesFromDB, getLayoutsForCourse, updateLayoutRating, saveCourseToDB, getOrCreateLayout } = require('../models/course');
|
||||||
|
const { searchTjingCourses, getTjingCourse } = require('../scrapers/tjing');
|
||||||
const { launchBrowser } = require('../scrapers/browser');
|
const { launchBrowser } = require('../scrapers/browser');
|
||||||
const { layoutEventCache, scrapeCourseDirectory, scrapeCourseLayouts, scrapeEventResults } = require('../scrapers/course-puppeteer');
|
const { layoutEventCache, scrapeCourseDirectory, scrapeCourseLayouts, scrapeEventResults } = require('../scrapers/course-puppeteer');
|
||||||
const logger = require('../logger');
|
const logger = require('../logger');
|
||||||
@@ -11,19 +12,30 @@ const activeScrapes = new Map();
|
|||||||
|
|
||||||
router.get('/partials/course-table', async (req, res) => {
|
router.get('/partials/course-table', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const allCourses = await getAllCoursesFromDB();
|
const oneYearAgo = new Date();
|
||||||
const query = req.query.q || '';
|
oneYearAgo.setDate(oneYearAgo.getDate() - 365);
|
||||||
let courses = allCourses;
|
const oneYearAgoStr = oneYearAgo.toISOString().slice(0, 10);
|
||||||
|
|
||||||
if (query) {
|
const allCourses = await new Promise((resolve, reject) => {
|
||||||
const q = query.toLowerCase();
|
db.all(
|
||||||
courses = allCourses.filter(c =>
|
`SELECT c.*,
|
||||||
c.name.toLowerCase().includes(q) || c.city.toLowerCase().includes(q)
|
COUNT(l.id) AS layoutCount,
|
||||||
|
SUM(CASE WHEN l.last_played >= ? THEN 1 ELSE 0 END) AS activeLayoutCount
|
||||||
|
FROM courses c
|
||||||
|
LEFT JOIN layouts l ON l.course_id = c.id
|
||||||
|
GROUP BY c.id
|
||||||
|
ORDER BY c.name ASC`,
|
||||||
|
[oneYearAgoStr],
|
||||||
|
(err, rows) => {
|
||||||
|
if (err) reject(err);
|
||||||
|
else resolve(rows);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
res.render('../partials/course-table', { courses, query, total: allCourses.length });
|
res.render('../partials/course-table', { courses: allCourses });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
logger.error({ err: error }, 'Error loading course table');
|
||||||
res.status(500).send('<p>Error loading courses. Please try again.</p>');
|
res.status(500).send('<p>Error loading courses. Please try again.</p>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -34,7 +46,7 @@ router.get('/partials/course-layouts/:courseId', async (req, res) => {
|
|||||||
const layouts = await getLayoutsForCourse(courseId);
|
const layouts = await getLayoutsForCourse(courseId);
|
||||||
res.render('../partials/course-layouts', { layouts, courseId });
|
res.render('../partials/course-layouts', { layouts, courseId });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error loading course layouts:', error.message);
|
logger.error({ err: error }, 'Error loading course layouts');
|
||||||
res.status(500).send('<div class="no-layouts">Error loading layouts</div>');
|
res.status(500).send('<div class="no-layouts">Error loading layouts</div>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -44,7 +56,7 @@ router.get('/api/courses', async (req, res) => {
|
|||||||
const courses = await getAllCoursesFromDB();
|
const courses = await getAllCoursesFromDB();
|
||||||
res.json(courses);
|
res.json(courses);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error fetching courses:', error.message);
|
logger.error({ err: error }, 'Error fetching courses');
|
||||||
res.status(500).json({ error: 'Failed to fetch courses' });
|
res.status(500).json({ error: 'Failed to fetch courses' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -55,7 +67,7 @@ router.get('/api/layouts/:courseId', async (req, res) => {
|
|||||||
const layouts = await getLayoutsForCourse(courseId);
|
const layouts = await getLayoutsForCourse(courseId);
|
||||||
res.json(layouts);
|
res.json(layouts);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error fetching layouts:', error.message);
|
logger.error({ err: error }, 'Error fetching layouts');
|
||||||
res.status(500).json({ error: 'Failed to fetch layouts' });
|
res.status(500).json({ error: 'Failed to fetch layouts' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -214,7 +226,7 @@ router.post('/api/scrape-layouts/:courseId', async (req, res) => {
|
|||||||
savedCount++;
|
savedCount++;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(` Error updating layout ${layoutDataResult.name}:`, err.message);
|
logger.error({ err, layoutName: layoutDataResult.name }, 'Error updating layout');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,7 +360,7 @@ router.post('/api/scrape-event-results/:courseId', async (req, res) => {
|
|||||||
savedCount++;
|
savedCount++;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(` Error updating layout ${ld.name}:`, err.message);
|
logger.error({ err, layoutName: ld.name }, 'Error updating layout');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,4 +381,53 @@ router.post('/api/scrape-event-results/:courseId', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Search Tjing for courses
|
||||||
|
router.get('/api/tjing/search', async (req, res) => {
|
||||||
|
const { q } = req.query;
|
||||||
|
if (!q || q.trim().length === 0) {
|
||||||
|
return res.json({ results: [] });
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await searchTjingCourses(q.trim());
|
||||||
|
if (result.error) {
|
||||||
|
logger.warn({ q, err: result.error }, 'Tjing search error');
|
||||||
|
return res.status(502).json({ error: result.error });
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ results: result.data });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Import a course from Tjing
|
||||||
|
router.post('/api/tjing/import/:tjingId', async (req, res) => {
|
||||||
|
const { tjingId } = req.params;
|
||||||
|
|
||||||
|
const result = await getTjingCourse(tjingId);
|
||||||
|
if (result.error) {
|
||||||
|
logger.warn({ tjingId, err: result.error }, 'Tjing import error');
|
||||||
|
return res.status(502).json({ error: result.error });
|
||||||
|
}
|
||||||
|
|
||||||
|
const courseData = result.data;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const courseId = await saveCourseToDB({
|
||||||
|
name: courseData.name,
|
||||||
|
link: `https://tjing.se/courses/${tjingId}`,
|
||||||
|
city: courseData.address || ''
|
||||||
|
});
|
||||||
|
|
||||||
|
let layoutsImported = 0;
|
||||||
|
for (const layout of courseData.layouts) {
|
||||||
|
await getOrCreateLayout(courseId, layout.name, layout.par);
|
||||||
|
layoutsImported++;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info({ courseId, name: courseData.name, layoutsImported }, 'Imported course from Tjing');
|
||||||
|
res.json({ courseId, layoutsImported });
|
||||||
|
} catch (err) {
|
||||||
|
logger.error({ err, tjingId }, 'Failed to save Tjing course to DB');
|
||||||
|
res.status(500).json({ error: 'Failed to save course to database' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ router.post('/api/refresh-round-history/:pdgaNumber', async (req, res) => {
|
|||||||
|
|
||||||
const result = calculatePredictedRating(roundsForPrediction);
|
const result = calculatePredictedRating(roundsForPrediction);
|
||||||
|
|
||||||
await savePredictedRatingToDB(pdgaNumber, result.rating, result.stdDev);
|
await savePredictedRatingToDB(pdgaNumber, result.rating, result.stdDev, result.excludedRoundsCount, result.cutoffRating);
|
||||||
|
|
||||||
const officialCount = allRounds.filter(r => r.source === 'official').length;
|
const officialCount = allRounds.filter(r => r.source === 'official').length;
|
||||||
const newCount = allRounds.filter(r => r.source === 'new').length;
|
const newCount = allRounds.filter(r => r.source === 'new').length;
|
||||||
@@ -409,7 +409,8 @@ router.post('/api/refresh-round-history/:pdgaNumber', async (req, res) => {
|
|||||||
success: true,
|
success: true,
|
||||||
predictedRating: result.rating,
|
predictedRating: result.rating,
|
||||||
stdDev: result.stdDev,
|
stdDev: result.stdDev,
|
||||||
debugLog: result.debugLog,
|
excludedRoundsCount: result.excludedRoundsCount,
|
||||||
|
cutoffRating: result.cutoffRating,
|
||||||
totalRounds: roundsForPrediction.length,
|
totalRounds: roundsForPrediction.length,
|
||||||
officialRounds: officialCount,
|
officialRounds: officialCount,
|
||||||
newRounds: newCount,
|
newRounds: newCount,
|
||||||
|
|||||||
@@ -156,13 +156,18 @@ async function getNewTournamentRounds(browser, pdgaNumber, afterDate) {
|
|||||||
|
|
||||||
logger.info(`Looking for tournaments after ${afterDate.toDateString()}...`);
|
logger.info(`Looking for tournaments after ${afterDate.toDateString()}...`);
|
||||||
|
|
||||||
const newTournamentUrls = await page.evaluate((afterTimestamp) => {
|
const { urls: newTournamentUrls, counts } = await page.evaluate((afterTimestamp) => {
|
||||||
const afterDate = new Date(afterTimestamp);
|
const afterDate = new Date(afterTimestamp);
|
||||||
const tables = document.querySelectorAll('table[id*="player-results"]');
|
const tables = document.querySelectorAll('table[id*="player-results"]');
|
||||||
const urls = [];
|
const urls = [];
|
||||||
|
const seenUrls = new Set();
|
||||||
|
let table = 0;
|
||||||
|
let recentEvents = 0;
|
||||||
|
let recentEventsAnchorsSeen = 0;
|
||||||
|
let recentEventsSkippedDuplicates = 0;
|
||||||
|
|
||||||
tables.forEach(table => {
|
tables.forEach(tbl => {
|
||||||
const rows = table.querySelectorAll('tbody tr');
|
const rows = tbl.querySelectorAll('tbody tr');
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
const dateCell = row.querySelector('.dates');
|
const dateCell = row.querySelector('.dates');
|
||||||
const tournamentCell = row.querySelector('.tournament a');
|
const tournamentCell = row.querySelector('.tournament a');
|
||||||
@@ -178,11 +183,17 @@ async function getNewTournamentRounds(browser, pdgaNumber, afterDate) {
|
|||||||
if (date > afterDate) {
|
if (date > afterDate) {
|
||||||
const href = tournamentCell.getAttribute('href');
|
const href = tournamentCell.getAttribute('href');
|
||||||
if (href) {
|
if (href) {
|
||||||
urls.push({
|
const absoluteUrl = new URL(href, location.origin).href;
|
||||||
url: `https://www.pdga.com${href}`,
|
if (!seenUrls.has(absoluteUrl)) {
|
||||||
date: dateStr,
|
seenUrls.add(absoluteUrl);
|
||||||
name: tournamentCell.innerText.trim()
|
urls.push({
|
||||||
});
|
url: absoluteUrl,
|
||||||
|
date: dateStr,
|
||||||
|
name: tournamentCell.innerText.trim(),
|
||||||
|
source: 'table'
|
||||||
|
});
|
||||||
|
table++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,18 +201,81 @@ async function getNewTournamentRounds(browser, pdgaNumber, afterDate) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return urls;
|
const recentAnchors = document.querySelectorAll('.recent-events a[href*="/tour/event/"]');
|
||||||
|
recentAnchors.forEach(anchor => {
|
||||||
|
recentEventsAnchorsSeen++;
|
||||||
|
const href = anchor.getAttribute('href');
|
||||||
|
if (href) {
|
||||||
|
const absoluteUrl = new URL(href, location.origin).href;
|
||||||
|
if (seenUrls.has(absoluteUrl)) {
|
||||||
|
recentEventsSkippedDuplicates++;
|
||||||
|
} else {
|
||||||
|
seenUrls.add(absoluteUrl);
|
||||||
|
urls.push({
|
||||||
|
url: absoluteUrl,
|
||||||
|
date: null,
|
||||||
|
name: anchor.innerText.trim() || 'Recent event',
|
||||||
|
source: 'recent-events'
|
||||||
|
});
|
||||||
|
recentEvents++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return { urls, counts: { table, recentEvents, recentEventsAnchorsSeen, recentEventsSkippedDuplicates } };
|
||||||
}, afterDate.getTime());
|
}, afterDate.getTime());
|
||||||
|
|
||||||
logger.info(`Found ${newTournamentUrls.length} new tournaments after ${afterDate.toDateString()}`);
|
logger.info({
|
||||||
|
pdgaNumber,
|
||||||
|
afterDate: afterDate.toISOString(),
|
||||||
|
tableMatches: counts.table,
|
||||||
|
recentEventsMatches: counts.recentEvents,
|
||||||
|
recentEventsAnchorsSeen: counts.recentEventsAnchorsSeen,
|
||||||
|
recentEventsSkippedDuplicates: counts.recentEventsSkippedDuplicates,
|
||||||
|
totalUrlsToScrape: newTournamentUrls.length
|
||||||
|
}, 'new tournament URL discovery completed');
|
||||||
|
|
||||||
for (const tournamentData of newTournamentUrls) {
|
for (const tournamentData of newTournamentUrls) {
|
||||||
try {
|
try {
|
||||||
logger.info(`Scraping new tournament: ${tournamentData.name} (${tournamentData.date})`);
|
if (tournamentData.source === 'recent-events') {
|
||||||
|
logger.debug({ pdgaNumber, url: tournamentData.url }, 'recent-events: scraping tournament');
|
||||||
|
} else {
|
||||||
|
logger.info(`Scraping new tournament: ${tournamentData.name} (${tournamentData.date})`);
|
||||||
|
}
|
||||||
|
|
||||||
await page.goto(tournamentData.url, { waitUntil: 'domcontentloaded', timeout: 30000 });
|
await page.goto(tournamentData.url, { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||||||
await new Promise(r => setTimeout(r, 500));
|
await new Promise(r => setTimeout(r, 500));
|
||||||
|
|
||||||
|
let parsedDate;
|
||||||
|
if (tournamentData.date !== null) {
|
||||||
|
parsedDate = parseDate(tournamentData.date);
|
||||||
|
} else {
|
||||||
|
const eventDateStr = await page.evaluate(() => {
|
||||||
|
const body = document.body ? document.body.innerText : '';
|
||||||
|
const m = body.match(/\d{1,2}\s+to\s+\d{1,2}-[A-Za-z]{3}-\d{4}/)
|
||||||
|
|| body.match(/\d{1,2}-[A-Za-z]{3}-\d{4}/);
|
||||||
|
return m ? m[0] : null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (eventDateStr) {
|
||||||
|
parsedDate = parseDate(eventDateStr);
|
||||||
|
if (!(parsedDate > afterDate)) {
|
||||||
|
logger.warn({
|
||||||
|
pdgaNumber,
|
||||||
|
url: tournamentData.url,
|
||||||
|
eventDateStr,
|
||||||
|
parsedDate: parsedDate ? parsedDate.toISOString() : null,
|
||||||
|
afterDate: afterDate.toISOString()
|
||||||
|
}, 'recent-events: extracted event date is not newer than afterDate, likely captured a non-tournament date — skipping');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
logger.debug({ pdgaNumber, url: tournamentData.url, eventDateStr }, 'recent-events: extracted date from event page');
|
||||||
|
} else {
|
||||||
|
logger.warn({ pdgaNumber, url: tournamentData.url }, 'recent-events: could not extract date from event page, skipping tournament');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const roundRatings = await page.evaluate((pdgaNum) => {
|
const roundRatings = await page.evaluate((pdgaNum) => {
|
||||||
const rows = document.querySelectorAll('tr');
|
const rows = document.querySelectorAll('tr');
|
||||||
|
|
||||||
@@ -230,7 +304,6 @@ async function getNewTournamentRounds(browser, pdgaNumber, afterDate) {
|
|||||||
}, pdgaNumber);
|
}, pdgaNumber);
|
||||||
|
|
||||||
if (roundRatings.length > 0) {
|
if (roundRatings.length > 0) {
|
||||||
const parsedDate = parseDate(tournamentData.date);
|
|
||||||
roundRatings.forEach(rating => {
|
roundRatings.forEach(rating => {
|
||||||
newRounds.push({
|
newRounds.push({
|
||||||
rating,
|
rating,
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
const logger = require('../logger');
|
||||||
|
|
||||||
|
const TJING_API = 'https://api.tjing.se/graphql';
|
||||||
|
const FETCH_TIMEOUT_MS = 8000;
|
||||||
|
|
||||||
|
async function tjingFetch(query) {
|
||||||
|
const controller = new AbortController();
|
||||||
|
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
||||||
|
|
||||||
|
let response;
|
||||||
|
try {
|
||||||
|
response = await fetch(TJING_API, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ query }),
|
||||||
|
signal: controller.signal
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
if (err.name === 'AbortError') {
|
||||||
|
return { error: 'Tjing API request timed out' };
|
||||||
|
}
|
||||||
|
return { error: `Network error: ${err.message}` };
|
||||||
|
} finally {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
return { error: `Tjing API returned ${response.status}` };
|
||||||
|
}
|
||||||
|
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = await response.json();
|
||||||
|
} catch (err) {
|
||||||
|
return { error: 'Invalid JSON from Tjing API' };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.errors && data.errors.length > 0) {
|
||||||
|
return { error: data.errors[0].message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { data: data.data };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchTjingCourses(searchTerm) {
|
||||||
|
const query = `{
|
||||||
|
courses(first: 10, filter: { search: "${searchTerm.replace(/"/g, '\\"')}" }) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
address
|
||||||
|
type
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
const result = await tjingFetch(query);
|
||||||
|
if (result.error) return result;
|
||||||
|
|
||||||
|
return { data: result.data.courses || [] };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getTjingCourse(courseId) {
|
||||||
|
const query = `{
|
||||||
|
course(courseId: "${courseId.replace(/"/g, '\\"')}") {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
address
|
||||||
|
layouts {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
published
|
||||||
|
latestVersion {
|
||||||
|
holes {
|
||||||
|
number
|
||||||
|
par
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
const result = await tjingFetch(query);
|
||||||
|
if (result.error) return result;
|
||||||
|
|
||||||
|
const course = result.data.course;
|
||||||
|
if (!course) {
|
||||||
|
return { error: 'Course not found' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate total par per layout from holes
|
||||||
|
const layouts = (course.layouts || [])
|
||||||
|
.filter(l => l.published && l.latestVersion && l.latestVersion.holes.length > 0)
|
||||||
|
.map(l => ({
|
||||||
|
name: l.name,
|
||||||
|
par: l.latestVersion.holes.reduce((sum, h) => sum + h.par, 0),
|
||||||
|
holes: l.latestVersion.holes.length
|
||||||
|
}));
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
name: course.name,
|
||||||
|
address: course.address,
|
||||||
|
tjingId: course.id,
|
||||||
|
layouts
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
searchTjingCourses,
|
||||||
|
getTjingCourse
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const { db } = require('../db');
|
const { db } = require('../db');
|
||||||
const { getPlayerFromDB, getRoundHistoryFromDB, savePredictedRatingToDB, savePlayerToDB, getMonthlyHistory, getAllMonthlyHistoriesFromDB, getAllRatingHistoriesFromDB } = require('../models/player');
|
const { getPlayerFromDB, getRoundHistoryFromDB, savePredictedRatingToDB, savePlayerToDB, getMonthlyHistory, getAllMonthlyHistoriesFromDB, getAllRatingHistoriesFromDB } = require('../models/player');
|
||||||
const { fetchPlayerDataHTTP, parsePlayerData } = require('../scrapers/player-http');
|
const { fetchPlayerDataHTTP, parsePlayerData } = require('../scrapers/player-http');
|
||||||
const { calculatePredictedRating } = require('./rating-calculator');
|
const { calculatePredictedRating, getPreviousPDGAUpdateDate } = require('./rating-calculator');
|
||||||
const logger = require('../logger');
|
const logger = require('../logger');
|
||||||
|
|
||||||
function formatDisplayDate(dateStr) {
|
function formatDisplayDate(dateStr) {
|
||||||
@@ -40,10 +40,35 @@ async function getPlayerDataFromDB(pdgaNumber, { includeMonthlyHistory = true }
|
|||||||
|
|
||||||
let predictedRating = cachedPlayer.predicted_rating;
|
let predictedRating = cachedPlayer.predicted_rating;
|
||||||
let stdDev = cachedPlayer.std_dev;
|
let stdDev = cachedPlayer.std_dev;
|
||||||
|
let excludedRoundsCount = cachedPlayer.excluded_rounds_count;
|
||||||
|
let cutoffRating = cachedPlayer.cutoff_rating;
|
||||||
|
let predictedCalculatedAtRaw = cachedPlayer.predicted_calculated_at;
|
||||||
if (!predictedRating || predictedRating === 0) {
|
if (!predictedRating || predictedRating === 0) {
|
||||||
predictedRating = await getPredictedRatingFromDB(pdgaNumber);
|
predictedRating = await getPredictedRatingFromDB(pdgaNumber);
|
||||||
const updatedPlayer = await getPlayerFromDB(pdgaNumber);
|
const updatedPlayer = await getPlayerFromDB(pdgaNumber);
|
||||||
stdDev = updatedPlayer?.std_dev;
|
stdDev = updatedPlayer?.std_dev;
|
||||||
|
excludedRoundsCount = updatedPlayer?.excluded_rounds_count;
|
||||||
|
cutoffRating = updatedPlayer?.cutoff_rating;
|
||||||
|
predictedCalculatedAtRaw = updatedPlayer?.predicted_calculated_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Staleness-check: invalidate cached predicted_rating if the PDGA cycle has
|
||||||
|
// rolled over since it was calculated. Don't recompute — round_history may be
|
||||||
|
// equally stale. UI will show "—" until the next manual refresh.
|
||||||
|
const predictedCalculatedAt = predictedCalculatedAtRaw
|
||||||
|
? new Date(predictedCalculatedAtRaw)
|
||||||
|
: null;
|
||||||
|
const previousUpdate = getPreviousPDGAUpdateDate();
|
||||||
|
const hasPredicted = predictedRating !== null && predictedRating !== 0;
|
||||||
|
const isStale = hasPredicted && (
|
||||||
|
predictedCalculatedAt === null || predictedCalculatedAt < previousUpdate
|
||||||
|
);
|
||||||
|
if (isStale) {
|
||||||
|
logger.debug(`PDGA ${pdgaNumber}: predicted rating stale (calculated ${predictedCalculatedAt?.toISOString() ?? 'unknown'}, cycle rolled ${previousUpdate.toISOString()})`);
|
||||||
|
predictedRating = null;
|
||||||
|
stdDev = null;
|
||||||
|
excludedRoundsCount = null;
|
||||||
|
cutoffRating = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rating = cachedPlayer.current_rating;
|
const rating = cachedPlayer.current_rating;
|
||||||
@@ -65,6 +90,8 @@ async function getPlayerDataFromDB(pdgaNumber, { includeMonthlyHistory = true }
|
|||||||
ratingChange,
|
ratingChange,
|
||||||
predictedRating: resolvedPredicted,
|
predictedRating: resolvedPredicted,
|
||||||
stdDev: resolvedStdDev,
|
stdDev: resolvedStdDev,
|
||||||
|
excludedRoundsCount: (excludedRoundsCount != null && excludedRoundsCount >= 0) ? excludedRoundsCount : null,
|
||||||
|
cutoffRating: (cutoffRating != null && cutoffRating > 0) ? cutoffRating : null,
|
||||||
lastMonthRating,
|
lastMonthRating,
|
||||||
// gap between next predicted update and current rating (null when either is missing)
|
// gap between next predicted update and current rating (null when either is missing)
|
||||||
deltaPredicted: (resolvedPredicted != null && rating != null) ? resolvedPredicted - rating : null,
|
deltaPredicted: (resolvedPredicted != null && rating != null) ? resolvedPredicted - rating : null,
|
||||||
@@ -145,7 +172,7 @@ async function getPredictedRatingFromDB(pdgaNumber) {
|
|||||||
|
|
||||||
const result = calculatePredictedRating(roundRatings);
|
const result = calculatePredictedRating(roundRatings);
|
||||||
|
|
||||||
await savePredictedRatingToDB(pdgaNumber, result.rating, result.stdDev);
|
await savePredictedRatingToDB(pdgaNumber, result.rating, result.stdDev, result.excludedRoundsCount, result.cutoffRating);
|
||||||
|
|
||||||
return result.rating;
|
return result.rating;
|
||||||
}
|
}
|
||||||
@@ -229,6 +256,8 @@ async function getAllRatingsFromDB(progressCallback = null) {
|
|||||||
ratingChange: errorRatingChange,
|
ratingChange: errorRatingChange,
|
||||||
predictedRating: null,
|
predictedRating: null,
|
||||||
stdDev: null,
|
stdDev: null,
|
||||||
|
excludedRoundsCount: null,
|
||||||
|
cutoffRating: null,
|
||||||
lastMonthRating: (errorRating != null && errorRatingChange != null) ? errorRating - errorRatingChange : null,
|
lastMonthRating: (errorRating != null && errorRatingChange != null) ? errorRating - errorRatingChange : null,
|
||||||
deltaPredicted: null,
|
deltaPredicted: null,
|
||||||
monthlyHistory: [],
|
monthlyHistory: [],
|
||||||
|
|||||||
@@ -37,39 +37,43 @@ function parseDate(dateStr) {
|
|||||||
return new Date(dateStr);
|
return new Date(dateStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function secondTuesdayOf(year, month) {
|
||||||
|
const firstDay = new Date(year, month, 1);
|
||||||
|
const daysUntilTuesday = (2 - firstDay.getDay() + 7) % 7;
|
||||||
|
const firstTuesday = new Date(year, month, 1 + daysUntilTuesday);
|
||||||
|
const secondTuesday = new Date(firstTuesday);
|
||||||
|
secondTuesday.setDate(firstTuesday.getDate() + 7);
|
||||||
|
return secondTuesday;
|
||||||
|
}
|
||||||
|
|
||||||
function getNextPDGAUpdateDate() {
|
function getNextPDGAUpdateDate() {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const currentMonth = today.getMonth();
|
const currentMonth = today.getMonth();
|
||||||
const currentYear = today.getFullYear();
|
const currentYear = today.getFullYear();
|
||||||
|
|
||||||
const firstDayOfMonth = new Date(currentYear, currentMonth, 1);
|
const secondTuesday = secondTuesdayOf(currentYear, currentMonth);
|
||||||
const firstTuesday = new Date(firstDayOfMonth);
|
|
||||||
|
|
||||||
const daysUntilTuesday = (2 - firstDayOfMonth.getDay() + 7) % 7;
|
|
||||||
firstTuesday.setDate(1 + daysUntilTuesday);
|
|
||||||
|
|
||||||
const secondTuesday = new Date(firstTuesday);
|
|
||||||
secondTuesday.setDate(firstTuesday.getDate() + 7);
|
|
||||||
|
|
||||||
if (today <= secondTuesday) {
|
if (today <= secondTuesday) {
|
||||||
return secondTuesday;
|
return secondTuesday;
|
||||||
} else {
|
} else {
|
||||||
const nextMonth = currentMonth === 11 ? 0 : currentMonth + 1;
|
const nextMonth = currentMonth === 11 ? 0 : currentMonth + 1;
|
||||||
const nextYear = currentMonth === 11 ? currentYear + 1 : currentYear;
|
const nextYear = currentMonth === 11 ? currentYear + 1 : currentYear;
|
||||||
|
return secondTuesdayOf(nextYear, nextMonth);
|
||||||
const firstDayNextMonth = new Date(nextYear, nextMonth, 1);
|
|
||||||
const firstTuesdayNext = new Date(firstDayNextMonth);
|
|
||||||
|
|
||||||
const daysUntilTuesdayNext = (2 - firstDayNextMonth.getDay() + 7) % 7;
|
|
||||||
firstTuesdayNext.setDate(1 + daysUntilTuesdayNext);
|
|
||||||
|
|
||||||
const secondTuesdayNext = new Date(firstTuesdayNext);
|
|
||||||
secondTuesdayNext.setDate(firstTuesdayNext.getDate() + 7);
|
|
||||||
|
|
||||||
return secondTuesdayNext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPreviousPDGAUpdateDate() {
|
||||||
|
const today = new Date();
|
||||||
|
const year = today.getFullYear();
|
||||||
|
const month = today.getMonth();
|
||||||
|
const secondTuesday = secondTuesdayOf(year, month);
|
||||||
|
if (today > secondTuesday) return secondTuesday;
|
||||||
|
// Otherwise: last month's second Tuesday
|
||||||
|
const prevMonth = month === 0 ? 11 : month - 1;
|
||||||
|
const prevYear = month === 0 ? year - 1 : year;
|
||||||
|
return secondTuesdayOf(prevYear, prevMonth);
|
||||||
|
}
|
||||||
|
|
||||||
function calculateStandardDeviation(ratings) {
|
function calculateStandardDeviation(ratings) {
|
||||||
if (!ratings || ratings.length === 0) return 0;
|
if (!ratings || ratings.length === 0) return 0;
|
||||||
|
|
||||||
@@ -85,7 +89,7 @@ function calculatePredictedRating(roundRatings) {
|
|||||||
|
|
||||||
if (!roundRatings || roundRatings.length === 0) {
|
if (!roundRatings || roundRatings.length === 0) {
|
||||||
debugLog.push('❌ No rounds provided for prediction');
|
debugLog.push('❌ No rounds provided for prediction');
|
||||||
return { rating: 0, debugLog };
|
return { rating: 0, debugLog, excludedRoundsCount: null, cutoffRating: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog.push(`📊 Starting with ${roundRatings.length} total rounds`);
|
debugLog.push(`📊 Starting with ${roundRatings.length} total rounds`);
|
||||||
@@ -100,7 +104,7 @@ function calculatePredictedRating(roundRatings) {
|
|||||||
|
|
||||||
if (allSortedRounds.length === 0) {
|
if (allSortedRounds.length === 0) {
|
||||||
debugLog.push('❌ No valid rounds after filtering for update date');
|
debugLog.push('❌ No valid rounds after filtering for update date');
|
||||||
return { rating: 0, debugLog };
|
return { rating: 0, debugLog, excludedRoundsCount: null, cutoffRating: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog.push(`📊 After update date filter: ${allSortedRounds.length} rounds`);
|
debugLog.push(`📊 After update date filter: ${allSortedRounds.length} rounds`);
|
||||||
@@ -127,7 +131,7 @@ function calculatePredictedRating(roundRatings) {
|
|||||||
|
|
||||||
if (eligibleRounds.length === 0) {
|
if (eligibleRounds.length === 0) {
|
||||||
debugLog.push('❌ No eligible rounds found');
|
debugLog.push('❌ No eligible rounds found');
|
||||||
return { rating: 0, debugLog };
|
return { rating: 0, debugLog, excludedRoundsCount: null, cutoffRating: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLog.push(`📈 ELIGIBLE ROUNDS: ${eligibleRounds.length}`);
|
debugLog.push(`📈 ELIGIBLE ROUNDS: ${eligibleRounds.length}`);
|
||||||
@@ -137,6 +141,8 @@ function calculatePredictedRating(roundRatings) {
|
|||||||
|
|
||||||
let workingRounds = [...eligibleRounds];
|
let workingRounds = [...eligibleRounds];
|
||||||
let workingRatings = workingRounds.map(r => r.rating);
|
let workingRatings = workingRounds.map(r => r.rating);
|
||||||
|
let excludedRoundsCount = 0;
|
||||||
|
let cutoffRating = null;
|
||||||
|
|
||||||
if (workingRatings.length >= 7) {
|
if (workingRatings.length >= 7) {
|
||||||
debugLog.push('🔍 OUTLIER EXCLUSION (≥7 rounds available):');
|
debugLog.push('🔍 OUTLIER EXCLUSION (≥7 rounds available):');
|
||||||
@@ -160,6 +166,9 @@ function calculatePredictedRating(roundRatings) {
|
|||||||
const stdDevOutliers = workingRatings.filter(rating => rating < stdDevCutoff);
|
const stdDevOutliers = workingRatings.filter(rating => rating < stdDevCutoff);
|
||||||
const hundredPointOutliers = workingRatings.filter(rating => rating < hundredPointCutoff && rating >= stdDevCutoff);
|
const hundredPointOutliers = workingRatings.filter(rating => rating < hundredPointCutoff && rating >= stdDevCutoff);
|
||||||
|
|
||||||
|
excludedRoundsCount = stdDevOutliers.length + hundredPointOutliers.length;
|
||||||
|
cutoffRating = Math.round(Math.max(stdDevCutoff, hundredPointCutoff));
|
||||||
|
|
||||||
if (stdDevOutliers.length > 0) {
|
if (stdDevOutliers.length > 0) {
|
||||||
debugLog.push(` ❌ 2.5σ outliers removed: ${stdDevOutliers.length} rounds`);
|
debugLog.push(` ❌ 2.5σ outliers removed: ${stdDevOutliers.length} rounds`);
|
||||||
stdDevOutliers.forEach(rating => {
|
stdDevOutliers.forEach(rating => {
|
||||||
@@ -188,6 +197,8 @@ function calculatePredictedRating(roundRatings) {
|
|||||||
debugLog.push(` ✅ Using ${filteredRatings.length} rounds after outlier removal`);
|
debugLog.push(` ✅ Using ${filteredRatings.length} rounds after outlier removal`);
|
||||||
} else {
|
} else {
|
||||||
debugLog.push(` ⚠️ Too few rounds after outlier removal (${filteredRatings.length}), keeping all rounds`);
|
debugLog.push(` ⚠️ Too few rounds after outlier removal (${filteredRatings.length}), keeping all rounds`);
|
||||||
|
excludedRoundsCount = 0;
|
||||||
|
cutoffRating = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debugLog.push(`⏭️ OUTLIER EXCLUSION SKIPPED (only ${workingRatings.length} rounds, need ≥7)`);
|
debugLog.push(`⏭️ OUTLIER EXCLUSION SKIPPED (only ${workingRatings.length} rounds, need ≥7)`);
|
||||||
@@ -228,7 +239,7 @@ function calculatePredictedRating(roundRatings) {
|
|||||||
debugLog.push(` Final Rating: ${finalRating}`);
|
debugLog.push(` Final Rating: ${finalRating}`);
|
||||||
debugLog.push('=== END PDGA CALCULATION ===');
|
debugLog.push('=== END PDGA CALCULATION ===');
|
||||||
|
|
||||||
return { rating: finalRating, stdDev: Math.round(stdDev), debugLog };
|
return { rating: finalRating, stdDev: Math.round(stdDev), debugLog, excludedRoundsCount, cutoffRating };
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { parseDate, getNextPDGAUpdateDate, calculatePredictedRating, calculateStandardDeviation };
|
module.exports = { parseDate, getNextPDGAUpdateDate, getPreviousPDGAUpdateDate, calculatePredictedRating, calculateStandardDeviation };
|
||||||
|
|||||||
+26
-19
@@ -1,25 +1,32 @@
|
|||||||
<% var body = `
|
<% var body = `
|
||||||
<div class="card-section">
|
<main class="page-courses">
|
||||||
<h3>Find Courses</h3>
|
<section class="action-card">
|
||||||
<div class="card-section-form">
|
<div class="action-card-tabs" role="tablist">
|
||||||
<input
|
<button class="action-tab is-active" role="tab" aria-selected="true" data-tab="find" id="tab-find">Find courses</button>
|
||||||
type="text"
|
<button class="action-tab" role="tab" aria-selected="false" data-tab="tjing" id="tab-tjing">Import from Tjing</button>
|
||||||
class="input"
|
</div>
|
||||||
id="course-search"
|
<div class="action-card-body">
|
||||||
name="q"
|
<div class="action-pane is-active" id="tab-pane-find" role="tabpanel" aria-labelledby="tab-find">
|
||||||
placeholder="Search courses by name or city..."
|
<input type="text" id="course-filter-input" placeholder="Find a course…" autocomplete="off">
|
||||||
hx-get="/partials/course-table"
|
<p class="action-hint">Filters the list below as you type.</p>
|
||||||
hx-trigger="input changed delay:300ms, search"
|
</div>
|
||||||
hx-target="#courses-table"
|
<div class="action-pane" id="tab-pane-tjing" role="tabpanel" aria-labelledby="tab-tjing" hidden>
|
||||||
style="width: 340px;"
|
<div class="tjing-search-row">
|
||||||
/>
|
<input type="text" id="tjing-search-input" placeholder="Search Tjing courses…" autocomplete="off">
|
||||||
<button class="btn" onclick="scrapeCourses()" id="scrape-courses-btn">
|
<button id="tjing-search-btn" class="btn-primary" onclick="searchTjing()">Search Tjing</button>
|
||||||
<i class="fas fa-sync-alt"></i> Scrape Courses
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<p class="action-hint">Find and import Swedish courses from tjing.se.</p>
|
||||||
|
<div id="tjing-results"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div id="courses-table" hx-get="/partials/course-table" hx-trigger="load"></div>
|
<div class="results-bar">
|
||||||
|
<span class="results-count">Showing <strong id="visible-count">0</strong> of <strong id="total-count">0</strong> courses</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="course-table-region" hx-get="/partials/course-table" hx-trigger="load, refresh from:body" hx-swap="innerHTML"></div>
|
||||||
|
</main>
|
||||||
`; %>
|
`; %>
|
||||||
|
|
||||||
<%- include('../partials/layout', {
|
<%- include('../partials/layout', {
|
||||||
|
|||||||
+14
-9
@@ -78,18 +78,23 @@
|
|||||||
|
|
||||||
<!-- Footnote -->
|
<!-- Footnote -->
|
||||||
<p class="footnote">Unofficial PDGA rating tracker. Ratings scraped from pdga.com on each refresh.</p>
|
<p class="footnote">Unofficial PDGA rating tracker. Ratings scraped from pdga.com on each refresh.</p>
|
||||||
|
|
||||||
|
<!-- Mobile sticky add-bar (visible only on mobile via CSS) -->
|
||||||
|
<form class="mobile-add-bar" onsubmit="searchAndAddPlayerMobile(event)">
|
||||||
|
<input
|
||||||
|
id="pdga-number-input-mobile"
|
||||||
|
name="pdga"
|
||||||
|
type="text"
|
||||||
|
inputmode="numeric"
|
||||||
|
placeholder="PDGA #"
|
||||||
|
oninput="this.value = this.value.replace(/\\D/g,'')"
|
||||||
|
aria-label="PDGA number"
|
||||||
|
/>
|
||||||
|
<button type="submit" class="btn-primary">Add</button>
|
||||||
|
</form>
|
||||||
`; %>
|
`; %>
|
||||||
|
|
||||||
<% var modals = `
|
<% var modals = `
|
||||||
<!-- Debug Modal -->
|
|
||||||
<div id="debug-modal" class="debug-modal" onclick="closeDebugModal(event)">
|
|
||||||
<div class="debug-content" onclick="event.stopPropagation()">
|
|
||||||
<button class="debug-close" onclick="closeDebugModal()">×</button>
|
|
||||||
<div class="debug-header" id="debug-header">Prediction Calculation Details</div>
|
|
||||||
<div class="debug-log" id="debug-log">Loading...</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Add Player Confirmation Modal -->
|
<!-- Add Player Confirmation Modal -->
|
||||||
<div id="add-player-modal" class="modal" onclick="closeAddPlayerModal(event)">
|
<div id="add-player-modal" class="modal" onclick="closeAddPlayerModal(event)">
|
||||||
<div class="modal-content" onclick="event.stopPropagation()">
|
<div class="modal-content" onclick="event.stopPropagation()">
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<%
|
||||||
|
var _query = (typeof query !== 'undefined') ? query : null;
|
||||||
|
var _total = (typeof total !== 'undefined') ? total : courses.length;
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if (courses.length === 0) { %>
|
||||||
|
<p style="text-align: center; color: var(--ink-3); padding: 40px 0;">No courses found.</p>
|
||||||
|
<% } else { %>
|
||||||
|
<div class="mobile-section-head">
|
||||||
|
<span class="kicker">Showing <%= courses.length %> of <%= _total %></span>
|
||||||
|
<a href="/courses">View all →</a>
|
||||||
|
</div>
|
||||||
|
<div class="mobile-list">
|
||||||
|
<% courses.forEach(function(course) {
|
||||||
|
var lastUpdated = new Date(course.last_updated).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
|
||||||
|
%>
|
||||||
|
<div class="m-course-card" id="m-course-<%= course.id %>"
|
||||||
|
tabindex="0" role="button" aria-expanded="false" aria-label="Expand course details"
|
||||||
|
onclick="toggleMobileCourseLayouts(<%= course.id %>)"
|
||||||
|
onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();toggleMobileCourseLayouts(<%= course.id %>);}">
|
||||||
|
<div class="m-course-card__head">
|
||||||
|
<div class="m-course-card__name-stack">
|
||||||
|
<div class="m-course-name-row">
|
||||||
|
<span class="m-course-name"><%= course.name %></span>
|
||||||
|
</div>
|
||||||
|
<div class="m-course-card__meta"><%= course.city %> · <%= lastUpdated %></div>
|
||||||
|
</div>
|
||||||
|
<span class="m-chevron">▼</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m-course-card__expand">
|
||||||
|
<div id="m-layouts-container-<%= course.id %>" class="layouts-container">
|
||||||
|
<div class="no-layouts">Tap to load layouts...</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% }); %>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
@@ -1,71 +1,67 @@
|
|||||||
<% if (layouts.length === 0) { %>
|
<% if (!layouts || layouts.length === 0) { %>
|
||||||
<div class="no-layouts">No layouts found. Click the refresh icon to scrape layouts.</div>
|
<div class="no-layouts">No layouts found. Click the refresh button to scrape layouts.</div>
|
||||||
<% } else {
|
<% } else {
|
||||||
var oneYearAgo = new Date();
|
var oneYearAgo = new Date();
|
||||||
oneYearAgo.setDate(oneYearAgo.getDate() - 365);
|
oneYearAgo.setDate(oneYearAgo.getDate() - 365);
|
||||||
|
var activeLayouts = [];
|
||||||
var activeLayouts = [];
|
var inactiveLayouts = [];
|
||||||
var inactiveLayouts = [];
|
layouts.forEach(function(l) {
|
||||||
|
if (l.last_played && new Date(l.last_played) >= oneYearAgo) {
|
||||||
layouts.forEach(function(layout) {
|
activeLayouts.push(l);
|
||||||
if (layout.last_played) {
|
} else {
|
||||||
var lastPlayedDate = new Date(layout.last_played);
|
inactiveLayouts.push(l);
|
||||||
if (lastPlayedDate >= oneYearAgo) {
|
}
|
||||||
activeLayouts.push(layout);
|
});
|
||||||
} else {
|
var RATING_TIER_HIGH = 970;
|
||||||
inactiveLayouts.push(layout);
|
var RATING_TIER_MID = 940;
|
||||||
}
|
function ratingTier(r) {
|
||||||
} else {
|
if (r == null) return null;
|
||||||
inactiveLayouts.push(layout);
|
if (r >= RATING_TIER_HIGH) return 'green';
|
||||||
}
|
if (r >= RATING_TIER_MID) return 'amber';
|
||||||
});
|
return 'orange';
|
||||||
|
}
|
||||||
%>
|
%>
|
||||||
<h4>Layouts:</h4>
|
<div class="layouts-header">
|
||||||
|
<span class="layouts-kicker">LAYOUTS</span>
|
||||||
<% if (activeLayouts.length > 0) { %>
|
<span class="layouts-count"><%= activeLayouts.length %> active · <%= inactiveLayouts.length %> inactive</span>
|
||||||
<% activeLayouts.forEach(function(layout) {
|
</div>
|
||||||
var ratingDisplay = layout.mean_rating ?
|
<ul class="layout-list">
|
||||||
'<span style="color: var(--green); font-weight: 700; margin-left: 10px;">Rating: ' + layout.mean_rating + '</span>' : '';
|
<% activeLayouts.forEach(function(l) { var tier = ratingTier(l.mean_rating); %>
|
||||||
var dateDisplay = layout.last_played ?
|
<li class="layout-card layout-card--active">
|
||||||
'<span style="color: var(--text-muted); font-size: 12px; margin-left: 10px;">Last played: ' + new Date(layout.last_played).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) + '</span>' : '';
|
<div class="layout-info">
|
||||||
%>
|
<span class="layout-name"><%= l.name %></span>
|
||||||
<div class="layout-item">
|
<span class="layout-last-played">Last played: <%= l.last_played %></span>
|
||||||
<div>
|
</div>
|
||||||
<span class="layout-name"><%= layout.name %></span>
|
<div class="layout-chips">
|
||||||
<%- dateDisplay %>
|
<span class="chip chip-par">Par <%= l.par %></span>
|
||||||
</div>
|
<% if (tier) { %><span class="chip chip-rating chip-rating--<%= tier %>">Rating: <%= Math.round(l.mean_rating) %></span><% } %>
|
||||||
<span class="layout-par">Par <%= layout.par %><%- ratingDisplay %></span>
|
</div>
|
||||||
</div>
|
</li>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<% } %>
|
</ul>
|
||||||
|
<% if (inactiveLayouts.length > 0) { %>
|
||||||
<% if (inactiveLayouts.length > 0) { %>
|
<div class="inactive-layouts">
|
||||||
<div class="inactive-layouts-accordion">
|
<button class="inactive-toggle" type="button" onclick="toggleInactiveLayouts(this)" aria-expanded="false">
|
||||||
<div class="accordion-header" onclick="toggleAccordion('accordion-<%= courseId %>')">
|
<span>Inactive layouts (<%= inactiveLayouts.length %>) — Not played in last year</span>
|
||||||
<span class="accordion-header-text">Inactive Layouts (<%= inactiveLayouts.length %>) - Not played in last year</span>
|
<i class="icon-chev fas fa-chevron-down"></i>
|
||||||
<span class="accordion-icon" id="accordion-<%= courseId %>-icon">▼</span>
|
</button>
|
||||||
</div>
|
<ul class="layout-list inactive-layouts-body" hidden>
|
||||||
<div class="accordion-content" id="accordion-<%= courseId %>">
|
<% inactiveLayouts.forEach(function(l) { %>
|
||||||
<% inactiveLayouts.forEach(function(layout) {
|
<li class="layout-card layout-card--inactive">
|
||||||
var ratingDisplay = layout.mean_rating ?
|
<div class="layout-info">
|
||||||
'<span style="color: var(--green); font-weight: 700; margin-left: 10px;">Rating: ' + layout.mean_rating + '</span>' : '';
|
<span class="layout-name"><%= l.name %></span>
|
||||||
var dateDisplay = layout.last_played ?
|
<% if (l.last_played) { %>
|
||||||
'<span style="color: var(--text-muted); font-size: 12px; margin-left: 10px;">Last played: ' + new Date(layout.last_played).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) + '</span>' :
|
<span class="layout-last-played">Last played: <%= l.last_played %></span>
|
||||||
'<span style="color: var(--red); font-size: 12px; margin-left: 10px;">Never played</span>';
|
<% } else { %>
|
||||||
%>
|
<span class="layout-never-played">Never played</span>
|
||||||
<div class="layout-item inactive">
|
<% } %>
|
||||||
<div>
|
</div>
|
||||||
<span class="layout-name"><%= layout.name %></span>
|
<div class="layout-chips">
|
||||||
<%- dateDisplay %>
|
<span class="chip chip-par">Par <%= l.par %></span>
|
||||||
</div>
|
</div>
|
||||||
<span class="layout-par">Par <%= layout.par %><%- ratingDisplay %></span>
|
</li>
|
||||||
</div>
|
<% }); %>
|
||||||
<% }); %>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% } %>
|
||||||
<% } %>
|
|
||||||
|
|
||||||
<% if (activeLayouts.length === 0 && inactiveLayouts.length === 0) { %>
|
|
||||||
<div class="no-layouts">No layouts found. Click the refresh icon to scrape layouts.</div>
|
|
||||||
<% } %>
|
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -1,46 +1,49 @@
|
|||||||
<div id="search-results-info" class="search-results-info">
|
<% if (!courses || courses.length === 0) { %>
|
||||||
<% if (typeof query !== 'undefined' && query) { %>
|
<p style="text-align: center; color: var(--ink-3); padding: 40px 0;">No courses found. Use "Import from Tjing" or scrape courses from PDGA.</p>
|
||||||
Showing <%= courses.length %> of <%= total %> courses
|
|
||||||
<% } else { %>
|
|
||||||
Showing all <%= courses.length %> courses
|
|
||||||
<% } %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% if (courses.length === 0) { %>
|
|
||||||
<p>No courses found. Click "Scrape Courses" to load Swedish courses from PDGA.</p>
|
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<table>
|
<div class="course-grid" data-total-count="<%= courses.length %>">
|
||||||
<thead>
|
<div class="course-row course-row--header" role="row">
|
||||||
<tr>
|
<div class="course-header-cell">Course</div>
|
||||||
<th>Course Name</th>
|
<div class="course-header-cell">City</div>
|
||||||
<th class="mobile-hide">City</th>
|
<div class="course-header-cell">Last updated</div>
|
||||||
<th class="mobile-hide">Last Updated</th>
|
<div class="course-header-cell"></div>
|
||||||
<th>Actions</th>
|
</div>
|
||||||
</tr>
|
<% courses.forEach(function(course) {
|
||||||
</thead>
|
var layoutCount = course.layoutCount || 0;
|
||||||
<tbody>
|
var activeLayoutCount = course.activeLayoutCount || 0;
|
||||||
<% courses.forEach(function(course) {
|
%>
|
||||||
var lastUpdated = new Date(course.last_updated).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
|
<div class="course-row expandable-row" data-course-id="<%= course.id %>" data-course-name="<%= (course.name || '').toLowerCase() %>" data-course-city="<%= (course.city || '').toLowerCase() %>" onclick="toggleCourseLayouts(<%= course.id %>)">
|
||||||
%>
|
<div class="course-cell">
|
||||||
<tr id="row-<%= course.id %>" class="expandable-row" onclick="toggleCourseLayouts(<%= course.id %>)">
|
<span class="course-name"><%= course.name %></span>
|
||||||
<td>
|
<span class="course-meta">
|
||||||
<a href="<%= course.link %>" target="_blank" onclick="event.stopPropagation()"><%= course.name %></a>
|
<% if (layoutCount > 0) { %>
|
||||||
<div class="mobile-only" style="font-size: 11px; color: #999; margin-top: 2px;"><%= course.city %></div>
|
<% if (activeLayoutCount !== layoutCount) { %>
|
||||||
</td>
|
<%= layoutCount %> layouts · <%= activeLayoutCount %> active
|
||||||
<td class="mobile-hide"><%= course.city %></td>
|
<% } else { %>
|
||||||
<td class="mobile-hide"><%= lastUpdated %></td>
|
<%= layoutCount %> layouts
|
||||||
<td>
|
<% } %>
|
||||||
<i class="fas fa-sync-alt refresh-icon" onclick="scrapeLayouts(<%= course.id %>, '<%= course.name.replace(/'/g, "\\'") %>'); event.stopPropagation();" title="Scrape layouts for this course"></i>
|
<% } else { %>
|
||||||
</td>
|
No layouts
|
||||||
</tr>
|
<% } %>
|
||||||
<tr id="layouts-<%= course.id %>" class="expanded-content">
|
</span>
|
||||||
<td colspan="4">
|
</div>
|
||||||
<div class="layouts-container" id="layouts-container-<%= course.id %>">
|
<div class="course-city"><%= course.city || '—' %></div>
|
||||||
<div class="no-layouts">Click to load layouts...</div>
|
<div class="course-updated"><%= course.last_updated ? new Date(course.last_updated).toISOString().slice(0,10) : '—' %></div>
|
||||||
</div>
|
<div class="course-actions">
|
||||||
</td>
|
<button class="icon-btn refresh-icon" onclick="event.stopPropagation(); scrapeLayouts(<%= course.id %>, this)" title="Refresh layouts" aria-label="Refresh layouts">
|
||||||
</tr>
|
<i class="fas fa-sync-alt"></i>
|
||||||
<% }); %>
|
</button>
|
||||||
</tbody>
|
<button class="icon-btn icon-chev" onclick="event.stopPropagation(); toggleCourseLayouts(<%= course.id %>)" title="Expand row" aria-label="Expand">
|
||||||
</table>
|
<i class="fas fa-chevron-down"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="expanded-content" id="course-layouts-<%= course.id %>">
|
||||||
|
<div class="expanded-cell">
|
||||||
|
<div class="loading">Loading layouts…</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% }); %>
|
||||||
|
</div>
|
||||||
|
<%- include('course-cards', { courses: courses, total: courses.length }) %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||||
<title><%= title %></title>
|
<title><%= title %></title>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300..800;1,300..800&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300..800;1,300..800&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||||
<link rel="stylesheet" href="/css/shared.css">
|
<link rel="stylesheet" href="/css/shared.css">
|
||||||
|
<link rel="stylesheet" href="/css/mobile.css">
|
||||||
<% if (typeof cssFiles !== 'undefined') { %>
|
<% if (typeof cssFiles !== 'undefined') { %>
|
||||||
<% cssFiles.forEach(function(file) { %>
|
<% cssFiles.forEach(function(file) { %>
|
||||||
<link rel="stylesheet" href="/css/<%= file %>">
|
<link rel="stylesheet" href="/css/<%= file %>">
|
||||||
|
|||||||
@@ -26,8 +26,29 @@ const chartPdgaNumber = hasPlayer ? player.pdgaNumber : pdgaNumber;
|
|||||||
<dt>Gap to predicted</dt>
|
<dt>Gap to predicted</dt>
|
||||||
<dd><%- include('delta-pill', { value: player.deltaPredicted, extraClass: 'delta-predicted-pill' }) %></dd>
|
<dd><%- include('delta-pill', { value: player.deltaPredicted, extraClass: 'delta-predicted-pill' }) %></dd>
|
||||||
</div>
|
</div>
|
||||||
|
<% if (player.stdDev != null && player.rating) { %>
|
||||||
|
<div>
|
||||||
|
<dt>Round spread</dt>
|
||||||
|
<dd>±<%= player.stdDev %></dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt>Rating range</dt>
|
||||||
|
<dd><%= player.rating - player.stdDev %>–<%= player.rating + player.stdDev %></dd>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
<% if (player.excludedRoundsCount != null && player.rating) { %>
|
||||||
|
<div>
|
||||||
|
<dt>Excluded rounds</dt>
|
||||||
|
<dd><%= player.excludedRoundsCount %></dd>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
<% if (player.cutoffRating != null && player.rating) { %>
|
||||||
|
<div>
|
||||||
|
<dt>Cutoff rating</dt>
|
||||||
|
<dd><%= player.cutoffRating %></dd>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
</dl>
|
</dl>
|
||||||
<button class="link-btn" onclick="showDebugInfo(<%= player.pdgaNumber %>)" style="margin-top: 4px;">View calculation details →</button>
|
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
<%
|
||||||
|
// Mobile sparkline helper — parametrised, used only in this partial
|
||||||
|
function renderSparkline(values, opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
var w = opts.w || 70;
|
||||||
|
var h = opts.h || 26;
|
||||||
|
if (!values || values.length < 2) return '';
|
||||||
|
var min = Math.min.apply(null, values);
|
||||||
|
var max = Math.max.apply(null, values);
|
||||||
|
var range = max - min || 1;
|
||||||
|
var xStep = w / (values.length - 1);
|
||||||
|
|
||||||
|
var pts = values.map(function(v, i) {
|
||||||
|
return {
|
||||||
|
x: (i * xStep).toFixed(1),
|
||||||
|
y: (((max - v) / range) * (h - 4) + 2).toFixed(1)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
var linePath = pts.map(function(p, i) {
|
||||||
|
return (i === 0 ? 'M' : 'L') + ' ' + p.x + ' ' + p.y;
|
||||||
|
}).join(' ');
|
||||||
|
|
||||||
|
var last = pts[pts.length - 1];
|
||||||
|
var areaPath = linePath + ' L ' + last.x + ' ' + h + ' L 0 ' + h + ' Z';
|
||||||
|
|
||||||
|
return '<svg width="' + w + '" height="' + h + '" viewBox="0 0 ' + w + ' ' + h + '" class="m-chart-spark" aria-hidden="true">' +
|
||||||
|
'<path d="' + areaPath + '" style="fill:var(--accent);fill-opacity:0.10"/>' +
|
||||||
|
'<path d="' + linePath + '" style="stroke:var(--accent);stroke-width:1.5;fill:none;stroke-linejoin:round;stroke-linecap:round"/>' +
|
||||||
|
'<circle cx="' + last.x + '" cy="' + last.y + '" r="2.5" style="fill:var(--accent)"/>' +
|
||||||
|
'</svg>';
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if (ratings.length === 0) { %>
|
||||||
|
<p style="text-align: center; color: var(--ink-3); padding: 40px 0;">No players tracked yet.</p>
|
||||||
|
<% } else { %>
|
||||||
|
<div class="mobile-section-head">
|
||||||
|
<span class="kicker">TRACKED PLAYERS · <%= ratings.length %></span>
|
||||||
|
<button id="trendchart-toggle-mobile" class="pill-button" type="button" aria-pressed="false">Trend chart</button>
|
||||||
|
</div>
|
||||||
|
<div class="mobile-list">
|
||||||
|
<% ratings.forEach(function(player, index) {
|
||||||
|
var sparkSvg = renderSparkline(player.monthlyHistory || [], { w: 70, h: 26 });
|
||||||
|
var isFirst = index === 0;
|
||||||
|
var rank = index + 1;
|
||||||
|
|
||||||
|
var ratingIsNull = (player.rating == null);
|
||||||
|
var ratingCls = ratingIsNull ? 'flat' : (player.ratingChange > 0 ? 'up' : player.ratingChange < 0 ? 'down' : 'flat');
|
||||||
|
var ratingGlyph = (ratingIsNull || player.ratingChange === 0) ? '–' : (player.ratingChange > 0 ? '▲' : '▼');
|
||||||
|
var ratingNum = ratingIsNull ? '—' : (player.ratingChange > 0 ? '+' + player.ratingChange : String(player.ratingChange));
|
||||||
|
|
||||||
|
var predIsNull = (player.predictedRating == null);
|
||||||
|
var predCls = predIsNull ? 'flat' : (player.deltaPredicted > 0 ? 'up' : player.deltaPredicted < 0 ? 'down' : 'flat');
|
||||||
|
var predGlyph = (predIsNull || player.deltaPredicted === 0) ? '–' : (player.deltaPredicted > 0 ? '▲' : '▼');
|
||||||
|
var predNum = predIsNull ? '—' : (player.deltaPredicted > 0 ? '+' + player.deltaPredicted : String(player.deltaPredicted));
|
||||||
|
%>
|
||||||
|
<div class="m-card" id="m-card-<%= player.pdgaNumber %>"
|
||||||
|
tabindex="0" role="button" aria-expanded="false" aria-label="Expand player details"
|
||||||
|
onclick="toggleMobilePlayerCard(<%= player.pdgaNumber %>)"
|
||||||
|
onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();toggleMobilePlayerCard(<%= player.pdgaNumber %>);}">
|
||||||
|
<div class="m-card__head">
|
||||||
|
<div class="m-rank-chip<%= isFirst ? ' m-rank-chip--first' : '' %>"><%= rank %></div>
|
||||||
|
<div class="m-card__name-stack">
|
||||||
|
<span class="m-player-name"><%= player.name %></span>
|
||||||
|
<span class="m-pdga-num">#<%= player.pdgaNumber %></span>
|
||||||
|
</div>
|
||||||
|
<button class="icon-btn refresh-icon m-refresh-icon" type="button"
|
||||||
|
onclick="event.stopPropagation(); refreshPlayerData(<%= player.pdgaNumber %>)"
|
||||||
|
title="Refresh rating + prediction" aria-label="Refresh rating and prediction">
|
||||||
|
<i class="fas fa-sync-alt"></i>
|
||||||
|
</button>
|
||||||
|
<span class="m-chevron">▼</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m-card__body">
|
||||||
|
<div class="m-card__stats">
|
||||||
|
<div class="m-stat-row">
|
||||||
|
<span class="m-stat-label">RATING</span>
|
||||||
|
<span class="m-num"><%= player.rating || '—' %></span>
|
||||||
|
<span class="delta-pill <%= ratingCls %>"><span class="delta-glyph"><%= ratingGlyph %></span><span class="delta-num"><%= ratingNum %></span></span>
|
||||||
|
</div>
|
||||||
|
<div class="m-stat-row">
|
||||||
|
<span class="m-stat-label">PREDICTED</span>
|
||||||
|
<span class="m-num m-num--predicted"><%= player.predictedRating || '—' %></span>
|
||||||
|
<span class="delta-pill <%= predCls %> delta-predicted-pill"><span class="delta-glyph"><%= predGlyph %></span><span class="delta-num"><%= predNum %></span></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% if (sparkSvg) { %>
|
||||||
|
<div class="m-card__sparkline"><span class="sparkline"><%- sparkSvg %></span></div>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m-card__expand">
|
||||||
|
<% if (player.ratingHistory && player.ratingHistory.length > 0) { %>
|
||||||
|
<div class="player-chart m-chart"
|
||||||
|
data-variant="mobile"
|
||||||
|
data-history="<%= JSON.stringify(player.ratingHistory) %>">
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
<dl class="m-detail-grid">
|
||||||
|
<div>
|
||||||
|
<dt>Current rating</dt>
|
||||||
|
<dd><%= player.rating || '—' %></dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt>Last month</dt>
|
||||||
|
<dd><%= player.lastMonthRating || '—' %></dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt>Change vs last month</dt>
|
||||||
|
<dd><span class="delta-pill <%= ratingCls %>"><span class="delta-glyph"><%= ratingGlyph %></span><span class="delta-num"><%= ratingNum %></span></span></dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt>Predicted next update</dt>
|
||||||
|
<dd><%= player.predictedRating || '—' %></dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt>Gap to predicted</dt>
|
||||||
|
<dd><span class="delta-pill <%= predCls %> delta-predicted-pill"><span class="delta-glyph"><%= predGlyph %></span><span class="delta-num"><%= predNum %></span></span></dd>
|
||||||
|
</div>
|
||||||
|
<% if (player.stdDev != null && player.rating) { %>
|
||||||
|
<div>
|
||||||
|
<dt>Round spread</dt>
|
||||||
|
<dd>±<%= player.stdDev %></dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt>Rating range</dt>
|
||||||
|
<dd><%= player.rating - player.stdDev %>–<%= player.rating + player.stdDev %></dd>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
<% if (player.excludedRoundsCount != null && player.rating) { %>
|
||||||
|
<div>
|
||||||
|
<dt>Excluded rounds</dt>
|
||||||
|
<dd><%= player.excludedRoundsCount %></dd>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
<% if (player.cutoffRating != null && player.rating) { %>
|
||||||
|
<div>
|
||||||
|
<dt>Cutoff rating</dt>
|
||||||
|
<dd><%= player.cutoffRating %></dd>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% }); %>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
<%
|
<%
|
||||||
function renderSparkline(values) {
|
function renderSparkline(values, opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
var w = opts.w || 96;
|
||||||
|
var h = opts.h || 28;
|
||||||
if (!values || values.length < 2) return '';
|
if (!values || values.length < 2) return '';
|
||||||
var w = 96, h = 28;
|
|
||||||
var min = Math.min.apply(null, values);
|
var min = Math.min.apply(null, values);
|
||||||
var max = Math.max.apply(null, values);
|
var max = Math.max.apply(null, values);
|
||||||
var range = max - min || 1;
|
var range = max - min || 1;
|
||||||
@@ -65,7 +67,6 @@ function renderSparkline(values) {
|
|||||||
<% } else { %>
|
<% } else { %>
|
||||||
<span class="rating-pending">Click to load</span>
|
<span class="rating-pending">Click to load</span>
|
||||||
<% } %>
|
<% } %>
|
||||||
<div class="std-dev-tooltip" id="tooltip-rating-<%= player.pdgaNumber %>"></div>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="col-predicted" id="predicted-<%= player.pdgaNumber %>">
|
<td class="col-predicted" id="predicted-<%= player.pdgaNumber %>">
|
||||||
<% if (player.predictedRating) { %>
|
<% if (player.predictedRating) { %>
|
||||||
@@ -76,7 +77,6 @@ function renderSparkline(values) {
|
|||||||
<% } else { %>
|
<% } else { %>
|
||||||
<span class="rating-pending">—</span>
|
<span class="rating-pending">—</span>
|
||||||
<% } %>
|
<% } %>
|
||||||
<div class="std-dev-tooltip" id="tooltip-stddev-<%= player.pdgaNumber %>"></div>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="col-actions cell-actions" onclick="event.stopPropagation()">
|
<td class="col-actions cell-actions" onclick="event.stopPropagation()">
|
||||||
<button class="icon-btn refresh-icon" onclick="refreshPlayerData(<%= player.pdgaNumber %>)" title="Refresh rating + prediction" aria-label="Refresh rating and prediction">
|
<button class="icon-btn refresh-icon" onclick="refreshPlayerData(<%= player.pdgaNumber %>)" title="Refresh rating + prediction" aria-label="Refresh rating and prediction">
|
||||||
@@ -104,4 +104,5 @@ function renderSparkline(values) {
|
|||||||
<% }); %>
|
<% }); %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<%- include('ratings-cards', { ratings: ratings }) %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@@ -43,4 +43,41 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="topbar__mobile">
|
||||||
|
<div class="topbar__mobile-row1">
|
||||||
|
<a href="/" class="topbar__mobile-brand">
|
||||||
|
<span class="topbar__mobile-mark" aria-hidden="true">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M3 17 L9 11 L13 15 L21 6" />
|
||||||
|
<path d="M14 6 L21 6 L21 13" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span class="topbar__mobile-brand-text">
|
||||||
|
<span class="topbar__mobile-title">Rating Tracker</span>
|
||||||
|
<span class="topbar__mobile-sub">Disc golf · unofficial</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
class="topbar__mobile-refresh"
|
||||||
|
type="button"
|
||||||
|
hx-post="/api/refresh-all"
|
||||||
|
hx-vals='{"page": "<%= activePage %>"}'
|
||||||
|
hx-target="#topbar"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-disabled-elt="this"
|
||||||
|
title="Refresh all"
|
||||||
|
aria-label="Refresh all"
|
||||||
|
>
|
||||||
|
<span class="topbar__refresh-icon" aria-hidden="true">↻</span>
|
||||||
|
<span class="topbar__refresh-spinner" aria-hidden="true"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="topbar__mobile-row2">
|
||||||
|
<nav class="topbar__mobile-nav" aria-label="Primary">
|
||||||
|
<a href="/" class="<%= activePage === 'players' ? 'active' : '' %>">Players</a>
|
||||||
|
<a href="/courses" class="<%= activePage === 'courses' ? 'active' : '' %>">Courses</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in New Issue
Block a user