Remove local storage for presets on presets.json restore.

This commit is contained in:
Blaz Kristan 2021-07-30 17:45:47 +02:00
parent bd0f84605f
commit 3c545d488d
3 changed files with 10 additions and 5 deletions

View File

@ -46,6 +46,11 @@
fO.value = '';
return false;
}
function clearLS()
{
localStorage.removeItem('wledP');
localStorage.removeItem('wledPmt');
}
function GetV()
{
//values injected by server while sending HTML
@ -75,7 +80,7 @@
HTTP traffic is unencrypted. An attacker in the same network can intercept form data!
<h3>Backup & Restore</h3>
<a class="btn lnk" href="/presets.json?download" target="download-frame">Backup presets</a><br>
<div id="presets">Restore presets:<input type="file" name="data" accept=".json"> <input type="button" value="Upload" onclick="uploadFile(d.Sf.data,'/presets.json');"><br></div>
<div id="presets">Restore presets:<input type="file" name="data" accept=".json"> <input type="button" value="Upload" onclick="uploadFile(d.Sf.data,'/presets.json');clearLS();"><br></div>
<a class="btn lnk" href="/cfg.json?download" target="download-frame">Backup configuration</a><br>
<div id="presets">Restore configuration:<input type="file" name="data2" accept=".json"> <input type="button" value="Upload" onclick="uploadFile(d.Sf.data2,'/cfg.json');"><br></div>
<div style="color: #fa0;">&#9888; Restoring presets/configuration will OVERWRITE your current presets/configuration.<br>

View File

@ -377,7 +377,7 @@ type="button" onclick="B()">Back</button><button type="submit">Save</button>
// Autogenerated from wled00/data/settings_sec.htm, do not edit!!
const char PAGE_settings_sec[] PROGMEM = R"=====(<!DOCTYPE html><html lang="en"><head><meta name="viewport" content="width=500">
<meta charset="utf-8"><title>Misc Settings</title><script>
var timeout,d=document;function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#security-settings")}function B(){window.open("/settings","_self")}function U(){window.open("/update","_self")}function gId(t){return d.getElementById(t)}function isObject(t){return t&&"object"==typeof t&&!Array.isArray(t)}function showToast(t,e=!1){var n=gId("toast");n.innerHTML=t,n.className=e?"error":"show",clearTimeout(timeout),n.style.animation="none",timeout=setTimeout((function(){n.className=n.className.replace("show","")}),2900)}function uploadFile(t,e){var n=new XMLHttpRequest;n.addEventListener("load",(function(){showToast(this.responseText)})),n.addEventListener("error",(function(t){showToast(t.stack,!0)})),n.open("POST","/upload");var o=new FormData;return o.append("data",t.files[0],e),n.send(o),t.value="",!1}function GetV() {var d=document;
var timeout,d=document;function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#security-settings")}function B(){window.open("/settings","_self")}function U(){window.open("/update","_self")}function gId(e){return d.getElementById(e)}function isObject(e){return e&&"object"==typeof e&&!Array.isArray(e)}function showToast(e,t=!1){var o=gId("toast");o.innerHTML=e,o.className=t?"error":"show",clearTimeout(timeout),o.style.animation="none",timeout=setTimeout((function(){o.className=o.className.replace("show","")}),2900)}function uploadFile(e,t){var o=new XMLHttpRequest;o.addEventListener("load",(function(){showToast(this.responseText)})),o.addEventListener("error",(function(e){showToast(e.stack,!0)})),o.open("POST","/upload");var n=new FormData;return n.append("data",e.files[0],t),o.send(n),e.value="",!1}function clearLS(){localStorage.removeItem("wledP"),localStorage.removeItem("wledPmt")}function GetV() {var d=document;
%CSS%%SCSS%<link href="/skin.css"
rel="stylesheet"></head><body onload="GetV()"><form id="form_s" name="Sf"
method="post"><div class="toprow"><div class="helpB"><button type="button"
@ -397,8 +397,8 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
<h3>Backup & Restore</h3><a class="btn lnk" href="/presets.json?download"
target="download-frame">Backup presets</a><br><div id="presets">Restore presets:
<input type="file" name="data" accept=".json"> <input type="button"
value="Upload" onclick='uploadFile(d.Sf.data,"/presets.json")'><br></div><a
class="btn lnk" href="/cfg.json?download" target="download-frame">
value="Upload" onclick='uploadFile(d.Sf.data,"/presets.json"),clearLS()'><br>
</div><a class="btn lnk" href="/cfg.json?download" target="download-frame">
Backup configuration</a><br><div id="presets">Restore configuration:<input
type="file" name="data2" accept=".json"> <input type="button" value="Upload"
onclick='uploadFile(d.Sf.data2,"/cfg.json")'><br></div><div style="color:#fa0">

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2107291
#define VERSION 2107301
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG