summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen D'Ambrosio <ken@claude>2026-05-25 01:17:28 +0000
committerKen D'Ambrosio <ken@claude>2026-05-25 01:17:28 +0000
commitec8364baf3cf95fa2404c4e5e1e6b70bf3e7311c (patch)
treec600ecac8e71bb4fede838570f9d4323a0b5626f
parentab9b1465ec45570938dc7a3eaf3e4c44dc9be0d6 (diff)
Replace <input type="week"> with <input type="date"> for browser compatmaster
type="week" is unsupported in Firefox and Safari. Use type="date" instead — pick any day in the target week and JS rewinds to Monday. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--app/templates/index.html16
1 files changed, 7 insertions, 9 deletions
diff --git a/app/templates/index.html b/app/templates/index.html
index c690525..1714ddb 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -9,8 +9,8 @@
</div>
<div class="d-flex gap-2 align-items-center">
<a href="/?week={{ prev_week }}" class="btn btn-outline-secondary btn-sm"><i class="bi bi-chevron-left"></i></a>
- <input type="week" id="weekPicker" class="form-control form-control-sm" style="width:160px"
- value="{{ week_start.strftime('%G-W%V') }}">
+ <input type="date" id="weekPicker" class="form-control form-control-sm" style="width:150px"
+ value="{{ week_start.isoformat() }}" title="Pick any day in the week you want">
{% if not is_current_week %}
<a href="/" class="btn btn-outline-secondary btn-sm">Today</a>
{% endif %}
@@ -123,13 +123,11 @@
const todayStr = '{{ today_str }}';
document.getElementById('weekPicker').addEventListener('change', function() {
if (!this.value) return;
- // value is "YYYY-Www" — convert to Mon of that ISO week
- const [year, week] = this.value.split('-W').map(Number);
- const jan4 = new Date(year, 0, 4); // Jan 4 is always in week 1
- const dayOfWeek = jan4.getDay() || 7; // Mon=1..Sun=7
- const mon = new Date(jan4);
- mon.setDate(jan4.getDate() - (dayOfWeek - 1) + (week - 1) * 7);
- const iso = mon.toISOString().split('T')[0];
+ // Rewind picked date to Monday of that week
+ const d = new Date(this.value + 'T00:00:00');
+ const day = d.getDay() || 7; // Sun=0→7, Mon=1
+ d.setDate(d.getDate() - (day - 1));
+ const iso = d.toISOString().split('T')[0];
window.location.href = '/?week=' + iso;
});
</script>