1document.addEventListener('DOMContentLoaded', () => { 2 // ========================================================================== 3 // ãã¥ã¼ã¹ä¸è¦§ãã¼ã¸ ãã£ã«ã¿ãªã³ã°æ©è½ï¼å ¬å¼ãµã¤ããå ¥è©¦ãAIã»ãã¼ã¿ãµã¤ã¨ã³ã¹ãæ å ±æ°çï¼ 4 // ========================================================================== 5 // ãã¥ã¼ã¹ä¸è¦§ã®ä¸»è¦ãªã³ã³ããè¦ç´ ãåå¨ããå ´åã®ã¿ã以ä¸ã®å¦çãå®è¡ãã 6 const newsListContainer = document.getElementById('news-list-container'); 7 if (newsListContainer) { 8 const mainFilterContainer = document.getElementById('news-main-filter'); 9 const subFiltersContainer = document.getElementById('news-sub-filters'); 10 const yearFilterContainer = document.getElementById('news-year-filter'); 11 const viewMoreButton = document.getElementById('view-more-button'); 12 13 // --- 1. äºåãã¼ã¿è§£æï¼èµ·åæã«ä¸åº¦ã ãå®è¡ï¼ --- 14 const newsCards = Array.from(newsListContainer.querySelectorAll('.news-list2__card')); 15 const cardCache = newsCards.map(card => { 16 let fYear = 0; 17 const dateEl = card.querySelector('.news-list2__date'); 18 if (dateEl) { 19 const parts = dateEl.textContent.trim().split('.'); 20 if (parts.length === 3) { 21 const y = parseInt(parts[0], 10); 22 const m = parseInt(parts[1], 10); 23 fYear = (m >= 4) ? y : y - 1; 24 } 25 } 26 return { 27 element: card, 28 mainCat: card.dataset.mainCategory, 29 year: fYear, 30 subCats: JSON.parse(card.dataset.filterCategory || '[]'), 31 targets: JSON.parse(card.dataset.filterTarget || '[]') 32 }; 33 }); 34 35 // --- 2. ç¶æ 管çï¼ããã·ã¥ãåªå çã«åæ ï¼ --- 36 const urlParams = new URLSearchParams(window.location.search); 37 const hashParams = new URLSearchParams(window.location.hash.slice(1)); 38 39 let currentMainCategory = hashParams.get('main') || urlParams.get('main') || 'all'; 40 let currentSubCategory = hashParams.get('sub') || urlParams.get('sub') || '00'; 41 let currentTarget = hashParams.get('target') || urlParams.get('target') || '00'; 42 let currentYear = hashParams.get('year') || urlParams.get('year') || 'all'; 43 let displayedCount = 9; 44 const increment = 9; 45 46 // --- 3. ãã£ã«ã¿é©ç¨é¢æ° --- 47 function applyFilters() { 48 const filteredResults = cardCache.filter(data => { 49 if (currentMainCategory !== 'all' && data.mainCat !== currentMainCategory) return false; 50 if (currentYear !== 'all') { 51 if (currentYear === 'before-2022') { 52 if (data.year > 2022) return false; 53 } else if (data.year !== parseInt(currentYear, 10)) { 54 return false; 55 } 56 } 57 const subMatch = (currentSubCategory === '00' || data.subCats.includes(currentSubCategory)); 58 const targetMatch = (currentTarget === '00' || data.targets.includes(currentTarget)); 59 return subMatch && targetMatch; 60 }); 61 62 newsCards.forEach(c => c.style.display = 'none'); 63 filteredResults.slice(0, displayedCount).forEach(data => { 64 data.element.style.display = ''; 65 }); 66 67 if (viewMoreButton) { 68 viewMoreButton.style.display = filteredResults.length > displayedCount ? '' : 'none'; 69 } 70 newsListContainer.classList.add('is-visible'); 71 } 72 73 // --- 4. UIç¶æ ã®åæ & ããã·ã¥æ´æ° --- 74 function syncUIState(updateHash = false) { 75 // URLããã·ã¥ã®æ´æ°ï¼ã¿ãåãæ¿ãæã«å®è¡ï¼ 76 if (updateHash) { 77 const newHash = `#main=${currentMainCategory}&sub=${currentSubCategory}&target=${currentTarget}&year=${currentYear}`; 78 history.replaceState(null, '', newHash); // ãªãã¼ãããã«URLãæ¸ãæã 79 } 80 81 if (mainFilterContainer) { 82 const active = mainFilterContainer.querySelector('.ptab__item_active'); 83 if (active) active.classList.remove('ptab__item_active'); 84 const target = mainFilterContainer.querySelector(`[data-main-category="${currentMainCategory}"]`); 85 if (target) target.classList.add('ptab__item_active'); 86 } 87 88 if (yearFilterContainer) { 89 const active = yearFilterContainer.querySelector('.ptab__item_active'); 90 if (active) active.classList.remove('ptab__item_active'); 91 const target = yearFilterContainer.querySelector(`[data-year="${currentYear}"]`); 92 if (target) target.classList.add('ptab__item_active'); 93 } 94 95 if (subFiltersContainer) { 96 subFiltersContainer.style.display = (currentMainCategory === 'pressrelease') ? 'none' : '';
97 Array.from(subFiltersContainer.children).forEach(child => { 98 if (child.dataset.mainCategory) { 99 child.style.display = (child.dataset.mainCategory === currentMainCategory) ? '' : 'none'; 100 } 101 }); 102 const activeBlock = subFiltersContainer.querySelector(`[data-main-category="${currentMainCategory}"]`) || subFiltersContainer; 103 const subInput = activeBlock.querySelector(`input[name="filter-category"][value="${currentSubCategory}"]`); 104 if (subInput) subInput.checked = true; 105 const targetInput = activeBlock.querySelector(`input[name="filter-target"][value="${currentTarget}"]`); 106 if (targetInput) targetInput.checked = true; 107 } 108 } 109 110 // --- 5. ã¤ãã³ããªã¹ãã¼ --- 111 if (mainFilterContainer) { 112 mainFilterContainer.addEventListener('click', (e) => { 113 const item = e.target.closest('.ptab__item'); 114 if (!item) return; 115 currentMainCategory = item.dataset.mainCategory; 116 currentSubCategory = '00'; currentTarget = '00'; displayedCount = increment; 117 syncUIState(true); // ããã·ã¥ãæ´æ° 118 applyFilters(); 119 }); 120 } 121 122 if (subFiltersContainer) { 123 subFiltersContainer.addEventListener('change', () => { 124 const activeBlock = subFiltersContainer.querySelector(`[data-main-category="${currentMainCategory}"]`) || subFiltersContainer; 125 currentSubCategory = activeBlock.querySelector('input[name="filter-category"]:checked')?.value || '00'; 126 currentTarget = activeBlock.querySelector('input[name="filter-target"]:checked')?.value || '00'; 127 displayedCount = increment; 128 syncUIState(true); // ããã·ã¥ãæ´æ° 129 applyFilters(); 130 }); 131 } 132 133 if (yearFilterContainer) { 134 yearFilterContainer.addEventListener('click', (e) => { 135 const item = e.target.closest('.ptab__item'); 136 if (!item) return; 137 currentYear = item.dataset.year; displayedCount = increment; 138 syncUIState(true); // ããã·ã¥ãæ´æ° 139 applyFilters(); 140 }); 141 } 142 143 if (viewMoreButton) { 144 viewMoreButton.addEventListener('click', () => { 145 displayedCount += increment; 146 applyFilters(); 147 }); 148 } 149 150 // ãã©ã¦ã¶ã®æ»ãã»é²ãï¼ããã·ã¥å¤æ´ï¼ã«å¯¾å¿ 151 window.addEventListener('hashchange', () => { 152 const h = new URLSearchParams(window.location.hash.slice(1)); 153 if (h.has('main')) { 154 currentMainCategory = h.get('main'); 155 currentSubCategory = h.get('sub') || '00'; 156 currentTarget = h.get('target') || '00'; 157 currentYear = h.get('year') || 'all'; 158 syncUIState(false); 159 applyFilters(); 160 } 161 }); 162 163 // èµ·åå¦ç 164 syncUIState(false); 165 applyFilters(); 166 } else { 167 // ------------------------------------------------------------------------ 168 // ãã¥ã¼ã¹ä»¥å¤ã®ä¸è¦§ã®çµãè¾¼ã¿ã¨MOREãã¿ã³ 169 // ------------------------------------------------------------------------ 170 const newsCards = document.querySelectorAll('.gradually-list__card'); 171 const moreBtn = document.querySelector('.gradually-more'); 172 const graduallyList = document.querySelector('.gradually-list'); 173 // åæè¡¨ç¤ºä»¶æ°ï¼ããã©ã«ãï¼9ä»¶ï¼ 174 // data-init-numãããã°ãã®å¤ãä½¿ç¨ 175 const itemsToShowInitially = (graduallyList && graduallyList.dataset.initNum) ? parseInt(graduallyList.dataset.initNum, 10) : 9; 176 // console.log('itemsToShowInitially='+ itemsToShowInitially); 177 178 // ã©ã¸ãªãã¿ã³ã®åå¨ãã§ã㯠179 const categoryRadios = document.querySelectorAll('.pradio input[name="filter-category"]'); 180 const targetRadios = document.querySelectorAll('.pradio input[name="filter-target"]'); 181 182 const hasCategoryFilter = categoryRadios.length > 0;
183 const hasTargetFilter = targetRadios.length > 0; 184 const hasAnyFilter = hasCategoryFilter || hasTargetFilter; 185 186 // ãã£ã«ã¿ãªã³ã°ã«ãã£ã¦è¡¨ç¤ºãããã«ã¼ãã®ãªã¹ã 187 let currentlyVisibleCards = []; 188 189 // çµãè¾¼ã¿ã¨è¡¨ç¤ºå¶å¾¡ãçµ±åãã颿° 190 const applyFilterAndManageDisplay = () => { 191 // NEWã©ãã«ãé©ç¨ 192 applyNewLabelsToCards(newsCards); 193 194 // 鏿ããã¦ããã«ãã´ãªã¨å¯¾è±¡ã®å¤ãåå¾ 195 const selectedCategory = hasCategoryFilter ? document.querySelector('.pradio input[name="filter-category"]:checked').value : '00'; 196 const selectedTarget = hasTargetFilter ? document.querySelector('.pradio input[name="filter-target"]:checked').value : '00'; 197 198 const tempFilteredCards = []; 199 200 newsCards.forEach(card => { 201 const cardCategories = JSON.parse(card.dataset.filterCategory || '[]'); 202 const cardTargets = JSON.parse(card.dataset.filterTarget || '[]'); 203 204 let isCategoryMatch = false; 205 let isTargetMatch = false; 206 207 // ã«ãã´ãªãã£ã«ã¿ã¼ãããå ´åããã®æ¡ä»¶ã§å¤å®ããªãå ´åã¯å¸¸ã«true 208 if (!hasCategoryFilter || selectedCategory === '00' || cardCategories.includes(selectedCategory)) { 209 isCategoryMatch = true; 210 } 211 212 // ã¿ã¼ã²ãããã£ã«ã¿ã¼ãããå ´åããã®æ¡ä»¶ã§å¤å®ããªãå ´åã¯å¸¸ã«true 213 if (!hasTargetFilter || selectedTarget === '00' || cardTargets.includes(selectedTarget)) { 214 isTargetMatch = true; 215 } 216 217 if (isCategoryMatch && isTargetMatch) { 218 tempFilteredCards.push(card); 219 } 220 }); 221 222 currentlyVisibleCards = tempFilteredCards; 223 224 // ãã¹ã¦ã®ã«ã¼ãã䏿¦é表示ã«ãã 225 newsCards.forEach(card => { 226 card.style.display = 'none'; 227 }); 228 229 // ãã£ã«ã¿ãªã³ã°ãããã«ã¼ãã®ä¸ãããåæè¡¨ç¤ºä»¶æ°åã ã表示ãã 230 currentlyVisibleCards.forEach((card, index) => { 231 if (index < itemsToShowInitially) { 232 card.style.display = 'grid'; // CSSã«åããã¦é©å®å¤æ´ï¼ä¾: 'block', 'flex'ãªã©ï¼ 233 } else { 234 card.style.display = 'none'; 235 } 236 }); 237 238 // MOREãã¿ã³ã®è¡¨ç¤º/éè¡¨ç¤ºãæ±ºå® 239 if (moreBtn) { 240 if (currentlyVisibleCards.length > itemsToShowInitially) { 241 moreBtn.style.display = ''; // 表示 242 } else { 243 moreBtn.style.display = 'none'; // é表示 244 } 245 } 246 }; 247 248 // çµãè¾¼ã¿æ©è½ãããå ´åã®å¦ç 249 if (hasAnyFilter && newsCards.length > 0) { 250 if (hasCategoryFilter) { 251 categoryRadios.forEach(radio => { 252 radio.addEventListener('change', applyFilterAndManageDisplay); 253 }); 254 } 255 if (hasTargetFilter) { 256 targetRadios.forEach(radio => { 257 radio.addEventListener('change', applyFilterAndManageDisplay); 258 }); 259 } 260 261 // åæè¡¨ç¤ºæã«çµãè¾¼ã¿ãå®è¡ 262 applyFilterAndManageDisplay(); 263 264 // MOREãã¿ã³ã®ã¯ãªãã¯ã¤ãã³ã (çµãè¾¼ã¿æ©è½ãããå ´å) 265 if (moreBtn) { 266 moreBtn.addEventListener('click', function() { 267 let visibleCount = 0; 268 currentlyVisibleCards.forEach(card => { 269 if (card.style.display !== 'none') { 270 visibleCount++; 271 } 272 }); 273 274 let cardsShownByMore = 0; 275 for (let i = visibleCount; i < currentlyVisibleCards.length && cardsShownByMore < itemsToShowInitially; i++) { 276 currentlyVisibleCards[i].style.display = 'grid'; // CSSã«åããã¦é©å®å¤æ´ 277 cardsShownByMore++; 278 } 279 280 if (visibleCount + cardsShownByMore >= currentlyVisibleCards.length) { 281 moreBtn.style.display = 'none'; 282 } 283 }); 284 } 285 } 286 // çµãè¾¼ã¿æ©è½ãå ¨ããªãå ´åã®MOREãã¿ã³ã®ãã¸ã㯠287 else if (newsCards.length > 0 && moreBtn) { 288 // åæè¡¨ç¤ºã§ itemsToShowInitially ä»¶ã¾ã§è¡¨ç¤ºããæ®ããé表示ã«ãã 289 newsCards.forEach((card, index) => { 290 if (index >= itemsToShowInitially) { 291 card.style.display = 'none'; 292 } 293 }); 294 295 // MOREãã¿ã³ã®è¡¨ç¤º/éè¡¨ç¤ºãæ±ºå® 296 if (newsCards.length > itemsToShowInitially) { 297 moreBtn.style.display = ''; // 表示 298 } else { 299 moreBtn.style.display = 'none'; // é表示 300 } 301 302 // MOREãã¿ã³ã®ã¯ãªãã¯ã¤ãã³ã (çµãè¾¼ã¿æ©è½ããªãå ´å) 303 moreBtn.addEventListener('click', function() { 304 let visibleCount = 0; 305 // ç¾å¨è¡¨ç¤ºããã¦ããã«ã¼ãã®æ°ãæ°ãã 306 newsCards.forEach(card => { 307 if (card.style.display !== 'none') { 308 visibleCount++; 309 } 310 }); 311 312 let cardsShownByMore = 0; 313 // é表示ã«ãªã£ã¦ããã«ã¼ãã itemsToShowInitially ä»¶ãã¤è¡¨ç¤º 314 for (let i = visibleCount; i < newsCards.length && cardsShownByMore < itemsToShowInitially; i++) { 315 newsCards[i].style.display = 'grid'; // CSSã«åããã¦é©å®å¤æ´ 316 cardsShownByMore++; 317 } 318 319 // ãã¹ã¦ã®ã«ã¼ãã表示ããããMOREãã¿ã³ãé表示ã«ãã 320 if (visibleCount + cardsShownByMore >= newsCards.length) { 321 moreBtn.style.display = 'none'; 322 } 323 }); 324 } 325 326 // ------------------------------------------------------------------------ 327 // æå¦ã®çç±ï¼èªãæããæ¢ãï¼ 328 // #ã®ã¤ãã<a>
328ã¿ã°ãã¯ãªãã¯ããæãé·ç§»å ã®å¯¾å¿ããã©ã¸ãªãã¿ã³ããã§ãã¯ãã 329 // ------------------------------------------------------------------------ 330 const anchorLinks = document.querySelectorAll('a[href*="#"]'); 331 anchorLinks.forEach(link => { 332 link.addEventListener('click', function(event) { 333 const hash = this.hash; 334 const targetNumber = hash.substring(1); 335 const targetRadio = document.querySelector(`input[name="filter-target"][value="${targetNumber}"]`); 336 const targetRadio2 = document.querySelector(`input[name="filter-category"][value="${targetNumber}"]`); 337 if (targetRadio) { 338 targetRadio.checked = true; 339 } 340 if (targetRadio2) { 341 targetRadio2.checked = true; 342 } 343 }); 344 }); 345 346 function checkHashOnLoad() { 347 const currentHash = window.location.hash; 348 if (currentHash) { 349 const targetNumber = currentHash.substring(1); 350 const targetRadio = document.querySelector(`input[name="filter-target"][value="${targetNumber}"]`); 351 const targetRadio2 = document.querySelector(`input[name="filter-category"][value="${targetNumber}"]`); 352 if (targetRadio) { 353 targetRadio.checked = true; 354 } 355 if (targetRadio2) { 356 targetRadio2.checked = true; 357 } 358 } 359 } 360 361 // ãã¼ãæã«ããã·ã¥ããã§ãã¯+çµãè¾¼ã¿çºç« 362 checkHashOnLoad(); 363 applyFilterAndManageDisplay(); 364 } 365 366 // ------------------------------------------------------------------------ 367 // æå¦ã®çç± è©³ç´°ãã¼ã¸ 368 // .editorå ã®h2ã§ç®æ¬¡ã®èªåçæï¼#anchor-00ï¼ 369 // ------------------------------------------------------------------------ 370 const editor = document.querySelector('.editor'); 371 const h2Elements = editor ? editor.querySelectorAll('h2') : []; // .editorãåå¨ããªãå ´åã¯ç©ºã®é å 372 const toc = document.querySelector('.article-toc'); 373 const tocList = document.querySelector('.article-toc__list'); 374 if (h2Elements.length > 0 && tocList) { 375 h2Elements.forEach((h2, index) => { 376 const anchorId = `anchor-${String(index + 1).padStart(2, '0')}`; 377 h2.id = anchorId; 378 379 const tocLink = document.createElement('a'); 380 tocLink.classList.add('article-toc__list-link'); 381 tocLink.href = `#${anchorId}`; // href屿§ã«çæããIDãå ¥ãã 382 tocLink.textContent = h2.textContent; // h2ã®ããã¹ããç®æ¬¡ãªã³ã¯ã®ããã¹ãã«å ¥ãã 383 384 tocList.appendChild(tocLink); 385 }); 386 } else { 387 if(toc) toc.style.display = 'none'; 388 } 389 390 // ------------------------------------------------------------------------ 391 // ã¨ãã£ã¿ç¨ 392 // å é ã®details以å¤open屿§ãåé¤ 393 // ------------------------------------------------------------------------
394 const pdetailsTabContainers = document.querySelectorAll('[class*="pdetails_tab"]'); 395 pdetailsTabContainers.forEach(container => { 396 const allDetailsInContainer = container.querySelectorAll('details'); 397 if (allDetailsInContainer.length <= 1) { 398 for (let i = 1; i < allDetailsInContainer.length; i++) { 399 allDetailsInContainer[i].removeAttribute('open'); 400 } 401 } 402 }); 403 404 // ------------------------------------------------------------------------ 405 // ç½ééä¿¡ 詳細ãã¼ã¸ 406 // æå®ã¯ã©ã¹ã®ç»åãç¥æ¡å¤§ 407 // ------------------------------------------------------------------------ 408 const zoomableImages = document.querySelectorAll('.js-img-zoom-trigger'); 409 if (zoomableImages.length > 0) { 410 zoomableImages.forEach(img => { 411 img.addEventListener('click', function () { 412 const overlay = document.createElement('div'); 413 overlay.className = 'img-zoom-overlay'; 414 415 const enlargedImg = document.createElement('img'); 416 enlargedImg.className = 'img-zoom-overlay__image'; 417 enlargedImg.src = this.src; 418 419 overlay.appendChild(enlargedImg); 420 421 overlay.addEventListener('click', function () { 422 document.body.removeChild(overlay); 423 }); 424 425 document.body.appendChild(overlay); 426 }); 427 }); 428 } 429}); 430 431/** 432 * å¤é¨JSONãã¡ã¤ã«ãèªã¿è¾¼ãã§ãã¥ã¼ã¹ãªã¹ããçæãã 433 * @param {string} targetSelector - ãã¥ã¼ã¹ãªã¹ããæ¿å ¥ããè¦ç´ ã®CSSã»ã¬ã¯ã¿ (e.g., '.news-list.faculty_english') 434 * @param {string} jsonPath - èªã¿è¾¼ãJSONãã¡ã¤ã«ã®ãã¹ (e.g., '/external_article/faculty_english.json') 435 */ 436function loadJsonNews(targetSelector, jsonPath) { 437 const newsListContainers = document.querySelectorAll(targetSelector); 438 439 // 対象ã®è¦ç´ ããã¼ã¸ã«åå¨ããªãå ´åã¯å¦çãçµäº 440 if (newsListContainers.length === 0) { 441 return; 442 } 443 444 fetch(jsonPath) 445 .then(response => { 446 if (!response.ok) { 447 throw new Error('Network response was not ok for ' + jsonPath + ': ' + response.statusText); 448 } 449 // .json()ã®ä»£ããã«.text()ã使ãã䏿£ãªæ¹è¡æåãåé¤ãã¦ãããã¼ã¹ãã 450 return response.text(); 451 }) 452 .then(text => { 453 // JSONæååå ã®æ¹è¡æåãåé¤ 454 const cleanedText = text.replace(/[\n\r]/g, ''); 455 return JSON.parse(cleanedText); 456 }) 457 .then(data => { 458 const articles = data.entrys; // JSONãã¼ã¿ã®ã«ã¼ãã¯ãªãã¸ã§ã¯ããªã®ã§ã'entrys'ããããã£ããé åãåå¾ 459 460 if (!Array.isArray(articles)) { 461 console.error('Loaded data from ' + jsonPath + ' does not contain an "entrys" array:', data); 462 throw new Error('Invalid JSON format: Expected an object with an "entrys" array.'); 463 } 464 465 const htmlContent = articles.length === 0 ? '<li>ç¾å¨ããç¥ããã¯ããã¾ããã</li>' : articles.map(article => { 466 // å®å ¨ã®ãããåããããã£ãåå¨ããã確èªãããªããã°ç©ºæåãå²ãå½ã¦ã 467 const url = article.url || '#'; 468 const date = article.date ? article.date.replace(/\//g, '.') : ''; // æ¥ä»ã®åºåãæåã'/'ãã'.'ã«å¤æ 469 const title = article.title || ''; 470 471 return ` 472 <li class="news-list__item"> 473 <a class="news-list__link" href="${url}"> 474 <div class="news-list__date">${date}</div> 475 <div class="news-list__title pclamp pclamp_line2">${title}</div> 476 </a> 477 </li>`; 478 }).join(''); 479 480 newsListContainers.forEach(container => { 481 container.innerHTML = htmlContent; 482 }); 483 }) 484 .catch(error => { 485 console.error('Error fetching or parsing ' + jsonPath + ':', error);
486 newsListContainers.forEach(container => { 487 container.innerHTML = '<li>ãç¥ããã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããã</li>'; 488 }); 489 }); 490} 491 492document.addEventListener('DOMContentLoaded', function() { 493 // ------------------------------------------------------------------------ 494 // .pbox_bg 495 // ã¹ã¯ãã¼ã«ã«åããã¦èæ¯ç»åãåãæ¿ãã 496 // ------------------------------------------------------------------------ 497 const pboxBgElements = document.querySelectorAll('.pbox_bg'); 498 const pboxBgImages = document.querySelectorAll('.pbox_bg__image'); 499 // if (pboxBgElements.length === 0 || pboxBgImages.length === 0 || pboxBgElements.length !== pboxBgImages.length) { 500 // console.log('pbox_bg ã¾ã㯠pbox_bg__image è¦ç´ ãè¦ã¤ãããªãããæ°ãä¸è´ãã¾ããã'); 501 // return; 502 // } 503 pboxBgImages.forEach(img => { 504 img.style.opacity = '0'; 505 img.style.transition = 'opacity 0.8s ease-out'; 506 }); 507 const options = { 508 root: null, 509 rootMargin: '0px 0px -10% 0px', 510 threshold: 0.1 511 }; 512 const observerCallback = (entries, observer) => { 513 entries.forEach(entry => { 514 if (entry.isIntersecting) { 515 const index = Array.from(pboxBgElements).indexOf(entry.target); 516 if (index !== -1 && pboxBgImages[index]) { 517 pboxBgImages[index].style.opacity = '1'; 518 } 519 } else { 520 const index = Array.from(pboxBgElements).indexOf(entry.target); 521 if (index !== -1 && pboxBgImages[index]) { 522 pboxBgImages[index].style.opacity = '0'; 523 } 524 } 525 }); 526 }; 527 const observer = new IntersectionObserver(observerCallback, options); 528 pboxBgElements.forEach(element => { 529 observer.observe(element); 530 }); 531 532 // ------------------------------------------------------------------------ 533 // å ±éï¼æå®IDã®è¦ç´ ã«æå®ãã¹ã®HTMLãèªã¿è¾¼ã颿° 534 // ------------------------------------------------------------------------ 535 function loadHtmlIntoElement(elementId, htmlPath, callback) { 536 const el = document.getElementById(elementId); 537 if (el) { 538 fetch(htmlPath) 539 .then(response => { 540 if (!response.ok) throw new Error('Network response was not ok'); 541 return response.text(); 542 }) 543 .then(html => { 544 el.innerHTML = html; 545 // matchHeightã®åå®è¡ 546 if (typeof window.funcMatchHeight === 'object' && typeof window.funcMatchHeight.funcInit === 'function') { 547 window.funcMatchHeight.funcInit(); 548 } 549 if (typeof callback === 'function') { 550 callback(); 551 } 552 }) 553 .catch(error => { 554 console.error(`Error loading ${elementId}:`, error); 555 }); 556 } 557 } 558 559 // å¤é¨ãã¥ã¼ã¹èªã¿è¾¼ã¿å¦çãå¼ã³åºã 560 loadJsonNews('.news-list.faculty_english', '/external_article/faculty_english.json'); 561 loadJsonNews('.news-list.faculty_french', '/external_article/faculty_french.json'); 562 loadJsonNews('.news-list.faculty_art', '/external_article/faculty_art.json'); 563 loadJsonNews('.news-list.faculty_econ', '/external_article/faculty_econ.json'); 564 loadJsonNews('.news-list.faculty_soc', '/external_article/faculty_soc.json'); 565 loadJsonNews('.news-list.faculty_law', '/external_article/faculty_law.json'); 566 loadJsonNews('.news-list.faculty_fis', '/external_article/faculty_fis.json'); 567 loadJsonNews('.news-list.faculty_psy', '/external_article/faculty_psy.json'); 568 loadJsonNews('.news-list.research_kiriken', '/external_article/research_kiriken.json'); 569 loadJsonNews('.news-list.research_prime', '/external_article/research_prime.json'); 570 loadJsonNews('.news-list.research_fusion', '/external_article/research_fusion.json'); 571 loadJsonNews('.news-list.research_gengobunka', '/external_article/research_gengobunka.json'); 572 loadJsonNews('.news-list.research_fuzoku', '/external_article/research_fuzoku.json'); 573 loadJsonNews('.news-list.research_iism', '/external_article/research_iism.json'); 574 loadJsonNews('.news-list.research_psy', '/external_article/research_psy.json'); 575 loadJsonNews('.news-list.research_cfla', '/external_article/research_cfla.json'); 576 loadJsonNews('.news-list.research_mbl', '/external_article/research_mbl.json'); 577 578 // åæã§å©ç¨ 579 //loadHtmlIntoElement('include-news-sample', '/_include/news/sample.html'); 580 //loadHtmlIntoElement('include-event-sample', '/_include/event/sample.html'); 581 loadHtmlIntoElement('include-news-student', '/_include/news/student.html'); 582 loadHtmlIntoElement('include-news-graduate', '/_include/news/graduate.html'); 583 loadHtmlIntoElement('include-news-guarantor', '/_include/news/guarantor.html'); 584 loadHtmlIntoElement('include-news-industry', '/_include/news/industry.html'); 585 loadHtmlIntoElement('include-news-visitors', '/_include/news/visitors.html'); 586 loadHtmlIntoElement('include-news-corporations', '/_include/news/corporations.html'); 587 loadHtmlIntoElement('include-news-about-christianity', '/_include/news/about-christianity.html'); 588 loadHtmlIntoElement('include-news-academics', '/_include/news/academics.html'); 589 loadHtmlIntoElement('include-news-academics-graduate', '/_include/news/academics-graduate.html'); 590 loadHtmlIntoElement('include-news-academics-literature', '/_include/news/academics-literature.html'); 591 loadHtmlIntoElement('include-news-academics-economics', '/_include/news/academics-economics.html'); 592 loadHtmlIntoElement('include-news-academics-sociology', '/_include/news/academics-sociology.html'); 593 loadHtmlIntoElement('include-news-academics-law', '/_include/news/academics-law.html'); 594 loadHtmlIntoElement('include-news-academics-international', '/_include/news/academics-international.html'); 595 loadHtmlIntoElement('include-news-academics-psychology', '/_include/news/academics-psychology.html'); 596 loadHtmlIntoElement('include-news-academics-mathematical_informatics', '/_include/news/academics-mathematical_informatics.html'); 597 loadHtmlIntoElement('include-news-research', '/_include/news/research.html'); 598 loadHtmlIntoElement('include-news-campuslife', '/_include/news/campuslife.html'); 599 loadHtmlIntoElement('include-news-campuslife-ekiden', '/_include/news/campuslife-ekiden.html'); 600 loadHtmlIntoElement('include-news-campuslife-sports', '/_include/news/campuslife-sports.html'); 601 loadHtmlIntoElement('include-news-campuslife-support', '/_include/news/campuslife-support.html'); 602 loadHtmlIntoElement('include-news-international', '/_include/news/international.html'); 603 loadHtmlIntoElement('include-news-volunteer_activities', '/_include/news/volunteer_activities.html'); 604 loadHtmlIntoElement('include-news-regionalalliances', '/_include/news/regionalalliances.html'); 605 loadHtmlIntoElement('include-news-regionalalliances-challengecommunity', '/_include/news/regionalalliances-challengecommunity.html'); 606 loadHtmlIntoElement('include-news-regionalalliances-platinum_college', '/_include/news/regionalalliances-platinum_college.html'); 607 loadHtmlIntoElement('include-news-campus-yokohama-new_building', '/_include/news/campus-yokohama-new_building.html'); 608 609 loadHtmlIntoElement('include-news-admission-event', '/_include/news/admission-event.html'); 610 611 loadHtmlIntoElement('include-event-student', '/_include/event/student.html'); 612 loadHtmlIntoElement('include-event-graduate', '/_include/event/graduate.html'); 613 loadHtmlIntoElement('include-event-guarantor', '/_include/event/guarantor.html'); 614 loadHtmlIntoElement('include-event-industry', '/_include/event/industry.html'); 615 loadHtmlIntoElement('include-event-visitors', '/_include/event/visitors.html'); 616 loadHtmlIntoElement('include-event-campuslife', '/_include/event/campuslife.html'); 617 loadHtmlIntoElement('include-event-campuslife-support', '/_include/event/campuslife-support.html'); 618 loadHtmlIntoElement('include-event-regionalalliances', '/_include/event/regionalalliances.html'); 619 loadHtmlIntoElement('include-event-regionalalliances-open_academy', '/_include/event/regionalalliances-open_academy.html'); 620 621 loadHtmlIntoElement('include-why-research', '/_include/why/research.html'); 622 loadHtmlIntoElement('include-why-international', '/_include/why/international.html'); 623 loadHtmlIntoElement('include-why-career', '/_include/why/career.html'); 624 loadHtmlIntoElement('include-why-volunteer_activities', '/_include/why/volunteer_activities.html'); 625 loadHtmlIntoElement('include-why-academics-literature', '/_include/why/academics-literature.html'); 626 loadHtmlIntoElement('include-why-academics-economics', '/_include/why/academics-economics.html'); 627 loadHtmlIntoElement('include-why-academics-sociology', '/_include/why/academics-sociology.html'); 628 loadHtmlIntoElement('include-why-academics-law', '/_include/why/academics-law.html'); 629 loadHtmlIntoElement('include-why-academics-international', '/_include/why/academics-international.html'); 630 loadHtmlIntoElement('include-why-academics-psychology', '/_include/why/academics-psychology.html'); 631 loadHtmlIntoElement('include-why-academics-mathematical_informatics', '/_include/why/academics-mathematical_informatics.html'); 632 loadHtmlIntoElement('include-en-why-campuslife-volunteer_activities', '/en/_include/why/volunteer.html'); 633 634 loadHtmlIntoElement('include-shirogane-archive', '/_include/shirogane/archive.html', () => { 635 const shiroganeArchive = document.querySelectorAll('#include-shirogane-archive details');
636 if (typeof funcAccordionDetailsAnimation === "object" && shiroganeArchive.length > 0) { 637 funcAccordionDetailsAnimation.funcInit(); 638 } 639 }); 640 loadHtmlIntoElement('include-volunteer-activity-others', '/_include/volunteer/others.html', () => { 641 const volunteerOtherCards = document.querySelectorAll('#include-volunteer-activity-others .gradually-list__card'); 642 if (volunteerOtherCards.length > 0) { 643 applyNewLabelsToCards(volunteerOtherCards); 644 } 645 }); 646 loadHtmlIntoElement('include-volunteer-activity-latest-articles', '/_include/volunteer-activity/latest-articles.html'); 647 loadHtmlIntoElement('include-volunteer-activity-latest-articles-itsudemo', '/_include/volunteer-activity/latest-articles-itsudemo.html'); 648 loadHtmlIntoElement('include-volunteer-activity-latest-articles-1day', '/_include/volunteer-activity/latest-articles-1day.html'); 649 loadHtmlIntoElement('include-graduate-interview-latest-articles', '/_include/graduate-interview/latest-articles.html'); 650 loadHtmlIntoElement('include-club-list-sports-project', '/_include/club/list-sports-project.html'); 651 loadHtmlIntoElement('include-club-event-list-sports-project', '/_include/club/event-list-sports-project.html', () => { 652 const clubEventCalendar = document.querySelectorAll('#include-club-event-list-sports-project .calendar-slider'); 653 if (clubEventCalendar.length > 0) { 654 initCalendarSlider(); 655 } 656 657 }); 658 loadHtmlIntoElement('include-story-latest-articles', '/academics/faculty/mathematical_informatics/_include/story/latest-articles.html'); 659 660 const recommend_el = document.getElementById('include-common-recommend'); 661 if (recommend_el) { 662 const identifier = recommend_el.dataset.fileIdentifier; 663 if (identifier) { 664 const path = `/_include/common_recommend/${identifier}.html`; 665 loadHtmlIntoElement('include-common-recommend', path, initRecommendedSlider); 666 } 667 } 668 669 $(function () { 670 initRecommendedSlider(); 671 initCalendarSlider(); 672 }); 673}); 674 675function initRecommendedSlider() { 676 const mvSlider = $('.recommended__slider'); 677 if (mvSlider.length > 0) { 678 mvSlider.each(function () { 679 $(this).slick({ 680 dots: false, 681 arrows: true, 682 slidesToShow: 1, 683 slidesToScroll: 1, 684 prevArrow: '<button class="slick-prev"></button>', 685 nextArrow: '<button class="slick-next"></button>' 686 }); 687 }); 688 } 689} 690function initCalendarSlider() { 691 const mvSlider = $('.calendar-slider'); 692 if (mvSlider.length > 0) { 693 mvSlider.each(function () { 694 $(this).slick({ 695 // autoplay: true, 696 dots: false, 697 slidesToShow: 4, 698 prevArrow: '<button class="calendar-slider__arrow calendar-slider__arrow_prev"></button>', 699 nextArrow: '<button class="calendar-slider__arrow calendar-slider__arrow_next"></button>', 700 responsive: [ 701 { 702 breakpoint: 768, 703 settings: { 704 centerMode: true, 705 centerPadding: '50px', 706 slidesToShow: 1 707 } 708 } 709 ] 710 }); 711 }); 712 } 713} 714 715// NEW表示å¦çï¼æ¥ä»ãåå¾ãã1ãæä»¥å ãªãNEW追å 716function applyNewLabelsToCards(cards) { 717 const today = new Date(); 718 const oneMonthAgo = new Date(today); 719 oneMonthAgo.setMonth(today.getMonth() - 1); 720 cards.forEach(card => { 721 const dateEl = card.querySelector('.js-publish-date'); 722 if (dateEl) { 723 const dateText = dateEl.textContent.trim().replace(/\./g, '/'); // 2023.3.20 â 2023/3/20 724 const cardDate = new Date(dateText); 725 726 if (!isNaN(cardDate.getTime()) && cardDate >= oneMonthAgo) { 727 // æ¢ã«NEWãåå¨ããªãå ´åã ã追å 728 if (!card.querySelector('.news-list2__new')) { 729 const newEl = document.createElement('div'); 730 newEl.className = 'news-list2__new'; 731 newEl.textContent = 'NEW'; 732 dateEl.insertAdjacentElement('afterend', newEl); 733 } 734 } 735 } 736 });
vendor: 3 bytes, line 737
737}
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.