From a3f2fe943ca18603ab170eeffb560d1122521e14 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 16 Apr 2022 10:27:04 -0400
Subject: [PATCH] JS refresh of most recent detection
Hello!
I've gone ahead and implemented some JS into overview.php that will automatically refresh the most recent audio detection, if there is a newer one. This means you don't have to manually refresh overview anymore.
Open to feedback/suggestions!
-Ethan
---
scripts/overview.php | 92 +++++++++++++++++++++++++++++------
scripts/todays_detections.php | 1 -
2 files changed, 78 insertions(+), 15 deletions(-)
diff --git a/scripts/overview.php b/scripts/overview.php
index c622faa..2a14563 100644
--- a/scripts/overview.php
+++ b/scripts/overview.php
@@ -1,5 +1,5 @@
execute();
$totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC);
+
+
+if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isset($_GET['previous_detection_identifier'])) {
+ if($_GET['previous_detection_identifier'] != $filename || $_GET['previous_detection_identifier'] == "undefined") {
+ // check to make sure the image actually exists, sometimes it takes a minute to be created
+ $headers = @get_headers("http://".$_SERVER['HTTP_HOST'].$filename.".png");
+ if(strpos($headers[0],'200')) {
+ ?>
+
+
+ Most Recent Detection:
+
+ |
+ |
+
+
+
@@ -113,20 +156,41 @@ if (file_exists('./Charts/'.$chart)) {
}
?>
-
- Most Recent Detection:
-
- |
- |
-
-
-
+
+
+
Currently Analyzing
+
+
+
diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php
index e50a2e7..f9b4319 100644
--- a/scripts/todays_detections.php
+++ b/scripts/todays_detections.php
@@ -143,7 +143,6 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse