mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-04-19 12:57:19 +00:00
Add Content-Security-Policy #246
This commit is contained in:
parent
3781ddcf52
commit
f04b01ec1f
@ -11,11 +11,13 @@ 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() {
|
||||
document.getElementById("lic").innerHTML =
|
||||
'<h3>openHASP</h3>Copyright© 2019-2022 Francis Van Roie</br>MIT License</p><p>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:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>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.</p>';
|
||||
document.getElementById("pkg").innerHTML =
|
||||
"<hr><p>Based on the previous work of the following open source developers:</p><h3>HASwitchPlate</h3><p>Copyright© 2019 Allen Derusha allen @derusha.org</b></br>MIT License</p><h3>LVGL</h3><p>Copyright© 2021 LVGL Kft</br>MIT License</p><h3>LovyanGFX</h3><p>Copyright© 2020 lovyan03 (https://github.com/lovyan03) All rights reserved.</br>FreeBSD License</p><h3>TFT_eSPI</h3><p>Copyright© 2020 Bodmer (https://github.com/Bodmer) All rights reserved.</br>FreeBSD License</p><h3>Adafruit_GFX</h3><p>Copyright© 2012 Adafruit Industries. All rights reserved</br>BSD License</p><h3>ArduinoJson</h3><p>Copyright© 2014-2021 Benoit BLANCHON</br>MIT License</p><h3>PubSubClient</h3><p>Copyright© 2008-2015 Nicholas O'Leary</br>MIT License</p><h3>ArduinoLog</h3><p>Copyright© 2017,2018 Thijs Elenbaas, MrRobot62, rahuldeo2047, NOX73, dhylands, Josha blemasle, mfalkvidd</br>MIT License</p><h3>QR Code generator</h3><p>Copyright© Project Nayuki</br>MIT License</p><h3>SimpleFTPServer</h3><p>Copyright© 2017 Renzo Mischianti www.mischianti.org All right reserved.</br>MIT License</p><h3>AceButton</h3><p>Copyright© 2018 Brian T. Park</br>MIT License</p>";
|
||||
ihtm("lic",'<h3>openHASP</h3>Copyright© 2019-2022 Francis Van Roie</br>MIT License</p><p>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:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>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.</p>');
|
||||
ihtm("pkg","<hr><p>Based on the previous work of the following open source developers:</p><h3>HASwitchPlate</h3><p>Copyright© 2019 Allen Derusha allen @derusha.org</b></br>MIT License</p><h3>LVGL</h3><p>Copyright© 2021 LVGL Kft</br>MIT License</p><h3>LovyanGFX</h3><p>Copyright© 2020 lovyan03 (https://github.com/lovyan03) All rights reserved.</br>FreeBSD License</p><h3>TFT_eSPI</h3><p>Copyright© 2020 Bodmer (https://github.com/Bodmer) All rights reserved.</br>FreeBSD License</p><h3>Adafruit_GFX</h3><p>Copyright© 2012 Adafruit Industries. All rights reserved</br>BSD License</p><h3>ArduinoJson</h3><p>Copyright© 2014-2021 Benoit BLANCHON</br>MIT License</p><h3>PubSubClient</h3><p>Copyright© 2008-2015 Nicholas O'Leary</br>MIT License</p><h3>ArduinoLog</h3><p>Copyright© 2017,2018 Thijs Elenbaas, MrRobot62, rahuldeo2047, NOX73, dhylands, Josha blemasle, mfalkvidd</br>MIT License</p><h3>QR Code generator</h3><p>Copyright© Project Nayuki</br>MIT License</p><h3>SimpleFTPServer</h3><p>Copyright© 2017 Renzo Mischianti www.mischianti.org All right reserved.</br>MIT License</p><h3>AceButton</h3><p>Copyright© 2018 Brian T. Park</br>MIT License</p>");
|
||||
}
|
||||
function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
@ -23,15 +25,19 @@ function handleSubmit(e) {
|
||||
o = Object.fromEntries(t.entries());
|
||||
console.log({ value: o });
|
||||
}
|
||||
function info() {
|
||||
data = JSON.parse(this.response);
|
||||
var e = "<table>";
|
||||
for (let t in data) {
|
||||
e += `<tr><td colspan=2></td></tr><tr><th colspan=2>${t}</th></tr>`;
|
||||
for (let o in data[t])
|
||||
e += `<tr><td>${o}: </td><td>${data[t][o]}</td></tr>`;
|
||||
function info2() {
|
||||
try {
|
||||
data = JSON.parse(this.response);
|
||||
var e = "<table>";
|
||||
for (let t in data) {
|
||||
e += `<tr><td colspan=2></td></tr><tr><th colspan=2>${t}</th></tr>`;
|
||||
for (let o in data[t])
|
||||
e += `<tr><td>${o}: </td><td>${data[t][o]}</td></tr>`;
|
||||
}
|
||||
(e += "</table>"), (document.getElementById("info").innerHTML = e);
|
||||
} catch (e) {
|
||||
console.log('invalid json');
|
||||
}
|
||||
(e += "</table>"), (document.getElementById("info").innerHTML = e);
|
||||
}
|
||||
function loader(e, t, o) {
|
||||
window.addEventListener("load", function () {
|
||||
@ -39,9 +45,19 @@ function loader(e, t, o) {
|
||||
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() {
|
||||
data = JSON.parse(this.response);
|
||||
for (const form of document.forms) populate(form, data);
|
||||
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 () {
|
||||
@ -53,6 +69,12 @@ 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)) {
|
||||
@ -101,3 +123,11 @@ function populate(e, t, o) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window.addEventListener('load', (event) => {
|
||||
console.log('The page has fully loaded');
|
||||
forms();
|
||||
info();
|
||||
about();
|
||||
});
|
Binary file not shown.
@ -611,7 +611,8 @@ static void webHandleAbout()
|
||||
|
||||
httpMessage += "<div id='lic'></div>";
|
||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||
httpMessage += "<div id='pkg'></div><script>window.addEventListener('load', about());</script>";
|
||||
httpMessage += "<div id='pkg'></div>";
|
||||
// TOREMOVE httpMessage += "<script>window.addEventListener('load', about());</script>";
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
@ -633,7 +634,8 @@ static void webHandleInfoJson()
|
||||
htmldata += haspDevice.get_hostname();
|
||||
htmldata += F("</h1><hr>");
|
||||
|
||||
htmldata += "<div id=\"info\"></div><script>loader(\"GET\", \"/api/info/\", info)</script>";
|
||||
htmldata += "<div id=\"info\"></div>";
|
||||
// TOREMOVE httpdata += "<script>loader(\"GET\", \"/api/info/\", info)</script>";
|
||||
htmldata += FPSTR(MAIN_MENU_BUTTON);
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), htmldata.length(), 0);
|
||||
@ -1151,7 +1153,7 @@ static void webHandleMqttConfig()
|
||||
httpMessage += F("</form></div>");
|
||||
|
||||
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
|
||||
// httpMessage += "<script>filler(\"GET\", \"/api/config/mqtt/\")</script>";
|
||||
// TOREMOVE httpMessage += "<script>filler(\"GET\", \"/api/config/mqtt/\")</script>";
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
@ -1247,7 +1249,7 @@ static void webHandleGuiConfig()
|
||||
|
||||
add_form_button(httpMessage, F(D_HTTP_ANTIBURN), F("/config/gui?brn=1"));
|
||||
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
|
||||
// httpMessage += F("<script>filler(\"GET\",\"/api/config/gui/\")</script>");
|
||||
// TOREMOVE httpMessage += F("<script>filler(\"GET\",\"/api/config/gui/\")</script>");
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
@ -1305,7 +1307,7 @@ static void webHandleWifiConfig()
|
||||
}
|
||||
#endif // HASP_USE_WIFI
|
||||
|
||||
// httpMessage += F("<script>filler(\"GET\",\"/api/config/wifi/\")</script>");
|
||||
// TOREMOVE httpMessage += F("<script>filler(\"GET\",\"/api/config/wifi/\")</script>");
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
@ -1348,7 +1350,7 @@ static void webHandleHttpConfig()
|
||||
httpMessage += F("</form></div>");
|
||||
|
||||
httpMessage += F("<a href='/config'>" D_HTTP_CONFIGURATION "</a>");
|
||||
// httpMessage += F("<script>filler(\"GET\",\"/api/config/http/\")</script>");
|
||||
// TOREMOVE httpMessage += F("<script>filler(\"GET\",\"/api/config/http/\")</script>");
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
@ -1792,7 +1794,7 @@ static void webHandleDebugConfig()
|
||||
// *******************************************************************
|
||||
|
||||
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
|
||||
// httpMessage += F("<script>filler(\"GET\",\"/api/config/debug/\")</script>");
|
||||
// TOREMOVE httpMessage += F("<script>filler(\"GET\",\"/api/config/debug/\")</script>");
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
@ -1909,7 +1911,7 @@ static void webHandleHaspConfig()
|
||||
httpMessage += F("</form></div>");
|
||||
|
||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||
// httpMessage += F("<script>filler(\"GET\",\"/api/config/hasp/\")</script>");
|
||||
// TOREMOVE httpMessage += F("<script>filler(\"GET\",\"/api/config/hasp/\")</script>");
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
@ -2039,7 +2041,7 @@ static void webHandleFirmware()
|
||||
httpMessage += F("</form></div>");
|
||||
|
||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||
// httpMessage += "<script>filler(\"GET\", \"/api/config/ota/\")</script>";
|
||||
// TOREMOVE TOREMOVE httpMessage += "<script>filler(\"GET\", \"/api/config/ota/\")</script>";
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), 0);
|
||||
webServer.sendContent(httpMessage);
|
||||
|
Loading…
x
Reference in New Issue
Block a user