refactor: move std-dev info to accordion, remove tooltip (#19)
- Add "Round spread" row (±stdDev, range lo–hi) to desktop accordion (player-history.ejs) and mobile card expanded section (ratings-cards.ejs) - Remove .std-dev-tooltip div and .std-dev-inline span from table partial - Remove stdDevTooltipText, updateStdDevInline, initRatingsTooltips helpers and all call sites from players.js - Remove .std-dev-tooltip and .std-dev-inline CSS rules; drop cursor:help from .rating-value
This commit is contained in:
@@ -26,27 +26,6 @@ function applyDeltaPill(pillEl, value) {
|
||||
pillEl.appendChild(numSpan);
|
||||
}
|
||||
|
||||
// ── Std-dev helpers ───────────────────────────────
|
||||
function stdDevTooltipText(rating, stdDev) {
|
||||
return `Spridning: ±${stdDev} poäng\nIntervall: ${rating - stdDev}–${rating + stdDev}`;
|
||||
}
|
||||
|
||||
function updateStdDevInline(predStack, stdDev) {
|
||||
if (!predStack) return;
|
||||
let stdDevInline = predStack.querySelector('.std-dev-inline');
|
||||
if (stdDev) {
|
||||
if (!stdDevInline) {
|
||||
stdDevInline = document.createElement('span');
|
||||
stdDevInline.className = 'std-dev-inline mono';
|
||||
predStack.appendChild(stdDevInline);
|
||||
}
|
||||
stdDevInline.textContent = '±' + stdDev;
|
||||
stdDevInline.style.display = '';
|
||||
} else if (stdDevInline) {
|
||||
stdDevInline.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function initChartsIn(rootEl) {
|
||||
rootEl.querySelectorAll('.player-chart').forEach(function(container) {
|
||||
if (container.dataset.charted === 'true') return;
|
||||
@@ -78,7 +57,6 @@ function setupAfterTableSwap() {
|
||||
document.body.addEventListener('htmx:afterSwap', function(event) {
|
||||
const target = event.detail.target;
|
||||
if (target.id === 'ratings-table') {
|
||||
initRatingsTooltips();
|
||||
initChartsIn(target);
|
||||
return;
|
||||
}
|
||||
@@ -88,19 +66,6 @@ function setupAfterTableSwap() {
|
||||
});
|
||||
}
|
||||
|
||||
function initRatingsTooltips() {
|
||||
document.querySelectorAll('.rating-value').forEach(span => {
|
||||
const pdgaNumber = span.dataset.pdga;
|
||||
const rating = parseInt(span.dataset.rating);
|
||||
const stdDev = parseInt(span.dataset.stddev);
|
||||
const tooltip = document.getElementById(`tooltip-rating-${pdgaNumber}`);
|
||||
|
||||
if (rating && stdDev && tooltip) {
|
||||
setupTooltip(span, tooltip, () => stdDevTooltipText(rating, stdDev));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function togglePlayerHistory(pdgaNumber) {
|
||||
const historyRow = document.getElementById('history-' + pdgaNumber);
|
||||
const contentDiv = document.getElementById('history-content-' + pdgaNumber);
|
||||
@@ -200,14 +165,6 @@ async function refreshPlayer(pdgaNumber) {
|
||||
if (ratingValue) {
|
||||
ratingValue.textContent = data.player.rating || 'N/A';
|
||||
ratingValue.dataset.rating = data.player.rating || '';
|
||||
|
||||
const stdDev = parseInt(ratingValue.dataset.stddev);
|
||||
const rating = parseInt(data.player.rating);
|
||||
const tooltip = document.getElementById(`tooltip-rating-${pdgaNumber}`);
|
||||
|
||||
if (rating && stdDev && tooltip) {
|
||||
replaceWithTooltip(ratingValue, tooltip, () => stdDevTooltipText(rating, stdDev));
|
||||
}
|
||||
}
|
||||
|
||||
const deltaMonthPill = ratingCell ? ratingCell.querySelector('.delta-pill') : null;
|
||||
@@ -239,8 +196,6 @@ async function refreshRoundHistory(pdgaNumber) {
|
||||
if (predictedValue) {
|
||||
predictedValue.textContent = data.predictedRating || 'N/A';
|
||||
predictedValue.dataset.stddev = data.stdDev || '';
|
||||
|
||||
updateStdDevInline(predictedValue.closest('.pred-stack'), data.stdDev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,14 +204,6 @@ async function refreshRoundHistory(pdgaNumber) {
|
||||
const ratingValue = ratingCell ? ratingCell.querySelector('.rating-value') : null;
|
||||
if (ratingValue && data.stdDev) {
|
||||
ratingValue.dataset.stddev = data.stdDev;
|
||||
|
||||
const rating = parseInt(ratingValue.dataset.rating);
|
||||
const stdDev = parseInt(data.stdDev);
|
||||
const ratingTooltip = document.getElementById(`tooltip-rating-${pdgaNumber}`);
|
||||
|
||||
if (rating && stdDev && ratingTooltip) {
|
||||
replaceWithTooltip(ratingValue, ratingTooltip, () => stdDevTooltipText(rating, stdDev));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -772,7 +719,6 @@ async function refreshHistoryThenCalculate(pdgaNumber) {
|
||||
if (predictedValue) {
|
||||
predictedValue.textContent = data.predictedRating || 'N/A';
|
||||
predictedValue.dataset.stddev = data.stdDev || '';
|
||||
updateStdDevInline(predictedValue.closest('.pred-stack'), data.stdDev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user