From 0c70a6c80f50dc48241a9860b2364affd3a09042 Mon Sep 17 00:00:00 2001 From: YurenHao0426 Date: Wed, 29 Jul 2026 18:57:24 -0500 Subject: =?UTF-8?q?EPT=20project=20page=20=E2=80=94=20Academic=20Project?= =?UTF-8?q?=20Page=20Template=20port=20(grant-review=20noindex=20mode)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Template: github.com/eliahuhorwitz/Academic-project-page-template (CC BY-SA 4.0, attribution retained) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_014FAPDWQ49M5Ye3NpTndTpn --- static/js/index.js | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 static/js/index.js (limited to 'static/js/index.js') diff --git a/static/js/index.js b/static/js/index.js new file mode 100644 index 0000000..de8c42c --- /dev/null +++ b/static/js/index.js @@ -0,0 +1,142 @@ +window.HELP_IMPROVE_VIDEOJS = false; + +// More Works Dropdown Functionality +function toggleMoreWorks() { + const dropdown = document.getElementById('moreWorksDropdown'); + const button = document.querySelector('.more-works-btn'); + + if (dropdown.classList.contains('show')) { + dropdown.classList.remove('show'); + button.classList.remove('active'); + } else { + dropdown.classList.add('show'); + button.classList.add('active'); + } +} + +// Close dropdown when clicking outside +document.addEventListener('click', function(event) { + const container = document.querySelector('.more-works-container'); + const dropdown = document.getElementById('moreWorksDropdown'); + const button = document.querySelector('.more-works-btn'); + + if (container && !container.contains(event.target)) { + dropdown.classList.remove('show'); + button.classList.remove('active'); + } +}); + +// Close dropdown on escape key +document.addEventListener('keydown', function(event) { + if (event.key === 'Escape') { + const dropdown = document.getElementById('moreWorksDropdown'); + const button = document.querySelector('.more-works-btn'); + dropdown.classList.remove('show'); + button.classList.remove('active'); + } +}); + +// Copy BibTeX to clipboard +function copyBibTeX() { + const bibtexElement = document.getElementById('bibtex-code'); + const button = document.querySelector('.copy-bibtex-btn'); + const copyText = button.querySelector('.copy-text'); + + if (bibtexElement) { + navigator.clipboard.writeText(bibtexElement.textContent).then(function() { + // Success feedback + button.classList.add('copied'); + copyText.textContent = 'Cop'; + + setTimeout(function() { + button.classList.remove('copied'); + copyText.textContent = 'Copy'; + }, 2000); + }).catch(function(err) { + console.error('Failed to copy: ', err); + // Fallback for older browsers + const textArea = document.createElement('textarea'); + textArea.value = bibtexElement.textContent; + document.body.appendChild(textArea); + textArea.select(); + document.execCommand('copy'); + document.body.removeChild(textArea); + + button.classList.add('copied'); + copyText.textContent = 'Cop'; + setTimeout(function() { + button.classList.remove('copied'); + copyText.textContent = 'Copy'; + }, 2000); + }); + } +} + +// Scroll to top functionality +function scrollToTop() { + window.scrollTo({ + top: 0, + behavior: 'smooth' + }); +} + +// Show/hide scroll to top button +window.addEventListener('scroll', function() { + const scrollButton = document.querySelector('.scroll-to-top'); + if (window.pageYOffset > 300) { + scrollButton.classList.add('visible'); + } else { + scrollButton.classList.remove('visible'); + } +}); + +// Video carousel autoplay when in view +function setupVideoCarouselAutoplay() { + const carouselVideos = document.querySelectorAll('.results-carousel video'); + + if (carouselVideos.length === 0) return; + + const observer = new IntersectionObserver((entries) => { + entries.forEach(entry => { + const video = entry.target; + if (entry.isIntersecting) { + // Video is in view, play it + video.play().catch(e => { + // Autoplay failed, probably due to browser policy + console.log('Autoplay prevented:', e); + }); + } else { + // Video is out of view, pause it + video.pause(); + } + }); + }, { + threshold: 0.5 // Trigger when 50% of the video is visible + }); + + carouselVideos.forEach(video => { + observer.observe(video); + }); +} + +$(document).ready(function() { + // Check for click events on the navbar burger icon + + var options = { + slidesToScroll: 1, + slidesToShow: 1, + loop: true, + infinite: true, + autoplay: true, + autoplaySpeed: 5000, + } + + // Initialize all div with carousel class + var carousels = bulmaCarousel.attach('.carousel', options); + + bulmaSlider.attach(); + + // Setup video autoplay for carousel + setupVideoCarouselAutoplay(); + +}) -- cgit v1.2.3