diff --git a/data/edit.htm b/data/edit.htm index cd185e2c..f25ffeff 100644 --- a/data/edit.htm +++ b/data/edit.htm @@ -1,665 +1 @@ - - - - - - - - - - - - - openHASP - - - - - - - - - - - - -
-
-
-
- -
-
-
-
-
-
- - -
- - - -
- - config.jsonl - - -
-
-
- -
-
- -
-
- - - - - +openHASP File Editor
L:
\ No newline at end of file diff --git a/data/main.js b/data/main.js index faad72b7..a74ef0c9 100644 --- a/data/main.js +++ b/data/main.js @@ -1 +1 @@ -import{createApp,reactive,createI18n}from"/static/petite-vue.hasp.js?COMMIT_HASH";const languages=[{code:"en",name:"English"},{code:"nl",name:"Nederlands"},{code:"fr",name:"Français"}];var locations={af:["Abidjan","Algiers","Bissau","Cairo","Casablanca","El_Aaiun","Johannesburg","Juba","Khartoum","Lagos","Maputo","Monrovia","Nairobi","Ndjamena","Sao_Tome","Tripoli","Tunis","Windhoek","Cape_Verde","Mauritius"],eu:["Ceuta","Danmarkshavn","Nuuk","Scoresbysund","Thule","Anadyr","Barnaul","Chita","Irkutsk","Kamchatka","Khandyga","Krasnoyarsk","Magadan","Novokuznetsk","Novosibirsk","Omsk","Sakhalin","Srednekolymsk","Tomsk","Ust-Nera","Vladivostok","Yakutsk","Yekaterinburg","Azores","Canary","Faroe","Madeira","Andorra","Astrakhan","Athens","Belgrade","Berlin","Brussels","Bucharest","Budapest","Chisinau","Dublin","Gibraltar","Helsinki","Istanbul","Kaliningrad","Kirov","Kyiv","Lisbon","London","Madrid","Malta","Minsk","Moscow","Paris","Prague","Riga","Rome","Samara","Saratov","Sofia","Tallinn","Tirane","Ulyanovsk","Vienna","Vilnius","Volgograd","Warsaw","Zurich"],as:["Almaty","Amman","Aqtau","Aqtobe","Ashgabat","Atyrau","Baghdad","Baku","Bangkok","Beirut","Bishkek","Choibalsan","Colombo","Damascus","Dhaka","Dili","Dubai","Dushanbe","Famagusta","Gaza","Hebron","Ho_Chi_Minh","Hong_Kong","Hovd","Jakarta","Jayapura","Jerusalem","Kabul","Karachi","Kathmandu","Kolkata","Kuching","Macau","Makassar","Manila","Nicosia","Oral","Pontianak","Pyongyang","Qatar","Qostanay","Qyzylorda","Riyadh","Samarkand","Seoul","Shanghai","Singapore","Taipei","Tashkent","Tbilisi","Tehran","Thimphu","Tokyo","Ulaanbaatar","Urumqi","Yangon","Yerevan","Chagos","Maldives"],au:["Perth","Eucla","Adelaide","Broken_Hill","Darwin","Brisbane","Hobart","Lindeman","Melbourne","Sydney","Lord_Howe"],na:["Adak","Anchorage","Bahia_Banderas","Barbados","Belize","Boise","Cambridge_Bay","Cancun","Chicago","Chihuahua","Ciudad_Juarez","Costa_Rica","Dawson","Dawson_Creek","Denver","Detroit","Edmonton","El_Salvador","Fort_Nelson","Glace_Bay","Goose_Bay","Grand_Turk","Guatemala","Halifax","Havana","Hermosillo","Indiana/Indianapolis","Indiana/Knox","Indiana/Marengo","Indiana/Petersburg","Indiana/Tell_City","Indiana/Vevay","Indiana/Vincennes","Indiana/Winamac","Inuvik","Iqaluit","Jamaica","Juneau","Kentucky/Louisville","Kentucky/Monticello","Los_Angeles","Managua","Martinique","Matamoros","Mazatlan","Menominee","Merida","Metlakatla","Mexico_City","Miquelon","Moncton","Monterrey","New_York","Nome","North_Dakota/Beulah","North_Dakota/Center","North_Dakota/New_Salem","Ojinaga","Panama","Phoenix","Port-au-Prince","Puerto_Rico","Rankin_Inlet","Regina","Resolute","Santo_Domingo","Sitka","St_Johns","Swift_Current","Tegucigalpa","Tijuana","Toronto","Vancouver","Whitehorse","Winnipeg","Yakutat","Yellowknife","Bermuda","Honolulu"],sa:["Araguaina","Argentina/Buenos_Aires","Argentina/Catamarca","Argentina/Cordoba","Argentina/Jujuy","Argentina/La_Rioja","Argentina/Mendoza","Argentina/Rio_Gallegos","Argentina/Salta","Argentina/San_Juan","Argentina/San_Luis","Argentina/Tucuman","Argentina/Ushuaia","Asuncion","Bahia","Belem","Boa_Vista","Bogota","Campo_Grande","Caracas","Cayenne","Cuiaba","Eirunepe","Fortaleza","Guayaquil","Guyana","La_Paz","Lima","Maceio","Manaus","Montevideo","Noronha","Paramaribo","Porto_Velho","Punta_Arenas","Recife","Rio_Branco","Santarem","Santiago","Sao_Paulo","Palmer","South_Georgia","Stanley","Easter","Galapagos"],at:["Cape_Verde","Canary","Faroe","Madeira","Azores","Bermuda","South_Georgia","Stanley"],in:["Mauritius","Maldives","Chagos"],pa:["Palau","Guam","Port_Moresby","Bougainville","Efate","Guadalcanal","Kosrae","Norfolk","Noumea","Auckland","Fiji","Kwajalein","Nauru","Tarawa","Chatham","Apia","Fakaofo","Kanton","Tongatapu","Kiritimati","Pitcairn","Gambier","Marquesas","Rarotonga","Tahiti","Niue","Pago_Pago","Honolulu","Easter","Galapagos"],aq:["Troll","Mawson","Davis","Casey","Rothera","Macquarie","Palmer"],etc:["Greenwich","Universal","Zulu","GMT-14","GMT-13","GMT-12","GMT-11","GMT-10","GMT-9","GMT-8","GMT-7","GMT-6","GMT-5","GMT-4","GMT-3","GMT-2","GMT-1","GMT","GMT+1","GMT+2","GMT+3","GMT+4","GMT+5","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12","UCT","UTC"]};const regions={etc:"Etc",af:"Africa",as:"Asia",au:"Australia",aq:"Antarctica",eu:"Europe",na:"America",sa:"America",at:"Atlantic",in:"Indian",pa:"Pacific"},licenseData=[],licenseApp=[{t:"Petite Vue",y:2021,a:"Yuxi (Evan) You",l:"mit"},{t:"Petite Vue I18n Lite",y:2021,a:"Front Labs",l:"mit"},{t:"Ace Editor",y:2010,a:"Ajax.org B.V.",r:1,l:"bsd"},{t:"MaterialDesign Icons",y:2022,a:"Google",l:"apache2"}];function Credits(a){return{$template:"#credit-template",model:a}}function RegionItem(a,e,t){return{$template:"#region-template",model:a,region:e,i18n:t,list(t){if(a[t]&&e[t]){for(var n="etc"===t?a[t]:a[t].sort(),o=[],i=0;it.t(a).toString().replace(/_/g," ")}}fetch("/static/en.json?COMMIT_HASH").then((a=>a.json())).then((a=>{const e=reactive(createI18n({locale:"en",fallbackLocale:"en",messages:{en:a.en}}));createApp({i18n:e,languages:languages,RegionItem:RegionItem,regions:regions,locations:locations,licenseData:licenseData,licenseApp:licenseApp,Credits:Credits,hostname:null,title:null,config:{hasp:null,wifi:null,mqtt:null,http:null,gui:null,gpio:null,debug:null,time:null,ota:null},info:null,files:null,show:null,t(a){return this.i18n.t(a)},fetchConfig(a){fetch("/api/config/"+a+"/").then((a=>a.json())).then((e=>{this.config[a]=e,this.show=a,document.title=a}))},submitConfig(){let a=this.show;fetch("/api/config/"+a+"/",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(this.config[a])}).then((a=>a.json())).then((e=>{this.config[a]=e,window.history.pushState({},"","/config/"),window.dispatchEvent(new Event("popstate"))}))},submitOldConfig(a){fetch("/api/config/"+a+"/",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(this.config[a])}).then((a=>a.json())).then((a=>{window.location.href="/config"}))},fetchLang(a){fetch("/static/"+a+".json?COMMIT_HASH").then((a=>a.json())).then((e=>{let t=e[a]?e[a]:{};this.i18n.setLocaleMessage(a,t),this.i18n.changeLocale(a)}))},fetchInfo(){fetch("/api/info/").then((a=>a.json())).then((a=>{this.info=a,this.show="info",document.title="Info"}))},fetchAbout(){fetch("/api/credits/").then((a=>a.json())).then((a=>{this.licenseData=a,this.show="about",document.title="About"}))},showPage(a){this.show=a,document.title=a,""!=a&&(a+="/")},showInfo(){this.fetchInfo(),document.title="Info"},showConfig(a){this.fetchConfig(a),document.title=a},showEditor(){fetch("/api/files/").then((a=>a.json())).then((a=>{this.files=a,this.show="edit";var e=document.getElementsByClassName("container__editor")[0];e&&(e.style.display="flex"),document.title="Editor"}))},handleLocation(a,e){const t={"/":()=>{this.showPage("")},"/hasp.htm":()=>{this.showPage("")},"/config/":()=>{this.showPage("config")},"/config/hasp/":()=>{this.showConfig("hasp")},"/config/wifi/":()=>{this.showConfig("wifi")},"/config/http/":()=>{this.showConfig("http")},"/config/mqtt/":()=>{this.showConfig("mqtt")},"/config/gui/":()=>{this.showConfig("gui")},"/config/ftp/":()=>{this.showConfig("ftp")},"/config/time/":()=>{this.showConfig("time")},"/config/debug/":()=>{this.showConfig("debug")},"/config/reset/":()=>{this.showPage("reset")},"/firmware/":()=>{this.showConfig("ota")},"/info/":()=>{this.showInfo()},"/screenshot/":()=>{this.showPage("screenshot")},"/about/":()=>{this.fetchAbout()},"/edit/":()=>{this.showEditor()},"/edit":()=>{},"/static/editor.htm":()=>{},"/reboot/":()=>{this.showPage("reboot")}};"function"==typeof t[a]?t[a]():"/"!==a.slice(-1)&&"function"==typeof t[a+"/"]?t[a+"/"]():t["/"];const n=document.getElementsByClassName("container__editor")[0];n&&(n.style.display=a.includes("/edit")?"flex":"none"),window.scrollTo({top:e})},mounted(){let a=decodeURIComponent(document.cookie).split(";");for(let e=0;e{const e=window.location.pathname;var t=a.state,n=0;t&&(n=t.scrollTop),this.handleLocation(e,n)};const e=window.location.pathname;this.handleLocation(e,0)},route(a){(a=a||window.event).preventDefault();const e=a.currentTarget.href||a.target.parentNode.href,t=new URL(e).pathname;if(window.location.pathname!=t){var n={path:window.location.href||a.target.href,scrollTop:document.body.scrollTop};window.history.replaceState(n,"",document.location.pathname),n={path:window.location.href,scrollTop:0},window.history.pushState(n,"",t),window.dispatchEvent(new Event("popstate"))}},goto(a){if(window.location.pathname!=a){var e={path:window.location.href,scrollTop:document.body.scrollTop};window.history.replaceState(e,"",document.location.pathname),e={path:window.location.href,scrollTop:0},window.history.pushState(e,"",a),window.dispatchEvent(new Event("popstate"))}},ref(a){},aref(a){setTimeout((function(){}),1e3*a)},upd(a){var e=(new Date).getTime();document.getElementById("bmp").src="/screenshot?a="+a+"&q="+e}}).directive("t",(({el:a,get:t,effect:n})=>n((()=>a.textContent=e.t(t()))))).directive("ts",(({el:a,get:t,effect:n})=>n((()=>a.textContent=e.t(t()).replace(/_/g," "))))).mount()})); \ No newline at end of file +import{createApp,reactive,createI18n}from"/static/petite-vue.hasp.js?COMMIT_HASH";const languages=[{code:"en",name:"English"},{code:"nl",name:"Nederlands"},{code:"fr",name:"Français"}];var locations={af:["Abidjan","Algiers","Bissau","Cairo","Casablanca","El_Aaiun","Johannesburg","Juba","Khartoum","Lagos","Maputo","Monrovia","Nairobi","Ndjamena","Sao_Tome","Tripoli","Tunis","Windhoek","Cape_Verde","Mauritius"],eu:["Ceuta","Danmarkshavn","Nuuk","Scoresbysund","Thule","Anadyr","Barnaul","Chita","Irkutsk","Kamchatka","Khandyga","Krasnoyarsk","Magadan","Novokuznetsk","Novosibirsk","Omsk","Sakhalin","Srednekolymsk","Tomsk","Ust-Nera","Vladivostok","Yakutsk","Yekaterinburg","Azores","Canary","Faroe","Madeira","Andorra","Astrakhan","Athens","Belgrade","Berlin","Brussels","Bucharest","Budapest","Chisinau","Dublin","Gibraltar","Helsinki","Istanbul","Kaliningrad","Kirov","Kyiv","Lisbon","London","Madrid","Malta","Minsk","Moscow","Paris","Prague","Riga","Rome","Samara","Saratov","Sofia","Tallinn","Tirane","Ulyanovsk","Vienna","Vilnius","Volgograd","Warsaw","Zurich"],as:["Almaty","Amman","Aqtau","Aqtobe","Ashgabat","Atyrau","Baghdad","Baku","Bangkok","Beirut","Bishkek","Choibalsan","Colombo","Damascus","Dhaka","Dili","Dubai","Dushanbe","Famagusta","Gaza","Hebron","Ho_Chi_Minh","Hong_Kong","Hovd","Jakarta","Jayapura","Jerusalem","Kabul","Karachi","Kathmandu","Kolkata","Kuching","Macau","Makassar","Manila","Nicosia","Oral","Pontianak","Pyongyang","Qatar","Qostanay","Qyzylorda","Riyadh","Samarkand","Seoul","Shanghai","Singapore","Taipei","Tashkent","Tbilisi","Tehran","Thimphu","Tokyo","Ulaanbaatar","Urumqi","Yangon","Yerevan","Chagos","Maldives"],au:["Perth","Eucla","Adelaide","Broken_Hill","Darwin","Brisbane","Hobart","Lindeman","Melbourne","Sydney","Lord_Howe"],na:["Adak","Anchorage","Bahia_Banderas","Barbados","Belize","Boise","Cambridge_Bay","Cancun","Chicago","Chihuahua","Ciudad_Juarez","Costa_Rica","Dawson","Dawson_Creek","Denver","Detroit","Edmonton","El_Salvador","Fort_Nelson","Glace_Bay","Goose_Bay","Grand_Turk","Guatemala","Halifax","Havana","Hermosillo","Indiana/Indianapolis","Indiana/Knox","Indiana/Marengo","Indiana/Petersburg","Indiana/Tell_City","Indiana/Vevay","Indiana/Vincennes","Indiana/Winamac","Inuvik","Iqaluit","Jamaica","Juneau","Kentucky/Louisville","Kentucky/Monticello","Los_Angeles","Managua","Martinique","Matamoros","Mazatlan","Menominee","Merida","Metlakatla","Mexico_City","Miquelon","Moncton","Monterrey","New_York","Nome","North_Dakota/Beulah","North_Dakota/Center","North_Dakota/New_Salem","Ojinaga","Panama","Phoenix","Port-au-Prince","Puerto_Rico","Rankin_Inlet","Regina","Resolute","Santo_Domingo","Sitka","St_Johns","Swift_Current","Tegucigalpa","Tijuana","Toronto","Vancouver","Whitehorse","Winnipeg","Yakutat","Yellowknife","Bermuda","Honolulu"],sa:["Araguaina","Argentina/Buenos_Aires","Argentina/Catamarca","Argentina/Cordoba","Argentina/Jujuy","Argentina/La_Rioja","Argentina/Mendoza","Argentina/Rio_Gallegos","Argentina/Salta","Argentina/San_Juan","Argentina/San_Luis","Argentina/Tucuman","Argentina/Ushuaia","Asuncion","Bahia","Belem","Boa_Vista","Bogota","Campo_Grande","Caracas","Cayenne","Cuiaba","Eirunepe","Fortaleza","Guayaquil","Guyana","La_Paz","Lima","Maceio","Manaus","Montevideo","Noronha","Paramaribo","Porto_Velho","Punta_Arenas","Recife","Rio_Branco","Santarem","Santiago","Sao_Paulo","Palmer","South_Georgia","Stanley","Easter","Galapagos"],at:["Cape_Verde","Canary","Faroe","Madeira","Azores","Bermuda","South_Georgia","Stanley"],in:["Mauritius","Maldives","Chagos"],pa:["Palau","Guam","Port_Moresby","Bougainville","Efate","Guadalcanal","Kosrae","Norfolk","Noumea","Auckland","Fiji","Kwajalein","Nauru","Tarawa","Chatham","Apia","Fakaofo","Kanton","Tongatapu","Kiritimati","Pitcairn","Gambier","Marquesas","Rarotonga","Tahiti","Niue","Pago_Pago","Honolulu","Easter","Galapagos"],aq:["Troll","Mawson","Davis","Casey","Rothera","Macquarie","Palmer"],etc:["Greenwich","Universal","Zulu","GMT-14","GMT-13","GMT-12","GMT-11","GMT-10","GMT-9","GMT-8","GMT-7","GMT-6","GMT-5","GMT-4","GMT-3","GMT-2","GMT-1","GMT","GMT+1","GMT+2","GMT+3","GMT+4","GMT+5","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12","UCT","UTC"]};const regions={etc:"Etc",af:"Africa",as:"Asia",au:"Australia",aq:"Antarctica",eu:"Europe",na:"America",sa:"America",at:"Atlantic",in:"Indian",pa:"Pacific"},licenseData=[],licenseApp=[{t:"Petite Vue",y:2021,a:"Yuxi (Evan) You",l:"mit"},{t:"Petite Vue I18n Lite",y:2021,a:"Front Labs",l:"mit"},{t:"Ace Editor",y:2010,a:"Ajax.org B.V.",r:1,l:"bsd"},{t:"MaterialDesign Icons",y:2022,a:"Google",l:"apache2"}];function Credits(a){return{$template:"#credit-template",model:a}}function RegionItem(a,o,e){return{$template:"#region-template",model:a,region:o,i18n:e,list(e){if(a[e]&&o[e]){for(var n="etc"===e?a[e]:a[e].sort(),t=[],i=0;ie.t(a).toString().replace(/_/g," ")}}fetch("/static/en.json?COMMIT_HASH").then((a=>a.json())).then((a=>{const o=reactive(createI18n({locale:"en",fallbackLocale:"en",messages:{en:a.en}}));createApp({i18n:o,languages:languages,RegionItem:RegionItem,regions:regions,locations:locations,licenseData:licenseData,licenseApp:licenseApp,Credits:Credits,hostname:null,title:null,config:{hasp:null,wifi:null,mqtt:null,http:null,gui:null,gpio:null,debug:null,time:null,ota:null},info:null,files:null,show:null,t(a){return this.i18n.t(a)},fetchConfig(a){fetch("/api/config/"+a+"/").then((a=>a.json())).then((o=>{this.config[a]=o,this.show=a,document.title=a}))},submitConfig(){let a=this.show;fetch("/api/config/"+a+"/",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(this.config[a])}).then((a=>a.json())).then((o=>{this.config[a]=o,window.history.pushState({},"","/config/"),window.dispatchEvent(new Event("popstate"))}))},submitOldConfig(a){fetch("/api/config/"+a+"/",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(this.config[a])}).then((a=>a.json())).then((a=>{window.location.href="/config"}))},fetchLang(a){fetch("/static/"+a+".json?COMMIT_HASH").then((a=>a.json())).then((o=>{let e=o[a]?o[a]:{};this.i18n.setLocaleMessage(a,e),this.i18n.changeLocale(a),console.log(a)}))},fetchInfo(){fetch("/api/info/").then((a=>a.json())).then((a=>{this.info=a,this.show="info",document.title="Info"}))},fetchAbout(){fetch("/api/credits/").then((a=>a.json())).then((a=>{this.licenseData=a,this.show="about",document.title="About"}))},showPage(a){console.log("showPage "+a),this.show=a,document.title=a,""!=a&&(a+="/")},showInfo(){console.log("showInfo"),this.fetchInfo(),document.title="Info"},showConfig(a){console.log("showConfig "+a),this.fetchConfig(a),document.title=a},showEditor(){console.log("showEditor"),fetch("/api/files/").then((a=>a.json())).then((a=>{this.files=a,this.show="edit";var o=document.getElementsByClassName("container__editor")[0];o&&(o.style.display="flex"),document.title="Editor"}))},handleLocation(a,o){const e={"/":()=>{this.showPage("")},"/hasp.htm":()=>{this.showPage("")},"/config/":()=>{this.showPage("config")},"/config/hasp/":()=>{this.showConfig("hasp")},"/config/wifi/":()=>{this.showConfig("wifi")},"/config/http/":()=>{this.showConfig("http")},"/config/mqtt/":()=>{this.showConfig("mqtt")},"/config/gui/":()=>{this.showConfig("gui")},"/config/ftp/":()=>{this.showConfig("ftp")},"/config/time/":()=>{this.showConfig("time")},"/config/debug/":()=>{this.showConfig("debug")},"/config/reset/":()=>{this.showPage("reset")},"/firmware/":()=>{this.showConfig("ota")},"/info/":()=>{this.showInfo()},"/screenshot/":()=>{this.showPage("screenshot")},"/about/":()=>{this.fetchAbout()},"/edit/":()=>{this.showEditor()},"/edit":()=>{},"/static/editor.htm":()=>{},"/reboot/":()=>{this.showPage("reboot")}};"function"==typeof e[a]?(console.log("Location: "+a),e[a]()):"/"!==a.slice(-1)&&"function"==typeof e[a+"/"]?(console.log("Location: "+a),e[a+"/"]()):(console.log("Not found: "+a),e["/"]);const n=document.getElementsByClassName("container__editor")[0];n&&(n.style.display=a.includes("/edit")?"flex":"none"),window.scrollTo({top:o})},mounted(){let a=decodeURIComponent(document.cookie).split(";");for(let o=0;o{const o=window.location.pathname;console.log("Popstate: "+o),console.log(a);var e=a.state,n=0;e&&(n=e.scrollTop),this.handleLocation(o,n)};const o=window.location.pathname;this.handleLocation(o,0),console.log("App Mounted")},route(a){console.log("Routing..."),a=a||window.event,console.log(a.target),a.preventDefault();const o=a.currentTarget.href||a.target.parentNode.href,e=new URL(o).pathname;if(window.location.pathname!=e){console.log("Push Route: "+e);var n={path:window.location.href||a.target.href,scrollTop:document.body.scrollTop};window.history.replaceState(n,"",document.location.pathname),n={path:window.location.href,scrollTop:0},window.history.pushState(n,"",e),window.dispatchEvent(new Event("popstate"))}},goto(a){if(console.log("Goto..."),window.location.pathname!=a){console.log("Push Route: "+a);var o={path:window.location.href,scrollTop:document.body.scrollTop};window.history.replaceState(o,"",document.location.pathname),o={path:window.location.href,scrollTop:0},window.history.pushState(o,"",a),window.dispatchEvent(new Event("popstate"))}},ref(a){},aref(a){setTimeout((function(){}),1e3*a)},upd(a){var o=(new Date).getTime();document.getElementById("bmp").src="/screenshot?a="+a+"&q="+o}}).directive("t",(({el:a,get:e,effect:n})=>n((()=>a.textContent=o.t(e()))))).directive("ts",(({el:a,get:e,effect:n})=>n((()=>a.textContent=o.t(e()).replace(/_/g," "))))).mount(),console.log("JS Loaded...")})); \ No newline at end of file diff --git a/data/script.js b/data/script.js index 9a9fcc6f..541761af 100644 --- a/data/script.js +++ b/data/script.js @@ -1,133 +1 @@ -function aref(e) { - setTimeout(function () { - ref(""); - }, 1e3 * e); -} -function upd(e) { - var t = new Date().getTime(); - return (document.getElementById("bmp").src = "?a=" + e + "&q=" + t), !1; -} -async function ref(e) { - var t = new Date().getTime(); - (await fetch("/screenshot?d=" + t + "&a=" + e)).ok ? upd(e) : aref(2); -} -function ihtm(id, html) { - if (obj = document.getElementById(id)) - obj.innerHTML = html; -} -function about() { - ihtm("lic",'

openHASP

Copyright© 2019-2022 Francis Van Roie
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

'); - ihtm("pkg","

Based on the previous work of the following open source developers:

HASwitchPlate

Copyright© 2019 Allen Derusha allen @derusha.org
MIT License

LVGL

Copyright© 2021 LVGL Kft
MIT License

LovyanGFX

Copyright© 2020 lovyan03 (https://github.com/lovyan03) All rights reserved.
FreeBSD License

TFT_eSPI

Copyright© 2020 Bodmer (https://github.com/Bodmer) All rights reserved.
FreeBSD License

Adafruit_GFX

Copyright© 2012 Adafruit Industries. All rights reserved
BSD License

ArduinoJson

Copyright© 2014-2021 Benoit BLANCHON
MIT License

PubSubClient

Copyright© 2008-2015 Nicholas O'Leary
MIT License

ArduinoLog

Copyright© 2017,2018 Thijs Elenbaas, MrRobot62, rahuldeo2047, NOX73, dhylands, Josha blemasle, mfalkvidd
MIT License

QR Code generator

Copyright© Project Nayuki
MIT License

SimpleFTPServer

Copyright© 2017 Renzo Mischianti www.mischianti.org All right reserved.
MIT License

AceButton

Copyright© 2018 Brian T. Park
MIT License

"); -} -function handleSubmit(e) { - e.preventDefault(); - const t = new FormData(e.target), - o = Object.fromEntries(t.entries()); - console.log({ value: o }); -} -function info2() { - try { - data = JSON.parse(this.response); - var e = ""; - for (let t in data) { - e += ``; - for (let o in data[t]) - e += ``; - } - (e += "
${t}
${o}: ${data[t][o]}
"), (document.getElementById("info").innerHTML = e); - } catch (e) { - console.log('invalid json'); - } -} -function loader(e, t, o) { - window.addEventListener("load", function () { - var n = new XMLHttpRequest(); - n.addEventListener("load", o), n.open(e, t), n.send(); - }); -} -function info() { - if (obj = document.getElementById("info")) { - var n = new XMLHttpRequest(); - n.addEventListener("load", info2), n.open("GET", "/api/info/"), n.send(); - } -} -function fill() { - try { - data = JSON.parse(this.response); - for (const form of document.forms) populate(form, data); - } catch (e) { - console.log('invalid json'); - } -} -function filler(e, t) { - window.addEventListener("load", function () { - var o = new XMLHttpRequest(); - o.addEventListener("load", fill), o.open(e, t), o.send(); - }); -} -function filler2(e, t) { - var o = new XMLHttpRequest(); - o.addEventListener("load", fill), o.open(e, t), o.send(); -} -function forms() { - document.querySelectorAll("form").forEach(function(f) { - console.log(f.id); - filler2("GET", "/api/config/" + f.id + "/"); - }); -} -function populate(e, t, o) { - for (var n in t) - if (t.hasOwnProperty(n)) { - var r = n, - i = t[n]; - if ( - (void 0 === i && (i = ""), - null === i && (i = ""), - void 0 !== o && (r = o + "[" + n + "]"), - i.constructor === Array) - ) - r += "[]"; - else if ("object" == typeof i) { - populate(e, i, r); - continue; - } - var a = e.elements.namedItem(r); - if (a) - switch (a.type || a[0].type) { - default: - a.value = i; - break; - case "radio": - for ( - var s = i.constructor === Array ? i : [i], c = 0; - c < a.length; - c++ - ) - a[c].checked = s.indexOf(Number(a[c].value)) > -1; - break; - case "checkbox": - (s = i.constructor === Array ? i : [i]), - (a.checked = s.indexOf(Number(a.value)) > -1); - break; - case "select-multiple": - s = i.constructor === Array ? i : [i]; - for (var p = 0; p < a.options.length; p++) - a.options[p].selected = s.indexOf(a.options[p].value) > -1; - break; - case "select": - case "select-one": - a.value = i.toString() || i; - break; - case "date": - a.value = new Date(i).toISOString().split("T")[0]; - } - } -} - - -window.addEventListener('load', (event) => { - // console.log('The page has fully loaded'); - forms(); - info(); - about(); -}); \ No newline at end of file +var ctx_el;function _(e){return document.getElementById(e)}function hidectx(){_("ctx").style.display="none",ctx_el&&ctx_el.classList.remove("selitem"),ctx_el=void 0}function doesFontExist(e){var t=document.createElement("canvas"),n=t.getContext("2d"),o="abcdefghijklmnopqrstuvwxyz0123456789";n.font="72px monospace";var a=n.measureText(o).width;return n.font="72px '"+e+"', monospace",t=null,n.measureText(o).width!=a}function createEditor(e,t,n,o,a){function i(e){let t=/(?:\.([^.]+))?$/.exec(e)[1];if(void 0!==typeof t)switch(t){case"htm":case"html":return"html";case"js":return"javascript";case"cmd":case"json":case"jsonl":return"json";case"css":case"svg":case"xml":return t}return"plain_text"}void 0===n&&(n=i(t)),void 0===a&&(a="text/"+n);["basePath","modePath","themePath"].forEach((e=>{ace.config.set(e,"https://cdnjs.cloudflare.com/ajax/libs/ace/1.15.2")}));var c=ace.edit(e,{useWorker:!1,wrap:!0,indentedSoftWrap:!1,showPrintMargin:!1,highlightGutterLine:!0,useSoftTabs:!0,tabSize:2});c.setFontSize(parseFloat(getComputedStyle(document.documentElement).fontSize)),c.setReadOnly(!0),c.getSession().setUndoManager(new ace.UndoManager),void 0===o&&(o=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"monokai":"textmate");var s=_("save"),l=_("undo"),r=_("redo"),d=_("cut"),m=_("copy"),u=_("paste"),p=_("font"),f=_("fontsize"),g="none"!==_(e).display;f.value=parseFloat(c.getFontSize()).toFixed(1),p.onchange=function(){c.setOption("fontFamily","'"+p.value+"',monospace")},f.onchange=function(){var e=parseFloat(f.value);!isNaN(e)&&e>=9&&e<=40&&c.setFontSize(e),f.value=parseFloat(c.getFontSize()).toFixed(1)};function h(){let e=!g||c.session.getSelection().isEmpty();d.disabled=e,m.disabled=e}function y(){let e=c.session.getUndoManager();s.disabled=!g||e.isClean(),l.disabled=!g||!e.hasUndo(),r.disabled=!g||!e.hasRedo()}function v(){if(void 0===t)return;const e=function(e){var t=e.getValue();try{var n=JSON.parse(t);return JSON.stringify(n)}catch(e){return t+""}}(c),n=new FormData;n.append("data",new Blob([e],{type:a}),t),fetch("/edit",{method:"POST",body:n}).then((e=>e.ok?e.text().then((e=>{console.log("Save OK /edit "+e)})):e.text().then((e=>{throw console.log("Save FAIL /edit"),new Error(e)})))).then((e=>{console.log(e),generateToast({message:"Saved "+t,background:"#ddd",color:"#000"})})).catch((e=>{console.warn("AbortError"===e.name?"Promise Aborted":"Promise Rejected"),alert(e)})).finally((()=>{y()}))}function x(){var e=c.getCopyText();if(window.clipboardData&&window.clipboardData.setData)return window.clipboardData.setData("Text",e);if(document.queryCommandSupported&&document.queryCommandSupported("copy")){c.focus();try{return document.execCommand("copy")}catch(t){return console.warn("Copy to clipboard failed.",t),prompt("Copy to clipboard: Ctrl+C, Enter",e)}}}function w(e){_("name").innerHTML=e;fetch(e).then((t=>t.ok?(console.log("OK "+e),t.text()):t.text().then((e=>{throw console.log("ERROR "+url),new Error(e)})))).then((e=>{try{var t=JSON.parse(e);c.setValue(JSON.stringify(t,null,4)),console.log("parse json OK")}catch(t){c.setValue(e),console.log("parse json FAIL")}null!==_("editor")&&(_("editor").style.display="block"),null!==_("preview")&&(_("preview").style.display="none"),g=!0,c.setReadOnly(!1),c.focus(),y()})).catch((e=>{console.log(e),alert(e),c.setReadOnly(!0)})).finally((()=>{c.resize(!0),c.scrollToLine(1,!0,!0,(function(){})),c.gotoLine(1,0,!0),c.clearSelection(),c.session.getUndoManager().reset()}))}return["Courier New","Monaco","Lucida Console","Monospace","ui-monospace","Roboto Mono","Inconsolata","IBM Plex Mono","Space Mono","PT Mono","Ubuntu Mono","Nanum Gothic Coding","Cousine","Fira Mono","Share Tech Mono","Courier Prime","Anonymous Pro","Cutive Mono","Overpass Mono","Fira Code","VT323","DM Mono","Oxygen Mono","Nova Mono","B612 Mono","Spline Sans Mono","Noto Sans Mono","Major Mono Display","Azeret Mono","Red Hat Mono","Syne Mono","Xanh Mono"].sort().forEach((function(e,t){if(doesFontExist(e)){var n=document.createElement("option");n.text=e,p.add(n)}})),null!==s&&null!==l&&null!==r&&c.on("input",y),c.session.selection.on("changeCursor",h),s.onclick=v,l.onclick=e=>{c.undo()&&c.focus()},r.onclick=e=>{c.redo()&&c.focus()},d.onclick=e=>{x()&&c.execCommand("cut")},m.onclick=e=>{x()&&c.execCommand("copy")},u.onclick=function(){try{navigator.clipboard.readText().then((e=>{c.execCommand("paste",e)})).catch((e=>{u.disabled=!0}))}catch{u.disabled=!0}},c.loadUrl=(e,o)=>{n=i(t=e+o),a="text/"+n,"plain"!==n&&c.getSession().setMode("ace/mode/"+n),w(e+o)},c.hide=()=>{g=!1,y(),h(),_("editor").style.display="none"},"plain"!==n&&c.getSession().setMode("ace/mode/"+n),c.setTheme("ace/theme/"+o),c.$blockScrolling=1/0,c.commands.addCommand({name:"save",bindKey:{win:"Ctrl-S",mac:"Command-S"},exec:v,readOnly:!1}),c.commands.addCommand({name:"undo",bindKey:{win:"Ctrl-Z",mac:"Command-Z"},exec:function(){c.undo()}}),c.commands.addCommand({name:"redo",bindKey:{win:"Ctrl-Y",mac:"Command-Y"},exec:function(){c.redo()}}),void 0!==t&&w(t),c.resize(),c}function uploadFileAsync(e,t,n,o,a,i){fetchData("/edit","POST",e).then((e=>{generateToast({message:"Upload "+n+"/"+o+" "+t+" done.",background:"#ddd",color:"#000"}),n==o&&listFiles(a,i)}))}function doUpload(e,t){const n=_("upload"),o=n.files.length;if(0!==o)for(let a=0;a=0}function isText(e){if(isFolder(e))return!1;var t=/(?:\.([^.]+))?$/.exec(e.name)[1];if(void 0!==typeof t)switch(t){case"txt":case"cmd":case"json":case"jsonl":case"htm":case"html":case"js":case"c":case"cpp":case"css":case"svg":case"xml":return!0}return!1}function isImage(e){if(isFolder(e))return!1;var t=/(?:\.([^.]+))?$/.exec(e.name)[1];if(void 0!==typeof t)switch(t){case"bmp":case"png":case"jpg":case"gif":case"svg":return!0}return!1}function isAudio(e){if(isFolder(e))return!1;var t=/(?:\.([^.]+))?$/.exec(e.name)[1];if(void 0!==typeof t)switch(t){case"wav":case"mp3":case"aac":case"m4a":case"wma":return!0}return!1}function icon(e){if(isFolder(e))return"dir";if(isImage(e))return"image";if(isAudio(e))return"audio";var t=/(?:\.([^.]+))?$/.exec(e.name)[1];if(void 0!==typeof t)switch(t){case"cmd":case"css":case"json":case"jsonl":case"ttf":return t;case"zip":case"gz":return"zip";case"html":case"htm":return"html"}return"file"}function preview(e,t){if(isImage(e)){let n=t+e.name;const o=_("preview");o.innerHTML='',o.style.display="block",ace.edit("editor").hide(),_("name").innerHTML=n}}function edit(e,t){isText(e)&&(ace.edit("editor").loadUrl(t,e.name),_("preview").style.display="none")}function url(e,t){console.log("click "+t+e.name),isImage(e)?preview(e,t):isText(e)&&edit(e,t)}async function fetchData(e,t,n,o){await fetch(e,{method:t,body:n}).then((n=>n.ok?(console.log(t+" OK "+e),n.text()):n.text().then((n=>{throw console.log(t+" FAIL "+e),new Error(n)})))).then((e=>{o&&o.remove(),console.log(e)})).catch((e=>{console.warn("AbortError"===e.name?"Promise Aborted":"Promise Rejected"),alert(e)})).finally((()=>{}))}function download(e,t){console.log("download "+t+e.name),document.getElementById("download-frame").src=t+e.name+"?download=true"}function remove(e,t,n){let o=t+e.name;isFolder(e)&&(o+="/"),console.log("remove "+o);const a=new FormData;a.append("path",o),fetchData("/edit","DELETE",a,n)}function create(e,t,n){var o=window.prompt("Create File in "+e,"");if(null==o||""==o||o.includes("/"))return;const a=new FormData;a.append("path",e+o),fetchData("/edit","PUT",a),fetch("/api/files/").then((e=>e.json())).then((o=>{t&&t.remove(),listFiles(n,e),console.log(o)}))}function upload(e,t){_("upload").onchange=()=>{doUpload(e,t)},_("upload").click()}function ctx(e,t,n,o){e.preventDefault(),ctx_el=o;let a,i=isFolder(t),c=_("ctx");c.style.display="block",a=c.getElementsByTagName("li")[0],a.onclick=i?function(){hidectx(),create(n+t.name+"/",o.children.item(1),o)}:function(){hidectx(),create(n,o.parentNode,o.parentNode.parentNode)},a.style.display=i?"block":"none",a=c.getElementsByTagName("li")[1],i&&(a.onclick=function(){hidectx(),upload(o,n+t.name+"/")}),a.style.display=i?"block":"none",a=c.getElementsByTagName("li")[2],a.onclick=function(){edit(t,n),hidectx()},a.style.display=isText(t)?"block":"none",a=c.getElementsByTagName("li")[3],a.onclick=function(){preview(t,n),hidectx()},a.style.display=isImage(t)?"block":"none",a=c.getElementsByTagName("li")[4],a.onclick=function(){download(t,n),hidectx()},a.style.display=i?"none":"block",a=c.getElementsByTagName("li")[5],a.onclick=function(){remove(t,n,o),hidectx()},a.style.display=n?"block":"none";var s=document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop,l=document.body.scrollLeft?document.body.scrollLeft:document.documentElement.scrollLeft,r=e.clientX+l+10,d=e.clientY+s-20,m=(c.offsetWidth,c.offsetHeight),u=document.documentElement.clientHeight;d+m>u&&(d=u-m-20),c.style.left=r+"px",c.style.top=d+"px",o&&o.classList.add("selitem")}function drag(e,t,n){let o=n+t.name;isFolder(t)&&(o+="/"),e.dataTransfer.setData("text",o),console.log("drag start "+o)}function drop(e,t){let n=e.dataTransfer.getData("text");n.startsWith(t)||(e.preventDefault(),console.log("Move "+n+" to "+t))}function listFiles(e,t){return console.log("listFiles"),fetch("/api/files/?dir="+t).then((e=>e.json())).then((n=>{if(0==n.length)return!1;let o=e.getElementsByTagName("div")[0];o&&(o.onclick=n=>{i.remove(),o.onclick=()=>{listFiles(e,t)},n.stopPropagation()});let a=e.getElementsByTagName("ul");for(let e=0;e{drag(event,e,t)},a.appendChild(s),s.innerHTML=''+o+"",isFolder(e)){let n=t+e.name+"/";s.classList.add("bold"),s.onclick=function(e){listFiles(a,n)},s.ondragover=e=>{e.preventDefault()},s.ondrop=e=>{drop(e,n)}}else(isText(e)||isImage(e)||isAudio(e))&&(s.onclick=function(n){url(e,t)});s.oncontextmenu=n=>{ctx(n,e,t,a)}}return e.scrollIntoView(),!0}))}function generateToast({message:e,background:t="#00214d",color:n="#fffffe",length:o="7000ms"}){_("toast").insertAdjacentHTML("afterbegin",`

\n ${e}\n

`);const a=_("toast").firstElementChild;a.addEventListener("animationend",(()=>a.remove()))}document.addEventListener("blur",(function(){hidectx()})),document.addEventListener("DOMContentLoaded",(function(){createEditor("editor",void 0,void 0,void 0);listFiles(_("tree"),"/"),_("tree").getElementsByTagName("div")[0].oncontextmenu=e=>{ctx(e,{name:"",children:[]},"",_("tree"))},_("load").onclick=function(e){const t=new FormData;t.append("load",""),fetchData("/edit","PUT",t)},_("init").onclick=function(e){const t=new FormData;t.append("init",""),fetchData("/edit","PUT",t)},_("home").onclick=function(e){window.location.href="/"},_("page").onchange=function(e){const t=new FormData;t.append("page",_("page").value),fetchData("/edit","PUT",t)}})),document.addEventListener("DOMContentLoaded",(function(){const e=document.getElementById("dragMe"),t=e.previousElementSibling,n=e.nextElementSibling;let o=0,a=0,i=0;const c=function(a){const c=a.clientX-o,s=(a.clientY,100*(i+c)/e.parentNode.getBoundingClientRect().width);t.style.width=`${s}%`,t.style.right=t.style.width,e.style.cursor="col-resize",document.body.style.cursor="col-resize",t.style.userSelect="none",t.style.pointerEvents="none",n.style.userSelect="none",n.style.pointerEvents="none",ace.edit("editor").resize()},s=function(){e.style.removeProperty("cursor"),document.body.style.removeProperty("cursor"),t.style.removeProperty("user-select"),t.style.removeProperty("pointer-events"),n.style.removeProperty("user-select"),n.style.removeProperty("pointer-events"),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s)};e.addEventListener("mousedown",(function(e){o=e.clientX,a=e.clientY,i=t.getBoundingClientRect().width,document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)})),e.addEventListener("dblclick",(()=>{var e=t.style.visibility="hidden"===t.style.visibility;t.style.visibility=e?"unset":"hidden",t.style.position=e?"unset":"absolute",ace.edit("editor").resize()}))})); \ No newline at end of file diff --git a/data/static/edit.htm.gz b/data/static/edit.htm.gz index cbea9b3c..8ddca4a7 100644 Binary files a/data/static/edit.htm.gz and b/data/static/edit.htm.gz differ diff --git a/data/static/en.json.gz b/data/static/en.json.gz index 4c8f258b..69abbe80 100644 Binary files a/data/static/en.json.gz and b/data/static/en.json.gz differ diff --git a/data/static/main.js.gz b/data/static/main.js.gz index d5feb9cf..1db00d05 100644 Binary files a/data/static/main.js.gz and b/data/static/main.js.gz differ diff --git a/data/static/script.js.gz b/data/static/script.js.gz index 3fc28f3e..0bbc6fe8 100644 Binary files a/data/static/script.js.gz and b/data/static/script.js.gz differ diff --git a/data/static/style.css.gz b/data/static/style.css.gz index d7ed0ac6..6d8a3513 100644 Binary files a/data/static/style.css.gz and b/data/static/style.css.gz differ diff --git a/data/style.css b/data/style.css index eea45e82..6b3ac6eb 100644 --- a/data/style.css +++ b/data/style.css @@ -9,6 +9,8 @@ --star: url('data:image/svg+xml,'); --trash: url('data:image/svg+xml,'); --download: url('data:image/svg+xml,'); + --upload: url('data:image/svg+xml,'); + --flash: url('data:image/svg+xml,'); --file: url('data:image/svg+xml,'); --dir: url('data:image/svg+xml,'); --diropen: url('data:image/svg+xml,'); @@ -17,8 +19,10 @@ --zip: url('data:image/svg+xml,'); --cmd: url('data:image/svg+xml,'); --css: url('data:image/svg+xml,'); + --ttf: url('data:image/svg+xml,'); --eye: url('data:image/svg+xml,'); --json: url('data:image/svg+xml,'); + --audio: url('data:image/svg+xml,'); } .fn:hover { @@ -57,12 +61,14 @@ .fa-browse { mask-image: var(--browse); -webkit-mask-image: var(--browse)} .fa-cog { mask-image: var(--cog); -webkit-mask-image: var(--cog)} .fa-download{ mask-image: var(--download); -webkit-mask-image: var(--download)} +.fa-upload { mask-image: var(--upload); -webkit-mask-image: var(--upload)} .fa-home { mask-image: var(--home); -webkit-mask-image: var(--home)} .fa-info { mask-image: var(--info); -webkit-mask-image: var(--info)} .fa-ota { mask-image: var(--ota); -webkit-mask-image: var(--ota)} .fa-shot { mask-image: var(--shot); -webkit-mask-image: var(--shot)} .fa-star { mask-image: var(--star); -webkit-mask-image: var(--star)} .fa-trash { mask-image: var(--trash); -webkit-mask-image: var(--trask)} +.fa-flash { mask-image: var(--flash); -webkit-mask-image: var(--flash)} .fa-file { mask-image: var(--file); -webkit-mask-image: var(--file)} .fa-dir { mask-image: var(--dir); -webkit-mask-image: var(--dir)} .fa-diropen { mask-image: var(--diropen); -webkit-mask-image: var(--diropen)} @@ -73,7 +79,9 @@ .fa-json { mask-image: var(--json); -webkit-mask-image: var(--json)} .fa-jsonl { mask-image: var(--json); -webkit-mask-image: var(--json)} .fa-image { mask-image: var(--image); -webkit-mask-image: var(--image)} +.fa-audio { mask-image: var(--audio); -webkit-mask-image: var(--audio)} .fa-html { mask-image: var(--html); -webkit-mask-image: var(--html)} +.fa-ttf { mask-image: var(--ttf); -webkit-mask-image: var(--ttf)} .nav-list { font-size: var(--fs-nav); @@ -455,6 +463,7 @@ a.foot:visited { justify-content: left; overflow-x: clip; overflow-y: scroll; + background-color: var(--treebg); /* Popout */ top: 0; @@ -479,8 +488,7 @@ a.foot:visited { /* Misc */ align-items: center; display: flex; - justify-content: center; - background-color: var(--grpbg) + background-color: #888; } .toolbar { text-align: center; @@ -519,9 +527,7 @@ a.foot:visited { #ctx > ul { padding-left: 0px; } -#ctx > ul > li, -.sub_div > ul > li { - cursor: pointer; +#ctx > ul > li { white-space: nowrap } #ctx > ul > li:hover { @@ -531,8 +537,7 @@ a.foot:visited { width: 3rem } #preview { - background-color: #888; - padding: 5px; + padding: 0.3rem; overflow: scroll; } #preview > img { @@ -550,10 +555,11 @@ a.foot:visited { width: 100%; line-height: 1.3rem; font-size: 0.95rem; - background-color: var(--treebg) } .download{background-image: var(--download)} +.upload{background-image: var(--upload)} .eye{background-image: var(--eye)} +.flash{background-image: var(--flash)} .file{background-image: var(--file)} .zip{background-image: var(--zip)} .css{background-image: var(--css)} @@ -561,6 +567,41 @@ a.foot:visited { .json{background-image: var(--json)} .jsonl{background-image: var(--json)} .image{background-image: var(--image)} +.audio{background-image: var(--audio)} .html{background-image: var(--html)} .dir{background-image: var(--dir)} .diropen{background-image: var(--diropen)} + + +#toast { + position: fixed; + bottom: 1rem; + right: 1.5rem; + display: grid; + align-items: end; + align-content: end; + gap: 1rem; +} + +.toast { + font-size: 1rem; + margin: 0; + font-weight: bold; + line-height: 1; + padding: 0.5em 1em; + background-color: lightblue; + animation: toastIt 3000ms cubic-bezier(0.785, 0.135, 0.15, 0.86) forwards; +} + +@keyframes toastIt { + 0%, + 100% { + transform: translateY(150%); + opacity: 0; + } + 10%, + 90% { + transform: translateY(0); + opacity: 1; + } +} diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 75ccecf2..a72d94aa 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -80,16 +80,16 @@ extern const uint8_t SCRIPT_JS_GZ_START[] asm("_binary_data_static_script_js_gz_ extern const uint8_t SCRIPT_JS_GZ_END[] asm("_binary_data_static_script_js_gz_end"); extern const uint8_t LOGO_SVG_GZ_START[] asm("_binary_data_static_logo_svg_gz_start"); extern const uint8_t LOGO_SVG_GZ_END[] asm("_binary_data_static_logo_svg_gz_end"); -extern const uint8_t ACE_JS_GZ_START[] asm("_binary_data_static_ace_1_9_6_min_js_gz_start"); -extern const uint8_t ACE_JS_GZ_END[] asm("_binary_data_static_ace_1_9_6_min_js_gz_end"); extern const uint8_t PETITE_VUE_HASP_JS_GZ_START[] asm("_binary_data_static_petite_vue_hasp_js_gz_start"); extern const uint8_t PETITE_VUE_HASP_JS_GZ_END[] asm("_binary_data_static_petite_vue_hasp_js_gz_end"); extern const uint8_t MAIN_JS_GZ_START[] asm("_binary_data_static_main_js_gz_start"); extern const uint8_t MAIN_JS_GZ_END[] asm("_binary_data_static_main_js_gz_end"); extern const uint8_t EN_JSON_GZ_START[] asm("_binary_data_static_en_json_gz_start"); extern const uint8_t EN_JSON_GZ_END[] asm("_binary_data_static_en_json_gz_end"); -extern const uint8_t HASP_HTM_GZ_START[] asm("_binary_data_static_hasp_htm_gz_start"); -extern const uint8_t HASP_HTM_GZ_END[] asm("_binary_data_static_hasp_htm_gz_end"); +// extern const uint8_t HASP_HTM_GZ_START[] asm("_binary_data_static_hasp_htm_gz_start"); +// extern const uint8_t HASP_HTM_GZ_END[] asm("_binary_data_static_hasp_htm_gz_end"); +// extern const uint8_t ACE_JS_GZ_START[] asm("_binary_data_static_ace_1_9_6_min_js_gz_start"); +// extern const uint8_t ACE_JS_GZ_END[] asm("_binary_data_static_ace_1_9_6_min_js_gz_end"); #endif // CONFIG_IDF_TARGET_ESP32 @@ -1218,22 +1218,31 @@ static void handleFileDelete() { if(!http_is_authenticated(F("filedelete"))) return; - char mimetype[16]; - snprintf_P(mimetype, sizeof(mimetype), PSTR("text/plain")); + const char mimetype[] = "text/plain"; - if(webServer.args() == 0) { - return webServer.send_P(500, mimetype, PSTR("BAD ARGS")); + if(!webServer.hasArg("path")) { + return webServer.send(500, mimetype, "BAD ARGS"); } - String path = webServer.arg(0); + String path = webServer.arg("path"); LOG_TRACE(TAG_HTTP, F("handleFileDelete: %s"), path.c_str()); if(path == "/") { - return webServer.send_P(500, mimetype, PSTR("BAD PATH")); + return webServer.send(500, mimetype, "BAD PATH"); } if(!HASP_FS.exists(path)) { - return webServer.send_P(404, mimetype, PSTR("FileNotFound")); + return webServer.send(404, mimetype, "FileNotFound"); + } + bool result; + if(path.endsWith("/")) { + path.remove(path.length() - 1); + result = HASP_FS.rmdir(path); + } else { + result = HASP_FS.remove(path); + } + if(result) { + webServer.send(200, mimetype, String("")); + } else { + webServer.send(405, mimetype, "RemoveFailed"); } - HASP_FS.remove(path); - webServer.send(200, mimetype, String("")); } static void handleFileCreate() @@ -2275,16 +2284,16 @@ static inline int handleFirmwareFile(String path) #if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) if(path == F("/edit.htm")) { return http_send_static_gzip_file(EDIT_HTM_GZ_START, EDIT_HTM_GZ_END, contentType); - } else if(path == F("/hasp.htm")) { // 39 kB - return http_send_static_gzip_file(HASP_HTM_GZ_START, HASP_HTM_GZ_END, contentType); + // } else if(path == F("/hasp.htm")) { // 39 kB + // return http_send_static_gzip_file(HASP_HTM_GZ_START, HASP_HTM_GZ_END, contentType); } else if(path == F("/logo.svg")) { // 300 bytes return http_send_static_gzip_file(LOGO_SVG_GZ_START, LOGO_SVG_GZ_END, contentType); } else if(path == F("/style.css")) { // 11 kB return http_send_static_gzip_file(STYLE_CSS_GZ_START, STYLE_CSS_GZ_END, contentType); } else if(path == F("/vars.css")) { return http_send_static_file(HTTP_VARS_CSS, HTTP_VARS_CSS + sizeof(HTTP_VARS_CSS) - 1, contentType); - // } else if(path == F("/script.js")) { // 3 kB - // return http_send_static_gzip_file(SCRIPT_JS_GZ_START, SCRIPT_JS_GZ_END, contentType); + } else if(path == F("/script.js")) { // 3 kB + return http_send_static_gzip_file(SCRIPT_JS_GZ_START, SCRIPT_JS_GZ_END, contentType); } else if(path == F("/en.json")) { // 2 kB return http_send_static_gzip_file(EN_JSON_GZ_START, EN_JSON_GZ_END, contentType); } else if(path == F("/main.js")) { // 9 kB @@ -2292,8 +2301,8 @@ static inline int handleFirmwareFile(String path) } else if(path == F("/petite-vue.hasp.js")) { // 9 kB return http_send_static_gzip_file(PETITE_VUE_HASP_JS_GZ_START, PETITE_VUE_HASP_JS_GZ_END, contentType); #if ESP_FLASH_SIZE > 4 - } else if(path == F("/ace.js")) { // 96 kB - return http_send_static_gzip_file(ACE_JS_GZ_START, ACE_JS_GZ_END, contentType); + // } else if(path == F("/ace.js")) { // 96 kB + // return http_send_static_gzip_file(ACE_JS_GZ_START, ACE_JS_GZ_END, contentType); #endif } #endif // ARDUINO_ARCH_ESP32 diff --git a/tools/auto_firmware_version.py b/tools/auto_firmware_version.py index f0a3d901..d4fd4f2e 100644 --- a/tools/auto_firmware_version.py +++ b/tools/auto_firmware_version.py @@ -48,3 +48,21 @@ with open("data/main.js", "r", encoding="utf-8") as f: html = html.replace("COMMIT_HASH", commit_hash) with gzip.open('data/static/main.js.gz', 'wb') as f: f.write(html.encode('utf-8')) + +with open("data/script.js", "r", encoding="utf-8") as f: + html=f.read() +html = html.replace("COMMIT_HASH", commit_hash) +with gzip.open('data/static/script.js.gz', 'wb') as f: + f.write(html.encode('utf-8')) + +with open("data/en.json", "r", encoding="utf-8") as f: + html=f.read() +html = html.replace("COMMIT_HASH", commit_hash) +with gzip.open('data/static/en.json.gz', 'wb') as f: + f.write(html.encode('utf-8')) + +with open("data/style.css", "r", encoding="utf-8") as f: + html=f.read() +html = html.replace("COMMIT_HASH", commit_hash) +with gzip.open('data/static/style.css.gz', 'wb') as f: + f.write(html.encode('utf-8')) diff --git a/tools/esp_merge_bin.py b/tools/esp_merge_bin.py index 6cada46c..4c484f78 100644 --- a/tools/esp_merge_bin.py +++ b/tools/esp_merge_bin.py @@ -58,10 +58,11 @@ def copy_merge_bins(source, target, env): mcu = board.get("build.mcu", "esp32") bootloader = "{}tools{}sdk{}{}{}bin{}bootloader_{}_{}.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, mcu, os.path.sep, os.path.sep, flash_mode, flash_freq) + # # if not os.path.isfile(bootloader): + # # bootloader = "{}tools{}sdk{}bin{}bootloader_dio_40m.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, os.path.sep, os.path.sep, os.path.sep) # if not os.path.isfile(bootloader): - # bootloader = "{}tools{}sdk{}bin{}bootloader_dio_40m.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, os.path.sep, os.path.sep, os.path.sep) - if not os.path.isfile(bootloader): - bootloader = "{}tools{}sdk{}{}{}bin{}bootloader_{}_{}.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, mcu, os.path.sep, os.path.sep, flash_mode, flash_freq) + # bootloader = "{}tools{}sdk{}{}{}bin{}bootloader_{}_{}.bin".format(FRAMEWORK_DIR, os.path.sep, os.path.sep, mcu, os.path.sep, os.path.sep, flash_mode, flash_freq) + bootloader = str(target[0]).replace('firmware.bin','bootloader.bin') bootloader_location = '0x1000' if (mcu == 'esp32s3'): bootloader_location = '0x0000' @@ -94,7 +95,10 @@ def copy_merge_bins(source, target, env): print(f_flash) print(flash_mode) - process = subprocess.Popen(['python', 'tools/esptool_with_merge_bin.py', '--chip', mcu, 'merge_bin', '--output', firmware_dst, '--flash_mode', 'dio', '--flash_size', flash_size, '--flash_freq', flash_freq, bootloader_location, bootloader, '0x8000', partitions, '0xe000', boot_app0, '0x10000', firmware_src], + # esptool = 'tools/esptool_with_merge_bin.py' + esptool = '{}{}esptool.py'.format(platform.get_package_dir("tool-esptoolpy"),os.path.sep) + print(esptool) + process = subprocess.Popen(['python', esptool, '--chip', mcu, 'merge_bin', '--output', firmware_dst, '--flash_mode', 'dio', '--flash_size', flash_size, '--flash_freq', flash_freq, bootloader_location, bootloader, '0x8000', partitions, '0xe000', boot_app0, '0x10000', firmware_src], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() diff --git a/tools/minifiy.py b/tools/minifiy.py new file mode 100644 index 00000000..1c83e7b2 --- /dev/null +++ b/tools/minifiy.py @@ -0,0 +1,69 @@ +import gzip, minify_html + +# options = { +# "do_not_minify_doctype": True, +# "ensure_spec_compliant_unquoted_attribute_values": False, +# "keep_closing_tags": True, +# "keep_html_and_head_opening_tags": True, +# "keep_spaces_between_attributes": True, +# "keep_comments": True, +# "minify_css": True, +# "minify_js": True, +# "remove_bangs": False, +# "remove_processing_instructions": False +# } + +# with open("data/script.js", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/script.js.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/editor.htm", "r") as f: +# html=f.read() +# # minified = minify_html.minify(html, options) +# with gzip.open('data/static/edit.htm.gz', 'wb') as f: +# f.write(html.encode('utf-8')) +# with open('data/edit.htm', 'wb') as f: +# f.write(html.encode('utf-8')) + + +# with open("data/style.css", "r") as f: +# html=f.read() +# with gzip.open('data/static/style.css.gz', 'wb') as f: +# f.write(html.encode('utf-8')) +# minified = minify_html.minify(html, options).replace('"id=mdi-','" id=mdi-') +# with open('data/style.min.css', 'wb') as f: +# f.write(minified.encode('utf-8')) + + +# with open("data/hasp.htm", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/hasp.htm.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + + + +# with open("data/en.json", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/en.json.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/nl.json", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/nl.json.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/fr.json", "r") as f: +# html=f.read() +# minified = minify_html.minify(html, options) +# with gzip.open('data/static/fr.json.gz', 'wb') as f: +# f.write(minified.encode('utf-8')) + +# with open("data/main.js", "r") as f: +# html=f.read() +# with gzip.open('data/static/main.js.gz', 'wb') as f: +# f.write(html.encode('utf-8')) diff --git a/user_setups/esp32/_esp32.ini b/user_setups/esp32/_esp32.ini index 727dce69..5b969c98 100644 --- a/user_setups/esp32/_esp32.ini +++ b/user_setups/esp32/_esp32.ini @@ -23,11 +23,11 @@ board_build.embed_files = data/cert/x509_crt_bundle.bin ; -- new dynamic website files ------------------- data/static/logo.svg.gz - data/static/ace.1.9.6.min.js.gz + ; data/static/ace.1.9.6.min.js.gz data/static/petite-vue.hasp.js.gz data/static/main.js.gz data/static/en.json.gz - data/static/hasp.htm.gz + ; data/static/hasp.htm.gz build_flags = ${env.build_flags}