summary refs log tree commit diff stats
path: root/web/assets/index.js
blob: f10dc603d0e019538fef1eb7a46d9be44fe82fb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";

var timer;
var prevIndex = 0;
var slideCount = 2;

function setSlideShow(index, short) {
  if (index >= slideCount) index = 0;
  document.getElementById("slide"+prevIndex).className = "";
  document.getElementById("slide"+index).className = "active";
  document.getElementById("slideControl"+prevIndex).className = "";
  document.getElementById("slideControl"+index).className = "active";
  prevIndex = index;
  startTimer(short ? 8000 : 32000);
}

function nextSlide() { setSlideShow(prevIndex + 1, true); }
function startTimer(t) { timer = setTimeout(nextSlide, t); }

function slideshow_enter() { clearTimeout(timer); }
function slideshow_exit () { startTimer(16000); }

function slideshow_click(index) {
  clearTimeout(timer);
  setSlideShow(index, false);
}

window.onload = function() {
  var slideshow = document.getElementById("slideshow");
  slideshow.onmouseenter = slideshow_enter;
  slideshow.onmouseleave = slideshow_exit;
  slideCount = slideshow.children.length;
  startTimer(8000);
};