diff --git a/homepage/views.php b/homepage/views.php index 908d3ec43..6decc7821 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -447,6 +447,60 @@ function setLiveStreamVolume(vol) { audioelement.volume = 1 } } + +function getTheDate(increment) { + var theDate = ""; + + d = new Date(theDate); + d.setDate(d.getDate(theDate) + increment); + yyyy = d.getFullYear(); + mm = d.getMonth() + 1; if (mm < 10) mm = "0" + mm; + dd = d.getDate(); if (dd < 10) dd = "0" + dd; + + swipeSpinner=document.getElementById("SwipeSpinner"); + swipeSpinner.setAttribute("src","images/spinner.gif"); + + window.location = "/views.php?date="+yyyy+"-"+mm+"-"+dd+"&view=Daily+Charts"; +} + +function installKeyAndSwipeEventHandler() { + for (var i = 0; i < topbuttons.length; i++) { + if (topbuttons[i].textContent == "Daily Charts" && + topbuttons[i].className == "button-hover") { + + document.onkeydown = function(event) { + switch (event.keyCode) { + case 37: //Left key + getTheDate(-1); + break; + case 39: //Right key + getTheDate(+1); + break; + } + } + + // https://stackoverflow.com/questions/2264072/detect-a-finger-swipe-through-javascript-on-the-iphone-and-android + let touchstartX = 0 + let touchendX = 0 + + function checkDirection() { + if (touchendX < touchstartX) getTheDate(+1); + if (touchendX > touchstartX) getTheDate(-1); + } + + document.addEventListener('touchstart', e => { + touchstartX = e.changedTouches[0].screenX + }) + + document.addEventListener('touchend', e => { + touchendX = e.changedTouches[0].screenX + checkDirection() + }) + } + } +} + +installKeyAndSwipeEventHandler(); diff --git a/scripts/history.php b/scripts/history.php index 7b639f862..31cc39956 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -149,6 +149,7 @@ function submitID() { Total Detections For The Day +

?>