|
|
@@ -226,8 +226,87 @@ function topBarClick(id) {
|
|
|
|
|
|
|
|
|
function resetESP() {
|
|
|
- sendWebRequest("http://192.168.1.170/reset", "", "POST")
|
|
|
+ sendWebRequest("http://192.168.1.170/admin/reset", "", "POST")
|
|
|
}
|
|
|
|
|
|
|
|
|
+function updateFirmware() {
|
|
|
+ if (getEByID("updateFirmwareInput").files.length > 0) {
|
|
|
+ const file = getEByID("updateFirmwareInput").files[0]
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.set('update', file);
|
|
|
+ fetch("http://192.168.1.170/admin/doUpdate", {
|
|
|
+ method: "POST",
|
|
|
+ body: formData
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function uploadFile() {
|
|
|
+ if (getEByID("fileUpload").files.length > 0) {
|
|
|
+ const file = getEByID("fileUpload").files[0]
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.set('data', file);
|
|
|
+ fetch("http://192.168.1.170/admin/upload_file", {
|
|
|
+ method: "POST",
|
|
|
+ body: formData
|
|
|
+ }).then(_ => {
|
|
|
+ getEByID("fileUpload").value = ""
|
|
|
+ listESPFiles()
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function listESPFiles() {
|
|
|
+ const xmlhttp = new XMLHttpRequest()
|
|
|
+ xmlhttp.open("GET", "/admin/listfiles", false)
|
|
|
+ xmlhttp.send()
|
|
|
+ document.getElementById("fileListerDiv").innerHTML = xmlhttp.responseText
|
|
|
+}
|
|
|
+
|
|
|
+async function reloadFiles1Sec() {
|
|
|
+ await new Promise(r => setTimeout(r, 1000));
|
|
|
+ listESPFiles()
|
|
|
+}
|
|
|
+
|
|
|
+function deleteFile(file) {
|
|
|
+ fetch("http://192.168.1.170/admin/del_file", {
|
|
|
+ method: 'POST',
|
|
|
+ headers: new Headers({'name': file}),
|
|
|
+ }).then(_ => {
|
|
|
+ listESPFiles()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+async function setSDCursor() {
|
|
|
+ let location = getEByID("cursorSet").value
|
|
|
+ console.log(location)
|
|
|
+ if (location === "/js" || location === "/css" || location === "/" || true) {
|
|
|
+ fetch("http://192.168.1.170/admin/set_sd_cursor", {
|
|
|
+ method: 'POST',
|
|
|
+ headers: new Headers({'value': location}),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ reloadFiles1Sec()
|
|
|
+}
|
|
|
+
|
|
|
+function openDirectory(path) {
|
|
|
+ getEByID("cursorSet").value = path
|
|
|
+ setSDCursor()
|
|
|
+}
|
|
|
+
|
|
|
+function getCursorValue() {
|
|
|
+ fetch("http://192.168.1.170/admin/get_sd_cursor", {
|
|
|
+ method: 'GET',
|
|
|
+ }).then(res => res.text().then(t => {
|
|
|
+ console.log(t)
|
|
|
+ getEByID("cursorSet").value = t
|
|
|
+ })
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+listESPFiles()
|
|
|
+getCursorValue()
|
|
|
+
|
|
|
updateConfig()
|