fix: reposition std-dev tooltip and surface ±-spread inline (#19)

This commit is contained in:
Samuel Enocsson
2026-05-23 06:40:08 +02:00
parent c69efa469e
commit c3fb850de3
3 changed files with 23 additions and 19 deletions
+12 -16
View File
@@ -68,16 +68,6 @@ function setupAfterTableSwap() {
}
function initRatingsTooltips() {
document.querySelectorAll('.predicted-value').forEach(span => {
const pdgaNumber = span.dataset.pdga;
const stdDev = span.dataset.stddev;
const tooltip = document.getElementById(`tooltip-stddev-${pdgaNumber}`);
if (stdDev && tooltip) {
setupTooltip(span, tooltip, () => `Standard Deviation: \u00b1${stdDev}`);
}
});
document.querySelectorAll('.rating-value').forEach(span => {
const pdgaNumber = span.dataset.pdga;
const rating = parseInt(span.dataset.rating);
@@ -87,7 +77,7 @@ function initRatingsTooltips() {
if (rating && stdDev && tooltip) {
const minRating = rating - stdDev;
const maxRating = rating + stdDev;
setupTooltip(span, tooltip, () => `Rating Range: ${minRating} - ${maxRating} (\u00b1${stdDev})`);
setupTooltip(span, tooltip, () => `Spridning: \u00b1${stdDev} po\u00e4ng\nIntervall: ${minRating}\u2013${maxRating}`);
}
});
}
@@ -199,7 +189,7 @@ async function refreshPlayer(pdgaNumber) {
if (rating && stdDev && tooltip) {
const minRating = rating - stdDev;
const maxRating = rating + stdDev;
replaceWithTooltip(ratingValue, tooltip, () => `Rating Range: ${minRating} - ${maxRating} (\u00b1${stdDev})`);
replaceWithTooltip(ratingValue, tooltip, () => `Spridning: \u00b1${stdDev} po\u00e4ng\nIntervall: ${minRating}\u2013${maxRating}`);
}
}
@@ -233,9 +223,15 @@ async function refreshRoundHistory(pdgaNumber) {
predictedValue.textContent = data.predictedRating || 'N/A';
predictedValue.dataset.stddev = data.stdDev || '';
const tooltip = document.getElementById(`tooltip-stddev-${pdgaNumber}`);
if (data.stdDev && tooltip) {
replaceWithTooltip(predictedValue, tooltip, () => `Standard Deviation: \u00b1${data.stdDev}`);
const predStack = predictedValue.closest('.pred-stack');
const stdDevInline = predStack ? predStack.querySelector('.std-dev-inline') : null;
if (stdDevInline) {
if (data.stdDev) {
stdDevInline.textContent = '\u00b1' + data.stdDev;
stdDevInline.style.display = '';
} else {
stdDevInline.style.display = 'none';
}
}
}
}
@@ -253,7 +249,7 @@ async function refreshRoundHistory(pdgaNumber) {
if (rating && stdDev && ratingTooltip) {
const minRating = rating - stdDev;
const maxRating = rating + stdDev;
replaceWithTooltip(ratingValue, ratingTooltip, () => `Rating Range: ${minRating} - ${maxRating} (\u00b1${stdDev})`);
replaceWithTooltip(ratingValue, ratingTooltip, () => `Spridning: \u00b1${stdDev} po\u00e4ng\nIntervall: ${minRating}\u2013${maxRating}`);
}
}
}