HOME

document.addEventListener('DOMContentLoaded', function () { document.querySelectorAll('.thesis-section').forEach(function (section) { const strip = section.querySelector('.thesis-strip'); if (!strip) return; const GAP = 16; let hold = 2800; // ms per step let timer = null; function cardStep() { const card = strip.querySelector('.thesis-card'); return card ? card.getBoundingClientRect().width + GAP : 336; } function next() { const step = cardStep(); const max = strip.scrollWidth - strip.clientWidth - 2; if (strip.scrollLeft + step >= max) { strip.scrollTo({ left: 0, behavior: 'smooth' }); } else { strip.scrollBy({ left: step, behavior: 'smooth' }); } } function prev() { const step = cardStep(); if (strip.scrollLeft - step <= 0) { strip.scrollTo({ left: strip.scrollWidth, behavior: 'smooth' }); } else { strip.scrollBy({ left: -step, behavior: 'smooth' }); } } function start() { if (!timer) timer = setInterval(next, hold); updateStatus('Playing'); togglePressed(playBtn, true); togglePressed(pauseBtn, false); } function stop() { if (timer) { clearInterval(timer); timer = null; } updateStatus('Paused'); togglePressed(playBtn, false); togglePressed(pauseBtn, true); } // auto-play if allowed if (strip.dataset.autoscroll !== 'false') start(); // pause on hover, resume on leave strip.addEventListener('mouseenter', stop); strip.addEventListener('mouseleave', function () { if (strip.dataset.autoscroll !== 'false') start(); }); // restart on resize window.addEventListener('resize', function () { if (timer) { stop(); start(); } }); // stop on tab change window.addEventListener('visibilitychange', () => document.hidden ? stop() : (strip.dataset.autoscroll !== 'false' && start()) ); // controls const controls = section.querySelector('.thesis-controls'); let playBtn, pauseBtn, statusEl; function updateStatus(msg) { if (statusEl) statusEl.textContent = msg; } function togglePressed(btn, state) { if (!btn) return; btn.setAttribute('aria-pressed', state ? 'true' : 'false'); } if (controls) { playBtn = controls.querySelector('[data-action="play"]'); pauseBtn = controls.querySelector('[data-action="pause"]'); statusEl = controls.querySelector('.thesis-status'); controls.addEventListener('click', function (e) { const btn = e.target.closest('.thesis-btn'); if (!btn) return; const action = btn.getAttribute('data-action'); if (action === 'next') next(); if (action === 'prev') prev(); if (action === 'play') { strip.dataset.autoscroll = 'true'; start(); } if (action === 'pause') { strip.dataset.autoscroll = 'false'; stop(); } }); } // keyboard arrows strip.tabIndex = 0; strip.addEventListener('keydown', function (e) { if (e.key === 'ArrowRight') { e.preventDefault(); stop(); next(); } if (e.key === 'ArrowLeft') { e.preventDefault(); stop(); prev(); } }); }); }); If you are using the jQuery library, then don't forget to wrap your code inside jQuery.ready() as follows: jQuery(document).ready(function( $ ){ // Your code in here }); -- If you want to link a JavaScript file that resides on another server (similar to ), then please use the "Add HTML Code" page, as this is a HTML code that links a JavaScript file. End of comment */