var validdates = [
{
"Date": "2025-07-04",
"Month": 7,
"Day": 4,
"ProductCount": "128件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250704/comiket_deadline_to:20250704"
},
{
"Date": "2025-07-07",
"Month": 7,
"Day": 7,
"ProductCount": "54件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250707/comiket_deadline_to:20250707"
},
{
"Date": "2025-07-08",
"Month": 7,
"Day": 8,
"ProductCount": "1件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250708/comiket_deadline_to:20250708"
},
{
"Date": "2025-07-09",
"Month": 7,
"Day": 9,
"ProductCount": "6件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250709/comiket_deadline_to:20250709"
},
{
"Date": "2025-07-10",
"Month": 7,
"Day": 10,
"ProductCount": "15件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250710/comiket_deadline_to:20250710"
},
{
"Date": "2025-07-11",
"Month": 7,
"Day": 11,
"ProductCount": "21件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250711/comiket_deadline_to:20250711"
},
{
"Date": "2025-07-14",
"Month": 7,
"Day": 14,
"ProductCount": "193件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250714/comiket_deadline_to:20250714"
},
{
"Date": "2025-07-15",
"Month": 7,
"Day": 15,
"ProductCount": "44件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250715/comiket_deadline_to:20250715"
},
{
"Date": "2025-07-16",
"Month": 7,
"Day": 16,
"ProductCount": "16件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250716/comiket_deadline_to:20250716"
},
{
"Date": "2025-07-17",
"Month": 7,
"Day": 17,
"ProductCount": "10件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250717/comiket_deadline_to:20250717"
},
{
"Date": "2025-07-18",
"Month": 7,
"Day": 18,
"ProductCount": "16件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250718/comiket_deadline_to:20250718"
},
{
"Date": "2025-07-22",
"Month": 7,
"Day": 22,
"ProductCount": "32件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250722/comiket_deadline_to:20250722"
},
{
"Date": "2025-07-23",
"Month": 7,
"Day": 23,
"ProductCount": "89件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250723/comiket_deadline_to:20250723"
},
{
"Date": "2025-07-24",
"Month": 7,
"Day": 24,
"ProductCount": "16件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250724/comiket_deadline_to:20250724"
},
{
"Date": "2025-07-25",
"Month": 7,
"Day": 25,
"ProductCount": "7件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250725/comiket_deadline_to:20250725"
},
{
"Date": "2025-07-29",
"Month": 7,
"Day": 29,
"ProductCount": "20件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250729/comiket_deadline_to:20250729"
},
{
"Date": "2025-07-30",
"Month": 7,
"Day": 30,
"ProductCount": "13件",
"URL": "https://goods.ryokuyou.co.jp/search/comiket_deadline_from:20250730/comiket_deadline_to:20250730"
}
]
$(document).ready(function() {
var event1 = "2025-08-16";
var event2 = "2025-08-17"; //event1;
var eventname1 = "コミックマーケット106 1日目"; //2日間や3日間イベント時変更 例:"夏コミ1日目";
var eventname2 = "コミックマーケット106 2日目・GOOD COMIC CITY 31 大阪"; //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-07-21", "2025-08-11"];
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
});
});