diff --git a/ippisite/ippidb/static/js/ippidb-slides.js b/ippisite/ippidb/static/js/ippidb-slides.js new file mode 100644 index 0000000000000000000000000000000000000000..02572fa3458f28e14fe44dc4c3c2a343ff54fe91 --- /dev/null +++ b/ippisite/ippidb/static/js/ippidb-slides.js @@ -0,0 +1,64 @@ +var slideIndex = 1; + +var myTimer; + +var slideshowContainer; + +window.addEventListener("load", function () { + showSlides(slideIndex); + myTimer = setInterval(function () { plusSlides(1) }, 5000); + + //COMMENT OUT THE LINE BELOW TO KEEP ARROWS PART OF MOUSEENTER PAUSE/RESUME + slideshowContainer = document.getElementsByClassName('slideshow-inner')[0]; + + //UNCOMMENT OUT THE LINE BELOW TO KEEP ARROWS PART OF MOUSEENTER PAUSE/RESUME + // slideshowContainer = document.getElementsByClassName('slideshow-container')[0]; + + slideshowContainer.addEventListener('mouseenter', pause) + slideshowContainer.addEventListener('mouseleave', resume) +}) + +// NEXT AND PREVIOUS CONTROL +function plusSlides(n) { + clearInterval(myTimer); + if (n < 0) { + showSlides(slideIndex -= 1); + } else { + showSlides(slideIndex += 1); + } + + //COMMENT OUT THE LINES BELOW TO KEEP ARROWS PART OF MOUSEENTER PAUSE/RESUME + + if (n === -1) { + myTimer = setInterval(function () { plusSlides(n + 2) }, 5000); + } else { + myTimer = setInterval(function () { plusSlides(n + 1) }, 5000); + } +} + +//Controls the current slide and resets interval if needed +function currentSlide(n) { + clearInterval(myTimer); + myTimer = setInterval(function () { plusSlides(n + 1) }, 5000); + showSlides(slideIndex = n); +} + +function showSlides(n) { + var i; + var slides = document.getElementsByClassName("mySlides"); + if (n > slides.length) { slideIndex = 1 } + if (n < 1) { slideIndex = slides.length } + for (i = 0; i < slides.length; i++) { + slides[i].style.display = "none"; + } + slides[slideIndex - 1].style.display = "block"; +} + +pause = () => { + clearInterval(myTimer); +} + +resume = () => { + clearInterval(myTimer); + myTimer = setInterval(function () { plusSlides(slideIndex) }, 5000); +} \ No newline at end of file diff --git a/ippisite/ippidb/static/js/ippidb.js b/ippisite/ippidb/static/js/ippidb.js index 2b443c06002198d9b502192811649ee43e1c7d9e..e45274297d1d1f185e24d3072a34b26bdcc8a3b6 100644 --- a/ippisite/ippidb/static/js/ippidb.js +++ b/ippisite/ippidb/static/js/ippidb.js @@ -226,71 +226,6 @@ $(document).ready(function () { }); }); -var slideIndex = 1; - -var myTimer; - -var slideshowContainer; - -window.addEventListener("load", function () { - showSlides(slideIndex); - myTimer = setInterval(function () { plusSlides(1) }, 5000); - - //COMMENT OUT THE LINE BELOW TO KEEP ARROWS PART OF MOUSEENTER PAUSE/RESUME - slideshowContainer = document.getElementsByClassName('slideshow-inner')[0]; - - //UNCOMMENT OUT THE LINE BELOW TO KEEP ARROWS PART OF MOUSEENTER PAUSE/RESUME - // slideshowContainer = document.getElementsByClassName('slideshow-container')[0]; - - slideshowContainer.addEventListener('mouseenter', pause) - slideshowContainer.addEventListener('mouseleave', resume) -}) - -// NEXT AND PREVIOUS CONTROL -function plusSlides(n) { - clearInterval(myTimer); - if (n < 0) { - showSlides(slideIndex -= 1); - } else { - showSlides(slideIndex += 1); - } - - //COMMENT OUT THE LINES BELOW TO KEEP ARROWS PART OF MOUSEENTER PAUSE/RESUME - - if (n === -1) { - myTimer = setInterval(function () { plusSlides(n + 2) }, 5000); - } else { - myTimer = setInterval(function () { plusSlides(n + 1) }, 5000); - } -} - -//Controls the current slide and resets interval if needed -function currentSlide(n) { - clearInterval(myTimer); - myTimer = setInterval(function () { plusSlides(n + 1) }, 5000); - showSlides(slideIndex = n); -} - -function showSlides(n) { - var i; - var slides = document.getElementsByClassName("mySlides"); - if (n > slides.length) { slideIndex = 1 } - if (n < 1) { slideIndex = slides.length } - for (i = 0; i < slides.length; i++) { - slides[i].style.display = "none"; - } - slides[slideIndex - 1].style.display = "block"; -} - -pause = () => { - clearInterval(myTimer); -} - -resume = () => { - clearInterval(myTimer); - myTimer = setInterval(function () { plusSlides(slideIndex) }, 5000); -} - var multiselectTypeAhead = function (idSearch, selection, onSelect) { var bh = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), diff --git a/ippisite/ippidb/templates/index.html b/ippisite/ippidb/templates/index.html index 970e4e9aab8068b87948fe68154b4b923439fff3..664931798fa7e308432c9ff8a1ef885d72d7ac30 100644 --- a/ippisite/ippidb/templates/index.html +++ b/ippisite/ippidb/templates/index.html @@ -1,5 +1,9 @@ {% extends "base.html" %} +{% block extra_js %} +<script src="/static/js/ippidb-slides.js" type="text/javascript"></script> +{% endblock %} + {% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %}