Skip to content

A live bird collage card for your Home Assistant dashboard.

consolidate Include/Exclude/Whitelist

frederik054b3b3dabae
diff --git a/.gitignore b/.gitignore
index 87eb4988..b6a8d5a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,4 +44,5 @@ exclude_species_list.txt
firstrun.ini
HUMAN.txt
include_species_list.txt
+whitelist_species_list.txt
/nbproject/private/
diff --git a/homepage/static/dark-style.css b/homepage/static/dark-style.css
index 1395d6bd..997d2e37 100644
--- a/homepage/static/dark-style.css
+++ b/homepage/static/dark-style.css
@@ -404,12 +404,6 @@ button:hover {
height: 80%;
}
-.column4 {
- text-align: justify;
- width: 10%;
- height: 50%;
-}
-
.column1 form,.column3 form {
width: 80%;
margin-left: auto;
@@ -502,7 +496,7 @@ button:hover {
}
@media screen and (max-width: 1290px) {
- .column1,.column2,.column3,.column4 {
+ .column1,.column2,.column3 {
height: 90%
}
.center-column {
@@ -542,7 +536,7 @@ button:hover {
background-color: #333; /* dark background */
color: #fff; /* white text */
}
- .column2,.column4 {
+ .column2 {
display: none;
}
.smaller{
diff --git a/homepage/style.css b/homepage/style.css
index 81ba76a6..89d629ee 100644
--- a/homepage/style.css
+++ b/homepage/style.css
@@ -384,12 +384,6 @@ button:hover {
height: 80%;
}
-.column4 {
- text-align: justify;
- width: 10%;
- height: 50%;
-}
-
.column1 form,.column3 form {
width: 80%;
margin-left: auto;
@@ -477,7 +471,7 @@ button:hover {
}
@media screen and (max-width: 1290px) {
- .column1,.column2,.column3,.column4 {
+ .column1,.column2,.column3 {
height: 90%
}
.center-column {
@@ -514,7 +508,7 @@ button:hover {
.column1 select,.column3 select {
height: 70%;
}
- .column2,.column4 {
+ .column2 {
display: none;
}
.smaller{
diff --git a/scripts/exclude_list.php b/scripts/exclude_list.php
deleted file mode 100644
index 310b3517..00000000
--- a/scripts/exclude_list.php
+++ /dev/null
@@ -1,104 +0,0 @@
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<style>
-</style>
-
-<div class="customlabels column1">
-<form action="" method="GET" id="add">
- <h3>All Species Labels</h3>
- <input autocomplete="off" size="18" type="text" placeholder="Search Species..." id="exclude_species_searchterm" name="exclude_species_searchterm">
- <br>
- <span>Once the desired species has been highlighted, click it and then click ADD to have it excluded.</span>
- <select name="species[]" id="species" multiple size="25">
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors',1);
-
- $filename = './scripts/labels.txt';
- $eachline = file($filename, FILE_IGNORE_NEW_LINES);
-
- foreach($eachline as $lines){echo
- "<option value=\"".$lines."\">$lines</option>";}
- ?>
- </select>
- <input type="hidden" name="add" value="add">
-</form>
-<div class="customlabels smaller">
- <button type="submit" name="view" value="Excluded" form="add">>>ADD>></button>
-</div>
-</div>
-
-<div class="customlabels column2">
- <table><td>
- <button type="submit" name="view" value="Excluded" form="add">>>ADD>></button>
- <br><br>
- <button type="submit" name="view" value="Excluded" form="del">REMOVE</button>
- </td></table>
-</div>
-
-<div class="customlabels column3">
-<form action="" method="GET" id="del">
- <h3>Excluded Species List</h3>
- <br><br><br>
- <select name="species[]" id="value2" multiple size="25">
- <option disabled value="base">Please Select</option>
-<?php
- $filename = './scripts/exclude_species_list.txt';
- $eachline = file($filename, FILE_IGNORE_NEW_LINES);
- foreach($eachline as $lines){
- echo
- "<option value=\"".$lines."\">$lines</option>";
-}?>
- </select>
- <input type="hidden" name="del" value="del">
-</form>
-<div class="customlabels smaller">
- <button type="submit" name="view" value="Excluded" form="del">REMOVE</button>
-</div>
-</div>
-
-<script>
- // Store the original list of options in a variable
- var originalOptions = {};
-
- document.getElementById("add").addEventListener("submit", function(event) {
- var speciesSelect = document.getElementById("species");
- if (speciesSelect.selectedIndex < 0) {
- alert("Please click the species you want to add.");
- document.querySelector('.views').style.opacity = 1;
- event.preventDefault();
- }
- });
-
- var search_term = document.querySelector("input#exclude_species_searchterm");
- search_term.addEventListener("keyup", function() {
- filterOptions("species");
- });
-
- // Function to filter options in a select element
- function filterOptions(id) {
- var input = document.getElementById("exclude_species_searchterm");
- var filter = input.value.toUpperCase();
- var select = document.getElementById(id);
- var options = select.getElementsByTagName("option");
-
- // If the original list of options for this select element hasn't been stored yet, store it
- if (!originalOptions[id]) {
- originalOptions[id] = Array.from(options).map(option => option.value);
- }
-
- // Clear the select element
- while (select.firstChild) {
- select.removeChild(select.firstChild);
- }
-
- // Populate the select element with the filtered labels
- originalOptions[id].forEach(label => {
- if (label.toUpperCase().indexOf(filter) > -1) {
- let option = document.createElement('option');
- option.value = label;
- option.text = label;
- select.appendChild(option);
- }
- });
- }
-</script>
diff --git a/scripts/include_list.php b/scripts/include_list.php
deleted file mode 100644
index fd48ed64..00000000
--- a/scripts/include_list.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<style>
-</style>
-
-<?php
-error_reporting(E_ALL);
-ini_set('display_errors',1);
-
-$filename = './scripts/labels.txt';
-$eachlines = file($filename, FILE_IGNORE_NEW_LINES);
-
-?>
-
-<div class="customlabels smaller">
-<br>
-</div>
-<body style="height: 90%;">
- <p>Warning!<br>If this list contains ANY species, the system will ONLY recognize those species. Keep this list EMPTY unless you are ONLY interested in detecting specific species.</p>
-<div class="customlabels2 column1">
-<form action="" method="GET" id="add">
- <h2>All Species Labels</h2>
- <input autocomplete="off" size="18" type="text" placeholder="Search Species..." id="species_searchterm" name="species_searchterm">
- <select name="species[]" id="species" multiple size="25">
- <?php
- foreach($eachlines as $lines){echo
- "<option value=\"".$lines."\">$lines</option>";}
- ?>
- </select>
- <input type="hidden" name="add" value="add">
-</form>
-<div class="customlabels2 smaller">
- <button type="submit" name="view" value="Included" form="add">>>ADD>></button>
-</div>
-</div>
-
-<div class="customlabels2 column4">
- <table><td>
- <button type="submit" name="view" value="Included" form="add">>>ADD>></button>
- <br><br>
- <button type="submit" name="view" value="Included" form="del">REMOVE</button>
- </td></table>
-</div>
-
-<div class="customlabels2 column3">
-<form action="" method="GET" id="del">
- <h2>Custom Species List</h2>
- <select name="species[]" id="value2" multiple size="25">
- <option disabled value="base">Please Select</option>
- <?php
- $filename = './scripts/include_species_list.txt';
- $eachlines = file($filename, FILE_IGNORE_NEW_LINES);
- foreach($eachlines as $lines){echo
- "<option value=\"".$lines."\">$lines</option>";}
- ?>
- </select>
- <input type="hidden" name="del" value="del">
-</form>
-<div class="customlabels2 smaller">
- <button type="submit" name="view" value="Included" form="del">REMOVE</button>
-</div>
-</div>
-
-<script>
- // Store the original list of options in a variable
- var originalOptions = {};
-
- document.getElementById("add").addEventListener("submit", function(event) {
- var speciesSelect = document.getElementById("species");
- if (speciesSelect.selectedIndex < 0) {
- alert("Please click the species you want to add.");
- document.querySelector('.views').style.opacity = 1;
- event.preventDefault();
- }
- });
-
- var search_term = document.querySelector("input#species_searchterm");
- search_term.addEventListener("keyup", function() {
- filterOptions("species");
- });
-
- // Function to filter options in a select element
- function filterOptions(id) {
- var input = document.getElementById(id + "_searchterm");
- var filter = input.value.toUpperCase();
- var select = document.getElementById(id);
- var options = select.getElementsByTagName("option");
-
- // If the original list of options for this select element hasn't been stored yet, store it
- if (!originalOptions[id]) {
- originalOptions[id] = Array.from(options).map(option => option.value);
- }
-
- // Clear the select element
- while (select.firstChild) {
- select.removeChild(select.firstChild);
- }
-
- // Populate the select element with the filtered labels
- originalOptions[id].forEach(label => {
- if (label.toUpperCase().indexOf(filter) > -1) {
- let option = document.createElement('option');
- option.value = label;
- option.text = label;
- select.appendChild(option);
- }
- });
- }
-</script>
diff --git a/scripts/species_list.php b/scripts/species_list.php
new file mode 100644
index 00000000..18eed512
--- /dev/null
+++ b/scripts/species_list.php
@@ -0,0 +1,125 @@
+<?php
+ error_reporting(E_ALL);
+ ini_set('display_errors',1);
+
+ if ($species_list=="include") {
+ $title="Included";
+ $message="Warning!<br>If this list contains ANY species, the system will ONLY recognize those species. Keep this list EMPTY unless you are ONLY interested in detecting specific species.";
+ $selectedfilename = './scripts/include_species_list.txt';
+ } elseif ($species_list=="exclude") {
+ $title="Excluded";
+ $message="Once the desired species has been highlighted, click it and then click ADD to have it excluded.";
+ $selectedfilename = './scripts/exclude_species_list.txt';
+ } elseif ($species_list=="whitelist") {
+ $title="Whitelisted";
+ $message="Once the desired species has been highlighted, click it and then click ADD to have it whitelisted. This species will be detected even if below the Species Occurrence Frequency Threshold defined in the settings.<br>This is not a recommended way of working : it is preferable to first try first both Species Occurrence models (v1 and v2.4).";
+ $selectedfilename = './scripts/whitelist_species_list.txt';
+ }
+
+
+ if (file_exists($selectedfilename)) {
+ $eachselected = file($selectedfilename, FILE_IGNORE_NEW_LINES);
+ }
+ else {
+ $eachselected = [];
+ }
+ $filename = './scripts/labels.txt';
+ $eachlabel = file($filename, FILE_IGNORE_NEW_LINES);
+?>
+
+
+<meta name="viewport" content="width=device-width, initial-scale=1">
+
+<div class="left-column">
+<?php echo $message ?>
+</div>
+
+<div class="customlabels column1">
+<form action="" method="GET" id="add">
+ <h3>All Species Labels</h3>
+ <input autocomplete="off" size="28" type="text" placeholder="Search Species..." id="species_searchterm" name="species_searchterm">
+ <select name="species[]" id="species" multiple size="25">
+ <?php
+ foreach($eachlabel as $lines){echo
+ "<option value=\"".$lines."\">$lines</option>";
+ } ?>
+ </select>
+ <input type="hidden" name="add" value="add">
+</form>
+<div class="customlabels smaller">
+ <button type="submit" name="view" value=<?php echo "\"$title\"" ?> form="add">>>ADD>></button>
+</div>
+</div>
+
+<div class="customlabels column2">
+ <table><td>
+ <button type="submit" name="view" value=<?php echo "\"$title\"" ?> form="add">>>ADD>></button>
+ <br><br>
+ <button type="submit" name="view" value=<?php echo "\"$title\"" ?> form="del">REMOVE</button>
+ </td></table>
+</div>
+
+<div class="customlabels column3">
+<form action="" method="GET" id="del">
+ <h3><?php echo "$title" ?> Species List</h3>
+ <input style="visibility:hidden" autocomplete="off" size="18" type="text" id="dummy" name="dummy">
+ <select name="species[]" id="value2" multiple size="25">
+ <?php
+ if (count($eachselected) == 0) echo '<option disabled value="base">Please Select</option>';
+ foreach($eachselected as $lines){echo
+ "<option value=\"".$lines."\">$lines</option>";
+ } ?>
+ </select>
+ <input type="hidden" name="del" value="del">
+</form>
+<div class="customlabels smaller">
+ <button type="submit" name="view" value=<?php echo "\"$title\"" ?> form="del">REMOVE</button>
+</div>
+</div>
+
+<script>
+ // Store the original list of options in a variable
+ var originalOptions = {};
+
+ document.getElementById("add").addEventListener("submit", function(event) {
+ var speciesSelect = document.getElementById("species");
+ if (speciesSelect.selectedIndex < 0) {
+ alert("Please click the species you want to add.");
+ document.querySelector('.views').style.opacity = 1;
+ event.preventDefault();
+ }
+ });
+
+ var search_term = document.querySelector("input#species_searchterm");
+ search_term.addEventListener("keyup", function() {
+ filterOptions("species");
+ });
+
+ // Function to filter options in a select element
+ function filterOptions(id) {
+ var input = document.getElementById("species_searchterm");
+ var filter = input.value.toUpperCase();
+ var select = document.getElementById(id);
+ var options = select.getElementsByTagName("option");
+
+ // If the original list of options for this select element hasn't been stored yet, store it
+ if (!originalOptions[id]) {
+ originalOptions[id] = Array.from(options).map(option => option.value);
+ }
+
+ // Clear the select element
+ while (select.firstChild) {
+ select.removeChild(select.firstChild);
+ }
+
+ // Populate the select element with the filtered labels
+ originalOptions[id].forEach(label => {
+ if (label.toUpperCase().indexOf(filter) > -1) {
+ let option = document.createElement('option');
+ option.value = label;
+ option.text = label;
+ select.appendChild(option);
+ }
+ });
+ }
+</script>
diff --git a/scripts/whitelist_list.php b/scripts/whitelist_list.php
deleted file mode 100644
index 90fa0a75..00000000
--- a/scripts/whitelist_list.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<style>
-</style>
-
-<div class="customlabels column1">
-<form action="" method="GET" id="add">
- <h3>All Species Labels</h3>
- <input autocomplete="off" size="18" type="text" placeholder="Search Species..." id="whitelist_species_searchterm" name="whitelist_species_searchterm">
- <br>
- <span>Once the desired species has been highlighted, click it and then click ADD to have it whitelisted. This species will be detected even if below the Species Occurrence Frequency Threshold defined in the settings.
- This is not a recommended way of working : it is preferable to first try first both Species Occurrence models (v1 and v2.4).</span>
- <select name="species[]" id="species" multiple size="25">
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors',1);
-
- $filename = './scripts/labels.txt';
- $eachline = file($filename, FILE_IGNORE_NEW_LINES);
-
- foreach($eachline as $lines){echo
- "<option value=\"".$lines."\">$lines</option>";}
- ?>
- </select>
- <input type="hidden" name="add" value="add">
-</form>
-<div class="customlabels smaller">
- <button type="submit" name="view" value="Whitelisted" form="add">>>ADD>></button>
-</div>
-</div>
-
-<div class="customlabels column2">
- <table><td>
- <button type="submit" name="view" value="Whitelisted" form="add">>>ADD>></button>
- <br><br>
- <button type="submit" name="view" value="Whitelisted" form="del">REMOVE</button>
- </td></table>
-</div>
-
-<div class="customlabels column3">
-<form action="" method="GET" id="del">
- <h3>Whitelisted Species List</h3>
- <br><br><br>
- <select name="species[]" id="value2" multiple size="25">
- <option disabled value="base">Please Select</option>
-<?php
- $filename = './scripts/whitelist_species_list.txt';
- $eachline = file($filename, FILE_IGNORE_NEW_LINES);
- foreach($eachline as $lines){
- echo
- "<option value=\"".$lines."\">$lines</option>";
-}?>
- </select>
- <input type="hidden" name="del" value="del">
-</form>
-<div class="customlabels smaller">
- <button type="submit" name="view" value="Whitelisted" form="del">REMOVE</button>
-</div>
-</div>
-
-<script>
- // Store the original list of options in a variable
- var originalOptions = {};
-
- document.getElementById("add").addEventListener("submit", function(event) {
- var speciesSelect = document.getElementById("species");
- if (speciesSelect.selectedIndex < 0) {
- alert("Please click the species you want to add.");
- document.querySelector('.views').style.opacity = 1;
- event.preventDefault();
- }
- });
-
- var search_term = document.querySelector("input#whitelist_species_searchterm");
- search_term.addEventListener("keyup", function() {
- filterOptions("species");
- });
-
- // Function to filter options in a select element
- function filterOptions(id) {
- var input = document.getElementById("whitelist_species_searchterm");
- var filter = input.value.toUpperCase();
- var select = document.getElementById(id);
- var options = select.getElementsByTagName("option");
-
- // If the original list of options for this select element hasn't been stored yet, store it
- if (!originalOptions[id]) {
- originalOptions[id] = Array.from(options).map(option => option.value);
- }
-
- // Clear the select element
- while (select.firstChild) {
- select.removeChild(select.firstChild);
- }
-
- // Populate the select element with the filtered labels
- originalOptions[id].forEach(label => {
- if (label.toUpperCase().indexOf(filter) > -1) {
- let option = document.createElement('option');
- option.value = label;
- option.text = label;
- select.appendChild(option);
- }
- });
- }
-</script>