-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -190,6 +210,30 @@ function updateTypeHint(v) {
document.getElementById('type-hint').textContent = typeHints[v] || '';
}
+// populate year dropdown: current year + 10 years ahead
+(function() {
+ const now = new Date();
+ const yearSel = document.getElementById('deadline-year');
+ const monthSel = document.getElementById('deadline-month');
+ for (let y = now.getFullYear(); y <= now.getFullYear() + 10; y++) {
+ const opt = document.createElement('option');
+ opt.value = String(y);
+ opt.textContent = String(y);
+ yearSel.appendChild(opt);
+ }
+ // default month to next month
+ const nextMonth = new Date(now.getFullYear(), now.getMonth() + 1, 1);
+ monthSel.value = String(nextMonth.getMonth() + 1).padStart(2, '0');
+ yearSel.value = String(nextMonth.getFullYear());
+})();
+
+// wire hidden field before submit
+document.querySelector('#new-goal-modal form').addEventListener('submit', function() {
+ const m = document.getElementById('deadline-month').value;
+ const y = document.getElementById('deadline-year').value;
+ document.getElementById('deadline-value').value = y + '-' + m;
+});
+
// close modal on backdrop click
document.getElementById('new-goal-modal').addEventListener('click', function(e) {
if (e.target === this) this.style.display = 'none';