38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
const Stand = {
|
|
init: async () => {
|
|
let html = await fetch('/lib/pages/stand/index.html').then((response) => response.text());
|
|
app.innerHTML = html;
|
|
|
|
let listDate = [1, 4];
|
|
|
|
function generateAvailableDates() {
|
|
let select = document.getElementById("dateSelect");
|
|
select.innerHTML = "";
|
|
|
|
let today = new Date();
|
|
today.setHours(0, 0, 0, 0);
|
|
let months = [today.getMonth(), today.getMonth() + 1];
|
|
let year = today.getFullYear();
|
|
|
|
months.forEach(month => {
|
|
let date = new Date(year, month, 1);
|
|
while (date.getMonth() === month) {
|
|
if (date >= today) {
|
|
let day = date.getDay();
|
|
if (listDate.includes(day)) {
|
|
let option = document.createElement("option");
|
|
option.value = date.toISOString().split("T")[0];
|
|
option.textContent = date.toLocaleDateString("uk-UA", {
|
|
weekday: "long", year: "numeric", month: "long", day: "numeric"
|
|
});
|
|
select.appendChild(option);
|
|
}
|
|
}
|
|
date.setDate(date.getDate() + 1);
|
|
}
|
|
});
|
|
}
|
|
|
|
generateAvailableDates();
|
|
}
|
|
} |