fill and clear
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
Nycki 2025-11-15 10:47:54 -08:00
parent 1a1c8bc5ba
commit 19e738c086

View file

@ -158,6 +158,14 @@
<label for="date">start date:</label> <label for="date">start date:</label>
<input id="settings-date" type="date" name="date"> <input id="settings-date" type="date" name="date">
</div> </div>
<div>
<label for="settings-has-week">show week number</label>
<input id="settings-has-week" type="checkbox" name="settings-has-week" checked>
</div>
<div>
<label for="settings-start-monday">always start on monday</label>
<input id="settings-start-monday" type="checkbox" name="settings-start-monday" checked>
</div>
<div> <div>
<label for="name">name:</label> <label for="name">name:</label>
<input id="settings-name" type="text" name="name"> <input id="settings-name" type="text" name="name">
@ -167,6 +175,7 @@
<input id="settings-contact" type="text" name="contact"> <input id="settings-contact" type="text" name="contact">
</div> </div>
<button id="settings-update">generate</button> <button id="settings-update">generate</button>
<button id="settings-clear">clear all</button>
</div> </div>
<div id="document"> <div id="document">
<div class="page"> <div class="page">
@ -306,7 +315,6 @@
</div> </div>
<script> <script>
const elDate = document.querySelector('#settings-date'); const elDate = document.querySelector('#settings-date');
const elButton = document.querySelector('#settings-update');
const weekday = [ const weekday = [
'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
@ -323,10 +331,16 @@
let startDate = new Date(elDate.value); let startDate = new Date(elDate.value);
if (isNaN(startDate)) startDate = new Date(); if (isNaN(startDate)) startDate = new Date();
if (document.querySelector('#settings-start-monday').checked) {
startDate.setDate(startDate.getDate() - startDate.getDay() + 1);
}
let d; let d;
startDate.setHours(12); // I don't care about the time zone startDate.setHours(12); // I don't care about the time zone
document.querySelector('.week').textContent = startDate.getFullYear() + "W" + getWeek(startDate); document.querySelector('.week').textContent = startDate.getFullYear();
if (document.querySelector('#settings-has-week').checked) {
document.querySelector('.week').textContent += `W${getWeek(startDate)}`;
}
const mm1 = startDate.getMonth() + 1; const mm1 = startDate.getMonth() + 1;
const dd1 = startDate.getDate(); const dd1 = startDate.getDate();
@ -355,7 +369,15 @@
} }
} }
elButton.onclick = update; function clear() {
document.querySelector('.week').textContent = '';
document.querySelector('.date').textContent = '';
document.querySelectorAll('td').forEach(el => el.innerHTML = '&nbsp;');
}
document.querySelector('#settings-update').onclick = update;
document.querySelector('#settings-clear').onclick = clear;
update();
</script> </script>
</body> </body>
</html> </html>