diff options
Diffstat (limited to 'slides/vendor/slides.js')
| -rw-r--r-- | slides/vendor/slides.js | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/slides/vendor/slides.js b/slides/vendor/slides.js deleted file mode 100644 index c987e51..0000000 --- a/slides/vendor/slides.js +++ /dev/null | |||
| @@ -1,140 +0,0 @@ | |||
| 1 | window.addEventListener('load', function(evt) { | ||
| 2 | |||
| 3 | let main = document.querySelector('main'); | ||
| 4 | let nav = document.querySelector('nav'); | ||
| 5 | let wrapper = document.querySelector('div.wrapper'); | ||
| 6 | let hash = window.location.hash.slice(1, window.location.hash.length); | ||
| 7 | |||
| 8 | if (hash.length > 0) { | ||
| 9 | |||
| 10 | fetch(`presentations/${hash}/default.pug`).then(function(response) { | ||
| 11 | response.text().then(function(template) { | ||
| 12 | if (response.status == 200) { | ||
| 13 | main.innerHTML = jade.render(template, {}); | ||
| 14 | initSlideshow(); | ||
| 15 | } else { | ||
| 16 | main.innerHTML = '<section><h3>Presentation does not exists!</h3></section>'; | ||
| 17 | } | ||
| 18 | }).catch(function(error) { | ||
| 19 | console.log(error); | ||
| 20 | }); | ||
| 21 | }); | ||
| 22 | |||
| 23 | fetch(`presentations/${hash}/meta.json`).then(function(response) { | ||
| 24 | response.json().then(function(data) { | ||
| 25 | document.title = data.title; | ||
| 26 | }).catch(function(error) { | ||
| 27 | console.log(error); | ||
| 28 | }); | ||
| 29 | }); | ||
| 30 | |||
| 31 | } | ||
| 32 | |||
| 33 | function initSlideshow() { | ||
| 34 | |||
| 35 | // mathjax formulas | ||
| 36 | MathJax.Hub.Config({ | ||
| 37 | //displayAlign: 'left', | ||
| 38 | extensions: ['tex2jax.js'], | ||
| 39 | jax: ['input/TeX', 'output/SVG'], | ||
| 40 | tex2jax: { | ||
| 41 | skipTags: ['script', 'noscript', 'style', 'textarea', 'code'], | ||
| 42 | inlineMath: [ | ||
| 43 | ['$', '$'], | ||
| 44 | ["\\(", "\\)"] | ||
| 45 | ], | ||
| 46 | displayMath: [ | ||
| 47 | ['$$', '$$'], | ||
| 48 | ["\\[", "\\]"] | ||
| 49 | ], | ||
| 50 | } | ||
| 51 | }); | ||
| 52 | MathJax.Hub.Configured(); | ||
| 53 | |||
| 54 | // syntax highlighting | ||
| 55 | Prism.highlightAll(); | ||
| 56 | |||
| 57 | // initializes slides | ||
| 58 | function showSlide(slides, op) { | ||
| 59 | let tmpIdx = currentIdx + op; | ||
| 60 | if (tmpIdx >= 0 && tmpIdx < slides.length) { | ||
| 61 | slides.forEach(function(slide) { | ||
| 62 | slide.classList.add('hide'); | ||
| 63 | }); | ||
| 64 | slides[tmpIdx].classList.remove('hide'); | ||
| 65 | window.scrollTo(0, 0); | ||
| 66 | nav.innerHTML = `${tmpIdx+1} / ${slides.length}`; | ||
| 67 | currentIdx = tmpIdx; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | // fixes images relative path | ||
| 72 | document.querySelectorAll('img').forEach(function(image) { | ||
| 73 | image.src = `presentations/${hash}/${image.getAttribute('src')}`; | ||
| 74 | }); | ||
| 75 | |||
| 76 | let slides = document.querySelectorAll('section'); | ||
| 77 | let currentIdx = 0; | ||
| 78 | showSlide(slides, currentIdx); | ||
| 79 | |||
| 80 | document.addEventListener('keydown', function(evt) { | ||
| 81 | switch (evt.code) { | ||
| 82 | case 'ArrowRight': | ||
| 83 | { | ||
| 84 | showSlide(slides, 1); | ||
| 85 | break; | ||
| 86 | } | ||
| 87 | case 'ArrowLeft': | ||
| 88 | { | ||
| 89 | showSlide(slides, -1); | ||
| 90 | break; | ||
| 91 | } | ||
| 92 | case 'KeyF': | ||
| 93 | { | ||
| 94 | if (wrapper.requestFullscreen) { | ||
| 95 | wrapper.requestFullscreen(); | ||
| 96 | } else if (wrapper.mozRequestFullScreen) { | ||
| 97 | wrapper.mozRequestFullScreen(); | ||
| 98 | } else if (wrapper.webkitRequestFullscreen) { | ||
| 99 | wrapper.webkitRequestFullscreen(); | ||
| 100 | } else if (wrapper.msRequestFullscreen) { | ||
| 101 | wrapper.msRequestFullscreen(); | ||
| 102 | } | ||
| 103 | break; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | }, false); | ||
| 107 | |||
| 108 | |||
| 109 | //var elem = document.getElementById("myvideo"); | ||
| 110 | //if (elem.requestFullscreen) { | ||
| 111 | // elem.requestFullscreen(); | ||
| 112 | //} | ||
| 113 | |||
| 114 | } | ||
| 115 | |||
| 116 | }, false); | ||
| 117 | |||
| 118 | |||
| 119 | // hide mouse after 5seconds | ||
| 120 | (function() { | ||
| 121 | var mouseTimer = null, | ||
| 122 | cursorVisible = true; | ||
| 123 | |||
| 124 | function disappearCursor() { | ||
| 125 | mouseTimer = null; | ||
| 126 | document.body.style.cursor = 'none'; | ||
| 127 | cursorVisible = false; | ||
| 128 | } | ||
| 129 | |||
| 130 | document.onmousemove = function() { | ||
| 131 | if (mouseTimer) { | ||
| 132 | window.clearTimeout(mouseTimer); | ||
| 133 | } | ||
| 134 | if (!cursorVisible) { | ||
| 135 | document.body.style.cursor = 'default'; | ||
| 136 | cursorVisible = true; | ||
| 137 | } | ||
| 138 | mouseTimer = window.setTimeout(disappearCursor, 2000); | ||
| 139 | }; | ||
| 140 | })(); | ||
