From b5c4160c9cc2b8952379e38f04ef40910ec9b68b Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 12 Mar 2023 19:34:40 -0400
Subject: [PATCH] Split "Recordings" species list into 3 columns to take up
less vertical space
---
scripts/play.php | 155 ++++++++++++++++++++++++++++++++--------------
scripts/stats.php | 71 +++++++++++++++------
2 files changed, 161 insertions(+), 65 deletions(-)
diff --git a/scripts/play.php b/scripts/play.php
index e4c020e..6dc91b0 100644
--- a/scripts/play.php
+++ b/scripts/play.php
@@ -109,27 +109,27 @@ if(isset($_GET['shiftfile'])) {
$pi = $home."/BirdSongs/Extracted/By_Date/";
if(isset($_GET['doshift'])) {
- $freqshift_tool = $config['FREQSHIFT_TOOL'];
+ $freqshift_tool = $config['FREQSHIFT_TOOL'];
- if ($freqshift_tool == "ffmpeg") {
- $cmd = "/usr/bin/nohup /usr/bin/ffmpeg -y -i \"".$pi.$filename."\" -af \"rubberband=pitch=".$config['FREQSHIFT_LO']."/".$config['FREQSHIFT_HI']."\" \"".$shifted_path.$filename."\"";
- shell_exec("mkdir -p ".$shifted_path.$dir." && echo \"".$cmd."\" > /tmp/shift.sh && chmod +x /tmp/shift.sh");
+ if ($freqshift_tool == "ffmpeg") {
+ $cmd = "/usr/bin/nohup /usr/bin/ffmpeg -y -i \"".$pi.$filename."\" -af \"rubberband=pitch=".$config['FREQSHIFT_LO']."/".$config['FREQSHIFT_HI']."\" \"".$shifted_path.$filename."\"";
+ shell_exec("mkdir -p ".$shifted_path.$dir." && echo \"".$cmd."\" > /tmp/shift.sh && chmod +x /tmp/shift.sh");
- } else if ($freqshift_tool == "sox") {
- //linux.die.net/man/1/sox
- $soxopt = "-q";
- $soxpitch = $config['FREQSHIFT_PITCH'];
- $cmd = "/usr/bin/nohup /usr/bin/sox \"".$pi.$filename."\" \"".$shifted_path.$filename."\" pitch ".$soxopt." ".$soxpitch;
- shell_exec("mkdir -p ".$shifted_path.$dir." && echo \"".$cmd."\" > /tmp/shift.sh && chmod +x /tmp/shift.sh");
- }
+ } else if ($freqshift_tool == "sox") {
+ //linux.die.net/man/1/sox
+ $soxopt = "-q";
+ $soxpitch = $config['FREQSHIFT_PITCH'];
+ $cmd = "/usr/bin/nohup /usr/bin/sox \"".$pi.$filename."\" \"".$shifted_path.$filename."\" pitch ".$soxopt." ".$soxpitch;
+ shell_exec("mkdir -p ".$shifted_path.$dir." && echo \"".$cmd."\" > /tmp/shift.sh && chmod +x /tmp/shift.sh");
+ }
- shell_exec("/tmp/shift.sh");
- shell_exec("rm -f /tmp/shift.sh");
+ shell_exec("/tmp/shift.sh");
+ shell_exec("rm -f /tmp/shift.sh");
} else {
- $cmd = "rm -f " . $shifted_path.$filename;
- shell_exec("echo \"".$cmd."\" > /tmp/unshift.sh && chmod +x /tmp/unshift.sh");
- shell_exec("/tmp/unshift.sh");
- shell_exec("rm -f /tmp/unshift.sh");
+ $cmd = "rm -f " . $shifted_path.$filename;
+ shell_exec("echo \"".$cmd."\" > /tmp/unshift.sh && chmod +x /tmp/unshift.sh");
+ shell_exec("/tmp/unshift.sh");
+ shell_exec("rm -f /tmp/unshift.sh");
}
echo "OK";
@@ -259,21 +259,21 @@ function toggleShiftFreq(filename, shiftAction, elem) {
elem.setAttribute("title", "This file has been shifted down in frequency.");
elem.setAttribute("onclick", elem.getAttribute("onclick").replace("shift","unshift"));
console.log("shifted freqs of " + filename);
- video=elem.parentNode.getElementsByTagName("video")[0];
- video.setAttribute("title", video.getAttribute("title").replace("/By_Date/","/By_Date/shifted/"));
- source = video.getElementsByTagName("source")[0];
- source.setAttribute("src", source.getAttribute("src").replace("/By_Date/","/By_Date/shifted/"));
- video.load();
+ video=elem.parentNode.getElementsByTagName("video")[0];
+ video.setAttribute("title", video.getAttribute("title").replace("/By_Date/","/By_Date/shifted/"));
+ source = video.getElementsByTagName("source")[0];
+ source.setAttribute("src", source.getAttribute("src").replace("/By_Date/","/By_Date/shifted/"));
+ video.load();
} else {
elem.setAttribute("src","images/shift.svg");
elem.setAttribute("title", "This file is not shifted in frequency.");
elem.setAttribute("onclick", elem.getAttribute("onclick").replace("unshift","shift"));
console.log("unshifted freqs of " + filename);
- video=elem.parentNode.getElementsByTagName("video")[0];
- video.setAttribute("title", video.getAttribute("title").replace("/By_Date/shifted/","/By_Date/"));
- source = video.getElementsByTagName("source")[0];
- source.setAttribute("src", source.getAttribute("src").replace("/By_Date/shifted/","/By_Date/"));
- video.load();
+ video=elem.parentNode.getElementsByTagName("video")[0];
+ video.setAttribute("title", video.getAttribute("title").replace("/By_Date/shifted/","/By_Date/"));
+ source = video.getElementsByTagName("source")[0];
+ source.setAttribute("src", source.getAttribute("src").replace("/By_Date/shifted/","/By_Date/"));
+ video.load();
}
}
}
@@ -325,22 +325,76 @@ if(!isset($_GET['species']) && !isset($_GET['filename'])){
#By Species
} elseif($view == "byspecies") {
- while($results=$result->fetchArray(SQLITE3_ASSOC)){
+ $birds = array();
+ while($results=$result->fetchArray(SQLITE3_ASSOC))
+ {
$name = $results['Com_Name'];
-
- echo "
- | ";}
-
- #Specific Date
- } elseif($view == "date") {
- while($results=$result->fetchArray(SQLITE3_ASSOC)){
- $name = $results['Com_Name'];
- if(realpath($home."/BirdSongs/Extracted/By_Date/".$date."/".str_replace(" ", "_",$name)) !== false){
- echo "
- | ";
- }
+ $birds[] = $name;
}
+ if(count($birds) > 45) {
+ $num_cols = 3;
+ } else {
+ $num_cols = 1;
+ }
+ $num_rows = ceil(count($birds) / $num_cols);
+
+ for ($row = 0; $row < $num_rows; $row++) {
+ echo "";
+
+ for ($col = 0; $col < $num_cols; $col++) {
+ $index = $row + $col * $num_rows;
+
+ if ($index < count($birds)) {
+ ?>
+ |
+
+ |
+ ";
+ }
+ }
+
+ echo "
";
+ }
+ } elseif($view == "date") {
+ $birds = array();
+while($results=$result->fetchArray(SQLITE3_ASSOC))
+{
+ $name = $results['Com_Name'];
+ if(realpath($home."/BirdSongs/Extracted/By_Date/".$date."/".str_replace(" ", "_",$name)) !== false){
+ $birds[] = $name;
+ }
+}
+
+if(count($birds) > 45) {
+ $num_cols = 3;
+} else {
+ $num_cols = 1;
+}
+$num_rows = ceil(count($birds) / $num_cols);
+
+for ($row = 0; $row < $num_rows; $row++) {
+ echo "";
+
+ for ($col = 0; $col < $num_cols; $col++) {
+ $index = $row + $col * $num_rows;
+
+ if ($index < count($birds)) {
+ ?>
+ |
+
+ |
+ ";
+ }
+ }
+
+ echo "
";
+}
+
#Choose
} else {
echo "
@@ -452,7 +506,7 @@ echo "
$shiftImageIcon = "images/unshift.svg";
$shiftTitle = "This file has been shifted down in frequency.";
$shiftAction = "unshift";
- $filename = $filename_shifted;
+ $filename = $filename_shifted;
} else {
$shiftImageIcon = "images/shift.svg";
$shiftTitle = "This file is not shifted in frequency.";
@@ -460,7 +514,7 @@ echo "
}
echo "
- |
+ |
@@ -471,7 +525,7 @@ echo "
";
} else {
echo "
- $date $time $confidence
+ | $date $time $confidence

".$imageelem."
|
@@ -527,7 +581,7 @@ echo "
$shiftImageIcon = "images/unshift.svg";
$shiftTitle = "This file has been shifted down in frequency.";
$shiftAction = "unshift";
- $filename = $filename_shifted;
+ $filename = $filename_shifted;
} else {
$shiftImageIcon = "images/shift.svg";
$shiftTitle = "This file is not shifted in frequency.";
@@ -535,7 +589,7 @@ echo "
}
echo "
- |
+ |
@@ -545,7 +599,7 @@ echo "
";
} else {
echo "
- $date $time $confidence
+ | $date $time $confidence

|
";
@@ -553,4 +607,13 @@ echo "";}?>
+
+
| | |