From 7153ef6f122a66bc74d95ebe04810e022e1ed5f1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 3 Mar 2023 11:46:51 +0200 Subject: [presentation] Added an anchor to the current slide, which also shows slide index, in controls --- src/scripts/presentation.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/scripts/presentation.js') diff --git a/src/scripts/presentation.js b/src/scripts/presentation.js index 8c78ed8..930c7b0 100644 --- a/src/scripts/presentation.js +++ b/src/scripts/presentation.js @@ -17,6 +17,7 @@ printBtn.addEventListener('click', function() { /* Next and previous buttons */ const prevSlideBtn = document.getElementById('prevSlideBtn'); +const slideIndexShow = document.getElementById('slideIndex'); const nextSlideBtn = document.getElementById('nextSlideBtn'); const slides = document.getElementsByClassName('slide'); @@ -24,6 +25,9 @@ var presenting = false; var slideIndex = parseInt(document.URL.substr(document.URL.indexOf("#slide") + 7)); if (isNaN(slideIndex)) slideIndex = 0; +slideIndexShow.innerText = slideIndex; +slideIndexShow.href = '#slide-' + slideIndex; + // Shows the "slideIndex + mod" numbered slide function showSlide(mod) { if (!presenting) return; @@ -31,6 +35,9 @@ function showSlide(mod) { slides[slideIndex].classList.remove('absolute-slide'); slideIndex = (slides.length + slideIndex + mod) % slides.length; slides[slideIndex].classList.add('absolute-slide'); + + slideIndexShow.innerText = slideIndex; + slideIndexShow.href = '#slide-' + slideIndex; } prevSlideBtn.addEventListener('click', function() { @@ -59,6 +66,7 @@ presentBtn.addEventListener('click', function() { // Show the slide controller presentCont.classList.toggle('absolute-cont'); prevSlideBtn.classList.toggle('nodisplay'); + slideIndexShow.classList.toggle('nodisplay'); nextSlideBtn.classList.toggle('nodisplay'); articleBtn.classList.toggle('nodisplay'); printBtn.classList.toggle('nodisplay'); -- cgit v1.3.1-23-gd82d