1const track = document.querySelector(".slider-track"); 2let originalSlides = Array.from(track.children); // ORIGINAL slides 3 4let index = 0; 5let slideWidth; 6 7// --- STEP 1: Clone all original slides and append --- 8originalSlides.forEach(slide => { 9 const clone = slide.cloneNode(true); 10 clone.classList.add("clone"); 11 track.appendChild(clone); 12}); 13 14// Now combine originals + clones 15let allSlides = Array.from(track.children); 16 17 18// --- STEP 2: Determine slide width dynamically --- 19function updateSlideWidth() { 20 const trackStyle = getComputedStyle(track); 21 const gap = parseInt(trackStyle.gap); 22 slideWidth = allSlides[0].offsetWidth + gap; 23} 24updateSlideWidth(); 25 26window.addEventListener("resize", () => { 27 updateSlideWidth(); 28 goToSlide(index, false); 29}); 30 31 32// --- STEP 3: Slide movement function --- 33function goToSlide(i, animate = true) { 34 if (animate) { 35 track.style.transition = "transform .5s ease"; 36 } else { 37 track.style.transition = "none"; 38 } 39 track.style.transform = `translateX(-${slideWidth * i}px)`; 40} 41 42 43// --- NEXT slide --- 44function slideNext() { 45 index++; 46 goToSlide(index, true); 47 48 // When reaching the end of original content 49 if (index === originalSlides.length) { 50 setTimeout(() => { 51 index = 0; 52 goToSlide(index, false); // instant reset, no jump 53 }, 500); 54 } 55} 56 57 58// --- PREVIOUS slide --- 59function slidePrev() { 60 index--; 61 goToSlide(index, true); 62 63 if (index < 0) { 64 setTimeout(() => { 65 index = originalSlides.length - 1; 66 goToSlide(index, false); 67 }, 500); 68 } 69} 70 71 72// --- Auto-slide --- 73let autoSlide = setInterval(slideNext, 3000); 74 75 76// --- Buttons --- 77document.querySelector(".NextNews").addEventListener("click", () => { 78 clearInterval(autoSlide); 79 slideNext(); 80 autoSlide = setInterval(slideNext, 3000); 81}); 82 83document.querySelector(".PrevNews").addEventListener("click", () => { 84 clearInterval(autoSlide); 85 slidePrev(); 86 autoSlide = setInterval(slideNext, 3000); 87}); 88 89 90 91//Socities and Clubs 92document.addEventListener('DOMContentLoaded', function () { 93 const track1 = document.querySelector('.SoucitiesCarousel-track'); 94 const slideWidth1 = track1.querySelector('.SoucitiesCarousel-slide').offsetWidth; 95 let speed = 1; 96 let position = 0; 97 98 function animate() { 99 position -= speed; 100 track1.style.transform = `translateX(${position}px)`; 101 102 if (Math.abs(position) >= slideWidth1) { 103 const first = track1.firstElementChild; 104 track1.appendChild(first); 105 position += slideWidth1; 106 } 107 108 requestAnimationFrame(animate); 109 } 110 111 animate(); 112}); 113//Socities and Clubs 114 115 116// Remove any contextmenu blocker 117document.addEventListener('contextmenu', function (e) { 118 e.stopImmediatePropagation(); // only stop blockers, not your own handlers 119}, true); // use capture phase 120 121 122// Remove any previous wheel or touch blockers 123window.onwheel = null; 124document.onwheel = null; 125window.onscroll = null; 126document.onscroll = null; 127 128window.ontouchmove = null; 129document.ontouchmove = null; 130 131 132 133 134['wheel', 'mousewheel', 'touchmove'].forEach(event => { 135 document.addEventListener(event, e => { 136 e.stopPropagation(); // stop propagation but donât prevent default 137 }, { passive: true }); 138}); 139 140document.querySelectorAll(".color-switch-btns button").forEach(btn => { 141 btn.addEventListener("click", function () { 142 143 // Get selected color 144 let themeColor = this.getAttribute("data-color"); 145 146 // Apply to current page using CSS variable 147 //document.documentElement.style.setProperty("--theme-color", themeColor); 148 149 // Save theme color to a shared cookie 150 document.cookie = "ThemeColor=" + themeColor; 151 152 153 console.log("Theme saved:", themeColor); 154 }); 155});
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.