Skip to content

Commit 25e9e80

Browse files
committed
update-sites/stats: simplify single site select
It was easy before the comparison feature was added. Let's keep it easy.
1 parent f720345 commit 25e9e80

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

_pages/update-sites/stats.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ section: Extend:Update Sites
5353

5454
<label class="heading">Compare To:</label>
5555
<div class="widgets">
56-
<select id="op" onchange="updateChart()">
57-
<option value="+">+</option>
56+
<select id="op" onchange="updateCompareMode(); updateChart()">
57+
<option value=""></option>
58+
<option value="+" selected>+</option>
5859
<option value="/">/</option>
5960
<option value="%">%</option>
6061
</select>
@@ -105,6 +106,21 @@ section: Extend:Update Sites
105106
return { site, op, site2, timeWindow, countType, rollingAverage };
106107
}
107108

109+
function updateCompareMode() {
110+
const op = document.getElementById('op').value;
111+
const site2Select = document.getElementById('site2');
112+
113+
if (op === '') {
114+
// Single site mode
115+
site2Select.disabled = true;
116+
site2Select.style.opacity = '0.5';
117+
} else {
118+
// Comparison mode
119+
site2Select.disabled = false;
120+
site2Select.style.opacity = '1';
121+
}
122+
}
123+
108124
function updateRollingAverageState() {
109125
const { timeWindow } = getSelectedValues();
110126
const checkbox = document.getElementById('rolling-average');
@@ -359,8 +375,8 @@ section: Extend:Update Sites
359375
};
360376
}
361377

362-
// If site2 is selected, fetch and combine data
363-
if (site2 && site2 !== site) {
378+
// If comparison mode is enabled and site2 is selected
379+
if (op && site2 && site2 !== site) {
364380
const rawData2 = await fetchStatsData(site2, timeWindow, countType);
365381
const filledData2 = fillDateGaps(rawData2, timeWindow);
366382

@@ -442,7 +458,8 @@ section: Extend:Update Sites
442458
site2Select.appendChild(site2Option);
443459
}
444460

445-
// Initial chart update
461+
// Initialize compare mode state and chart
462+
updateCompareMode();
446463
updateChart();
447464

448465
} catch (error) {
@@ -461,6 +478,7 @@ section: Extend:Update Sites
461478
siteSelect.appendChild(siteOption);
462479
site2Select.appendChild(site2Option);
463480
}
481+
updateCompareMode();
464482
updateChart();
465483
}
466484
}

0 commit comments

Comments
 (0)