Keep form fields updated.

This commit is contained in:
mattbk 2023-09-06 21:52:04 -05:00
parent a996c13e63
commit afe5b9338d

View File

@ -83,27 +83,26 @@ const char index_html[] PROGMEM = R"rawliteral(
HH + ':' + II + ':' + SS;
}
// Submit timestamps as unix seconds
// Submit timestamps as unix seconds when form is submitted
var putDate = function(form) {
form.inputTimeUnix.value = Math.floor(Date.now() / 1000);// - new Date().getTimezoneOffset()*60;
form.inputStartTimeUnix.value = ((Date.parse(js_start_time_unix_entry.value))/1000);
//document.getElementById("js_start_time_unix").value = ((Date.parse(js_start_time_unix_entry.value))/1000);
}
// Refresh page after submit so values are right https://stackoverflow.com/a/1860732/2152245
// Fill in page values
window.onload = function() {
//document.getElementById("hidden-form").onload = function() {
//top.location.reload();
//}
// Current start date to string
s = %inputStartTimeUnix%;
current_start = new Date(s * 1000);
document.getElementById('current-start').innerHTML = current_start.toLocaleString();
// Show the local time as a string
local_time_unix = new Date().toLocaleString();//toUTCString();
document.getElementById('local-time-unix').innerHTML = local_time_unix.toString();
// fill in the start time field as local time
//document.getElementById('js_start_time_unix_entry').value = current_start.toISOString().slice(0,16);
// Fill in the start time field as local time
document.getElementById('js_start_time_unix_entry').value = current_start.toDatetimeLocal();
// Fill in the other form fields
document.getElementById("send-program").value = %inputSend%;
document.getElementById("message").value = %inputMsg%;
}
</script></head><body>
@ -114,7 +113,7 @@ const char index_html[] PROGMEM = R"rawliteral(
<p>Sending program (cycle doesn't work yet) (current value: <b>%inputSend%</b>):
<select name="inputSend" id="send-program">
<option value="0">0 -Off</option>
<option value="0" >0 - Off</option>
<option value="1">1 - Continuous</option>
<option value="2">2 - Cycle Program</option>
</select><br>