Shelve.
This commit is contained in:
parent
55ea853100
commit
90b3137165
|
@ -61,32 +61,31 @@ int yourProgramRunning;
|
|||
// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat)
|
||||
const char index_html[] PROGMEM = R"rawliteral(
|
||||
<!DOCTYPE HTML><html><head>
|
||||
<link rel="icon" href="data:,">
|
||||
<title>ESP Input Form</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script type="text/javascript">
|
||||
console.log("JS");
|
||||
// Submit timestamps as unix seconds
|
||||
var putDate = function(form) {
|
||||
console.log("putDate");
|
||||
form.inputTimeUnix.value = Math.floor(Date.now() / 1000) - new Date().getTimezoneOffset()*60;
|
||||
document.getElementById("js_start_time_unix").value = ((Date.parse(js_start_time_unix_entry.value))/1000);
|
||||
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
|
||||
window.onload = function() {
|
||||
document.getElementById("hidden-form").onload = function() {
|
||||
top.location.reload();
|
||||
console.log("Reloading");
|
||||
}
|
||||
// Current start date to string
|
||||
s = %inputStartTimeUnix%;
|
||||
//s = "1694019170";
|
||||
console.log(s);
|
||||
current_start = new Date(s * 1000);
|
||||
//current_start_utc = current_start.toUTCString();
|
||||
document.getElementById('current-start').innerHTML = current_start.toString();
|
||||
// Show the local time
|
||||
local_time_unix = new Date().toString();
|
||||
document.getElementById('local-time-unix').innerHTML = local_time_unix.toString();
|
||||
// fill in the start time field
|
||||
document.getElementById('js_start_time_unix_entry').value = current_start.toISOString().slice(0,16);
|
||||
}
|
||||
|
||||
</script></head><body>
|
||||
|
@ -117,7 +116,6 @@ const char index_html[] PROGMEM = R"rawliteral(
|
|||
<!-- JS converts the entered start time to a unix timestamp, and copies that value
|
||||
to this hidden field so the user doesn't have to see it. -->
|
||||
<input type="hidden" name="inputStartTimeUnix" id="js_start_time_unix" /></p>
|
||||
|
||||
|
||||
<!-- This field is hidden so people don't change the submit time (it will be wrong).
|
||||
The value is automatically filled in with JS. -->
|
||||
|
@ -125,12 +123,15 @@ const char index_html[] PROGMEM = R"rawliteral(
|
|||
|
||||
<!-- Extra fields just in case I need them -->
|
||||
<input type="hidden" name="inputWPM" value = %inputWPM%>
|
||||
<input type="hidden" name="inputString" value=%inputString%>
|
||||
<input type="hidden" name="inputString" value = %inputString%>
|
||||
<input type="hidden" name="inputFloat" value = %inputFloat%>
|
||||
|
||||
<input type="submit" value="Submit"">
|
||||
</form>
|
||||
<iframe style="display:none" name="hidden-form" id="hidden-form"></iframe>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body></html>)rawliteral";
|
||||
|
||||
// Auxiliary variables to store the current output state
|
||||
|
@ -218,6 +219,7 @@ String processor(const String& var){
|
|||
else if(var == "inputFloat"){
|
||||
return readFile(SPIFFS, "/inputFloat.txt");
|
||||
} else if(var == "inputStartTimeUnix"){
|
||||
// Webform breaks if this value is empty.
|
||||
String temp = readFile(SPIFFS, "/inputStartTimeUnix.txt");
|
||||
if(temp == ""){
|
||||
temp = "0";
|
||||
|
|
Loading…
Reference in New Issue
Block a user