var validdates = [ { "Date": "2025-03-24", "Month": 3, "Day": 24, "ProductCount": "1件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250324/comiket_deadline_to:20250324" }, { "Date": "2025-03-25", "Month": 3, "Day": 25, "ProductCount": "9件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250325/comiket_deadline_to:20250325" }, { "Date": "2025-03-26", "Month": 3, "Day": 26, "ProductCount": "7件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250326/comiket_deadline_to:20250326" }, { "Date": "2025-03-27", "Month": 3, "Day": 27, "ProductCount": "51件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250327/comiket_deadline_to:20250327" }, { "Date": "2025-03-28", "Month": 3, "Day": 28, "ProductCount": "1件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250328/comiket_deadline_to:20250328" }, { "Date": "2025-03-31", "Month": 3, "Day": 31, "ProductCount": "6件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250331/comiket_deadline_to:20250331" }, { "Date": "2025-04-01", "Month": 4, "Day": 1, "ProductCount": "15件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250401/comiket_deadline_to:20250401" }, { "Date": "2025-04-02", "Month": 4, "Day": 2, "ProductCount": "21件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250402/comiket_deadline_to:20250402" }, { "Date": "2025-04-03", "Month": 4, "Day": 3, "ProductCount": "188件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250403/comiket_deadline_to:20250403" }, { "Date": "2025-04-04", "Month": 4, "Day": 4, "ProductCount": "44件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250404/comiket_deadline_to:20250404" }, { "Date": "2025-04-07", "Month": 4, "Day": 7, "ProductCount": "16件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250407/comiket_deadline_to:20250407" }, { "Date": "2025-04-08", "Month": 4, "Day": 8, "ProductCount": "12件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250408/comiket_deadline_to:20250408" }, { "Date": "2025-04-09", "Month": 4, "Day": 9, "ProductCount": "16件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250409/comiket_deadline_to:20250409" }, { "Date": "2025-04-10", "Month": 4, "Day": 10, "ProductCount": "32件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250410/comiket_deadline_to:20250410" }, { "Date": "2025-04-11", "Month": 4, "Day": 11, "ProductCount": "77件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250411/comiket_deadline_to:20250411" }, { "Date": "2025-04-14", "Month": 4, "Day": 14, "ProductCount": "15件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250414/comiket_deadline_to:20250414" }, { "Date": "2025-04-15", "Month": 4, "Day": 15, "ProductCount": "4件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250415/comiket_deadline_to:20250415" }, { "Date": "2025-04-17", "Month": 4, "Day": 17, "ProductCount": "19件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250417/comiket_deadline_to:20250417" }, { "Date": "2025-04-18", "Month": 4, "Day": 18, "ProductCount": "12件", "URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250418/comiket_deadline_to:20250418" } ] $(document).ready(function() { var event1 = "2025-05-03"; var event2 = "2025-05-04"; //event1; var eventname1 = "SUPER COMIC CITY 32 1日目"; //2日間や3日間イベント時変更 例:"夏コミ1日目"; var eventname2 = "SUPER COMIC CITY 32 2日目"; //eventname1; //2日間や3日間イベント時変更 例:"夏コミ2日目"; function createMonth(month, year) { var monthElement = document.createElement("div"); monthElement.className = "dp-month"; monthElement.innerHTML = "

" + year + "年" + getMonthName(month) + "

"; // Add row for day names var dayNamesRow = document.createElement("div"); dayNamesRow.className = "dp-day-names"; var dayNames = ["日", "月", "火", "水", "木", "金", "土"]; for (var i = 0; i < 7; i++) { var dayNameElement = document.createElement("div"); dayNameElement.className = "dp-day-name"; dayNameElement.textContent = dayNames[i]; dayNamesRow.appendChild(dayNameElement); } monthElement.appendChild(dayNamesRow); var daysInMonth = getDaysInMonth(month, year); var firstDay = new Date(year, month, 1).getDay(); for (var i = 0; i < firstDay; i++) { monthElement.innerHTML += "
"; } for (var i = 1; i <= daysInMonth; i++) { var dayElement = document.createElement("div"); dayElement.className = "dp-day"; // dayElement.setAttribute("data-date", new Date(year, month, i).toDateString()); // dayElement.setAttribute("data-date", new Date(year, month, i).toISOString().slice(0, 10)); const tokyoDate = new Date( new Date(year, month, i).getTime() + 9 * 60 * 60 * 1000 ); dayElement.setAttribute( "data-date", tokyoDate.toISOString().slice(0, 10) ); // Check Saturday or Sunday if ( new Date(year, month, i).getDay() === 6 || new Date(year, month, i).getDay() === 0 ) { dayElement.classList.add("dp-wknd"); } var dateValue = dayElement.getAttribute("data-date"); // Set event day if (dateValue === event1 || dateValue === event2) { // if (dateValue === event1) { dayElement.classList.remove("dp-wknd"); dayElement.classList.add("dp-event"); // Set the event name based on the matching date if (dateValue === event1) { dayElement.title = eventname1; } else { dayElement.title = eventname2; } } var holidays = ["2025-03-20", "2025-04-29"]; if (holidays.includes(dayElement.getAttribute("data-date"))) { dayElement.classList.add("dp-wknd"); } var currentDate = dayElement.getAttribute("data-date"); var matchingDate = validdates.find(function(item) { return ( item.Month - 1 === new Date(currentDate).getMonth() && item.Day === new Date(currentDate).getDate() ); }); validdates.forEach(function(item, index) { var productDate = item.Date; var productDateObj = new Date(productDate); // Convert productDate string to a Date object if (isNaN(productDateObj.getTime())) { console.error("Invalid date format: " + productDate); return; } var today = new Date(); var todayDate = new Date( today.getFullYear(), today.getMonth(), today.getDate() ); var isDateValid = productDateObj > todayDate; // console.log("Is date valid for item " + index + ": " + isDateValid); if (isDateValid) { var element = document.querySelector( ".dp-day.highlight:nth-child(" + (index + 1) + ")" ); if (element) { element.style.opacity = 0.4; } } }); // console.log("matchingDate: " + matchingDate); if (matchingDate) { dayElement.classList.add("highlight"); // console.log("data-deadline: ", dataDeadline); var linkElement = document.createElement("a"); // linkElement.href = "javascript:void(0);"; linkElement.href = matchingDate.url; linkElement.textContent = i; var dataDeadline = matchingDate.Date; linkElement.setAttribute("data-filter", dataDeadline); dayElement.innerHTML = ""; dayElement.appendChild(linkElement); } else { dayElement.textContent = i; } // console.log("matchingDate: ", matchingDate); monthElement.appendChild(dayElement); } // Add empty days for the remaining cells in the last row var lastDay = new Date(year, month, daysInMonth).getDay(); for (var i = lastDay + 1; i < 7; i++) { monthElement.innerHTML += "
"; } return monthElement; } function getDayName(day) { var dayNames = ["日", "月", "火", "水", "木", "金", "土"]; return dayNames[day]; } function getMonthName(month) { var monthNames = [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月", ]; return monthNames[month]; } function applyLinkUrls() { var dayElements = document.getElementsByClassName("dp-day"); for (var i = 0; i < dayElements.length; i++) { var dayElement = dayElements[i]; var currentDate = dayElement.getAttribute("data-date"); // Check if currentDate is valid if (currentDate) { var matchingDate = validdates.find(function(item) { // Compare the date in the format YYYY-MM-DD return item.Date === currentDate; }); if (matchingDate) { dayElement.classList.add("highlight"); // Create a link element var linkElement = document.createElement("a"); linkElement.href = matchingDate.URL; // Use the URL from validdates linkElement.textContent = dayElement.textContent; // Set the link text to the day number dayElement.innerHTML = ""; // Clear the day element dayElement.appendChild(linkElement); // Append the link to the day element } } } } function getDaysInMonth(month, year) { return new Date(year, month + 1, 0).getDate(); } var calendar = document.getElementById("dp-calendar"); var currentDate = new Date(); var currentMonth = currentDate.getMonth(); var currentYear = currentDate.getFullYear(); var months = []; function createCalendar() { for (var i = 0; i < monthsahead; i++) { var month = currentMonth + i; var year = currentYear; if (month >= 12) { month -= 12; year += 1; } var monthElement = createMonth(month, year); months.push(monthElement); } months.forEach(function(month) { calendar.appendChild(month); }); applyLinkUrls(); } createCalendar(); }); document.addEventListener("DOMContentLoaded", function () { validdates.forEach(function (item) { var productDate = item.Date; var productDateObj = new Date(productDate); // Convert productDate string to a Date object if (isNaN(productDateObj.getTime())) { console.error("Invalid date format: " + productDate); return; } var now = new Date(); var todayDate = new Date(now.getFullYear(), now.getMonth(), now.getDate()); var todayHour = now.getHours(); var isDatePassed = productDateObj < todayDate; // Dates before today var isToday = productDateObj.getFullYear() === todayDate.getFullYear() && productDateObj.getMonth() === todayDate.getMonth() && productDateObj.getDate() === todayDate.getDate(); // Compare year, month, and day // Format the date to match the 'data-date' attribute var formattedDate = productDateObj.toISOString().split("T")[0]; var element = document.querySelector( `.dp-day.highlight[data-date="${formattedDate}"]` ); // Debugging log console.log({ productDate, formattedDate, isDatePassed, isToday, todayHour, elementFound: !!element, }); if (!element) { console.error("No element found for date: " + formattedDate); return; } if (isDatePassed) { // Reduce opacity for past dates element.style.opacity = 0.4; } else if (isToday) { // Check if the hour is past the threshold for today if (todayHour >= 12) { // Adjusted threshold for testing element.style.opacity = 0.4; // Apply opacity for today's date console.log("Styling applied for today's date: ", formattedDate); } } // Future dates (from tomorrow onward) are unaffected }); });