Update convert_list.php

This commit is contained in:
Alexandre
2024-05-18 23:20:58 +02:00
committed by GitHub
parent 6b62200934
commit 1cc587d7fe

View File

@@ -1,25 +1,42 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<style> <style>
/* Add your custom styles here */
</style> </style>
<p><strong>This tool will allow to convert on-the-fly species to compensate for model errors. It SHOULD NOT BE USED except if you know what you are doing, instead the model errors should be reported to the owner. However, it is still convenient for systematic biases that are confirmed through careful listening of samples, while waiting for the models to be updated.</strong></p> <p><strong>This tool will allow to convert on-the-fly species to compensate for model errors. It SHOULD NOT BE USED except if you know what you are doing, instead the model errors should be reported to the owner. However, it is still convenient for systematic biases that are confirmed through careful listening of samples, while waiting for the models to be updated.</strong></p>
<div class="customlabels column1"> <div class="customlabels column1">
<form action="" method="GET" id="add"> <form action="" method="GET" id="add">
<input type="hidden" id="species" name="species"> <input type="hidden" id="species" name="species">
<h3>Specie to convert from:</h3> <h3>Specie to convert from :</h3>
<input type="text" id="species1Search" placeholder="Search for species..."> <!-- Input box to filter options in the first table -->
<select name="species1" id="species1" size="25"></select> <input type="text" id="species1Search" onkeyup="filterOptions('species1')" placeholder="Search for species...">
<br><br> <select name="species1" id="species1" size="25">
<h3>Specie to convert to:</h3> <?php
<input type="text" id="species2Search" placeholder="Search for species..."> error_reporting(E_ALL);
<select name="species2" id="species2" size="25"></select> ini_set('display_errors',1);
<input type="hidden" name="add" value="add">
</form> $filename = './scripts/labels.txt';
<div class="customlabels smaller"> $eachline = file($filename, FILE_IGNORE_NEW_LINES);
<button type="submit" name="view" value="Converted" form="add">>>ADD>></button>
</div> foreach($eachline as $lines){echo
"<option value=\"".$lines."\">$lines</option>";}
?>
</select>
<br><br> <!-- Added a space between the two tables -->
<h3>Specie to convert to :</h3>
<!-- Input box to filter options in the second table -->
<input type="text" id="species2Search" onkeyup="filterOptions('species2')" placeholder="Search for species...">
<select name="species2" id="species2" size="25">
<?php
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="Converted" form="add">>>ADD>></button>
</div>
</div> </div>
<div class="customlabels column2"> <div class="customlabels column2">
@@ -52,19 +69,7 @@
<input type="hidden" id="hiddenSpecies" name="hiddenSpecies"> <input type="hidden" id="hiddenSpecies" name="hiddenSpecies">
<script> <script>
// Assuming labels are defined in PHP and passed to JavaScript document.getElementById("add").addEventListener("submit", function(event) {
var labels1 = <?php echo json_encode($eachline); ?>;
var labels2 = <?php echo json_encode($eachline); ?>;
document.getElementById('species1Search').addEventListener('keyup', function() {
filterOptions('species1', labels1);
});
document.getElementById('species2Search').addEventListener('keyup', function() {
filterOptions('species2', labels2);
});
document.getElementById("add").addEventListener("submit", function(event) {
var speciesSelect1 = document.getElementById("species1"); var speciesSelect1 = document.getElementById("species1");
var speciesSelect2 = document.getElementById("species2"); var speciesSelect2 = document.getElementById("species2");
if (speciesSelect1.selectedIndex < 0 || speciesSelect2.selectedIndex < 0) { if (speciesSelect1.selectedIndex < 0 || speciesSelect2.selectedIndex < 0) {
@@ -78,23 +83,19 @@
} }
}); });
// Function to filter options in a select element // Function to filter options in a select element
function filterOptions(id, labels) { function filterOptions(id) {
var input = document.getElementById(id + 'Search'); var input = document.getElementById(id + "Search");
var filter = input.value.toUpperCase(); var filter = input.value.toUpperCase();
var select = document.getElementById(id); var select = document.getElementById(id);
// Clear the current options var options = select.getElementsByTagName("option");
while (select.firstChild) { for (var i = 0; i < options.length; i++) {
select.removeChild(select.firstChild); var txtValue = options[i].textContent || options[i].innerText;
} if (txtValue.toUpperCase().indexOf(filter) > -1) {
// Populate the select with options that match the filter options[i].style.display = "";
labels.forEach(function(label) { } else {
if (label.toUpperCase().indexOf(filter) > -1) { options[i].style.display = "none";
var option = document.createElement('option'); }
option.value = label;
option.text = label;
select.appendChild(option);
} }
}); }
}
</script> </script>