1// æ¥æ¬æéãåå¾ãã颿° 2function getJapanTime() { 3 // # test確èªç¨ 4 // const urlParams = new URLSearchParams(window.location.search); 5 // const timeParam = urlParams.get('time'); 6 // if (timeParam) { 7 // // ã¯ã¨ãªãã©ã¡ã¼ã¿ãåå¨ããå ´å 8 // // ä¾: ?time=202510300000 (YYYYMMDDHHmmå½¢å¼) 9 // const year = timeParam.substring(0, 4); 10 // const month = parseInt(timeParam.substring(4, 6)) - 1; // æã¯0ããå§ã¾ããã-1 11 // const day = timeParam.substring(6, 8); 12 // const hour = timeParam.substring(8, 10); 13 // const minute = timeParam.substring(10, 12); 14 15 // // æ¥æ¬æéã¨ãã¦Dateãªãã¸ã§ã¯ãã使 16 // // ISO 8601å½¢å¼ã§æååã使ããDateãªãã¸ã§ã¯ãã«æ¸¡ããã¨ã§ã¿ã¤ã ã¾ã¼ã³ã®æå®ã容æã«ãªãã¾ãã 17 // // 'YYYY-MM-DDTHH:mm:00+09:00' 18 // const japanTimeStr = `${year}-${(month + 1).toString().padStart(2, '0')}-${day}T${hour}:${minute}:00+09:00`; 19 // return new Date(japanTimeStr); 20 // } else { 21 // // ã¯ã¨ãªãã©ã¡ã¼ã¿ãåå¨ããªãå ´åãç¾å¨ã®æ¥æ¬æéãè¿ã 22 // let now = new Date(); 23 // let utc = now.getTime() + (now.getTimezoneOffset() * 60000); 24 // let japanTime = new Date(utc + (3600000 * 9)); 25 // return japanTime; 26 // } 27 // # ãªãªã¼ã¹ç¨ 28 let now = new Date(); 29 let utc = now.getTime() + (now.getTimezoneOffset() * 60000); 30 let japanTime = new Date(utc + (3600000 * 9)); 31 return japanTime; 32} 33 34 35// ææ¥ã¨æé帯ã«åºã¥ãã¦è¦ç´ ã®è¡¨ç¤ºã»éè¡¨ç¤ºãæ´æ°ãã颿° 36async function updateScheduleVisibility() { 37 // ç¾å¨ã®æ¥æãè¨å® 38 const jstNow = getJapanTime(); 39 40 // ç¾å¨ã®ææ¥ã¨æå»ãåå¾ 41 const currentDay = jstNow.getDay(); // 0:æ¥ææ¥, 1:æææ¥, ..., 6:åææ¥ 42 const currentTime = jstNow.getHours() * 60 + jstNow.getMinutes(); // ç¾å¨ã®æå»ãååä½ã«å¤æ 43 const year = jstNow.getFullYear();
44 const month = (jstNow.getMonth() + 1).toString().padStart(2, '0'); // æã¯0-11ãªã®ã§+1ãã2æ¡ã«ãã 45 const day = jstNow.getDate().toString().padStart(2, '0'); // æ¥ã2æ¡ã«ãã 46 const currentDate = `${year}-${month}-${day}`; 47 48 // ææ¥ãç縮形ã§åå¾ 49 const daysShort = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; 50 const today = daysShort[currentDay]; // ç¾å¨ã®ææ¥ãç縮形ã§åå¾ 51 52 // ç¹å®ã®æ¥ä»æ¡ä»¶ï¼ç¥æ¥ãç¹å¥ãªæ¥ï¼ãåå¾ 53 const specialDates = {}; 54 const dateFiles = { 55 "cs-holiday": "/web/shared/json/holidays.json", 56 "ifa-holiday": "/web/shared/json/holidays_ifa.json" 57 // "bu-holiday": "bu_holidays.json", 58 // "ifa-day": "ifa_days.json" 59 }; 60 61 // å JSON ãã¡ã¤ã«ãéåæã§åå¾ 62 await Promise.all( 63 Object.entries(dateFiles).map(async ([key, file]) => { 64 try { 65 const response = await fetch(file); 66 const data = await response.json(); 67 specialDates[key] = data.holidays || []; 68 } catch (error) { 69 console.error(`${file} ã®åå¾ã«å¤±æãã¾ãã:`, error); 70 specialDates[key] = []; // ã¨ã©ã¼æã¯ç©ºé åãè¨å® 71 } 72 }) 73 ); 74 75 // ã³ã³ã½ã¼ã«ãã°ã§ç¢ºèª 76 console.log(`ç¾å¨ã®æ¥æï¼æ¥æ¬æéï¼: ${jstNow}`); 77 console.log(`ç¾å¨ã®ææ¥: ${today}`); 78 console.log(`ç¾å¨ã®æ¥ä»: ${currentDate}`); 79 console.log(`ç¹å®ã®æ¥ä»ãªã¹ã:`, specialDates); 80 81 const elements = document.querySelectorAll('.schedule-item'); 82 83 elements.forEach(element => { 84 const dataDays = element.getAttribute('data-days'); 85 const dataTime = element.getAttribute('data-time'); 86 const dataDate = element.getAttribute('data-date'); 87 88 // ææ¥å¤å® 89 let isDayMatch = true; // ããã©ã«ãã§ true 90 if (dataDays) { 91 const daysArray = dataDays.split(','); 92 const positiveDays = daysArray.filter(day => !day.startsWith('!')); // é常æ¡ä»¶ 93 const negativeDays = daysArray.filter(day => day.startsWith('!')); // å¦å®æ¡ä»¶ 94 95 if (positiveDays.length > 0) { 96 isDayMatch = positiveDays.some(day => today === day); 97 } 98 99 if (negativeDays.length > 0) { 100 isDayMatch = isDayMatch && negativeDays.every(day => today !== day.slice(1)); 101 } 102 } 103 104 // æé帯å¤å® 105 let isTimeMatch = true; // ããã©ã«ãã§ true 106 if (dataTime) { 107 const timeRanges = dataTime.split(','); 108 isTimeMatch = timeRanges.some(range => { 109 if (range.startsWith('!')) { 110 const [start, end] = range.slice(1).split('-'); 111 const [startHour, startMinute] = start.split(':').map(Number); 112 const [endHour, endMinute] = end.split(':').map(Number); 113 const startTime = startHour * 60 + startMinute; 114 const endTime = endHour * 60 + endMinute; 115 return !(currentTime >= startTime && currentTime <= endTime); 116 } else { 117 const [start, end] = range.split('-'); 118 const [startHour, startMinute] = start.split(':').map(Number); 119 const [endHour, endMinute] = end.split(':').map(Number); 120 const startTime = startHour * 60 + startMinute; 121 const endTime = endHour * 60 + endMinute; 122 return currentTime >= startTime && currentTime <= endTime; 123 } 124 }); 125 } 126 127 // ç¹å®ã®æ¥ä»æ¡ä»¶å¤å® 128 let isDateMatch = true; // ããã©ã«ãã§ true 129 if (dataDate) { 130 const dateConditions = dataDate.split(','); 131 const positiveDates = dateConditions.filter(date => !date.startsWith('!')); // é常æ¡ä»¶ 132 const negativeDates = dateConditions.filter(date => date.startsWith('!')); // å¦å®æ¡ä»¶ 133 134 if (positiveDates.length > 0) { 135 isDateMatch = positiveDates.some(date => { 136 if (specialDates[date]) { 137 return specialDates[date].includes(currentDate); 138 } 139 return false; 140 }); 141 } 142 143 if (negativeDates.length > 0) { 144 isDateMatch = isDateMatch && negativeDates.every(date => { 145 if (specialDates[date.slice(1)]) { 146 return !specialDates[date.slice(1)].includes(currentDate); 147 } 148 return true; 149 }); 150 } 151 } 152 153 // æçµå¤å® 154 if (isDayMatch && isTimeMatch && isDateMatch) { 155 element.classList.add('is-active'); 156 element.classList.remove('is-disabled'); 157 } else { 158 element.classList.add('is-disabled'); 159 element.classList.remove('is-active'); 160 } 161 }); 162} 163 164// åæåå¦ç 165updateScheduleVisibility();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.