1function getHeaderHeight() { 2 let headerheight = document.querySelector('.header-wrap'); 3 let header = document.querySelector('.site-header'); 4 let height = headerheight.offsetHeight; 5 header.style.setProperty('--header-height', height + 'px'); 6 // Do whatever you need with the height here 7} 8getHeaderHeight(); 9 10 // Click to hide parent + run function 11 document.querySelectorAll('.close-nofi-btn').forEach(btn => { 12 btn.addEventListener('click', function () { 13 document.querySelector('.top-notifaction-bar').style.display = 'none'; 14 getHeaderHeight(); 15 }); 16 }); 17 18 // Run on window resize 19 window.addEventListener('resize', function () { 20 getHeaderHeight(); 21 }); 22 23document.addEventListener("click", function (e) { 24 let icon = e.target.closest(".colapse-filter .ft-title"); 25 26 if (icon) { 27 let li = icon.closest(".colapse-filter"); 28 29 li.classList.toggle("active"); 30 } 31}); 32/* Equal Height JS */ 33function setTallestHeight(grid, contentSelector) { 34 const items = grid.querySelectorAll('.item'); 35 const rowHeightMap = new Map(); 36 37 items.forEach(item => { 38 const content = item.querySelector(contentSelector); 39 if (!content) return; 40 41 const rowTop = item.getBoundingClientRect().top; 42 43 let key = null; 44 for (let existingKey of rowHeightMap.keys()) { 45 if (Math.abs(existingKey - rowTop) < 2) { 46 key = existingKey; 47 break; 48 } 49 } 50 51 if (key === null) { 52 key = rowTop; 53 rowHeightMap.set(key, []); 54 } 55 56 rowHeightMap.get(key).push(content); 57 }); 58 59 rowHeightMap.forEach(contents => { 60 contents.forEach(el => el.style.height = ''); 61 }); 62 63 rowHeightMap.forEach(contents => { 64 let max = 0; 65 66 contents.forEach(el => { 67 const h = el.offsetHeight; 68 if (h > max) max = h; 69 }); 70 71 contents.forEach(el => { 72 el.style.height = max + 'px'; 73 }); 74 }); 75} 76 77function initializeGridHeightAdjustment(grid,content) { 78 const grids = document.querySelectorAll(grid); 79 if (!grids.length) return; 80 81 const contentSelector = content; 82 let rafId = null; 83 84 const scheduleUpdate = () => { 85 if (rafId) return; 86 rafId = requestAnimationFrame(() => { 87 grids.forEach(grid => setTallestHeight(grid, contentSelector)); 88 rafId = null; 89 }); 90 }; 91 92 window.addEventListener('load', scheduleUpdate); 93 window.addEventListener('resize', scheduleUpdate); 94 95 const resizeObserver = new ResizeObserver(scheduleUpdate); 96 grids.forEach(grid => resizeObserver.observe(grid)); 97 98 const mutationObserver = new MutationObserver(scheduleUpdate); 99 grids.forEach(grid => { 100 mutationObserver.observe(grid, { childList: true, subtree: true }); 101 }); 102} 103 104(function () { 105 "use strict"; 106 107 function getDialog(id) { 108 if (!id) return null; 109 const el = document.getElementById(id); 110 return el instanceof HTMLDialogElement ? el : null; 111 } 112 113 function openPopup(dialog) { 114 if (!dialog || dialog.open) return; 115 dialog.showModal(); 116 dialog.dispatchEvent(new CustomEvent("popup:open", { bubbles: true })); 117 } 118 119 function closePopup(dialog) { 120 if (!dialog || !dialog.open) return; 121 dialog.close(); 122 dialog.dispatchEvent(new CustomEvent("popup:close", { bubbles: true })); 123 } 124 125 const anchorHrefMap = new WeakMap(); 126 127 function initAnchorTriggers(popupIds) { 128 popupIds.forEach(function (id) { 129 document.querySelectorAll('a[href="#' + id + '"]').forEach(function (a) { 130 anchorHrefMap.set(a, a.getAttribute("href")); 131 a.setAttribute("href", "#"); 132 }); 133 }); 134 } 135 136 function initTriggerClicks(popupIds) { 137 document.addEventListener("click", function (e) { 138 const trigger = e.target.closest("[data-popup], a[href]"); 139 if (!trigger) return; 140 141 let dialogId = null; 142 let originalHref = null; 143 144 if (trigger.hasAttribute("data-popup")) { 145 const val = trigger.getAttribute("data-popup"); 146 if (popupIds.includes(val)) dialogId = val; 147 148 } else if (trigger.tagName === "A" && anchorHrefMap.has(trigger)) { 149 const stored = anchorHrefMap.get(trigger); 150 const candidate = stored.slice(1); 151 if (popupIds.includes(candidate)) { 152 dialogId = candidate; 153 originalHref = stored; 154 } 155 } 156 157 if (!dialogId) return; 158 159 e.preventDefault(); 160 161 if (originalHref && originalHref !== "#" + dialogId) { 162 document.querySelectorAll("input[name*='input_11']").forEach(function (field) { 163 field.value = originalHref; 164 }); 165 } 166 167 openPopup(getDialog(dialogId)); 168 }); 169 } 170 171 function initCloseButton() { 172 document.addEventListener("click", function (e) { 173 const btn = e.target.closest("[closePopup]"); 174 if (!btn) return; 175 176 const dialog = btn.closest("dialog"); 177 if (dialog) closePopup(dialog); 178 }); 179 } 180 181 function initBackdropClose() { 182 document.addEventListener("click", function (e) { 183 const dialog = e.target.closest("dialog.popup"); 184 if (!dialog || !dialog.open) return; 185 186 const rect = dialog.getBoundingClientRect(); 187 const clickedInside = 188 e.clientX >
188= rect.left && 189 e.clientX <= rect.right && 190 e.clientY >= rect.top && 191 e.clientY <= rect.bottom; 192 193 if (!clickedInside) { 194 closePopup(dialog); 195 } 196 }); 197 } 198 199 function init() { 200 const popupIds = Array.from( 201 document.querySelectorAll("dialog.popup[id]") 202 ).map(function (el) { return el.id; }); 203 204 if (!popupIds.length) return; 205 206 initAnchorTriggers(popupIds); 207 initTriggerClicks(popupIds); 208 initCloseButton(); 209 initBackdropClose(); 210 } 211 212 if (document.readyState === "loading") { 213 document.addEventListener("DOMContentLoaded", init); 214 } else { 215 init(); 216 } 217})(); 218 219document.addEventListener( 'DOMContentLoaded', function() { 220 221 function equalHeight() { 222 let items = document.querySelectorAll('.box-sty-one.btn-type1 .item'); 223 let maxHeight = 0; 224 225 items.forEach(item => { 226 // Reset height to auto first to get natural height if it was already set 227 item.style.height = 'auto'; 228 let height = item.offsetHeight; 229 if (height > maxHeight) { 230 maxHeight = height; 231 } 232 }); 233 234 let box = document.querySelector('.box-sty-one.btn-type1'); 235 if (box) { 236 // Use setProperty for CSS variables 237 box.style.setProperty('--equal-height-item', `${maxHeight}px`); 238 } 239 240 let data = { maxHeight, itemCount: items.length }; 241 return data; // Returning the data object so it can be used outside the function 242 } 243 equalHeight(); 244 245 246 initializeGridHeightAdjustment('.news-item-listing','.title'); 247 initializeGridHeightAdjustment('.col-image--content-lists-section','.title'); 248 249 250 document.querySelectorAll('.video-play-section').forEach(section => { 251 const poster = section.querySelector('.video-poster'); 252 const iframeWrap = section.querySelector('.video-iframe-wrap'); 253 const iframe = section.querySelector('.youtube-iframe'); 254 const videoId = section.dataset.youtubeId; 255 256 if (!poster || !iframe || !videoId) return; 257 258 poster.addEventListener('click', () => { 259 260 // Stop all other videos 261 document.querySelectorAll('.video-play-section').forEach(other => { 262 if (other !== section) { 263 const otherPoster = other.querySelector('.video-poster'); 264 const otherWrap = other.querySelector('.video-iframe-wrap'); 265 const otherIframe = other.querySelector('.youtube-iframe'); 266 267 if (otherPoster && otherWrap && otherIframe) { 268 otherPoster.style.display = 'block'; 269 otherWrap.hidden = true; 270 otherIframe.src = ''; 271 } 272 } 273 }); 274 275 // Play current video 276 poster.style.display = 'none'; 277 iframeWrap.hidden = false; 278 iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&rel=0`; 279 }); 280 }); 281 282 if (document.querySelector('select[name="parasportfilter"]') && document.querySelectorAll('input[name="season"]')) { 283 const selectEl = document.querySelector('select[name="parasportfilter"]'); 284 const seasonRadios = document.querySelectorAll('input[name="season"]'); 285 286 function getSeasonSlugFromRadioValue(val) { 287 return String(val || '').toLowerCase(); 288 } 289
290 function renderSportsForSeason(seasonSlug) { 291 const data = window.ParaSportData || {}; 292 let sports = []; 293 294 // NEW LOGIC: If no season is provided, merge all categories (Winter, Summer, etc.) 295 if (!seasonSlug) { 296 Object.values(data).forEach(sportList => { 297 if (Array.isArray(sportList)) { 298 sports = sports.concat(sportList); 299 } 300 }); 301 302 // Optional: Remove duplicates if a sport exists in both seasons 303 const seen = new Set(); 304 sports = sports.filter(item => { 305 const duplicate = seen.has(item.id); 306 seen.add(item.id); 307 return !duplicate; 308 }); 309 } else { 310 // Default logic: get specific season 311 sports = Array.isArray(data[seasonSlug]) ? data[seasonSlug] : []; 312 } 313 314 // reset options 315 selectEl.innerHTML = '<option value="*">Para sport</option>'; 316 317 // add sports 318 sports.forEach(item => { 319 const opt = document.createElement('option'); 320 opt.value = item.id; 321 opt.textContent = item.title; 322 selectEl.appendChild(opt); 323 }); 324 } 325 326 // initial load (based on checked radio) 327 const checked = document.querySelector('input[name="season"]:checked'); 328 // If 'checked' is null, getSeasonSlug... returns "", triggering the "All" logic 329 renderSportsForSeason(getSeasonSlugFromRadioValue(checked?.value)); 330 331 // change handler 332 seasonRadios.forEach(radio => { 333 radio.addEventListener('change', function () { 334 renderSportsForSeason(getSeasonSlugFromRadioValue(this.value)); 335 }); 336 }); 337 } 338 339 if(document.querySelector('select[name="disabilitytype"]') && document.querySelectorAll('input[name="disability"]')){ 340 const selectEl = document.querySelector('select[name="disability"]'); 341 const disabilityType = document.querySelectorAll('select[name="disabilitytype"]'); 342 343 function getDisabilityItemsFromDisabilityType(val) { 344 return String(val || '').toLowerCase(); 345 } 346 347 function renderDisabilityItemsSelect(disabilitytypeSlug) { 348 const data = window.DisabilityType || {}; 349 const sports = Array.isArray(data[disabilitytypeSlug]) ? data[disabilitytypeSlug] : []; 350 351 // reset options 352 selectEl.innerHTML = '<option value="*">Impairment</option>'; 353 354 // add sports 355 sports.forEach(item => { 356 const opt = document.createElement('option'); 357 opt.value = item.id; 358 opt.textContent = item.title; 359 selectEl.appendChild(opt); 360 }); 361 } 362 363 // initial load (based on checked radio) 364 const checked = document.querySelector('select[name="disabilitytype"]')?.value; 365 renderDisabilityItemsSelect(getDisabilityItemsFromDisabilityType(checked?.value)); 366 367 // change handler 368 disabilityType.forEach(select => { 369 select.addEventListener('change', function () { 370 renderDisabilityItemsSelect(getDisabilityItemsFromDisabilityType(this.value)); 371 }); 372 }); 373 } 374 375 376 377 (function() { 378 const initLoadMore = () => { 379 const buttons = document.querySelectorAll('.showmoremedalitem'); 380 381 buttons.forEach(btn => { 382 // Prevent double-binding if script runs twice 383 if (btn.dataset.initialized) return; 384 btn.dataset.initialized = "true"; 385 386 btn.addEventListener('click', function() { 387 // Find the parent container to scope the search for rows 388 const parent = btn.closest('.country-medal-table'); 389 const hiddenRows = parent.querySelectorAll('.medal-row.is-hidden'); 390 391 // Show next 10 rows 392 for (let i = 0; i < 10; i++) { 393 if (hiddenRows[i]) { 394 hiddenRows[i].style.display = 'table-row'; 395 hiddenRows[i].classList.remove('is-hidden'); 396 } 397 } 398 399 // Remove button if no more rows are hidden 400 if (parent.querySelectorAll('.medal-row.is-hidden').length === 0) { 401 btn.parentElement.style.display = 'none'; 402 } 403 }); 404 }); 405 }; 406 407 // Run on load 408 if (document.readyState === 'loading') { 409 document.addEventListener('DOMContentLoaded', initLoadMore); 410 } else { 411 initLoadMore(); 412 } 413 })(); 414 415 416 417 418 419 420 421}); 422 423 424document.addEventListener('DOMContentLoaded', () => { 425 // 1. Grab the elements 426 const yearFilter = document.getElementById('year-filter'); 427 const gamesFilter = document.getElementById('games-filter'); 428 429 // 2. Create a reusable handler function 430 const handleFilterToggle = (changedSelect, targetSelect) => { 431 // Check if the user selected a real option (not the empty placeholder) 432 if (changedSelect.value !== "") { 433 targetSelect.disabled = true; 434 targetSelect.value = ""; // Reset the disabled dropdown to its placeholder 435 } else { 436 // If they went back to the placeholder, remove the disable 437 targetSelect.disabled = false;
438 } 439 }; 440 441 // 3. Attach the event listeners 442 yearFilter.addEventListener('change', () => { 443 handleFilterToggle(yearFilter, gamesFilter); 444 }); 445 446 gamesFilter.addEventListener('change', () => { 447 handleFilterToggle(gamesFilter, yearFilter); 448 }); 449}); 450 451 452window.addEventListener('load', function () { 453 function createButton() { 454 const btn = document.createElement('button'); 455 btn.type = 'button'; 456 btn.className = 'readmore-trigger'; 457 btn.innerHTML = ` 458 <span class="text">Read More</span> 459 <span class="readmore-icon"></span> 460 `; 461 // Hide initially so it doesn't flash before calculations are done 462 btn.style.display = 'none'; 463 btn.style.cursor = 'pointer'; 464 return btn; 465 } 466 467 document.querySelectorAll('.readmore-content').forEach(truncateEl => { 468 if (!truncateEl) return; 469 470 let truncateInnerEl = truncateEl.querySelector('.truncate__inner'); 471 472 if (!truncateInnerEl) { 473 truncateInnerEl = document.createElement('div'); 474 truncateInnerEl.className = 'truncate__inner'; 475 while (truncateEl.firstChild) { 476 truncateInnerEl.appendChild(truncateEl.firstChild); 477 } 478 truncateEl.appendChild(truncateInnerEl); 479 } 480 481 const button = createButton(); 482 truncateEl.insertAdjacentElement('afterend', button); 483 const textEl = button.querySelector('.text'); 484 485 function calculateHeights() { 486 const originalTransition = truncateEl.style.transition; 487 truncateEl.style.transition = 'none'; 488 489 // Measure true expanded 490 truncateEl.classList.remove('truncate--line-clamped'); 491 truncateEl.classList.remove('truncate--expanded'); 492 void truncateEl.offsetHeight; 493 const expandedHeight = truncateEl.getBoundingClientRect().height; 494 495 // Measure clamped 496 truncateEl.classList.add('truncate--line-clamped'); 497 void truncateEl.offsetHeight; 498 const clampedHeight = truncateEl.getBoundingClientRect().height; 499 500 truncateEl.style.setProperty('--truncate-height', `${clampedHeight}px`); 501 truncateEl.style.setProperty('--truncate-height-expanded', `${expandedHeight}px`); 502 truncateEl.style.setProperty('display', 'block'); 503 504 // The missing logic: Hide the button if the content doesn't overflow 505 // Using a +2 buffer accounts for minor sub-pixel rendering quirks in Safari 506 if (expandedHeight <= clampedHeight + 2) { 507 button.style.display = 'none'; 508 } else { 509 button.style.display = 'flex'; // Reverts to your intended layout display 510 } 511 512 requestAnimationFrame(() => { 513 truncateEl.style.transition = originalTransition; 514 }); 515 } 516 517 async function initWithFontWait() { 518 try { 519 if (document.fonts && document.fonts.ready) { 520 await document.fonts.ready; 521 } 522 } catch (e) {} 523 524 await new Promise(resolve => setTimeout(resolve, 200)); 525 calculateHeights(); 526 } 527 528 initWithFontWait(); 529 530// window.addEventListener('resize', () => { 531// clearTimeout(truncateEl._resizeTimeout); 532// truncateEl._resizeTimeout = setTimeout(calculateHeights, 250); 533// }); 534 535 function open() { 536 truncateEl.classList.remove('truncate--line-clamped'); 537 truncateEl.classList.add('truncate--expanded'); 538 textEl.textContent = 'Read Less'; 539 } 540 541 function close() { 542 truncateEl.classList.remove('truncate--expanded'); 543 textEl.textContent = 'Read More'; 544 setTimeout(() => { 545 truncateEl.classList.add('truncate--line-clamped'); 546 }, 300); 547 } 548 549 button.addEventListener('click', () => { 550 truncateEl.classList.contains('truncate--expanded') ? close() : open(); 551 }); 552 }); 553}); 554 555jQuery(document).on('gform_post_render', function (event, formId) { 556 if (parseInt(formId, 10) !== 2) return; 557 558 var inputField = document.getElementById('input_2_11'); 559 if (inputField) { 560 inputField.readOnly = true; 561 inputField.setAttribute('readonly', 'readonly'); 562 } 563});
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.