Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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.
|
||||
- **Frontend JS:** `console.error` is fine in `public/js/` — runs in browser, no Pino.
|
||||
- **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.
|
||||
- **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.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "pdga-ratings",
|
||||
"version": "1.2.8",
|
||||
"version": "1.2.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pdga-ratings",
|
||||
"version": "1.2.8",
|
||||
"version": "1.2.10",
|
||||
"dependencies": {
|
||||
"ejs": "^4.0.1",
|
||||
"express": "^4.18.2",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pdga-ratings",
|
||||
"version": "1.2.8",
|
||||
"version": "1.2.10",
|
||||
"description": "PDGA rating scraper and display",
|
||||
"main": "server.js",
|
||||
"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) */
|
||||
@@ -10,16 +10,6 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.mobile-only {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.player-name {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Rating values ────────────────────────────── */
|
||||
|
||||
.rating-value {
|
||||
@@ -286,19 +276,6 @@
|
||||
background: #059669;
|
||||
}
|
||||
|
||||
/* ── Responsive ───────────────────────────────── */
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.chart-container {
|
||||
height: 250px;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.chart-title {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Target Rating Calculator ─────────────────── */
|
||||
|
||||
.target-rating-icon {
|
||||
|
||||
+3
-34
@@ -708,21 +708,7 @@ a:hover {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.add-bar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.add-bar-controls {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.input-wrap {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
/* add-bar responsive handled by mobile.css (≤880px hides it entirely) */
|
||||
|
||||
/* ── Inputs ───────────────────────────────────── */
|
||||
|
||||
@@ -778,26 +764,9 @@ a:hover {
|
||||
|
||||
/* ── Responsive ───────────────────────────────── */
|
||||
|
||||
/* Responsive table/container tweaks handled by mobile.css (≤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 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
+14
-9
@@ -1,4 +1,5 @@
|
||||
function createRatingChart(container, history) {
|
||||
function createRatingChart(container, history, opts) {
|
||||
opts = opts || {};
|
||||
if (!history || history.length === 0) {
|
||||
container.textContent = '';
|
||||
var empty = document.createElement('div');
|
||||
@@ -8,8 +9,13 @@ function createRatingChart(container, history) {
|
||||
return;
|
||||
}
|
||||
|
||||
var W = 880, H = 240;
|
||||
var pad = { left: 44, right: 16, top: 20, bottom: 32 };
|
||||
var W = opts.w || 880;
|
||||
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 chartH = H - pad.top - pad.bottom;
|
||||
|
||||
@@ -61,8 +67,7 @@ function createRatingChart(container, history) {
|
||||
'aria-hidden': 'true'
|
||||
});
|
||||
|
||||
// Grid lines + y-axis labels (4 ticks)
|
||||
var tickCount = 4;
|
||||
// Grid lines + y-axis labels
|
||||
for (var i = 0; i <= tickCount; i++) {
|
||||
var gy = pad.top + (i / tickCount) * chartH;
|
||||
var gr = Math.round(maxR - (i / tickCount) * range);
|
||||
@@ -96,18 +101,18 @@ function createRatingChart(container, history) {
|
||||
if (isLast) {
|
||||
svg.appendChild(el('circle', {
|
||||
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 {
|
||||
svg.appendChild(el('circle', {
|
||||
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)
|
||||
var labelCount = Math.min(5, history.length);
|
||||
// X-axis labels (evenly spaced)
|
||||
var labelCount = Math.min(xLabelCount, history.length);
|
||||
var labelIndices = [];
|
||||
if (labelCount <= 1) {
|
||||
labelIndices.push(0);
|
||||
|
||||
@@ -30,6 +30,44 @@ function toggleCourseLayouts(courseId) {
|
||||
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() {
|
||||
const btn = document.getElementById('scrape-courses-btn');
|
||||
btn.disabled = true;
|
||||
|
||||
+114
-8
@@ -32,7 +32,20 @@ function initChartsIn(rootEl) {
|
||||
if (!container.dataset.history) return;
|
||||
try {
|
||||
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';
|
||||
} catch (e) {
|
||||
console.error('Error rendering chart:', e);
|
||||
@@ -516,18 +529,34 @@ function closeAddPlayerModal(event) {
|
||||
|
||||
// ── Sparkline toggle ───────────────────────────────
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const btn = document.getElementById('trendchart-toggle');
|
||||
if (!btn) return;
|
||||
const SPARKLINE_KEY = 'ratingtracker.sparklines';
|
||||
|
||||
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;
|
||||
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';
|
||||
document.body.dataset.sparklines = next;
|
||||
btn.setAttribute('aria-pressed', next === 'on' ? 'true' : 'false');
|
||||
localStorage.setItem('ratingtracker.sparklines', next);
|
||||
localStorage.setItem(SPARKLINE_KEY, 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');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -751,3 +780,80 @@ async function refreshHistoryThenCalculate(pdgaNumber) {
|
||||
_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 = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,24 @@
|
||||
</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>
|
||||
`; %>
|
||||
|
||||
|
||||
@@ -78,6 +78,20 @@
|
||||
|
||||
<!-- Footnote -->
|
||||
<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 = `
|
||||
|
||||
@@ -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>
|
||||
</table>
|
||||
<%- include('course-cards', { courses: courses, query: locals.query, total: locals.total }) %>
|
||||
<% } %>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
<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">
|
||||
@@ -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">
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||
<link rel="stylesheet" href="/css/shared.css">
|
||||
<link rel="stylesheet" href="/css/mobile.css">
|
||||
<% if (typeof cssFiles !== 'undefined') { %>
|
||||
<% cssFiles.forEach(function(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 '';
|
||||
var w = 96, h = 28;
|
||||
var min = Math.min.apply(null, values);
|
||||
var max = Math.max.apply(null, values);
|
||||
var range = max - min || 1;
|
||||
@@ -104,4 +106,5 @@ function renderSparkline(values) {
|
||||
<% }); %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%- include('ratings-cards', { ratings: ratings }) %>
|
||||
<% } %>
|
||||
|
||||
@@ -43,4 +43,41 @@
|
||||
</button>
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user