Use raw value as prevalue (#1405)

* remove loggng password

* use raw value of selected number as default value

* fix log message

Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
CaCO3
2022-11-25 07:24:23 +01:00
committed by GitHub
parent 9f20c126be
commit 3aa0411676
3 changed files with 49 additions and 24 deletions

View File

@@ -265,7 +265,7 @@ extern "C" void app_main(void)
} else { // Test Camera } else { // Test Camera
camera_fb_t * fb = esp_camera_fb_get(); camera_fb_t * fb = esp_camera_fb_get();
if (!fb) { if (!fb) {
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera cannot be initialzed. Will restart in 5 minutes!"); LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera Framebuffer cannot be initialzed. Will restart in 5 minutes!");
initSucessful = false; initSucessful = false;
} }
else { else {

View File

@@ -52,12 +52,12 @@ input[type=number] {
<div id="prevalue"></div> <div id="prevalue"></div>
<h3>Set Value:</h3><p> <h3>Set Value:</h3><p>
Input (Format = 123.456):<p> Input (Format = 123.456):<p>
PreValue: Previous Value:
<input type="number" id="myInput" name="myInput" <input type="number" id="myInput" name="myInput"
pattern="[0-9]+([\.,][0-9]+)?" step="0.001" pattern="[0-9]+([\.,][0-9]+)?" step="0.001"
title="This should be a number with up to 4 decimal places."> title="This should be a number with up to 4 decimal places.">
<p></p> <p></p>
<button class="button" type="button" onclick="setprevalue()">Set PreValue</button> <button class="button" type="button" onclick="setprevalue()">Set Previous Value</button>
</tr> </tr>
<tr> <tr>
<h3>Result:</h3><p> <h3>Result:</h3><p>
@@ -92,11 +92,12 @@ function setprevalue() {
} }
catch (error) catch (error)
{ {
// alert("Deleting Config.ini failed"); alert("Failed to get data from device!");
} }
} }
function loadPrevalue(_basepath) { function loadPrevalue(_basepath) {
// Get current Pre Value
var sel = document.getElementById("Numbers_value1"); var sel = document.getElementById("Numbers_value1");
var _number = sel.options[sel.selectedIndex].text; var _number = sel.options[sel.selectedIndex].text;
@@ -107,13 +108,38 @@ function loadPrevalue(_basepath) {
xhttp.send(); xhttp.send();
response = xhttp.responseText; response = xhttp.responseText;
document.getElementById("prevalue").innerHTML=response; document.getElementById("prevalue").innerHTML=response;
document.getElementById("myInput").value=response;
} }
catch (error) catch (error)
{ {
// alert("Deleting Config.ini failed"); alert("Failed to get data from device!");
}
// Get current RAW Value
var sel = document.getElementById("Numbers_value1");
var _number = sel.options[sel.selectedIndex].text;
var xhttp = new XMLHttpRequest();
try {
url = _basepath + '/value?all=true&type=raw';
xhttp.open("GET", url, false);
xhttp.send();
response = xhttp.responseText;
lines = response.split(/\r?\n/);
lines.forEach(function(line) {
arr = line.split("\t");
if (_number == arr[0]) {
document.getElementById("myInput").value=arr[1];
return;
}
});
}
catch (error)
{
alert("Failed to get data from device!");
} }
return true;
} }

View File

@@ -66,7 +66,6 @@ function ZerlegeZeile(input, delimiter = " =\t\r")
* equal sign, if the key is "password" * equal sign, if the key is "password"
*/ */
if (input.includes("password")) { // Line contains a password, use the equal sign as the only delimiter and only split on first occurrence if (input.includes("password")) { // Line contains a password, use the equal sign as the only delimiter and only split on first occurrence
console.log(input);
var pos = input.indexOf("="); var pos = input.indexOf("=");
Output.push(trim(input.substr(0, pos), delimiter)); Output.push(trim(input.substr(0, pos), delimiter));
Output.push(trim(input.substr(pos +1, input.length), delimiter)); Output.push(trim(input.substr(pos +1, input.length), delimiter));