Skip to content

Commit

Permalink
Loading data... and Submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
thdfw committed Oct 16, 2024
1 parent 9afc2ff commit 0d81891
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@
} catch (error) {
console.error('Error fetching plots:', error);
alert(`Error fetching plots for house '${house_alias}'.`);
} finally {
resetButton();
}
}

Expand Down Expand Up @@ -208,6 +210,13 @@
}
}

function resetButton() {
const submitButton = document.querySelector('input[type="submit"]');
const loadingText = document.getElementById('loadingText');
submitButton.style.display = 'inline'; // Show the button
loadingText.style.display = 'none'; // Hide loading text
}

function HousePassword() {
house_alias = prompt("Enter house alias:");
password = prompt("Enter password:");
Expand All @@ -219,10 +228,19 @@
document.getElementById('endDatePicker').value = getDefaultDate();
document.getElementById('endTimePicker').value = getDefaultTime();
document.getElementById("content").style.display = "block";

getData(event)
}

function getData(event) {
event.preventDefault();

// Hide submit button and replace by loading text
const submitButton = document.querySelector('input[type="submit"]');
const loadingText = document.getElementById('loadingText');
submitButton.style.display = 'none';
loadingText.style.display = 'inline';

const startdate = document.getElementById('startDatePicker').value;
const starttime = document.getElementById('startTimePicker').value;
const startDateObject = new Date(`${startdate}T${starttime}-04:00`);
Expand Down Expand Up @@ -263,6 +281,7 @@ <h2 id="houseAliasHeader"></h2>
<button onclick=setNow()>Now</button>
<br><br>
<input type="submit" value="Submit">
<span id="loadingText" style="display: none;">Loading data...</span>
</form>
<!-- <pre id="hpPowerData"></pre> -->
<div id="Plots"></div>
Expand Down

0 comments on commit 0d81891

Please sign in to comment.