diff --git a/static/score.js b/static/score.js index 1a7fff6..a1f9e52 100644 --- a/static/score.js +++ b/static/score.js @@ -14,7 +14,20 @@ const SEASON_NAMES = { djf: "Winter", mam: "Spring", jja: "Summer", son: "Fall" const SEASON_ORDER = ["djf", "mam", "jja", "son"]; const tintColor = (cls) => TIER_COLORS[cls] || ""; -const tintClass = (cls) => (cls ? `t-${cls}` : "t-none"); +const tintClass = (cls) => `t-${cls}`; + +// A signed-points chip, colored up (▲) or down (▼): "+3" / "-2". +const signedPts = (d, suffix = "") => + `${d >= 0 ? "+" : ""}${d}${suffix}`; + +// One tinted score cell (an em-dash when the entry has no score). `strong` bolds +// the number for an Overall row/column; the tint + hover title come from the entry. +function scoreCell(entry, strong = false) { + if (!entry || entry.score == null) return `—`; + const title = entry.label ? `${entry.label}: ${entry.grade}` : entry.grade; + const num = strong ? `${entry.score}` : `${entry.score}`; + return `${num}`; +} let selected = null; // {lat, lon} let lastData = null; // most recent /score response, for repainting on a unit switch @@ -101,7 +114,7 @@ function render(data) { // ---- hero: the overall annual score ---- scoreHead.innerHTML = `
-

Climate-shift score · ${esc(place)}

+

Climate-shift score · ${esc(place)}

${ov.score}
@@ -122,12 +135,8 @@ function render(data) { `${shortLabel(k)}`).join("")}`; const seasonRows = SEASON_ORDER.map((sk) => { const sl = s.slices[sk]; - const oc = sl.overall; - const overallCell = oc - ? `${oc.score}` - : `—`; - const cells = METRIC_ORDER.map((k) => seasonCell(sl.metrics[k])).join(""); - return `${SEASON_NAMES[sk]}${overallCell}${cells}`; + const cells = METRIC_ORDER.map((k) => scoreCell(sl.metrics[k])).join(""); + return `${SEASON_NAMES[sk]}${scoreCell(sl.overall, true)}${cells}`; }).join(""); scoreBody.innerHTML = ` @@ -135,7 +144,7 @@ function render(data) { ${wbNote}

By season

-
+
${seasonHead}${seasonRows}