var validdates = [
{
"Date": "2026-03-19",
"Month": 3,
"Day": 19,
"ProductCount": "15件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260319/comiket_deadline_to:20260319"
},
{
"Date": "2026-03-20",
"Month": 3,
"Day": 20,
"ProductCount": "2件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260320/comiket_deadline_to:20260320"
},
{
"Date": "2026-03-24",
"Month": 3,
"Day": 24,
"ProductCount": "2件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260324/comiket_deadline_to:20260324"
},
{
"Date": "2026-03-26",
"Month": 3,
"Day": 26,
"ProductCount": "7件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260326/comiket_deadline_to:20260326"
},
{
"Date": "2026-03-27",
"Month": 3,
"Day": 27,
"ProductCount": "72件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260327/comiket_deadline_to:20260327"
},
{
"Date": "2026-03-30",
"Month": 3,
"Day": 30,
"ProductCount": "2件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260330/comiket_deadline_to:20260330"
},
{
"Date": "2026-03-31",
"Month": 3,
"Day": 31,
"ProductCount": "6件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260331/comiket_deadline_to:20260331"
},
{
"Date": "2026-04-01",
"Month": 4,
"Day": 1,
"ProductCount": "16件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260401/comiket_deadline_to:20260401"
},
{
"Date": "2026-04-02",
"Month": 4,
"Day": 2,
"ProductCount": "19件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260402/comiket_deadline_to:20260402"
},
{
"Date": "2026-04-03",
"Month": 4,
"Day": 3,
"ProductCount": "182件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260403/comiket_deadline_to:20260403"
},
{
"Date": "2026-04-06",
"Month": 4,
"Day": 6,
"ProductCount": "44件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260406/comiket_deadline_to:20260406"
},
{
"Date": "2026-04-07",
"Month": 4,
"Day": 7,
"ProductCount": "17件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260407/comiket_deadline_to:20260407"
},
{
"Date": "2026-04-08",
"Month": 4,
"Day": 8,
"ProductCount": "10件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260408/comiket_deadline_to:20260408"
},
{
"Date": "2026-04-09",
"Month": 4,
"Day": 9,
"ProductCount": "16件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260409/comiket_deadline_to:20260409"
},
{
"Date": "2026-04-10",
"Month": 4,
"Day": 10,
"ProductCount": "35件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260410/comiket_deadline_to:20260410"
},
{
"Date": "2026-04-13",
"Month": 4,
"Day": 13,
"ProductCount": "95件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260413/comiket_deadline_to:20260413"
},
{
"Date": "2026-04-14",
"Month": 4,
"Day": 14,
"ProductCount": "18件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260414/comiket_deadline_to:20260414"
},
{
"Date": "2026-04-15",
"Month": 4,
"Day": 15,
"ProductCount": "13件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260415/comiket_deadline_to:20260415"
},
{
"Date": "2026-04-17",
"Month": 4,
"Day": 17,
"ProductCount": "23件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260417/comiket_deadline_to:20260417"
},
{
"Date": "2026-04-20",
"Month": 4,
"Day": 20,
"ProductCount": "13件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260420/comiket_deadline_to:20260420"
},
{
"Date": "2026-04-24",
"Month": 4,
"Day": 24,
"ProductCount": "2件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20260424/comiket_deadline_to:20260424"
}
];
$(document).ready(function () {
var event1 = "2026-05-05";
var event2 = "2026-05-06"; //event1;
var eventname1 = "SUPER COMIC CITY 33 -day1-"; //2日間や3日間イベント時変更 例:"夏コミ1日目";
var eventname2 = "SUPER COMIC CITY 33 -day2-"; //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 = ["2026-02-11", "2026-02-23", "2026-03-20", "2026-04-29", "2026-05-04"];
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");
dayElement.title = matchingDate.ProductCount; // show product count on hover
// 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
});
});