From 52dbc89c04e762cabdee8e28ed9d76a5cd7a1994 Mon Sep 17 00:00:00 2001 From: Louis Croisez Date: Mon, 2 Oct 2023 16:05:47 +0200 Subject: [PATCH 1/5] Added swipeL + swipeR + arrowL + arrowR events to DailyCharts form --- homepage/views.php | 57 +++++++++++++++++++++++++++++++++++++++++++++ scripts/history.php | 2 ++ 2 files changed, 59 insertions(+) diff --git a/homepage/views.php b/homepage/views.php index 908d3ec43..95f489283 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -136,6 +136,7 @@ function copyOutput(elem) { textArea.select(); document.execCommand("copy"); } +
@@ -447,6 +448,62 @@ 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; + + infoSwipe=document.getElementById("divInfoSwipe"); + console.log(infoSwipe); + + if (increment < 0) infoSwipe.textContent = "Decrementing date..." + if (increment > 0) infoSwipe.textContent = "Incrementing date..." + + 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..aa8dd39e5 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -145,6 +145,8 @@ function submitID() { +
+
From 18aa67a41894c7948a75c55070aabc5fa5a1519a Mon Sep 17 00:00:00 2001 From: Louis Croisez Date: Tue, 3 Oct 2023 10:00:28 +0200 Subject: [PATCH 2/5] Added swipeL + swipeR + arrowL + arrowR events to DailyCharts form --- homepage/views.php | 3 +-- scripts/history.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/homepage/views.php b/homepage/views.php index 95f489283..ba892f63c 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -136,7 +136,6 @@ function copyOutput(elem) { textArea.select(); document.execCommand("copy"); } -
@@ -451,6 +450,7 @@ function setLiveStreamVolume(vol) { function getTheDate(increment) { var theDate = ""; + d = new Date(theDate); d.setDate(d.getDate(theDate) + increment); yyyy = d.getFullYear(); @@ -458,7 +458,6 @@ function getTheDate(increment) { dd = d.getDate(); if (dd < 10) dd = "0" + dd; infoSwipe=document.getElementById("divInfoSwipe"); - console.log(infoSwipe); if (increment < 0) infoSwipe.textContent = "Decrementing date..." if (increment > 0) infoSwipe.textContent = "Incrementing date..." diff --git a/scripts/history.php b/scripts/history.php index aa8dd39e5..ff3c92f24 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -145,8 +145,7 @@ function submitID() { -
-
+
Total Detections For The Day
From 3256b678be78752737d26b45b74e7a4fd922b39e Mon Sep 17 00:00:00 2001 From: Louis Croisez Date: Tue, 3 Oct 2023 10:35:07 +0200 Subject: [PATCH 3/5] changed indicator from div to img, using spinner.gif --- homepage/views.php | 6 ++---- scripts/history.php | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/homepage/views.php b/homepage/views.php index ba892f63c..e0f10673f 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -457,10 +457,8 @@ function getTheDate(increment) { mm = d.getMonth() + 1; if (mm < 10) mm = "0" + mm; dd = d.getDate(); if (dd < 10) dd = "0" + dd; - infoSwipe=document.getElementById("divInfoSwipe"); - - if (increment < 0) infoSwipe.textContent = "Decrementing date..." - if (increment > 0) infoSwipe.textContent = "Incrementing date..." + swipeSpinner=document.getElementById("SwipeSpinner"); + swipeSpinner.setAttribute("src","images/spinner.gif"); window.location = "/views.php?date="+yyyy+"-"+mm+"-"+dd+"&view=Daily+Charts"; } diff --git a/scripts/history.php b/scripts/history.php index ff3c92f24..a228ae188 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -150,6 +150,7 @@ function submitID() { +
Total Detections For The Day
Total Detections For The Day


?> From 75bb752e754ea7b860759b94e22ec77208974734 Mon Sep 17 00:00:00 2001 From: Louis Croisez Date: Tue, 3 Oct 2023 10:40:12 +0200 Subject: [PATCH 4/5] changed indicator from div to img, using spinner.gif --- scripts/history.php | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/history.php b/scripts/history.php index a228ae188..31cc39956 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -145,7 +145,6 @@ function submitID() { -
From cfc7c9c283e32641b59351c40042ba8d58c89fbf Mon Sep 17 00:00:00 2001 From: Louis Croisez Date: Tue, 3 Oct 2023 10:43:01 +0200 Subject: [PATCH 5/5] invert swipe directions --- homepage/views.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homepage/views.php b/homepage/views.php index e0f10673f..6decc7821 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -484,8 +484,8 @@ function installKeyAndSwipeEventHandler() { let touchendX = 0 function checkDirection() { - if (touchendX < touchstartX) getTheDate(-1); - if (touchendX > touchstartX) getTheDate(+1); + if (touchendX < touchstartX) getTheDate(+1); + if (touchendX > touchstartX) getTheDate(-1); } document.addEventListener('touchstart', e => {
Total Detections For The Day