consolidate test-ip definition, added missing Access-Control-Allow-Origin,

This commit is contained in:
CaCO3
2023-01-02 00:53:14 +01:00
parent e6cb9d67ee
commit 56cfeb732e
28 changed files with 266 additions and 263 deletions

View File

@@ -212,6 +212,8 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
return ESP_FAIL; return ESP_FAIL;
} }
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
/* Send HTML file header */ /* Send HTML file header */
httpd_resp_sendstr_chunk(req, "<!DOCTYPE html><html><body>"); httpd_resp_sendstr_chunk(req, "<!DOCTYPE html><html><body>");
@@ -344,12 +346,6 @@ static esp_err_t send_datafile(httpd_req_t *req, bool send_full_file)
ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath); ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
// Since the log file is still could open for writing, we need to close it first
LogFile.CloseLogFileAppendHandle();
fd = fopen(currentfilename.c_str(), "r"); fd = fopen(currentfilename.c_str(), "r");
if (!fd) { if (!fd) {
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: " + std::string(filepath) +"!"); LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Failed to read existing file: " + std::string(filepath) +"!");
@@ -434,6 +430,8 @@ static esp_err_t send_logfile(httpd_req_t *req, bool send_full_file)
ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath); ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
// Since the log file is still could open for writing, we need to close it first
LogFile.CloseLogFileAppendHandle();
fd = fopen(currentfilename.c_str(), "r"); fd = fopen(currentfilename.c_str(), "r");
if (!fd) { if (!fd) {
@@ -614,6 +612,8 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
FILE *fd = NULL; FILE *fd = NULL;
struct stat file_stat; struct stat file_stat;
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
/* Skip leading "/upload" from URI to get filename */ /* Skip leading "/upload" from URI to get filename */
/* Note sizeof() counts NULL termination hence the -1 */ /* Note sizeof() counts NULL termination hence the -1 */
const char *filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path, const char *filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path,
@@ -764,6 +764,8 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
std::string directory; std::string directory;
std::string zw; std::string zw;
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK) if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
{ {
ESP_LOGD(TAG, "Query: %s", _query); ESP_LOGD(TAG, "Query: %s", _query);

View File

@@ -666,7 +666,7 @@ esp_err_t handler_reboot(httpd_req_t *req)
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handler_reboot"); LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handler_reboot");
ESP_LOGI(TAG, "!!! System will restart within 5 sec!!!"); ESP_LOGI(TAG, "!!! System will restart within 5 sec!!!");
const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s<br>(in case of a firmware update it can take up to 180s).<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch('/reboot_page.html',{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);</script>"; const char* resp_str = "<body style='font-family: arial'> <h3 id=t></h3></body><script>var h='Rebooting!<br>The page will automatically reload in around 25..60s<br>(in case of a firmware update it can take up to 180s).<br>'; document.getElementById('t').innerHTML=h; setInterval(function (){h +='.'; document.getElementById('t').innerHTML=h; fetch('reboot_page.html',{mode: 'no-cors'}).then(r=>{parent.location.href=('index.html');})}, 1000);</script>";
httpd_resp_send(req, resp_str, strlen(resp_str)); httpd_resp_send(req, resp_str, strlen(resp_str));
doReboot(); doReboot();

View File

@@ -147,6 +147,7 @@ esp_err_t handler_init(httpd_req_t *req)
doInit(); doInit();
resp_str = "Init done<br>"; resp_str = "Init done<br>";
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, resp_str, strlen(resp_str)); httpd_resp_send(req, resp_str, strlen(resp_str));
/* Respond with an empty chunk to signal HTTP response completion */ /* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
@@ -179,6 +180,8 @@ esp_err_t handler_flow_start(httpd_req_t *req) {
httpd_resp_send(req, resp_str, strlen(resp_str)); httpd_resp_send(req, resp_str, strlen(resp_str));
} }
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
/* Respond with an empty chunk to signal HTTP response completion */ /* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0); httpd_resp_send_chunk(req, NULL, 0);
@@ -421,6 +424,8 @@ esp_err_t handler_editflow(httpd_req_t *req)
char _valuechar[30]; char _valuechar[30];
string _task; string _task;
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK) if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
{ {
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK) if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)

View File

@@ -40,20 +40,18 @@ input[type=number] {
</body> </body>
<script src="common.js"></script>
<script src="jszip.min.js"></script> <script src="jszip.min.js"></script>
<script src="FileSaver.min.js"></script> <script src="FileSaver.min.js"></script>
<script> <script>
//var domain = "http://192.168.1.153"; // Testing
var domain = "";
function startBackup() { function startBackup() {
document.getElementById("progress").innerHTML = "Creating backup...<br>\n"; document.getElementById("progress").innerHTML = "Creating backup...<br>\n";
// Get hostname // Get hostname
try { try {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.open("GET", domain + "/info?type=Hostname", false); xhttp.open("GET", getDomainname() + "/info?type=Hostname", false);
xhttp.send(); xhttp.send();
hostname = xhttp.responseText; hostname = xhttp.responseText;
} }
@@ -72,7 +70,7 @@ function startBackup() {
setStatus("Fetching File List..."); setStatus("Fetching File List...");
try { try {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.open("GET", domain + "/fileserver/config/", false); xhttp.open("GET", getDomainname() + "/fileserver/config/", false);
xhttp.send(); xhttp.send();
var parser = new DOMParser(); var parser = new DOMParser();
@@ -88,7 +86,7 @@ function startBackup() {
for (a of list) { for (a of list) {
url = a.getAttribute("href"); url = a.getAttribute("href");
urls.push(domain + url); urls.push(getDomainname() + url);
} }
// Pack as zip and download // Pack as zip and download

View File

@@ -1,8 +1,52 @@
var basepath = "http://192.168.178.22"; /* The UI can also be run locally, but you have to set the IP of your devide accordingly.
* And you also might have to disable CORS in your webbrowser! */
var domainname_for_testing = "192.168.1.153";
function gethost_Version(){
return "1.0.0 - 20200910";
}
/* Returns the domainname with prepended protocol.
Eg. http://watermeter.fritz.box or http://192.168.1.5 */
function getDomainname(){
var host = window.location.hostname;
if (((host == "127.0.0.1") || (host == "localhost") || (host == ""))
// && ((window.location.port == "80") || (window.location.port == ""))
)
{
console.log("Using pre-defined domainname for testing: " + domainname_for_testing);
domainname = "http://" + domainname_for_testing
}
else
{
domainname = window.location.protocol + "//" + host;
if (window.location.port != "") {
domainname = domainname + ":" + window.location.port;
}
}
return domainname;
}
function UpdatePage(_dosession = true){
var zw = location.href;
zw = zw.substr(0, zw.indexOf("?"));
if (_dosession) {
window.location = zw + '?session=' + Math.floor((Math.random() * 1000000) + 1);
}
else {
window.location = zw;
}
}
function LoadHostname() { function LoadHostname() {
_basepath = getbasepath(); _domainname = getDomainname();
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
@@ -19,7 +63,7 @@ function LoadHostname() {
// var xhttp = new XMLHttpRequest(); // var xhttp = new XMLHttpRequest();
try { try {
url = _basepath + '/info?type=Hostname'; url = _domainname + '/info?type=Hostname';
xhttp.open("GET", url, true); xhttp.open("GET", url, true);
xhttp.send(); xhttp.send();
@@ -35,7 +79,7 @@ var fwVersion = "";
var webUiVersion = ""; var webUiVersion = "";
function LoadFwVersion() { function LoadFwVersion() {
_basepath = getbasepath(); _domainname = getDomainname();
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.addEventListener('load', function(event) { xhttp.addEventListener('load', function(event) {
@@ -52,7 +96,7 @@ function LoadFwVersion() {
}); });
try { try {
url = _basepath + '/info?type=FirmwareVersion'; url = _domainname + '/info?type=FirmwareVersion';
xhttp.open("GET", url, true); xhttp.open("GET", url, true);
xhttp.send(); xhttp.send();
} }
@@ -62,7 +106,7 @@ function LoadFwVersion() {
} }
function LoadWebUiVersion() { function LoadWebUiVersion() {
_basepath = getbasepath(); _domainname = getDomainname();
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.addEventListener('load', function(event) { xhttp.addEventListener('load', function(event) {
@@ -78,7 +122,8 @@ function LoadWebUiVersion() {
}); });
try { try {
url = _basepath + '/info?type=HTMLVersion'; url = _domainname + '/info?type=HTMLVersion';
console.log("url");
xhttp.open("GET", url, true); xhttp.open("GET", url, true);
xhttp.send(); xhttp.send();
} }

View File

@@ -30,21 +30,22 @@
font-size: small; font-size: small;
} }
</style> </style>
<script type="text/javascript" src="common.js"></script>
</head> </head>
<body> <body>
<div class="box"> <div class="box">
<div class="row header"> <div class="row header">
<button onClick="reload();">Reload</button> <button onClick="reload();">Reload</button>
<button onClick="window.open('datafileact');">Show full data</button> <button onClick="window.open(getDomainname() + '/datafileact');">Show full data</button>
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button> <button onClick="window.location.href = getDomainname() + '/fileserver/log/data/'">Show older data files</button>
<a href="graph.html" target="_self">Show graph</a> <button onClick="window.location.href = 'graph.html'">Show graph</button>
</div> </div>
<div class="row content" id="data"><br><br><br><b>Loading Data file, please wait...</b></div> <div class="row content" id="data"><br><br><br><b>Loading Data file, please wait...</b></div>
<div class="row footer"> <div class="row footer">
<button onClick="reload();">Reload</button> <button onClick="reload();">Reload</button>
<button onClick="window.open('datafileact');">Show full data</button> <button onClick="window.open(getDomainname() + '/datafileact');">Show full data</button>
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button> <button onClick="window.location.href = getDomainname() + '/fileserver/log/data/'">Show older data files</button>
<a href="graph.html" target="_self">Show graph</a> <button onClick="window.location.href = 'graph.html'">Show graph</button>
</div> </div>
</div> </div>
</body> </body>
@@ -53,7 +54,7 @@
function reload() { function reload() {
document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>"; document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>";
window.scrollBy(0,document.body.scrollHeight); window.scrollBy(0,document.body.scrollHeight);
funcRequest('data'); funcRequest(getDomainname() + '/data');
} }
async function funcRequest(url){ async function funcRequest(url){
@@ -76,7 +77,7 @@
}); });
} }
funcRequest('data'); funcRequest(getDomainname() + '/data');
</script> </script>
</html> </html>

View File

@@ -93,9 +93,9 @@ select {
</tr> </tr>
</table> </table>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
<script language="JavaScript"> <script language="JavaScript">
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
@@ -107,13 +107,12 @@ select {
refInfo, refInfo,
enhanceCon = false, enhanceCon = false,
param; param;
basepath = "http://192.168.178.26"; domainname = getDomainname();
basepath = "",
param; param;
function doReboot() { function doReboot() {
if (confirm("Are you sure you want to reboot? Did you save the config?")) { if (confirm("Are you sure you want to reboot? Did you save the config?")) {
var stringota = "/reboot"; var stringota = getDomainname() + "/reboot";
window.location = stringota; window.location = stringota;
window.location.href = stringota; window.location.href = stringota;
window.location.assign(stringota); window.location.assign(stringota);
@@ -128,8 +127,8 @@ function ChangeSelection(){
function SaveToConfig(){ function SaveToConfig(){
WriteConfigININew(); WriteConfigININew();
UpdateConfigReference(basepath) UpdateConfigReference(domainname)
SaveConfigToServer(basepath); SaveConfigToServer(domainname);
alert("Config.ini is updated!"); alert("Config.ini is updated!");
} }
@@ -141,7 +140,7 @@ function EnhanceContrast(){
refInfo[aktindex]["dy"] = document.getElementById("refdy").value; refInfo[aktindex]["dy"] = document.getElementById("refdy").value;
enhanceCon = true; enhanceCon = true;
MakeContrastImageZW(refInfo[aktindex], enhanceCon, basepath); MakeContrastImageZW(refInfo[aktindex], enhanceCon, domainname);
UpdateReference(); UpdateReference();
} }
@@ -158,11 +157,11 @@ function UpdateReference(){
_filenameurl = refInfo[aktindex]["name"].replace("/config/", "/img_tmp/"); _filenameurl = refInfo[aktindex]["name"].replace("/config/", "/img_tmp/");
var url = basepath + "/fileserver" + _filenameurl + "?" + Date.now(); var url = domainname + "/fileserver" + _filenameurl + "?" + Date.now();
document.getElementById("img_ref").src = url; document.getElementById("img_ref").src = url;
_filenameurl = _filenameurl.replace(".jpg", "_org.jpg"); _filenameurl = _filenameurl.replace(".jpg", "_org.jpg");
var url = basepath + "/fileserver" + _filenameurl + "?" + Date.now(); var url = domainname + "/fileserver" + _filenameurl + "?" + Date.now();
document.getElementById("img_ref_org").src = url; document.getElementById("img_ref_org").src = url;
document.getElementById("name").value = refInfo[aktindex]["name"]; document.getElementById("name").value = refInfo[aktindex]["name"];
@@ -214,17 +213,17 @@ function dataURLtoBlob(dataurl) {
function init() { function init() {
basepath = getbasepath(); domainname = getDomainname();
loadConfig(basepath); loadConfig(domainname);
ParseConfig(); ParseConfig();
param = getConfigParameters(); param = getConfigParameters();
canvas.addEventListener('mousedown', mouseDown, false); canvas.addEventListener('mousedown', mouseDown, false);
canvas.addEventListener('mouseup', mouseUp, false); canvas.addEventListener('mouseup', mouseUp, false);
canvas.addEventListener('mousemove', mouseMove, false); canvas.addEventListener('mousemove', mouseMove, false);
loadCanvas(basepath + "/fileserver/config/reference.jpg"); loadCanvas(domainname + "/fileserver/config/reference.jpg");
CopyReferenceToImgTmp(basepath); CopyReferenceToImgTmp(domainname);
refInfo = GetReferencesInfo(); refInfo = GetReferencesInfo();
UpdateReference(); UpdateReference();
@@ -247,7 +246,7 @@ function dataURLtoBlob(dataurl) {
refInfo[aktindex]["y"] = document.getElementById("refy").value; refInfo[aktindex]["y"] = document.getElementById("refy").value;
refInfo[aktindex]["dx"] = document.getElementById("refdx").value; refInfo[aktindex]["dx"] = document.getElementById("refdx").value;
refInfo[aktindex]["dy"] = document.getElementById("refdy").value; refInfo[aktindex]["dy"] = document.getElementById("refdy").value;
MakeRefZW(refInfo[aktindex], basepath); MakeRefZW(refInfo[aktindex], domainname);
UpdateReference(); UpdateReference();
document.getElementById("enhancecontrast").disabled = false; document.getElementById("enhancecontrast").disabled = false;
} }

View File

@@ -140,9 +140,9 @@ th, td {
</table> </table>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
<script language="JavaScript"> <script language="JavaScript">
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
@@ -155,11 +155,11 @@ th, td {
enhanceCon = false; enhanceCon = false;
lockAR = true; lockAR = true;
lockSizes = true; lockSizes = true;
basepath = "http://192.168.178.26"; domainname = getDomainname();
function doReboot() { function doReboot() {
if (confirm("Are you sure you want to reboot? Did you save the config?")) { if (confirm("Are you sure you want to reboot? Did you save the config?")) {
var stringota = "/reboot"; var stringota = getDomainname() + "/reboot";
window.location = stringota; window.location = stringota;
window.location.href = stringota; window.location.href = stringota;
window.location.assign(stringota); window.location.assign(stringota);
@@ -280,7 +280,7 @@ function SaveToConfig(){
_zwcat = getConfigCategory(); _zwcat = getConfigCategory();
_zwcat["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked; _zwcat["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked;
WriteConfigININew(); WriteConfigININew();
SaveConfigToServer(basepath); SaveConfigToServer(domainname);
alert("Config.ini is updated!"); alert("Config.ini is updated!");
} }
@@ -398,12 +398,12 @@ function UpdateROIs(_sel){
function init() { function init() {
basepath = getbasepath(); domainname = getDomainname();
canvas.addEventListener('mousedown', mouseDown, false); canvas.addEventListener('mousedown', mouseDown, false);
canvas.addEventListener('mouseup', mouseUp, false); canvas.addEventListener('mouseup', mouseUp, false);
canvas.addEventListener('mousemove', mouseMove, false); canvas.addEventListener('mousemove', mouseMove, false);
loadCanvas(basepath + "/fileserver/config/reference.jpg"); loadCanvas(domainname + "/fileserver/config/reference.jpg");
loadConfig(basepath); loadConfig(domainname);
ParseConfig(); ParseConfig();
param = getConfigParameters(); param = getConfigParameters();
UpdateNUMBERS(); UpdateNUMBERS();

View File

@@ -50,22 +50,22 @@ p {font-size: 1em;}
</tr> </tr>
</table> </table>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfig.js"></script> <script type="text/javascript" src="readconfig.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var basepath = "http://192.168.178.26"; var domainname = getDomainname();
function doAnalog(){ function doAnalog(){
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
url = basepath + "/editflow?task=test_analog"; url = domainname + "/editflow?task=test_analog";
if (basepath.length > 0){ if (domainname.length > 0){
url = url + "&host=" + basepath; url = url + "&host=" + domainname;
} }
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
var html = xhttp.responseText; var html = xhttp.responseText;
html = html.replace("src=\"/", "src=\"" + basepath + "/"); html = html.replace("src=\"/", "src=\"" + domainname + "/");
document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html); document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html);
} }
@@ -73,14 +73,14 @@ p {font-size: 1em;}
function doDigits(){ function doDigits(){
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
url = basepath + "/editflow?task=test_digits"; url = domainname + "/editflow?task=test_digits";
if (basepath.length > 0){ if (domainname.length > 0){
url = url + "&host=" + basepath; url = url + "&host=" + domainname;
} }
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
var html = xhttp.responseText; var html = xhttp.responseText;
html = html.replace("src=\"/", "src=\"" + basepath + "/"); html = html.replace("src=\"/", "src=\"" + domainname + "/");
document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html); document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html);
} }
@@ -88,14 +88,14 @@ p {font-size: 1em;}
function doAlign(){ function doAlign(){
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
url = basepath + "/editflow?task=test_align"; url = domainname + "/editflow?task=test_align";
if (basepath.length > 0){ if (domainname.length > 0){
url = url + "&host=" + basepath; url = url + "&host=" + domainname;
} }
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
var html = xhttp.responseText; var html = xhttp.responseText;
html = html.replace("src=\"/", "src=\"" + basepath + "/"); html = html.replace("src=\"/", "src=\"" + domainname + "/");
document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html); document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html);
@@ -107,9 +107,9 @@ p {font-size: 1em;}
function doTake(){ function doTake(){
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
url = basepath + "/editflow?task=test_take"; url = domainname + "/editflow?task=test_take";
if (basepath.length > 0){ if (domainname.length > 0){
url = url + "&host=" + basepath; url = url + "&host=" + domainname;
} }
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
@@ -122,7 +122,7 @@ p {font-size: 1em;}
} }
function Init(){ function Init(){
basepath = getbasepath(); domainname = getDomainname();
document.getElementById("align").disabled = true; document.getElementById("align").disabled = true;
document.getElementById("digits").disabled = true; document.getElementById("digits").disabled = true;
document.getElementById("analog").disabled = true; document.getElementById("analog").disabled = true;

View File

@@ -41,26 +41,26 @@ textarea {
</tr> </tr>
</table> </table>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
basepath = "http://192.168.178.26"; domainname = getDomainname();
function LoadConfigNeu() { function LoadConfigNeu() {
basepath = getbasepath(); domainname = getDomainname();
loadConfig(basepath); loadConfig(domainname);
document.getElementById("inputTextToSave").value = getConfig(); document.getElementById("inputTextToSave").value = getConfig();
} }
function saveTextAsFile() function saveTextAsFile()
{ {
if (confirm("Are you sure you want to update \"config.ini\"?")) { if (confirm("Are you sure you want to update \"config.ini\"?")) {
FileDeleteOnServer("/config/config.ini", basepath); FileDeleteOnServer("/config/config.ini", domainname);
var textToSave = document.getElementById("inputTextToSave").value; var textToSave = document.getElementById("inputTextToSave").value;
FileSendContent(textToSave, "/config/config.ini", basepath); FileSendContent(textToSave, "/config/config.ini", domainname);
alert("Config.ini is updated!") alert("Config.ini is updated!")
} }
} }

View File

@@ -1427,13 +1427,13 @@ textarea {
</div> </div>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
basepath = "http://192.168.178.22"; domainname = getDomainname();
param; param;
category; category;
NUNBERSAkt = -1; NUNBERSAkt = -1;
@@ -1448,8 +1448,8 @@ function LoadConfigNeu() {
} }
basepath = getbasepath(); domainname = getDomainname();
if (!loadConfig(basepath)) { if (!loadConfig(domainname)) {
alert("Config.ini could not be loaded!\nPlease reload the page."); alert("Config.ini could not be loaded!\nPlease reload the page.");
return; return;
} }
@@ -2064,14 +2064,14 @@ function saveTextAsFile()
if (confirm("Are you sure you want to update \"config.ini\"?")) { if (confirm("Are you sure you want to update \"config.ini\"?")) {
ReadParameterAll(); ReadParameterAll();
WriteConfigININew(); WriteConfigININew();
SaveConfigToServer(basepath); SaveConfigToServer(domainname);
alert("Config.ini is updated!") alert("Config.ini is updated!")
} }
} }
function doReboot() { function doReboot() {
if (confirm("Are you sure you want to reboot the ESP32?")) { if (confirm("Are you sure you want to reboot the ESP32?")) {
var stringota = "/reboot"; var stringota = getDomainname() + "/reboot";
window.location = stringota; window.location = stringota;
window.location.href = stringota; window.location.href = stringota;
window.location.assign(stringota); window.location.assign(stringota);
@@ -2081,7 +2081,7 @@ function doReboot() {
function editConfigDirect() { function editConfigDirect() {
if (confirm("Did you save your changes?")) { if (confirm("Did you save your changes?")) {
var stringota = "/edit_config.html"; var stringota = getDomainname() + "/edit_config.html";
window.location = stringota; window.location = stringota;
window.location.href = stringota; window.location.href = stringota;
window.location.assign(stringota); window.location.assign(stringota);

View File

@@ -131,11 +131,11 @@ th, td {
</tr> </tr>
</table> </table>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
<script type="text/javascript" src="./jquery-3.6.0.min.js"></script> <script type="text/javascript" src="jquery-3.6.0.min.js"></script>
<script language="JavaScript"> <script language="JavaScript">
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
@@ -149,11 +149,11 @@ th, td {
lockSizes = true; lockSizes = true;
lockSpaceEquidistant = true; lockSpaceEquidistant = true;
space = 3; space = 3;
basepath = "http://192.168.1.151"; domainname = getDomainname();
function doReboot() { function doReboot() {
if (confirm("Are you sure you want to reboot? Did you save the config?")) { if (confirm("Are you sure you want to reboot? Did you save the config?")) {
var stringota = "/reboot"; var stringota = getDomainname() + "/reboot";
window.location = stringota; window.location = stringota;
window.location.href = stringota; window.location.href = stringota;
window.location.assign(stringota); window.location.assign(stringota);
@@ -283,7 +283,7 @@ function SaveToConfig(){
_zwcat = getConfigCategory(); _zwcat = getConfigCategory();
_zwcat["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked; _zwcat["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked;
WriteConfigININew(); WriteConfigININew();
SaveConfigToServer(basepath); SaveConfigToServer(domainname);
alert("Config.ini is updated!"); alert("Config.ini is updated!");
} }
@@ -400,12 +400,12 @@ function UpdateROIs(_sel){
} }
function init() { function init() {
basepath = getbasepath(); domainname = getDomainname();
canvas.addEventListener('mousedown', mouseDown, false); canvas.addEventListener('mousedown', mouseDown, false);
canvas.addEventListener('mouseup', mouseUp, false); canvas.addEventListener('mouseup', mouseUp, false);
canvas.addEventListener('mousemove', mouseMove, false); canvas.addEventListener('mousemove', mouseMove, false);
loadCanvas(basepath + "/fileserver/config/reference.jpg"); loadCanvas(domainname + "/fileserver/config/reference.jpg");
loadConfig(basepath); loadConfig(domainname);
ParseConfig(); ParseConfig();
param = getConfigParameters(); param = getConfigParameters();
UpdateNUMBERS(); UpdateNUMBERS();

View File

@@ -41,19 +41,19 @@ p {font-size: 1em;}
<button class="button" onclick="reboot()">Leave Setup Modus and Reboot to Normal modus</button> <button class="button" onclick="reboot()">Leave Setup Modus and Reboot to Normal modus</button>
</p> </p>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
basepath = "http://192.168.178.22"; domainname = getDomainname();
aktstatu = 0; aktstatu = 0;
function reboot() { function reboot() {
if (confirm("Do you want to leave the configuration mode and restart the ESP32?\n\nPlease reload the page in about 30s.")) { if (confirm("Do you want to leave the configuration mode and restart the ESP32?\n\nPlease reload the page in about 30s.")) {
basepath = getbasepath(); domainname = getDomainname();
if (!loadConfig(basepath)) { if (!loadConfig(domainname)) {
alert("Setup Modus could not be deactivated!\Please retry."); alert("Setup Modus could not be deactivated!\Please retry.");
return; return;
} }
@@ -63,7 +63,7 @@ p {font-size: 1em;}
param["System"]["SetupMode"]["value1"] = "false"; param["System"]["SetupMode"]["value1"] = "false";
WriteConfigININew(); WriteConfigININew();
SaveConfigToServer(basepath); SaveConfigToServer(domainname);
var stringota = "/reboot"; var stringota = "/reboot";

View File

@@ -93,9 +93,9 @@ table {
</table> </table>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
@@ -103,13 +103,13 @@ table {
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d'), ctx = canvas.getContext('2d'),
imageObj = new Image() imageObj = new Image()
basepath = "http://192.168.178.26"; domainname = getDomainname();
isActReference = false; isActReference = false;
param; param;
function doReboot() { function doReboot() {
if (confirm("Are you sure you want to reboot? Did you save the config?")) { if (confirm("Are you sure you want to reboot? Did you save the config?")) {
var stringota = "/reboot"; var stringota = getDomainname() + "/reboot";
window.location = stringota; window.location = stringota;
window.location.href = stringota; window.location.href = stringota;
window.location.assign(stringota); window.location.assign(stringota);
@@ -126,15 +126,15 @@ table {
_brightness = document.getElementById("MakeImage_Brightness_value1").value; _brightness = document.getElementById("MakeImage_Brightness_value1").value;
_contrast = document.getElementById("MakeImage_Contrast_value1").value; _contrast = document.getElementById("MakeImage_Contrast_value1").value;
_saturation = document.getElementById("MakeImage_Saturation_value1").value; _saturation = document.getElementById("MakeImage_Saturation_value1").value;
url = basepath + "/editflow?task=test_take&bri=" + _brightness; url = getDomainname() + "/editflow?task=test_take&bri=" + _brightness;
url = url + "&con=" + _saturation + "&sat=" + _saturation + "&int=" + _intensity; url = url + "&con=" + _saturation + "&sat=" + _saturation + "&int=" + _intensity;
} }
else else
{ {
url = basepath + "/editflow?task=test_take"; url = domainname + "/editflow?task=test_take";
} }
if (basepath.length > 0){ if (domainname.length > 0){
url = url + "&host=" + basepath; url = url + "&host=" + domainname;
} }
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
@@ -145,7 +145,7 @@ table {
} }
function loadRawImage(){ function loadRawImage(){
url = basepath + "/img_tmp/raw.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1); url = getDomainname() + "/img_tmp/raw.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);
document.getElementById("finerotate").disabled = false; document.getElementById("finerotate").disabled = false;
document.getElementById("prerotateangle").disabled = false; document.getElementById("prerotateangle").disabled = false;
document.getElementById("updatereferenceimage").disabled = false; document.getElementById("updatereferenceimage").disabled = false;
@@ -189,7 +189,7 @@ table {
} }
function showReference(_param){ function showReference(_param){
url = basepath + "/fileserver/config/reference.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);; url = getDomainname() + "/fileserver/config/reference.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);;
document.getElementById("finerotate").value = 0; document.getElementById("finerotate").value = 0;
document.getElementById("prerotateangle").value = _param["Alignment"]["InitialRotate"].value1; document.getElementById("prerotateangle").value = _param["Alignment"]["InitialRotate"].value1;
@@ -263,9 +263,9 @@ table {
drawRotated(false); drawRotated(false);
WriteConfigININew(); WriteConfigININew();
SaveConfigToServer(basepath); SaveConfigToServer(getDomainname());
SaveCanvasToImage(canvas, "/config/reference.jpg", true, basepath); SaveCanvasToImage(canvas, "/config/reference.jpg", true, getDomainname());
showReference(param); showReference(param);
UpdatePage(); UpdatePage();
alert("Reference is updated!"); alert("Reference is updated!");
@@ -301,8 +301,7 @@ table {
function init() { function init() {
canvas.addEventListener('mousemove', mouseMove, false); canvas.addEventListener('mousemove', mouseMove, false);
basepath = getbasepath(); loadConfig(getDomainname());
loadConfig(basepath);
ParseConfig(); ParseConfig();
param = getConfigParameters(); param = getConfigParameters();

View File

@@ -1,41 +0,0 @@
function gethost_Version(){
return "1.0.0 - 20200910";
}
function getbasepath(){
var host = window.location.hostname;
if (((host == "127.0.0.1") || (host == "localhost") || (host == ""))
// && ((window.location.port == "80") || (window.location.port == ""))
)
{
// host = "http://192.168.2.219"; // jomjol interner test
// host = "http://192.168.178.46"; // jomjol interner test
host = "http://192.168.178.44"; // jomjol interner Real
// host = "http://192.168.43.191";
// host = "."; // jomjol interner localhost
}
else
{
host = window.location.protocol + "//" + host;
if (window.location.port != "") {
host = host + ":" + window.location.port;
}
}
return host;
}
function UpdatePage(_dosession = true){
var zw = location.href;
zw = zw.substr(0, zw.indexOf("?"));
if (_dosession) {
window.location = zw + '?session=' + Math.floor((Math.random() * 1000000) + 1);
}
else {
window.location = zw;
}
}

View File

@@ -2,9 +2,9 @@
<head> <head>
<script src='https://cdn.plot.ly/plotly-2.14.0.min.js'></script> <script src='https://cdn.plot.ly/plotly-2.14.0.min.js'></script>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
<style> <style>
textarea { textarea {
@@ -31,7 +31,7 @@
<option value="6">Change-Absolut</option> <option value="6">Change-Absolut</option>
</select> </select>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=fileserver/log/data/>Download</a> <button onClick="window.location.href = getDomainname() + '/fileserver/log/data/'">Show data files</button>
<!-- <button onclick="document.getElementById('editor').hidden = false; this.hidden = true;" >Editor</button> --> <!-- <button onclick="document.getElementById('editor').hidden = false; this.hidden = true;" >Editor</button> -->
<div id='editor' hidden='true'> <div id='editor' hidden='true'>
@@ -41,8 +41,8 @@ numbername = document.getElementById("numbers").value;
datatype = document.getElementById("datatype").value; datatype = document.getElementById("datatype").value;
//alert("Auslesen: " + datefile + " " + numbername); //alert("Auslesen: " + datefile + " " + numbername);
_basepath = getbasepath(); _domainname = getDomainname();
fetch(_basepath + '/fileserver/log/data/' + datefile) fetch(_domainname + '/fileserver/log/data/' + datefile)
.then(response => { .then(response => {
// handle the response // handle the response
if (response.status == 404) { if (response.status == 404) {

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="style.css" type="text/css" > <link rel="stylesheet" href="style.css" type="text/css" >
<script type="text/javascript" src="common.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
@@ -79,9 +79,9 @@
</li> </li>
</ul> </ul>
<li><a href="#" onclick="loadPage('value?full');">Recognition</a></li> <li><a href="#" onclick="loadPage(getDomainname() + '/value?full');">Recognition</a></li>
<li><a href="#" onclick="loadPage('graph.html');">Data Graph</a></li> <li><a href="#" onclick="loadPage('graph.html');">Data Graph</a></li>
<li><a href="#" onclick="loadPage('fileserver/');">File Server</a></li> <li><a href="#" onclick="loadPage(getDomainname() + '/fileserver/');">File Server</a></li>
<li><a>System <i class="arrow down"></i></a> <li><a>System <i class="arrow down"></i></a>
<ul class="submenu"> <ul class="submenu">
<li><a href="#" onclick="loadPage('backup.html');">Backup/Restore</a></li> <li><a href="#" onclick="loadPage('backup.html');">Backup/Restore</a></li>

View File

@@ -30,19 +30,20 @@
font-size: small; font-size: small;
} }
</style> </style>
<script type="text/javascript" src="common.js"></script>
</head> </head>
<body> <body>
<div class="box"> <div class="box">
<div class="row header"> <div class="row header">
<button onClick="reload();">Reload</button> <button onClick="reload();">Reload</button>
<button onClick="window.open('logfileact');">Show full log</button> <button onClick="window.open(getDomainname() + '/logfileact');">Show full log</button>
<button onClick="window.location.href = 'fileserver/log/message/'">Show older log files</button> <button onClick="window.location.href = getDomainname() + '/fileserver/log/message/'">Show older log files</button>
</div> </div>
<div class="row content" id="log"><br><br><br><b>Loading Logfile, please wait...</b></div> <div class="row content" id="log"><br><br><br><b>Loading Logfile, please wait...</b></div>
<div class="row footer"> <div class="row footer">
<button onClick="reload();">Reload</button> <button onClick="reload();">Reload</button>
<button onClick="window.open('logfileact');">Show full log</button> <button onClick="window.open(getDomainname() + '/logfileact');">Show full log</button>
<button onClick="window.location.href = 'fileserver/log/message/'">Show older log files</button> <button onClick="window.location.href = getDomainname() + '/fileserver/log/message/'">Show older log files</button>
</div> </div>
</div> </div>
</body> </body>
@@ -52,7 +53,7 @@
// document.getElementById('log').innerHTML += "<br><b>Reloading...<b><br><br>"; // document.getElementById('log').innerHTML += "<br><b>Reloading...<b><br><br>";
document.getElementById('log').innerHTML += "<b>Reloading...</b>"; document.getElementById('log').innerHTML += "<b>Reloading...</b>";
window.scrollBy(0,document.body.scrollHeight); window.scrollBy(0,document.body.scrollHeight);
funcRequest('log'); funcRequest(getDomainname() + '/log');
} }
@@ -102,7 +103,7 @@
}); });
} }
funcRequest('log'); funcRequest(getDomainname() + '/log');
</script> </script>
</html> </html>

View File

@@ -5,7 +5,7 @@
<title>OTA Update</title> <title>OTA Update</title>
<meta charset="utf-8"> <meta charset="utf-8">
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<style> <style>
h1 {font-size: 2em;} h1 {font-size: 2em;}
h2 {font-size: 1.5em;} h2 {font-size: 1.5em;}
@@ -69,7 +69,7 @@ web interface (<i><span style="font-family:monospace">html__*.zip</span></i>). H
<script language="JavaScript"> <script language="JavaScript">
var basepath = "http://192.168.178.26"; var domainname = getDomainname();
/* Max size of an individual file. Make sure this /* Max size of an individual file. Make sure this
@@ -82,7 +82,7 @@ var progressTimerHandle = null;
function init(){ function init(){
basepath = getbasepath(); domainname = getDomainname();
document.getElementById("doUpdate").disabled = true; document.getElementById("doUpdate").disabled = true;
} }
@@ -159,7 +159,7 @@ function prepareOnServer() {
startProgressTimer("Server preparations..."); startProgressTimer("Server preparations...");
var _toDo = basepath + "/ota?task=emptyfirmwaredir"; var _toDo = domainname + "/ota?task=emptyfirmwaredir";
xhttp.open("GET", _toDo, true); xhttp.open("GET", _toDo, true);
xhttp.send(); xhttp.send();
} }
@@ -235,7 +235,7 @@ function extract() {
var nameneu = document.getElementById("newfile").value; var nameneu = document.getElementById("newfile").value;
filePath = nameneu.split(/[\\\/]/).pop(); filePath = nameneu.split(/[\\\/]/).pop();
var _toDo = basepath + "/ota?task=update&file=" + filePath; var _toDo = domainname + "/ota?task=update&file=" + filePath;
xhttp.open("GET", _toDo, true); xhttp.open("GET", _toDo, true);
xhttp.send(); xhttp.send();
} }

View File

@@ -68,9 +68,9 @@
</table> </table>
<script src="/jquery-3.6.0.min.js"></script> <script src="jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function addZero(i) { function addZero(i) {
@@ -106,7 +106,7 @@ function addZero(i) {
var h = addZero(d.getHours()); var h = addZero(d.getHours());
var m = addZero(d.getMinutes()); var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds()); var s = addZero(d.getSeconds());
$('#img').html('<img src="/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'" max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>'); $('#img').html('<img src=' + getDomainname() + '/img_tmp/alg_roi.jpg?timestamp='+ timestamp +'" max-height:555px; display:block; margin-left:auto; margin-right:auto;"></img>');
$('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s)); $('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s));
} }
@@ -121,7 +121,7 @@ function addZero(i) {
function loadStatus() { function loadStatus() {
url = basepath + '/statusflow'; url = domainname + '/statusflow';
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@@ -135,7 +135,7 @@ function addZero(i) {
function loadCPUTemp() { function loadCPUTemp() {
url = basepath + '/cpu_temperature'; url = domainname + '/cpu_temperature';
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@@ -149,7 +149,7 @@ function addZero(i) {
function loadRSSI() { function loadRSSI() {
url = basepath + '/rssi'; url = domainname + '/rssi';
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@@ -163,7 +163,7 @@ function addZero(i) {
function loadUptime() { function loadUptime() {
url = basepath + '/uptime'; url = domainname + '/uptime';
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@@ -177,7 +177,7 @@ function addZero(i) {
function loadRoundCounter() { function loadRoundCounter() {
url = basepath + '/info?type=Round'; url = domainname + '/info?type=Round';
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@@ -191,7 +191,7 @@ function addZero(i) {
function loadValue(_type, _div, _style) { function loadValue(_type, _div, _style) {
url = basepath + '/value?all=true&type=' + _type; url = domainname + '/value?all=true&type=' + _type;
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@@ -232,7 +232,7 @@ function addZero(i) {
function init(){ function init(){
basepath = getbasepath(); domainname = getDomainname();
Refresh(); Refresh();
} }

View File

@@ -69,12 +69,12 @@ input[type=number] {
</body></html> </body></html>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="readconfigcommon.js"></script>
<script type="text/javascript" src="./readconfigparam.js"></script> <script type="text/javascript" src="readconfigparam.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var basepath = "http://192.168.178.22"; var domainname = getDomainname();
var NUMBERS; var NUMBERS;
function setprevalue() { function setprevalue() {
@@ -84,7 +84,7 @@ function setprevalue() {
inputVal = inputVal.replace(",", "."); inputVal = inputVal.replace(",", ".");
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
try { try {
url = basepath + "/setPreValue?value=" + inputVal + "&numbers=" + _number; url = domainname + "/setPreValue?value=" + inputVal + "&numbers=" + _number;
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
response = xhttp.responseText; response = xhttp.responseText;
@@ -96,14 +96,14 @@ function setprevalue() {
} }
} }
function loadPrevalue(_basepath) { function loadPrevalue(_domainname) {
// Get current Pre Value // Get current Pre Value
var sel = document.getElementById("Numbers_value1"); var sel = document.getElementById("Numbers_value1");
var _number = sel.options[sel.selectedIndex].text; var _number = sel.options[sel.selectedIndex].text;
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
try { try {
url = _basepath + '/setPreValue?numbers=' + _number; url = _domainname + '/setPreValue?numbers=' + _number;
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
response = xhttp.responseText; response = xhttp.responseText;
@@ -120,7 +120,7 @@ function loadPrevalue(_basepath) {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
try { try {
url = _basepath + '/value?all=true&type=raw'; url = _domainname + '/value?all=true&type=raw';
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
response = xhttp.responseText; response = xhttp.responseText;
@@ -144,7 +144,7 @@ function loadPrevalue(_basepath) {
function numberChanged(){ function numberChanged(){
loadPrevalue(basepath); loadPrevalue(domainname);
} }
function UpdateNUMBERS(_sel){ function UpdateNUMBERS(_sel){
@@ -170,16 +170,16 @@ function UpdateNUMBERS(_sel){
} }
_index.selectedIndex = index; _index.selectedIndex = index;
loadPrevalue(basepath); loadPrevalue(domainname);
} }
function init(){ function init(){
basepath = getbasepath(); domainname = getDomainname();
loadConfig(basepath); loadConfig(domainname);
ParseConfig(); ParseConfig();
UpdateNUMBERS(); UpdateNUMBERS();
loadPrevalue(basepath); loadPrevalue(domainname);
} }
init(); init();

View File

@@ -1,8 +1,4 @@
function readconfig_Version(){ function SaveConfigToServer(_domainname){
return "1.0.0 - 20200910";
}
function SaveConfigToServer(_basepath){
// leere Zeilen am Ende löschen // leere Zeilen am Ende löschen
var zw = config_split.length - 1; var zw = config_split.length - 1;
while (config_split[zw] == "") { while (config_split[zw] == "") {
@@ -15,16 +11,16 @@ function SaveConfigToServer(_basepath){
config_gesamt = config_gesamt + config_split[i] + "\n"; config_gesamt = config_gesamt + config_split[i] + "\n";
} }
FileDeleteOnServer("/config/config.ini", _basepath); FileDeleteOnServer("/config/config.ini", _domainname);
FileSendContent(config_gesamt, "/config/config.ini", _basepath); FileSendContent(config_gesamt, "/config/config.ini", _domainname);
} }
function UpdateConfig(zw, _index, _enhance, _basepath){ function UpdateConfig(zw, _index, _enhance, _domainname){
var namezw = zw["name"]; var namezw = zw["name"];
FileCopyOnServer("/img_tmp/ref_zw.jpg", namezw, _basepath); FileCopyOnServer("/img_tmp/ref_zw.jpg", namezw, _domainname);
var namezw = zw["name"].replace(".jpg", "_org.jpg"); var namezw = zw["name"].replace(".jpg", "_org.jpg");
FileCopyOnServer("/img_tmp/ref_zw_org.jpg", namezw, _basepath); FileCopyOnServer("/img_tmp/ref_zw_org.jpg", namezw, _domainname);
} }
@@ -134,10 +130,10 @@ function getConfig()
} }
function loadConfig(_basepath) { function loadConfig(_domainname) {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
try { try {
url = _basepath + '/fileserver/config/config.ini'; url = _domainname + '/fileserver/config/config.ini';
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
config_gesamt = xhttp.responseText; config_gesamt = xhttp.responseText;
@@ -162,8 +158,8 @@ function dataURLtoBlob(dataurl) {
return new Blob([u8arr], {type:mime}); return new Blob([u8arr], {type:mime});
} }
function FileCopyOnServer(_source, _target, _basepath = ""){ function FileCopyOnServer(_source, _target, _domainname = ""){
url = _basepath + "/editflow?task=copy&in=" + _source + "&out=" + _target; url = _domainname + "/editflow?task=copy&in=" + _source + "&out=" + _target;
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
try { try {
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
@@ -174,7 +170,7 @@ function FileCopyOnServer(_source, _target, _basepath = ""){
} }
} }
function FileDeleteOnServer(_filename, _basepath = ""){ function FileDeleteOnServer(_filename, _domainname = ""){
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
var okay = false; var okay = false;
@@ -192,7 +188,7 @@ function FileDeleteOnServer(_filename, _basepath = ""){
} }
}; };
try { try {
var url = _basepath + "/delete" + _filename; var url = _domainname + "/delete" + _filename;
xhttp.open("POST", url, false); xhttp.open("POST", url, false);
xhttp.send(); xhttp.send();
} }
@@ -204,7 +200,7 @@ function FileDeleteOnServer(_filename, _basepath = ""){
return okay; return okay;
} }
function FileSendContent(_content, _filename, _basepath = ""){ function FileSendContent(_content, _filename, _domainname = ""){
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
var okay = false; var okay = false;
@@ -221,7 +217,7 @@ function FileSendContent(_content, _filename, _basepath = ""){
}; };
try { try {
upload_path = _basepath + "/upload" + _filename; upload_path = _domainname + "/upload" + _filename;
xhttp.open("POST", upload_path, false); xhttp.open("POST", upload_path, false);
xhttp.send(_content); xhttp.send(_content);
} }
@@ -233,21 +229,21 @@ function FileSendContent(_content, _filename, _basepath = ""){
} }
function SaveCanvasToImage(_canvas, _filename, _delete = true, _basepath = ""){ function SaveCanvasToImage(_canvas, _filename, _delete = true, _domainname = ""){
var JPEG_QUALITY=0.8; var JPEG_QUALITY=0.8;
var dataUrl = _canvas.toDataURL('image/jpeg', JPEG_QUALITY); var dataUrl = _canvas.toDataURL('image/jpeg', JPEG_QUALITY);
var rtn = dataURLtoBlob(dataUrl); var rtn = dataURLtoBlob(dataUrl);
if (_delete) { if (_delete) {
FileDeleteOnServer(_filename, _basepath); FileDeleteOnServer(_filename, _domainname);
} }
FileSendContent(rtn, _filename, _basepath); FileSendContent(rtn, _filename, _domainname);
} }
function MakeContrastImageZW(zw, _enhance, _basepath){ function MakeContrastImageZW(zw, _enhance, _domainname){
_filename = zw["name"].replace("/config/", "/img_tmp/"); _filename = zw["name"].replace("/config/", "/img_tmp/");
url = _basepath + "/editflow?task=cutref&in=/config/reference.jpg&out=" + _filename + "&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"]; url = _domainname + "/editflow?task=cutref&in=/config/reference.jpg&out=" + _filename + "&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"];
if (_enhance == true){ if (_enhance == true){
url = url + "&enhance=true"; url = url + "&enhance=true";
} }
@@ -264,10 +260,10 @@ function MakeContrastImageZW(zw, _enhance, _basepath){
function MakeRefZW(zw, _basepath){ function MakeRefZW(zw, _domainname){
_filetarget = zw["name"].replace("/config/", "/img_tmp/"); _filetarget = zw["name"].replace("/config/", "/img_tmp/");
_filetarget = _filetarget.replace(".jpg", "_org.jpg"); _filetarget = _filetarget.replace(".jpg", "_org.jpg");
url = _basepath + "/editflow?task=cutref&in=/config/reference.jpg&out="+_filetarget+"&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"]; url = _domainname + "/editflow?task=cutref&in=/config/reference.jpg&out="+_filetarget+"&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"];
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
try { try {
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
@@ -278,6 +274,6 @@ function MakeRefZW(zw, _basepath){
} }
_filetarget2 = zw["name"].replace("/config/", "/img_tmp/"); _filetarget2 = zw["name"].replace("/config/", "/img_tmp/");
// _filetarget2 = _filetarget2.replace(".jpg", "_org.jpg"); // _filetarget2 = _filetarget2.replace(".jpg", "_org.jpg");
FileCopyOnServer(_filetarget, _filetarget2, _basepath); FileCopyOnServer(_filetarget, _filetarget2, _domainname);
} }

View File

@@ -1,7 +1,3 @@
function readconfig_Version(){
return "1.0.0 - 20200910";
}
var config_gesamt = ""; var config_gesamt = "";
var config_split = []; var config_split = [];
var param = []; var param = [];
@@ -12,7 +8,7 @@ var REFERENCES = new Array(0);
function getNUMBERSList() { function getNUMBERSList() {
_basepath = getbasepath(); _domainname = getDomainname();
var datalist = ""; var datalist = "";
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
@@ -25,7 +21,7 @@ function getNUMBERSList() {
}); });
try { try {
url = _basepath + '/editflow?task=namenumbers'; url = _domainname + '/editflow?task=namenumbers';
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
@@ -43,7 +39,7 @@ function getNUMBERSList() {
function getDATAList() { function getDATAList() {
_basepath = getbasepath(); _domainname = getDomainname();
tflitelist = ""; tflitelist = "";
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
@@ -56,7 +52,7 @@ function getDATAList() {
}); });
try { try {
url = _basepath + '/editflow?task=data'; url = _domainname + '/editflow?task=data';
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
@@ -74,7 +70,7 @@ function getDATAList() {
function getTFLITEList() { function getTFLITEList() {
_basepath = getbasepath(); _domainname = getDomainname();
tflitelist = ""; tflitelist = "";
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
@@ -87,7 +83,7 @@ function getTFLITEList() {
}); });
try { try {
url = _basepath + '/editflow?task=tflite'; url = _domainname + '/editflow?task=tflite';
xhttp.open("GET", url, false); xhttp.open("GET", url, false);
xhttp.send(); xhttp.send();
@@ -562,7 +558,7 @@ function isCommented(input)
return [isComment, input]; return [isComment, input];
} }
function SaveConfigToServer(_basepath){ function SaveConfigToServer(_domainname){
// leere Zeilen am Ende löschen // leere Zeilen am Ende löschen
var zw = config_split.length - 1; var zw = config_split.length - 1;
while (config_split[zw] == "") { while (config_split[zw] == "") {
@@ -575,8 +571,8 @@ function SaveConfigToServer(_basepath){
config_gesamt = config_gesamt + config_split[i] + "\n"; config_gesamt = config_gesamt + config_split[i] + "\n";
} }
FileDeleteOnServer("/config/config.ini", _basepath); FileDeleteOnServer("/config/config.ini", _domainname);
FileSendContent(config_gesamt, "/config/config.ini", _basepath); FileSendContent(config_gesamt, "/config/config.ini", _domainname);
} }
function getConfig() { function getConfig() {
@@ -665,19 +661,19 @@ function getNUMBERS(_name, _type, _create = true)
function CopyReferenceToImgTmp(_basepath) function CopyReferenceToImgTmp(_domainname)
{ {
for (index = 0; index < 2; ++index) for (index = 0; index < 2; ++index)
{ {
_filenamevon = REFERENCES[index]["name"]; _filenamevon = REFERENCES[index]["name"];
_filenamenach = _filenamevon.replace("/config/", "/img_tmp/"); _filenamenach = _filenamevon.replace("/config/", "/img_tmp/");
FileDeleteOnServer(_filenamenach, _basepath); FileDeleteOnServer(_filenamenach, _domainname);
FileCopyOnServer(_filenamevon, _filenamenach, _basepath); FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
_filenamevon = _filenamevon.replace(".jpg", "_org.jpg"); _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
_filenamenach = _filenamenach.replace(".jpg", "_org.jpg"); _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
FileDeleteOnServer(_filenamenach, _basepath); FileDeleteOnServer(_filenamenach, _domainname);
FileCopyOnServer(_filenamevon, _filenamenach, _basepath); FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
} }
} }
@@ -686,18 +682,18 @@ function GetReferencesInfo(){
} }
function UpdateConfigReference(_basepath){ function UpdateConfigReference(_domainname){
for (var index = 0; index < 2; ++index) for (var index = 0; index < 2; ++index)
{ {
_filenamenach = REFERENCES[index]["name"]; _filenamenach = REFERENCES[index]["name"];
_filenamevon = _filenamenach.replace("/config/", "/img_tmp/"); _filenamevon = _filenamenach.replace("/config/", "/img_tmp/");
FileDeleteOnServer(_filenamenach, _basepath); FileDeleteOnServer(_filenamenach, _domainname);
FileCopyOnServer(_filenamevon, _filenamenach, _basepath); FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
_filenamenach = _filenamenach.replace(".jpg", "_org.jpg"); _filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
_filenamevon = _filenamevon.replace(".jpg", "_org.jpg"); _filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
FileDeleteOnServer(_filenamenach, _basepath); FileDeleteOnServer(_filenamenach, _domainname);
FileCopyOnServer(_filenamevon, _filenamenach, _basepath); FileCopyOnServer(_filenamevon, _filenamenach, _domainname);
} }
} }

View File

@@ -18,6 +18,7 @@ p {font-size: 1em;}
} }
</style> </style>
<script type="text/javascript" src="common.js"></script>
</head> </head>
<body style="font-family: arial; padding: 0px 10px;"> <body style="font-family: arial; padding: 0px 10px;">
@@ -35,7 +36,7 @@ p {font-size: 1em;}
<script> <script>
function doReboot() { function doReboot() {
// if (confirm("Are you sure you want to reboot the ESP32?")) { // if (confirm("Are you sure you want to reboot the ESP32?")) {
var stringota = "/reboot"; var stringota = getDomainname() + "/reboot";
window.location = stringota; window.location = stringota;
window.location.href = stringota; window.location.href = stringota;
window.location.assign(stringota); window.location.assign(stringota);

View File

@@ -58,9 +58,10 @@ p {font-size: 1em;}
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var canvas = document.getElementById('canvas'), var canvas = document.getElementById('canvas'),
basepath = "http://192.168.178.22"; domainname = getDomainname();
aktstatu = 0; aktstatu = 0;
function clickNext() { function clickNext() {

View File

@@ -10,13 +10,13 @@
<div id="value"></div> <div id="value"></div>
</html> </html>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="common.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var basepath = "http://192.168.178.22"; var domainname = getDomainname();
function testinit(){ function testinit(){
basepath = getbasepath(); domainname = getDomainname();
url = basepath + '/value?all=true'; url = domainname + '/value?all=true';
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {

View File

@@ -30,7 +30,7 @@
</td></tr> </td></tr>
</table> </table>
<script type="text/javascript" src="/fileserver/html/gethost.js"> <script type="text/javascript" src="/fileserver/html/common.js">
</script> </script>
<script language="JavaScript"> <script language="JavaScript">
function setpath() { function setpath() {

View File

@@ -77,7 +77,7 @@ if (!file.name.includes("remote-setup")){if (!confirm("The zip file name should
var nameneu = document.getElementById("newfile").value; var nameneu = document.getElementById("newfile").value;
filePath = nameneu.split(/[\\\/]/).pop(); filePath = nameneu.split(/[\\\/]/).pop();
var _toDo = basepath + "/ota?task=update&file=" + filePath; var _toDo = domainname + "/ota?task=update&file=" + filePath;
xhttp.open("GET", _toDo, true); xhttp.open("GET", _toDo, true);
xhttp.send(); xhttp.send();
} }