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
+1 -1
View File
@@ -26,7 +26,7 @@ iframe {
padding: 0; padding: 0;
margin: 0; margin: 0;
border: none; border: none;
height: 93%; height: 90%;
width: 100%; width: 100%;
} }
+5 -2
View File
@@ -495,6 +495,7 @@ window.setInterval(function(){
</style> </style>
<script> <script>
function generateMiniGraph(elem, comname) { function generateMiniGraph(elem, comname) {
// Make an AJAX call to fetch the number of detections for the bird species // Make an AJAX call to fetch the number of detections for the bird species
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', '/todays_detections.php?comname=' + comname); xhr.open('GET', '/todays_detections.php?comname=' + comname);
@@ -502,9 +503,10 @@ function generateMiniGraph(elem, comname) {
if (xhr.status === 200) { if (xhr.status === 200) {
var detections = JSON.parse(xhr.responseText); var detections = JSON.parse(xhr.responseText);
console.log(detections)
// Create a div element for the chart window // Create a div element for the chart window
if (typeof(window.chartWindow) != 'undefined') {
document.body.removeChild(window.chartWindow);
}
var chartWindow = document.createElement('div'); var chartWindow = document.createElement('div');
chartWindow.className = "chartdiv" chartWindow.className = "chartdiv"
chartWindow.style.position = 'fixed'; chartWindow.style.position = 'fixed';
@@ -615,6 +617,7 @@ function generateMiniGraph(elem, comname) {
document.body.removeChild(chartWindow); document.body.removeChild(chartWindow);
}); });
chartWindow.appendChild(closeButton); chartWindow.appendChild(closeButton);
window.chartWindow = chartWindow;
} }
}; };
xhr.send(); xhr.send();
+4 -2
View File
@@ -660,9 +660,10 @@ function generateMiniGraph(elem, comname) {
if (xhr.status === 200) { if (xhr.status === 200) {
var detections = JSON.parse(xhr.responseText); var detections = JSON.parse(xhr.responseText);
console.log(detections)
// Create a div element for the chart window // Create a div element for the chart window
if (typeof(window.chartWindow) != 'undefined') {
document.body.removeChild(window.chartWindow);
}
var chartWindow = document.createElement('div'); var chartWindow = document.createElement('div');
chartWindow.className = "chartdiv" chartWindow.className = "chartdiv"
chartWindow.style.position = 'fixed'; chartWindow.style.position = 'fixed';
@@ -773,6 +774,7 @@ function generateMiniGraph(elem, comname) {
document.body.removeChild(chartWindow); document.body.removeChild(chartWindow);
}); });
chartWindow.appendChild(closeButton); chartWindow.appendChild(closeButton);
window.chartWindow = chartWindow;
} }
}; };
xhr.send(); xhr.send();