Merge pull request #898 from croisez/main

Removing DetectionsPanel if already present, before displaying a new one
This commit is contained in:
ehpersonal38
2023-05-15 18:43:00 -04:00
committed by GitHub
3 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -26,7 +26,7 @@ iframe {
padding: 0;
margin: 0;
border: none;
height: 93%;
height: 90%;
width: 100%;
}
@@ -836,4 +836,4 @@ pre#timer.bash {
#ddnewline::before {
content: none;
}
}
+6 -3
View File
@@ -495,6 +495,7 @@ window.setInterval(function(){
</style>
<script>
function generateMiniGraph(elem, comname) {
// Make an AJAX call to fetch the number of detections for the bird species
var xhr = new XMLHttpRequest();
xhr.open('GET', '/todays_detections.php?comname=' + comname);
@@ -502,9 +503,10 @@ function generateMiniGraph(elem, comname) {
if (xhr.status === 200) {
var detections = JSON.parse(xhr.responseText);
console.log(detections)
// Create a div element for the chart window
if (typeof(window.chartWindow) != 'undefined') {
document.body.removeChild(window.chartWindow);
}
var chartWindow = document.createElement('div');
chartWindow.className = "chartdiv"
chartWindow.style.position = 'fixed';
@@ -615,6 +617,7 @@ function generateMiniGraph(elem, comname) {
document.body.removeChild(chartWindow);
});
chartWindow.appendChild(closeButton);
window.chartWindow = chartWindow;
}
};
xhr.send();
@@ -631,4 +634,4 @@ window.addEventListener('scroll', function() {
});
});
</script>
</script>
+4 -2
View File
@@ -660,9 +660,10 @@ function generateMiniGraph(elem, comname) {
if (xhr.status === 200) {
var detections = JSON.parse(xhr.responseText);
console.log(detections)
// Create a div element for the chart window
if (typeof(window.chartWindow) != 'undefined') {
document.body.removeChild(window.chartWindow);
}
var chartWindow = document.createElement('div');
chartWindow.className = "chartdiv"
chartWindow.style.position = 'fixed';
@@ -773,6 +774,7 @@ function generateMiniGraph(elem, comname) {
document.body.removeChild(chartWindow);
});
chartWindow.appendChild(closeButton);
window.chartWindow = chartWindow;
}
};
xhr.send();