|
|
@@ -84,8 +84,13 @@
|
|
|
const monthSelect = document.querySelector("#historyForm select#month")
|
|
|
const yearSelect = document.querySelector("#historyForm select#year")
|
|
|
|
|
|
- monthSelect.addEventListener('change', resetHistoryForm)
|
|
|
- yearSelect.addEventListener('change', resetHistoryForm)
|
|
|
+ if (monthSelect) {
|
|
|
+ monthSelect.addEventListener('change', resetHistoryForm)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (yearSelect) {
|
|
|
+ yearSelect.addEventListener('change', resetHistoryForm)
|
|
|
+ }
|
|
|
|
|
|
function resetHistoryForm(e) {
|
|
|
daySelect.textContent = ''
|
|
|
@@ -99,19 +104,23 @@
|
|
|
|
|
|
const days = dateMap[selectedYear][selectedMonth]
|
|
|
|
|
|
- for (const day of days) {
|
|
|
- const option = document.createElement('option')
|
|
|
- option.textContent = day
|
|
|
- option.value = day
|
|
|
- daySelect.append(option)
|
|
|
+ if (daySelect) {
|
|
|
+ for (const day of days) {
|
|
|
+ const option = document.createElement('option')
|
|
|
+ option.textContent = day
|
|
|
+ option.value = day
|
|
|
+ daySelect.append(option)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (e.target.id === "year") {
|
|
|
- for (const [key, value] of Object.entries(months)) {
|
|
|
- const option = document.createElement('option')
|
|
|
- option.textContent = monthLang[key]()
|
|
|
- option.value = key
|
|
|
- monthSelect.append(option)
|
|
|
+ if (monthSelect) {
|
|
|
+ if (e.target.id === "year") {
|
|
|
+ for (const [key, value] of Object.entries(months)) {
|
|
|
+ const option = document.createElement('option')
|
|
|
+ option.textContent = monthLang[key]()
|
|
|
+ option.value = key
|
|
|
+ monthSelect.append(option)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|