Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts
diff options
context:
space:
mode:
Commitfccbced0ec577a8db6cca5055508cd8d93e6a986 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-09-27 19:56:11 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-09-27 19:56:11 +0300
Files28058474e9e50b6ee174af5e3a5b5a253e9f92a9 /src/scripts
syndamia.com-fccbced0ec577a8db6cca5055508cd8d93e6a986.tar
syndamia.com-fccbced0ec577a8db6cca5055508cd8d93e6a986.tar.gz
syndamia.com-fccbced0ec577a8db6cca5055508cd8d93e6a986.zip
Parent51e6043190563a60bdf86cd70a1364f37d3af59e (diff)
[scripts] Implemented a general styling and usage system for custom made presentations
1 files changed, 55 insertions, 0 deletions
-rw-r--r--src/scripts/presentation.js55
diff --git a/src/scripts/presentation.js b/src/scripts/presentation.js
new file mode 100644
index 0000000..b611355
--- /dev/null
+++ b/src/scripts/presentation.js
@@ -0,0 +1,55 @@
+/* Add stylesheet to page */
+
+var presStyle = document.createElement('link');
+presStyle.type = 'text/css';
+presStyle.rel = 'stylesheet';
+presStyle.href = '/presentation.css';
+document.head.appendChild(presStyle);
+
+/* Print button */
+
+const printBtn = document.getElementById('printBtn');
+
+printBtn.onclick = function() {
+ window.print();
+}
+
+/* Next and previous buttons */
+
+const prevSlideBtn = document.getElementById('prevSlideBtn');
+const nextSlideBtn = document.getElementById('nextSlideBtn');
+
+const slides = document.getElementsByClassName('slide');
+var slideIndex = 0;
+
+function showSlide(mod) {
+ slides[slideIndex].classList.remove('absolute-slide');
+ slideIndex = (slides.length + slideIndex + mod) % slides.length;
+ slides[slideIndex].classList.add('absolute-slide');
+}
+
+prevSlideBtn.onclick = function() {
+ showSlide(-1);
+}
+
+nextSlideBtn.onclick = function() {
+ showSlide(+1);
+}
+
+/* Present button */
+
+const presentCont = document.getElementById('presentCont');
+const presentBtn = document.getElementById('presentBtn');
+
+presentBtn.onclick = function() {
+ // Hide the whole page
+ document.body.classList.toggle('invisible');
+ document.body.classList.toggle('no-overflow');
+ // Show the slide controller
+ presentCont.classList.toggle('absolute-cont');
+ prevSlideBtn.classList.toggle('nodisplay');
+ nextSlideBtn.classList.toggle('nodisplay');
+ // Show the first slide
+ slides[slideIndex].classList.toggle('absolute-slide');
+ slideIndex = 0;
+}