Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c69efa469e | |||
| e21e6f2ef0 | |||
| 141dc90db7 | |||
| b4d9305550 | |||
| e900b86e69 | |||
| 4dc429b961 | |||
| 4bcf83d267 | |||
| 7ab16994c5 | |||
| b51c47dc4c | |||
| cc9d8eb4cd | |||
| e25f66c5d3 | |||
| 1442396418 | |||
| 307dffd3a7 | |||
| 46f78b42dc | |||
| d0c278ea1b | |||
| d0040901ab | |||
| c0f9dd5f33 | |||
| e29bc8ee80 | |||
| 96edc606d3 | |||
| 1e66b9f94f |
@@ -34,9 +34,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-and-push]
|
needs: [build-and-push]
|
||||||
steps:
|
steps:
|
||||||
- uses: shcizo/package-updater-action@v1
|
- uses: https://gitea.shcizo.se/shcizo/package-updater-action@v1
|
||||||
with:
|
with:
|
||||||
endpoint: https://updater.shcizo.se/update
|
endpoint: https://updater.shcizo.se/update
|
||||||
image: gitea.shcizo.se/shcizo/pdga-rating
|
image: gitea.shcizo.se/shcizo/pdga-rating
|
||||||
tag: ${{ gitea.ref_name }}
|
tag: ${{ gitea.ref_name }}
|
||||||
token: ${{ secrets.UPDATER_TOKEN }}
|
token: ${{ secrets.UPDATER_API_KEY }}
|
||||||
|
|||||||
@@ -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."
|
||||||
@@ -11,7 +11,7 @@ PDGA rating scraper and display app. Scrapes player ratings and course data from
|
|||||||
- **Frontend:** HTMX + vanilla JS (in `public/js/`)
|
- **Frontend:** HTMX + vanilla JS (in `public/js/`)
|
||||||
- **Scraping:** Puppeteer (with stealth plugin) + direct HTTP
|
- **Scraping:** Puppeteer (with stealth plugin) + direct HTTP
|
||||||
- **Logging:** Pino (JSON in production, pino-pretty in dev)
|
- **Logging:** Pino (JSON in production, pino-pretty in dev)
|
||||||
- **CI/CD:** Gitea Actions (tag-triggered docker build/push to `gitea.shcizo.se/shcizo/pdga-rating`)
|
- **CI/CD:** Gitea Actions (tag-triggered build + push + deploy via `.gitea/workflows/deploy.yml`)
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
@@ -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/docker-build.yml` which builds and pushes the image. Auth uses repo secret `PACKAGES_TOKEN` (PAT with `write:package`) — the auto-injected `GITEA_TOKEN` does not have effective registry access.
|
- **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.4",
|
"version": "1.2.10",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pdga-ratings",
|
"name": "pdga-ratings",
|
||||||
"version": "1.2.4",
|
"version": "1.2.10",
|
||||||
"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.4",
|
"version": "1.2.10",
|
||||||
"description": "PDGA rating scraper and display",
|
"description": "PDGA rating scraper and display",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -0,0 +1,642 @@
|
|||||||
|
/* ═══════════════════════════════════════════════════
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide search result info text on courses (mobile has section-head) */
|
||||||
|
#search-results-info { 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
.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) */
|
||||||
+80
-20
@@ -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 {
|
||||||
@@ -286,15 +276,85 @@
|
|||||||
background: #059669;
|
background: #059669;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Responsive ───────────────────────────────── */
|
/* ── Target Rating Calculator ─────────────────── */
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
.target-rating-icon {
|
||||||
.chart-container {
|
color: var(--accent);
|
||||||
height: 250px;
|
}
|
||||||
margin: 5px 0;
|
|
||||||
}
|
#target-rating-form .form-row {
|
||||||
|
display: flex;
|
||||||
.chart-title {
|
flex-direction: column;
|
||||||
font-size: 13px;
|
gap: 4px;
|
||||||
}
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#target-rating-form .form-row label {
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#target-rating-form .form-row input {
|
||||||
|
padding: 6px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#target-rating-form .form-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result {
|
||||||
|
margin-top: 16px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .target-summary div {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .warning {
|
||||||
|
color: var(--down);
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .error {
|
||||||
|
color: var(--red);
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .muted {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .loading {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .no-history-prompt {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .sensitivity {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px dashed var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .sensitivity-heading {
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .sensitivity-row {
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
padding-left: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.target-rating-result .sensitivity-row.is-target {
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-34
@@ -708,21 +708,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 +764,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);
|
||||||
|
|||||||
@@ -30,6 +30,44 @@ function toggleCourseLayouts(courseId) {
|
|||||||
layoutsContainer.dataset.loaded = 'true';
|
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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function scrapeCourses() {
|
async function scrapeCourses() {
|
||||||
const btn = document.getElementById('scrape-courses-btn');
|
const btn = document.getElementById('scrape-courses-btn');
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
|
|||||||
+325
-8
@@ -32,7 +32,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);
|
||||||
@@ -516,18 +529,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');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -540,3 +569,291 @@ document.addEventListener('keydown', function(e) {
|
|||||||
const pdgaNumber = row.id.replace('row-', '');
|
const pdgaNumber = row.id.replace('row-', '');
|
||||||
togglePlayerHistory(parseInt(pdgaNumber, 10));
|
togglePlayerHistory(parseInt(pdgaNumber, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ── Target Rating Calculator ───────────────────────
|
||||||
|
function openTargetRatingModal(pdgaNumber) {
|
||||||
|
const modal = document.getElementById('target-rating-modal');
|
||||||
|
const header = document.getElementById('target-rating-modal-header');
|
||||||
|
const pdgaField = document.getElementById('target-rating-pdga');
|
||||||
|
const result = document.getElementById('target-rating-result');
|
||||||
|
const targetInput = document.getElementById('target-rating-input');
|
||||||
|
const roundsInput = document.getElementById('target-rounds-input');
|
||||||
|
const submitBtn = document.getElementById('target-rating-submit');
|
||||||
|
|
||||||
|
const playerNameEl = document.querySelector('#row-' + pdgaNumber + ' .player-name a');
|
||||||
|
const playerName = playerNameEl ? playerNameEl.textContent : 'PDGA #' + pdgaNumber;
|
||||||
|
|
||||||
|
header.textContent = 'Calculate Target Rating — ' + playerName;
|
||||||
|
pdgaField.value = pdgaNumber;
|
||||||
|
result.style.display = 'none';
|
||||||
|
while (result.firstChild) result.removeChild(result.firstChild);
|
||||||
|
targetInput.value = '';
|
||||||
|
roundsInput.value = '4';
|
||||||
|
submitBtn.disabled = false;
|
||||||
|
submitBtn.textContent = 'Calculate';
|
||||||
|
modal.style.display = 'flex';
|
||||||
|
targetInput.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function _targetResultMsg(parent, cls, text) {
|
||||||
|
const d = document.createElement('div');
|
||||||
|
d.className = cls;
|
||||||
|
d.textContent = text;
|
||||||
|
parent.appendChild(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function calculateTargetRating(event) {
|
||||||
|
if (event) event.preventDefault();
|
||||||
|
const pdgaNumber = document.getElementById('target-rating-pdga').value;
|
||||||
|
const targetRating = parseInt(document.getElementById('target-rating-input').value, 10);
|
||||||
|
const rounds = parseInt(document.getElementById('target-rounds-input').value, 10);
|
||||||
|
const result = document.getElementById('target-rating-result');
|
||||||
|
const submitBtn = document.getElementById('target-rating-submit');
|
||||||
|
|
||||||
|
function clearResult() {
|
||||||
|
while (result.firstChild) result.removeChild(result.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Number.isInteger(targetRating) || targetRating < 400 || targetRating > 1200) {
|
||||||
|
result.style.display = 'block';
|
||||||
|
clearResult();
|
||||||
|
_targetResultMsg(result, 'error', 'Target rating must be 400-1200.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Number.isInteger(rounds) || rounds < 1 || rounds > 20) {
|
||||||
|
result.style.display = 'block';
|
||||||
|
clearResult();
|
||||||
|
_targetResultMsg(result, 'error', 'Rounds must be an integer 1-20.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitBtn.disabled = true;
|
||||||
|
submitBtn.textContent = 'Calculating...';
|
||||||
|
result.style.display = 'block';
|
||||||
|
clearResult();
|
||||||
|
_targetResultMsg(result, 'loading', 'Calculating...');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/calculate-target-rating/' + pdgaNumber, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ targetRating: targetRating, rounds: rounds })
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
clearResult();
|
||||||
|
|
||||||
|
if (!response.ok || !data.success) {
|
||||||
|
if (response.status === 404 && data.errorType === 'NO_ROUNDS') {
|
||||||
|
renderNoHistoryPrompt(pdgaNumber, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const msg = data.details ? data.error + ': ' + data.details : (data.error || 'Calculation failed');
|
||||||
|
_targetResultMsg(result, 'error', msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const summary = document.createElement('div');
|
||||||
|
summary.className = 'target-summary';
|
||||||
|
|
||||||
|
const avgLine = document.createElement('div');
|
||||||
|
const avgStrong = document.createElement('strong');
|
||||||
|
avgStrong.textContent = 'Required round average: ';
|
||||||
|
avgLine.appendChild(avgStrong);
|
||||||
|
avgLine.appendChild(document.createTextNode(String(data.requiredAverage)));
|
||||||
|
summary.appendChild(avgLine);
|
||||||
|
|
||||||
|
const currentLine = document.createElement('div');
|
||||||
|
currentLine.textContent = 'Current predicted rating: ' + data.currentRating;
|
||||||
|
summary.appendChild(currentLine);
|
||||||
|
|
||||||
|
const simLine = document.createElement('div');
|
||||||
|
simLine.textContent = 'Simulated predicted rating at this average: ' + data.predictedRating;
|
||||||
|
summary.appendChild(simLine);
|
||||||
|
|
||||||
|
const mutedLine = document.createElement('div');
|
||||||
|
mutedLine.className = 'muted';
|
||||||
|
mutedLine.textContent = 'Across ' + data.rounds + ' synthetic rounds before the next PDGA update.';
|
||||||
|
summary.appendChild(mutedLine);
|
||||||
|
|
||||||
|
if (data.sensitivity) {
|
||||||
|
renderSensitivity(data.sensitivity, summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.warning) {
|
||||||
|
_targetResultMsg(summary, 'warning', data.warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.appendChild(summary);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error calculating target rating:', err);
|
||||||
|
clearResult();
|
||||||
|
_targetResultMsg(result, 'error', 'Network error. Please try again.');
|
||||||
|
} finally {
|
||||||
|
submitBtn.disabled = false;
|
||||||
|
submitBtn.textContent = 'Calculate';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeTargetRatingModal(event) {
|
||||||
|
document.getElementById('target-rating-modal').style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSensitivity(sensitivity, container) {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
wrapper.className = 'sensitivity';
|
||||||
|
|
||||||
|
const heading = document.createElement('div');
|
||||||
|
heading.className = 'sensitivity-heading';
|
||||||
|
heading.textContent = 'Sensitivity:';
|
||||||
|
wrapper.appendChild(heading);
|
||||||
|
|
||||||
|
const rows = [
|
||||||
|
{ row: sensitivity.lower, isTarget: false },
|
||||||
|
{ row: sensitivity.target, isTarget: true },
|
||||||
|
{ row: sensitivity.upper, isTarget: false }
|
||||||
|
];
|
||||||
|
for (const { row, isTarget } of rows) {
|
||||||
|
const line = document.createElement('div');
|
||||||
|
line.className = 'sensitivity-row' + (isTarget ? ' is-target' : '');
|
||||||
|
line.textContent = 'Average ' + row.average + ' → predicted ' + row.predicted + (isTarget ? ' (target)' : '');
|
||||||
|
wrapper.appendChild(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
container.appendChild(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderNoHistoryPrompt(pdgaNumber, container) {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
wrapper.className = 'no-history-prompt';
|
||||||
|
|
||||||
|
const msg = document.createElement('div');
|
||||||
|
msg.textContent = 'No round-level history is stored for this player yet. Refresh from PDGA to enable the calculation.';
|
||||||
|
wrapper.appendChild(msg);
|
||||||
|
|
||||||
|
const btn = document.createElement('button');
|
||||||
|
btn.type = 'button';
|
||||||
|
btn.className = 'btn btn-confirm';
|
||||||
|
btn.textContent = 'Refresh round history & calculate';
|
||||||
|
btn.addEventListener('click', function () { refreshHistoryThenCalculate(pdgaNumber); });
|
||||||
|
wrapper.appendChild(btn);
|
||||||
|
|
||||||
|
container.appendChild(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshHistoryThenCalculate(pdgaNumber) {
|
||||||
|
const result = document.getElementById('target-rating-result');
|
||||||
|
while (result.firstChild) result.removeChild(result.firstChild);
|
||||||
|
_targetResultMsg(result, 'loading', 'Refreshing round history from PDGA — this may take up to 30 seconds...');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/refresh-round-history/' + pdgaNumber, { method: 'POST' });
|
||||||
|
const data = await response.json();
|
||||||
|
while (result.firstChild) result.removeChild(result.firstChild);
|
||||||
|
|
||||||
|
if (response.status === 429) {
|
||||||
|
const hours = data.hoursRemaining ? data.hoursRemaining + ' hour(s)' : 'a while';
|
||||||
|
_targetResultMsg(result, 'error', 'Round history was refreshed recently. Try again in ' + hours + '.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.ok || !data.success) {
|
||||||
|
const msg = data.details ? data.error + ': ' + data.details : (data.error || 'Refresh failed');
|
||||||
|
_targetResultMsg(result, 'error', msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.debugLog) cachedDebugInfo[pdgaNumber] = data.debugLog;
|
||||||
|
const predictedCell = document.getElementById('predicted-' + pdgaNumber);
|
||||||
|
if (predictedCell) {
|
||||||
|
const predictedValue = predictedCell.querySelector('.predicted-value');
|
||||||
|
if (predictedValue) {
|
||||||
|
predictedValue.textContent = data.predictedRating || 'N/A';
|
||||||
|
predictedValue.dataset.stddev = data.stdDev || '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await calculateTargetRating(null);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error refreshing round history:', err);
|
||||||
|
while (result.firstChild) result.removeChild(result.firstChild);
|
||||||
|
_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 = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const { launchBrowser } = require('../scrapers/browser');
|
|||||||
const { getPlayerDataFromDB, scrapePDGARating, getAllRatingsFromDB, refreshAllPlayersInDB, getPredictedRatingFromDB, formatDisplayDate } = require('../services/player-service');
|
const { getPlayerDataFromDB, scrapePDGARating, getAllRatingsFromDB, refreshAllPlayersInDB, getPredictedRatingFromDB, formatDisplayDate } = require('../services/player-service');
|
||||||
const { getTopbarLocals } = require('../services/topbar-service');
|
const { getTopbarLocals } = require('../services/topbar-service');
|
||||||
const { calculatePredictedRating } = require('../services/rating-calculator');
|
const { calculatePredictedRating } = require('../services/rating-calculator');
|
||||||
|
const { calculateRequiredAverage } = require('../services/target-rating-calculator');
|
||||||
const logger = require('../logger');
|
const logger = require('../logger');
|
||||||
|
|
||||||
let refreshInProgress = false;
|
let refreshInProgress = false;
|
||||||
@@ -442,4 +443,71 @@ router.post('/api/refresh-round-history/:pdgaNumber', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/api/calculate-target-rating/:pdgaNumber', async (req, res) => {
|
||||||
|
const { pdgaNumber } = req.params;
|
||||||
|
const pdgaNum = parseInt(pdgaNumber, 10);
|
||||||
|
const { targetRating, rounds } = req.body || {};
|
||||||
|
|
||||||
|
if (!Number.isFinite(pdgaNum) || pdgaNum <= 0) {
|
||||||
|
return res.status(400).json({ error: 'Invalid PDGA number' });
|
||||||
|
}
|
||||||
|
const target = Number(targetRating);
|
||||||
|
const numRounds = Number(rounds);
|
||||||
|
if (!Number.isFinite(target) || target < 400 || target > 1200) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Invalid target rating',
|
||||||
|
details: 'targetRating must be a number between 400 and 1200'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!Number.isInteger(numRounds) || numRounds < 1 || numRounds > 20) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Invalid round count',
|
||||||
|
details: 'rounds must be an integer between 1 and 20'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const dbRounds = await getRoundHistoryFromDB(pdgaNum);
|
||||||
|
if (!dbRounds || dbRounds.length === 0) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'No round history available',
|
||||||
|
details: 'Refresh the player round history before calculating a target.',
|
||||||
|
errorType: 'NO_ROUNDS'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const roundRatings = dbRounds.map(r => ({
|
||||||
|
rating: r.rating,
|
||||||
|
date: new Date(r.date),
|
||||||
|
competition: r.competition_name
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = calculateRequiredAverage(roundRatings, target, numRounds);
|
||||||
|
|
||||||
|
logger.info(`Target rating calc for PDGA ${pdgaNum}: target=${target} rounds=${numRounds} -> avg=${result.requiredAverage}`);
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
success: true,
|
||||||
|
pdgaNumber: pdgaNum,
|
||||||
|
targetRating: target,
|
||||||
|
rounds: numRounds,
|
||||||
|
currentRating: result.currentPredicted,
|
||||||
|
requiredAverage: result.requiredAverage,
|
||||||
|
predictedRating: result.simulatedPredicted,
|
||||||
|
warning: result.warning,
|
||||||
|
iterations: result.iterations,
|
||||||
|
sensitivity: result.sensitivity
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(`Target rating calc failed for PDGA ${pdgaNum}: ${err.message}`);
|
||||||
|
return res.status(500).json({
|
||||||
|
error: 'Failed to calculate target rating',
|
||||||
|
details: err.message,
|
||||||
|
errorType: err.code || 'CALC_ERROR',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
suggestion: 'Try refreshing the round history and retrying.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
const { calculatePredictedRating, getNextPDGAUpdateDate } = require('./rating-calculator');
|
||||||
|
const logger = require('../logger');
|
||||||
|
|
||||||
|
function calculateRequiredAverage(roundRatings, targetRating, numRounds) {
|
||||||
|
if (!Array.isArray(roundRatings) || roundRatings.length === 0) {
|
||||||
|
const err = new Error('No round history');
|
||||||
|
err.code = 'NO_ROUNDS';
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentPredicted = calculatePredictedRating(roundRatings).rating;
|
||||||
|
const nextUpdate = getNextPDGAUpdateDate();
|
||||||
|
const syntheticDate = new Date(nextUpdate.getTime() - 24 * 60 * 60 * 1000);
|
||||||
|
|
||||||
|
const simulate = (R) => {
|
||||||
|
const synthetic = [];
|
||||||
|
for (let i = 0; i < numRounds; i++) {
|
||||||
|
synthetic.push({ rating: R, date: syntheticDate, competition: 'TARGET_SIM' });
|
||||||
|
}
|
||||||
|
return calculatePredictedRating([...roundRatings, ...synthetic]).rating;
|
||||||
|
};
|
||||||
|
|
||||||
|
let lo = 400;
|
||||||
|
let hi = 1200;
|
||||||
|
let iterations = 0;
|
||||||
|
const maxIterations = 30;
|
||||||
|
let exactMatchAvg = null;
|
||||||
|
|
||||||
|
while (iterations < maxIterations && (hi - lo) >= 0.5) {
|
||||||
|
const mid = (lo + hi) / 2;
|
||||||
|
const predicted = simulate(mid);
|
||||||
|
if (predicted === targetRating) {
|
||||||
|
exactMatchAvg = mid;
|
||||||
|
// Narrow toward smaller R that still hits target — but break to bound iterations.
|
||||||
|
hi = mid;
|
||||||
|
} else if (predicted < targetRating) {
|
||||||
|
lo = mid;
|
||||||
|
} else {
|
||||||
|
hi = mid;
|
||||||
|
}
|
||||||
|
iterations++;
|
||||||
|
}
|
||||||
|
|
||||||
|
const candidate = exactMatchAvg !== null ? exactMatchAvg : (lo + hi) / 2;
|
||||||
|
const requiredAverage = Math.round(candidate * 10) / 10;
|
||||||
|
const simulatedPredicted = simulate(requiredAverage);
|
||||||
|
|
||||||
|
let warning = null;
|
||||||
|
if (requiredAverage >= 1199.5) {
|
||||||
|
warning = 'Target may be unreachable with this number of rounds within the simulated range [400, 1200].';
|
||||||
|
} else if (requiredAverage <= 400.5) {
|
||||||
|
warning = 'Required average is at the lower bound — target may already be exceeded or rounds would drag rating down.';
|
||||||
|
} else if (requiredAverage > 1050) {
|
||||||
|
warning = 'Required average is extremely high (>1050) — practically very difficult.';
|
||||||
|
} else if (requiredAverage < 600) {
|
||||||
|
warning = 'Required average is very low (<600) — check that your target is reasonable.';
|
||||||
|
} else if (iterations >= maxIterations && Math.abs(simulatedPredicted - targetRating) > 1) {
|
||||||
|
warning = 'Could not converge precisely; result is approximate.';
|
||||||
|
}
|
||||||
|
|
||||||
|
const lowerAvg = Math.max(400, Math.round((requiredAverage - 1) * 10) / 10);
|
||||||
|
const upperAvg = Math.min(1200, Math.round((requiredAverage + 1) * 10) / 10);
|
||||||
|
const sensitivity = {
|
||||||
|
lower: { average: lowerAvg, predicted: simulate(lowerAvg) },
|
||||||
|
target: { average: requiredAverage, predicted: simulatedPredicted },
|
||||||
|
upper: { average: upperAvg, predicted: simulate(upperAvg) }
|
||||||
|
};
|
||||||
|
|
||||||
|
logger.debug(`Target rating calc: target=${targetRating} rounds=${numRounds} → avg=${requiredAverage} (iterations=${iterations}, simulated=${simulatedPredicted})`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
requiredAverage,
|
||||||
|
currentPredicted,
|
||||||
|
simulatedPredicted,
|
||||||
|
iterations,
|
||||||
|
warning,
|
||||||
|
sensitivity
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { calculateRequiredAverage };
|
||||||
@@ -19,6 +19,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Mobile tab pill (visible only on mobile via CSS) -->
|
||||||
|
<div class="m-tab-pill">
|
||||||
|
<button class="m-tab-pill__btn m-tab-pill__btn--active" type="button">Find courses</button>
|
||||||
|
<button class="m-tab-pill__btn m-tab-pill__btn--disabled" type="button" disabled>Import from Tjing</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mobile search input (hidden on desktop, shown on mobile via CSS) -->
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="m-search-input"
|
||||||
|
id="course-search-mobile"
|
||||||
|
name="q"
|
||||||
|
placeholder="Search courses by name or city..."
|
||||||
|
hx-get="/partials/course-table"
|
||||||
|
hx-trigger="input changed delay:300ms, search"
|
||||||
|
hx-target="#courses-table"
|
||||||
|
/>
|
||||||
|
|
||||||
<div id="courses-table" hx-get="/partials/course-table" hx-trigger="load"></div>
|
<div id="courses-table" hx-get="/partials/course-table" hx-trigger="load"></div>
|
||||||
`; %>
|
`; %>
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,20 @@
|
|||||||
|
|
||||||
<!-- 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 = `
|
||||||
@@ -102,6 +116,31 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Target Rating Modal -->
|
||||||
|
<div id="target-rating-modal" class="modal" onclick="closeTargetRatingModal(event)">
|
||||||
|
<div class="modal-content" onclick="event.stopPropagation()">
|
||||||
|
<button class="modal-close" onclick="closeTargetRatingModal()">×</button>
|
||||||
|
<div class="modal-header" id="target-rating-modal-header">Calculate Target Rating</div>
|
||||||
|
<div class="modal-body" id="target-rating-modal-body">
|
||||||
|
<form id="target-rating-form" onsubmit="calculateTargetRating(event)">
|
||||||
|
<input type="hidden" id="target-rating-pdga" value="">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="target-rating-input">Target predicted rating</label>
|
||||||
|
<input type="number" id="target-rating-input" min="400" max="1200" step="1" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="target-rounds-input">Number of rounds</label>
|
||||||
|
<input type="number" id="target-rounds-input" min="1" max="20" step="1" value="4" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="submit" class="btn btn-confirm" id="target-rating-submit">Calculate</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div id="target-rating-result" class="target-rating-result" style="display:none;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
`; %>
|
`; %>
|
||||||
|
|
||||||
<%- include('../partials/layout', {
|
<%- include('../partials/layout', {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
<% } %>
|
||||||
@@ -43,4 +43,5 @@
|
|||||||
<% }); %>
|
<% }); %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<%- include('course-cards', { courses: courses, query: locals.query, total: locals.total }) %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@@ -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 %>">
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<%
|
||||||
|
// 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>
|
||||||
|
<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>
|
||||||
|
</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;
|
||||||
@@ -82,6 +84,9 @@ function renderSparkline(values) {
|
|||||||
<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">
|
||||||
<i class="fas fa-sync-alt"></i>
|
<i class="fas fa-sync-alt"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<button class="icon-btn target-rating-icon" onclick="openTargetRatingModal(<%= player.pdgaNumber %>)" title="Calculate target rating" aria-label="Calculate target rating">
|
||||||
|
<i class="fas fa-bullseye"></i>
|
||||||
|
</button>
|
||||||
<button class="icon-btn icon-chev" onclick="togglePlayerHistory(<%= player.pdgaNumber %>)" title="Expand row" aria-label="Expand">
|
<button class="icon-btn icon-chev" onclick="togglePlayerHistory(<%= player.pdgaNumber %>)" title="Expand row" aria-label="Expand">
|
||||||
<i class="fas fa-chevron-down"></i>
|
<i class="fas fa-chevron-down"></i>
|
||||||
</button>
|
</button>
|
||||||
@@ -101,4 +106,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