Upload files & skinning (#2084)
* Skinning WLED & uploading files. Backup & restore configuration & presets. External holidays.json * Option for segment count instead of stop. * Small fixes and improvements * Further improvements * Enable custom CSS by default Co-authored-by: Christian Schwinne <dev.aircoookie@gmail.com>
This commit is contained in:
		| @@ -5,6 +5,7 @@ | ||||
| 	<meta charset="utf-8"> | ||||
| 	<title>Misc Settings</title> | ||||
| 	<script> | ||||
| 		var d = document; | ||||
| 		function H() | ||||
| 		{ | ||||
| 			window.open("https://github.com/Aircoookie/WLED/wiki/Settings#security-settings"); | ||||
| @@ -17,6 +18,34 @@ | ||||
| 		{ | ||||
| 			window.open("/update","_self"); | ||||
| 		} | ||||
| 		function gId(s) | ||||
| 		{ | ||||
| 			return d.getElementById(s); | ||||
| 		} | ||||
| 		function isObject(item) { | ||||
| 			return (item && typeof item === 'object' && !Array.isArray(item)); | ||||
| 		} | ||||
| 		var timeout; | ||||
| 		function showToast(text, error = false) | ||||
| 		{ | ||||
| 			var x = gId("toast"); | ||||
| 			x.innerHTML = text; | ||||
| 			x.className = error ? "error":"show"; | ||||
| 			clearTimeout(timeout); | ||||
| 			x.style.animation = 'none'; | ||||
| 			timeout = setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2900); | ||||
| 		} | ||||
| 		function uploadFile(fO,name) { | ||||
| 			var req = new XMLHttpRequest(); | ||||
| 			req.addEventListener('load', function(){showToast(this.responseText)}); | ||||
| 			req.addEventListener('error', function(e){showToast(e.stack,true);}); | ||||
| 			req.open("POST", "/upload"); | ||||
| 			var formData = new FormData(); | ||||
| 			formData.append("data", fO.files[0], name); | ||||
| 			req.send(formData); | ||||
| 			fO.value = ''; | ||||
| 			return false; | ||||
| 	    } | ||||
| 		function GetV() | ||||
| 		{ | ||||
| 			//values injected by server while sending HTML | ||||
| @@ -44,6 +73,14 @@ | ||||
| 		<h3>Software Update</h3> | ||||
| 		<button type="button" onclick="U()">Manual OTA Update</button><br> | ||||
| 		Enable ArduinoOTA: <input type="checkbox" name="AO"><br> | ||||
|     <h3>Backup & Restore</h3> | ||||
| 		<a class="btn lnk" href="/presets.json?download" target="download-frame">Backup presets</a><br> | ||||
| 		<div>Restore presets<br><input type="file" name="data" accept=".json"> <input type="button" value="Upload" onclick="uploadFile(d.Sf.data,'/presets.json');"><br></div><br> | ||||
| 		<a class="btn lnk" href="/cfg.json?download" target="download-frame">Backup configuration</a><br> | ||||
| 		<div>Restore configuration<br><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;">⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.<br> | ||||
| 		Incorrect configuration may require a factory reset or re-flashing of your ESP.</div> | ||||
|     For security reasons, passwords are not backed up. | ||||
| 		<h3>About</h3> | ||||
| 		<a href="https://github.com/Aircoookie/WLED/" target="_blank">WLED</a> version ##VERSION##<!-- Autoreplaced from package.json --><br><br> | ||||
| 		<a href="https://github.com/Aircoookie/WLED/wiki/Contributors-and-credits" target="_blank">Contributors, dependencies and special thanks</a><br> | ||||
| @@ -51,7 +88,9 @@ | ||||
| 		(c) 2016-2021 Christian Schwinne <br> | ||||
| 		<i>Licensed under the <a href="https://github.com/Aircoookie/WLED/blob/master/LICENSE" target="_blank">MIT license</a></i><br><br> | ||||
| 		Server message: <span class="sip"> Response error! </span><hr> | ||||
| 		<div id="toast"></div> | ||||
| 		<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button> | ||||
| 	</form> | ||||
| 	<iframe name=download-frame style='display:none;'></iframe> | ||||
| </body> | ||||
| </html> | ||||
		Reference in New Issue
	
	Block a user
	 Blaž Kristan
					Blaž Kristan