@@ -71,7 +71,8 @@ section: Extend:Update Sites
71
71
72
72
<label class =" heading " >Time Window:</label >
73
73
<div class =" widgets " >
74
- <label><input type="radio" id="time-daily" name="timeWindow" value="daily" checked onchange="updateChart()"> Daily</label>
74
+ <label><input type="radio" id="time-daily" name="timeWindow" value="daily" onchange="updateChart()"> Daily</label>
75
+ <label><input type="radio" id="time-daily-avg" name="timeWindow" value="daily-avg" checked onchange="updateChart()"> Daily (7-day avg)</label>
75
76
<label><input type="radio" id="time-monthly" name="timeWindow" value="monthly" onchange="updateChart()"> Monthly</label>
76
77
<label><input type="radio" id="time-yearly" name="timeWindow" value="yearly" onchange="updateChart()"> Yearly</label>
77
78
<label><input type="radio" id="time-ever" name="timeWindow" value="ever" onchange="updateChart()"> Ever/Cumulative</label>
@@ -82,11 +83,6 @@ section: Extend:Update Sites
82
83
<label><input type="radio" id="count-unique" name="countType" value="unique" checked onchange="updateChart()"> Unique IPs</label>
83
84
<label><input type="radio" id="count-total" name="countType" value="total" onchange="updateChart()"> Total Checks</label>
84
85
</div >
85
-
86
- <label class =" heading " >Options:</label >
87
- <div class =" widgets " >
88
- <label for="rolling-average"><input type="checkbox" id="rolling-average" checked onchange="updateChart()"> 7-day rolling average</label>
89
- </div >
90
86
</div >
91
87
92
88
<div id =" loading " >Loading data...</div >
@@ -108,9 +104,8 @@ section: Extend:Update Sites
108
104
const site2 = document .getElementById (' site2' ).value ;
109
105
const timeWindow = document .querySelector (' input[name="timeWindow"]:checked' ).value ;
110
106
const countType = document .querySelector (' input[name="countType"]:checked' ).value ;
111
- const rollingAverage = document .getElementById (' rolling-average' ).checked ;
112
107
113
- return { site, op, site2, timeWindow, countType, rollingAverage };
108
+ return { site, op, site2, timeWindow, countType };
114
109
}
115
110
116
111
function updateSiteList () {
@@ -201,23 +196,10 @@ section: Extend:Update Sites
201
196
}
202
197
}
203
198
204
- function updateRollingAverageState () {
205
- const { timeWindow } = getSelectedValues ();
206
- const checkbox = document .getElementById (' rolling-average' );
207
- const label = document .querySelector (' label[for="rolling-average"]' );
208
-
209
- if (timeWindow === ' daily' ) {
210
- checkbox .disabled = false ;
211
- label .style .color = ' ' ;
212
- } else {
213
- checkbox .disabled = true ;
214
- checkbox .checked = false ;
215
- label .style .color = ' #999' ;
216
- }
217
- }
218
-
219
199
function buildStatsUrl (site , timeWindow , countType ) {
220
- const filename = ` stats-${ countType} -${ timeWindow} .txt.gz` ;
200
+ // Map daily-avg to daily for URL
201
+ const urlTimeWindow = timeWindow === ' daily-avg' ? ' daily' : timeWindow;
202
+ const filename = ` stats-${ countType} -${ urlTimeWindow} .txt.gz` ;
221
203
return ` https://sites.imagej.net/${ site} /${ filename} ` ;
222
204
}
223
205
@@ -226,7 +208,7 @@ section: Extend:Update Sites
226
208
}
227
209
228
210
function parseDate (dateStr , timeWindow ) {
229
- if (timeWindow === ' daily' || timeWindow === ' ever' ) {
211
+ if (timeWindow === ' daily' || timeWindow === ' daily-avg ' || timeWindow === ' ever' ) {
230
212
// YYYYMMDD format
231
213
const year = parseInt (dateStr .substring (0 , 4 ));
232
214
const month = parseInt (dateStr .substring (4 , 6 )) - 1 ; // JS months are 0-based
@@ -284,7 +266,7 @@ section: Extend:Update Sites
284
266
}
285
267
286
268
// Increment current date based on time window
287
- if (timeWindow === ' daily' || timeWindow === ' ever' ) {
269
+ if (timeWindow === ' daily' || timeWindow === ' daily-avg ' || timeWindow === ' ever' ) {
288
270
current .setDate (current .getDate () + 1 );
289
271
} else if (timeWindow === ' monthly' ) {
290
272
current .setMonth (current .getMonth () + 1 );
@@ -401,13 +383,10 @@ section: Extend:Update Sites
401
383
}
402
384
403
385
async function updateChart () {
404
- const { site , op , site2 , timeWindow , countType , rollingAverage } = getSelectedValues ();
386
+ const { site , op , site2 , timeWindow , countType } = getSelectedValues ();
405
387
406
388
if (! site) return ;
407
389
408
- // Update rolling average state
409
- updateRollingAverageState ();
410
-
411
390
// Show loading indicator
412
391
document .getElementById (' loading' ).style .display = ' block' ;
413
392
@@ -418,12 +397,17 @@ section: Extend:Update Sites
418
397
let chartTitle = site;
419
398
let yLabel = ` ${ countType === ' unique' ? ' Unique IP Addresses' : ' Total Update Checks' } ` ;
420
399
400
+ // Determine display time window for title
401
+ const displayTimeWindow = timeWindow === ' daily-avg' ?
402
+ ' Daily (7-day avg)' :
403
+ timeWindow .charAt (0 ).toUpperCase () + timeWindow .slice (1 );
404
+
421
405
// Configuration for chart
422
406
let chartConfig = {
423
- rollPeriod: rollingAverage && timeWindow === ' daily' ? 7 : 1 ,
407
+ rollPeriod: timeWindow === ' daily-avg ' ? 7 : 1 ,
424
408
labels: [' Date' , ` ${ countType === ' unique' ? ' Unique IPs' : ' Total Checks' } ` ],
425
409
ylabel: yLabel,
426
- title: ` ${ chartTitle} - ${ timeWindow . charAt ( 0 ). toUpperCase () + timeWindow . slice ( 1 ) } ${ countType === ' unique' ? ' Unique' : ' Total' } Statistics`
410
+ title: ` ${ chartTitle} - ${ displayTimeWindow } ${ countType === ' unique' ? ' Unique' : ' Total' } Statistics`
427
411
};
428
412
429
413
// Set X-axis formatting based on time window
@@ -483,7 +467,7 @@ section: Extend:Update Sites
483
467
}
484
468
}
485
469
486
- chartConfig .title = ` ${ chartTitle} - ${ timeWindow . charAt ( 0 ). toUpperCase () + timeWindow . slice ( 1 ) } ${ countType === ' unique' ? ' Unique' : ' Total' } Statistics` ;
470
+ chartConfig .title = ` ${ chartTitle} - ${ displayTimeWindow } ${ countType === ' unique' ? ' Unique' : ' Total' } Statistics` ;
487
471
chartConfig .ylabel = yLabel;
488
472
}
489
473
0 commit comments