Sfoglia il codice sorgente

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>
CaCO3 3 anni fa
parent
commit
3aa0411676
3 ha cambiato i file con 50 aggiunte e 25 eliminazioni
  1. 1 1
      code/main/main.cpp
  2. 49 23
      sd-card/html/prevalue_set.html
  3. 0 1
      sd-card/html/readconfigcommon.js

+ 1 - 1
code/main/main.cpp

@@ -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 {

+ 49 - 23
sd-card/html/prevalue_set.html

@@ -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>
@@ -90,30 +90,56 @@ function setprevalue() {
           response = xhttp.responseText;
           response = xhttp.responseText;
           document.getElementById("result").innerHTML=response;
           document.getElementById("result").innerHTML=response;
      }
      }
-     catch (error)
-     {
-     //          alert("Deleting Config.ini failed");
-     }
+    catch (error)
+    {
+      alert("Failed to get data from device!");
+    }
 }
 }
 
 
 function loadPrevalue(_basepath) {
 function loadPrevalue(_basepath) {
-    var sel = document.getElementById("Numbers_value1");
-    var _number = sel.options[sel.selectedIndex].text;  
-
-     var xhttp = new XMLHttpRequest();
-     try {
-          url = _basepath + '/setPreValue?numbers=' + _number;     
-          xhttp.open("GET", url, false);
-          xhttp.send();
-          response = xhttp.responseText;
-          document.getElementById("prevalue").innerHTML=response;
-          document.getElementById("myInput").value=response;
-     }
-     catch (error)
-     {
-     //          alert("Deleting Config.ini failed");
-     }
-     return true;
+  // Get current Pre Value
+  var sel = document.getElementById("Numbers_value1");
+  var _number = sel.options[sel.selectedIndex].text;
+
+  var xhttp = new XMLHttpRequest();
+  try {
+      url = _basepath + '/setPreValue?numbers=' + _number;
+      xhttp.open("GET", url, false);
+      xhttp.send();
+      response = xhttp.responseText;
+      document.getElementById("prevalue").innerHTML=response;
+  }
+  catch (error)
+  {
+    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!");
+  }
 }
 }
 
 
 
 

+ 0 - 1
sd-card/html/readconfigcommon.js

@@ -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));