diff --git a/code/components/jomjol_fileserver_ota/server_ota.cpp b/code/components/jomjol_fileserver_ota/server_ota.cpp index 728d800b..6bc3d172 100644 --- a/code/components/jomjol_fileserver_ota/server_ota.cpp +++ b/code/components/jomjol_fileserver_ota/server_ota.cpp @@ -666,8 +666,42 @@ esp_err_t handler_reboot(httpd_req_t *req) LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "handler_reboot"); ESP_LOGI(TAG, "!!! System will restart within 5 sec!!!"); - const char* resp_str = "

"; - httpd_resp_send(req, resp_str, strlen(resp_str)); + + char _query[200]; + char _valuechar[30]; + std::string _task; + std::string response = + "

"; + + if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK) + { + ESP_LOGD(TAG, "Query: %s", _query); + + if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK) + { + ESP_LOGD(TAG, "task is found: %s", _valuechar); + _task = std::string(_valuechar); + } + } + + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + + if (_task.compare("OTA") == 0) { // Reboot after OTA upload + response.append(""); + } + else { // Normal reboot + response.append(""); + } + + response.append(""); + httpd_resp_send(req, response.c_str(), strlen(response.c_str())); doReboot(); diff --git a/code/include/defines.h b/code/include/defines.h index d284539e..e8f86ec2 100644 --- a/code/include/defines.h +++ b/code/include/defines.h @@ -42,7 +42,7 @@ #define FILE_PATH_MAX (255) //Max length a file path can have on storage //server_file +(ota_page.html + upload_script.html) - #define MAX_FILE_SIZE (8000*1024) // 8 MB Max size of an individual file. Make sure this value is same as that set in upload_script.html + #define MAX_FILE_SIZE (8000*1024) // 8 MB Max size of an individual file. Make sure this value is same as that set in upload_script.html and ota_page.html! #define MAX_FILE_SIZE_STR "8MB" #define LOGFILE_LAST_PART_BYTES SERVER_FILER_SCRATCH_BUFSIZE * 20 // 80 kBytes // Size of partial log file to return diff --git a/images/close.png b/images/close.png new file mode 100644 index 00000000..12fbe67e Binary files /dev/null and b/images/close.png differ diff --git a/sd-card/html/backup.html b/sd-card/html/backup.html index da98c46c..fccfced5 100644 --- a/sd-card/html/backup.html +++ b/sd-card/html/backup.html @@ -40,9 +40,9 @@ input[type=number] { - - - + + + + @@ -129,7 +131,7 @@ function SaveToConfig(){ WriteConfigININew(); UpdateConfigReference(domainname) SaveConfigToServer(domainname); - alert("Config.ini is updated!"); + firework.launch('Configuration got updated. Please reboot to activate changes!', 'success', 5000); } function EnhanceContrast(){ diff --git a/sd-card/html/edit_analog.html b/sd-card/html/edit_analog.html index ca1c6775..2aed5251 100644 --- a/sd-card/html/edit_analog.html +++ b/sd-card/html/edit_analog.html @@ -60,7 +60,9 @@ th, td { opacity: 0.4; } - + + + @@ -227,7 +229,7 @@ function newROI(){ erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, 30, 30, false); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else UpdateROIs(_roinew); } @@ -281,7 +283,7 @@ function SaveToConfig(){ _zwcat["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked; WriteConfigININew(); SaveConfigToServer(domainname); - alert("Config.ini is updated!"); + firework.launch('Configuration got updated. Please reboot to activate changes!', 'success', 5000); } @@ -296,13 +298,13 @@ function UpdateROIs(_sel){ if (_catzw["Analog"]["enabled"] == false) { document.getElementById("Category_Analog_enabled").checked = false; - EnDisableDigits(); - alert("Analog ROIs are disabled - please enable (Check box top left).\n"); + EnDisableAnalog(); + firework.launch('Analog ROIs are disabled - please enable first (Check box top left)', 'warning', 10000); return; } if (ROIInfo.length == 0){ - alert("There are no ROIs defined.\nPlease first create a new ROI (\"New ROIs ...\").\n"); + firework.launch('There are no ROIs defined. Please first create a new ROI ("New ROIs ...")', 'danger', 10000); document.getElementById("newROI").disabled = false; document.getElementById("deleteROI").disabled = true; document.getElementById("index").disabled = true; @@ -454,7 +456,7 @@ function renameNumber(){ erg = RenameNUMBER(_delte, _numbernew); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else UpdateNUMBERS(_numbernew); } @@ -464,7 +466,7 @@ function newNumber(){ erg = CreateNUMBER(_numbernew); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else UpdateNUMBERS(_numbernew); } @@ -476,7 +478,7 @@ function removeNumber(){ var _delte= sel.options[sel.selectedIndex].text; erg = DeleteNUMBER(_delte); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); UpdateNUMBERS(); } } @@ -683,7 +685,7 @@ function drawTextBG(context, txt, x, y, padding) { erg = RenameROI(_number, "analog", _roialt, _roinew); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else UpdateROIs(_roinew); } diff --git a/sd-card/html/edit_config.html b/sd-card/html/edit_config.html index 06db66b5..da180442 100644 --- a/sd-card/html/edit_config.html +++ b/sd-card/html/edit_config.html @@ -21,7 +21,9 @@ textarea { font-size: 14px; } - + + + @@ -61,7 +63,7 @@ function saveTextAsFile() FileDeleteOnServer("/config/config.ini", domainname); var textToSave = document.getElementById("inputTextToSave").value; FileSendContent(textToSave, "/config/config.ini", domainname); - alert("Config.ini is updated!") + firework.launch('Configuration got updated. Please reboot to activate changes!', 'success', 5000); } } diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index 7cea9546..db80ea5b 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -72,7 +72,9 @@ textarea { } - + + + @@ -1450,7 +1452,7 @@ function LoadConfigNeu() { domainname = getDomainname(); if (!loadConfig(domainname)) { - alert("Config.ini could not be loaded!\nPlease reload the page."); + firework.launch('Configuration could not be loaded! Please reload the page!', 'danger', 30000); return; } ParseConfig(); @@ -1528,8 +1530,8 @@ function WriteParameter(_param, _category, _cat, _name, _optional, _number = -1) if (!_isFound) { _zw_txt = "In the selected field the value '" + textToFind + "' in the parameter '"; - _zw_txt = _zw_txt + _cat + "' in the field '" + _name + "' is invalid.\nPLEASE CHECK BEFORE SAVING!"; - alert(_zw_txt); + _zw_txt = _zw_txt + _cat + "' in the field '" + _name + "' is invalid. PLEASE CHECK BEFORE SAVING!"; + firework.launch(_zw_txt, 'warning', 10000); } } else if ((element.getAttribute("type") != null) && (element.getAttribute("type").toLowerCase() == "checkbox")) { @@ -1569,8 +1571,8 @@ function WriteParameter(_param, _category, _cat, _name, _optional, _number = -1) if (!_isFound) { _zw_txt = "In the selected field the value '" + textToFind + "' in the section '"; - _zw_txt = _zw_txt + _cat + "' in the field '" + _name + "' is invalid.\nPLEASE CHECK BEFORE SAVING!"; - alert(_zw_txt); + _zw_txt = _zw_txt + _cat + "' in the field '" + _name + "' is invalid. PLEASE CHECK BEFORE SAVING!"; + firework.launch(_zw_txt, 'warning', 10000); } } @@ -2057,7 +2059,7 @@ function saveTextAsFile() { ReadParameterAll(); if (document.getElementsByClassName("invalid-input").length > 0) { - alert("Settings cannot be saved. Please check your entries."); + firework.launch("Settings cannot be saved. Please check your entries!", 'danger', 30000); return; } @@ -2065,7 +2067,7 @@ function saveTextAsFile() ReadParameterAll(); WriteConfigININew(); SaveConfigToServer(domainname); - alert("Config.ini is updated!") + firework.launch('Configuration got updated. Please reboot to activate changes!', 'success', 5000); } } diff --git a/sd-card/html/edit_digits.html b/sd-card/html/edit_digits.html index 81347d3f..ed20b57c 100644 --- a/sd-card/html/edit_digits.html +++ b/sd-card/html/edit_digits.html @@ -51,7 +51,9 @@ th, td { padding: 5px 5px 5px 0px; } - + + + @@ -228,7 +230,7 @@ function newROI() { erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, 30, 51, 0); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else { UpdateROIs(_roinew); // Shift all ROIs on right side to the right @@ -265,7 +267,7 @@ function changelockSizes(){ lockSizes = document.getElementById("lockSizes").checked; if (!lockSizes) { - alert("For best results it is (in most cases) advised to keep the y, Δx and Δy identical!"); + firework.launch("For best results it is in most cases advised to keep the y, Δx and Δy identical!", 'warning', 10000); } } @@ -284,7 +286,7 @@ function SaveToConfig(){ _zwcat["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked; WriteConfigININew(); SaveConfigToServer(domainname); - alert("Config.ini is updated!"); + firework.launch('Configuration got updated. Please reboot to activate changes!', 'success', 5000); } @@ -300,12 +302,12 @@ function UpdateROIs(_sel){ { document.getElementById("Category_Digits_enabled").checked = false; EnDisableDigits(); - alert("Digital ROIs are disabled - please enable (Check box top left).\n"); + firework.launch('Digital ROIs are disabled - please enable first (Check box top left)', 'warning', 10000); return; } if (ROIInfo.length == 0){ - alert("There are no ROIs defined.\nPlease first create a new ROI (\"New ROIs ...\").\n"); + firework.launch('There are no ROIs defined. Please first create a new ROI ("New ROIs ...")', 'danger', 10000); document.getElementById("newROI").disabled = false; document.getElementById("deleteROI").disabled = true; document.getElementById("index").disabled = true; @@ -460,7 +462,7 @@ function renameNumber(){ erg = RenameNUMBER(_delte, _numbernew); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else UpdateNUMBERS(_numbernew); } @@ -470,7 +472,7 @@ function newNumber(){ erg = CreateNUMBER(_numbernew); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else UpdateNUMBERS(_numbernew); } @@ -482,7 +484,7 @@ function removeNumber(){ var _delte= sel.options[sel.selectedIndex].text; erg = DeleteNUMBER(_delte); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); UpdateNUMBERS(); } } @@ -747,7 +749,7 @@ function draw() { erg = RenameROI(_number, "digit", _roialt, _roinew); if (erg != "") - alert(erg); + firework.launch(erg, 'danger', 30000); else UpdateROIs(_roinew); } diff --git a/sd-card/html/edit_explain_6.html b/sd-card/html/edit_explain_6.html index d861f418..e50eb5c8 100644 --- a/sd-card/html/edit_explain_6.html +++ b/sd-card/html/edit_explain_6.html @@ -21,6 +21,9 @@ p {font-size: 1em;} + + + @@ -51,10 +54,10 @@ p {font-size: 1em;} aktstatu = 0; 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?")) { domainname = getDomainname(); if (!loadConfig(domainname)) { - alert("Setup Modus could not be deactivated!\Please retry."); + firework.launch('Setup Modus could not be deactivated! Please try again!', 'danger', 30000); return; } ParseConfig(); diff --git a/sd-card/html/edit_reference.html b/sd-card/html/edit_reference.html index ac83281b..c66f8972 100644 --- a/sd-card/html/edit_reference.html +++ b/sd-card/html/edit_reference.html @@ -30,7 +30,9 @@ table { padding: 5px; } - + + + @@ -268,7 +270,7 @@ table { SaveCanvasToImage(canvas, "/config/reference.jpg", true, getDomainname()); showReference(param); UpdatePage(); - alert("Reference is updated!"); + firework.launch('Reference got updated. Please reboot to activate changes!', 'success', 5000); } } diff --git a/sd-card/html/firework.css b/sd-card/html/firework.css new file mode 100644 index 00000000..e905579e --- /dev/null +++ b/sd-card/html/firework.css @@ -0,0 +1,38 @@ +/* Firework JS */ +.firework { + background-color: #888; + border-color: #888; + border-radius: 6px; + color: #fff; + left: 200px; + padding: 5px; + position: fixed; + opacity: 0; + text-align: center; + top: 0px; + width: 600px; + z-index: 99; + font-size:120%; +} +.firework a { + color: rgba(255, 255, 255, 0.9); + cursor: pointer; + float: right; + margin: 0 -5px 0 0; + padding: 0 5px; +} +.firework.success { + background-color: #669936f0; + border-color: #669936; + color: #fff +} +.firework.danger { + background-color: #E65A27f0; + border-color: #E65A27; + color: #fff +} +.firework.warning { + color: #5F612C; + background-color: #dbd567f0; + border-color: #DBD667; +} diff --git a/sd-card/html/firework.js b/sd-card/html/firework.js new file mode 100644 index 00000000..19bbfc56 --- /dev/null +++ b/sd-card/html/firework.js @@ -0,0 +1,68 @@ +/** + * Firework displays short notifications at top of page, + * then fades out a few seconds later (no user interaction) + * Source: https://www.jqueryscript.net/other/Simple-Top-Notification-Plugin-with-jQuery-firework-js.html + * https://github.com/smalldogs/fireworkjs + * @param m string message + * @param t string (optional) message type ('success', 'danger') + * @param l number (optional) length of time to display message in milliseconds + */ + ;(function ($, window) { + "use strict"; + + window.firework = { + launch: function(m, t, l) { + if (typeof m != 'string') { + console.error('Error: Call to firework() without a message'); + return false + } + + var c = 'firework' // css class(es) + , p = 10 // pixels from top or page to display + , d = new Date() + , s = d.getTime() // used to create unique element ids + , fid = "firework-"+ s; // firework id + + if (typeof t !== 'undefined') c += ' '+ t; // add any user defined classes + + $('.firework').each(function(){ // account for existing fireworks and move new one below + p += parseInt($(this).height()) + 30 + }); + + $('
'+ m +'
') + .appendTo('body') + .animate({ + opacity: 1, + top: p +'px' + }); + + setTimeout(function(){ firework.remove("#"+ fid) }, typeof l == "number" ? l : 1500); + }, + + remove : function(t) { + $(t) + .animate({ + opacity: 0 + }) + .promise() + .done(function(){ + $(t).remove() + }) + }, + + sticky : function(m, t, l) { + $.cookie("firework", '{ "message" : "'+ m +'", "type" : "'+ t +'", "display" : "'+ l +'" }', { path: '/' }) + } + }; + + // checks for firework cookie on dom ready + $(function() { + if (typeof $.cookie == "function") { + if ($.cookie("firework")) { + var ex = $.parseJSON($.cookie("firework")) + setTimeout(function(){ firework.launch(ex.message, ex.type, parseInt(ex.display) > 0 ? parseInt(ex.display) : null) }, 1000) + $.cookie("firework", null, { path: '/'}) + } + } + }); +})(jQuery, window); diff --git a/sd-card/html/graph.html b/sd-card/html/graph.html index 9dedef86..acf02355 100644 --- a/sd-card/html/graph.html +++ b/sd-card/html/graph.html @@ -1,6 +1,6 @@ - + @@ -18,7 +18,9 @@ el && eval(el.value); } - + + +
@@ -46,7 +48,7 @@ fetch(_domainname + '/fileserver/log/data/' + datefile) .then(response => { // handle the response if (response.status == 404) { - alert("no log data available for "+dateString); + firework.launch('No log data available for " + dateString, 'warning', 10000); } response.text() .then( result => { @@ -79,7 +81,6 @@ fetch(_domainname + '/fileserver/log/data/' + datefile) }).catch((error) => { // handle the error console.log(error); -alert("test"); });
diff --git a/sd-card/html/index.html b/sd-card/html/index.html index e7ab164e..be096379 100644 --- a/sd-card/html/index.html +++ b/sd-card/html/index.html @@ -7,7 +7,6 @@ - diff --git a/sd-card/html/ota_page.html b/sd-card/html/ota_page.html index 805e584d..4dbf077e 100644 --- a/sd-card/html/ota_page.html +++ b/sd-card/html/ota_page.html @@ -26,7 +26,9 @@ input[type=number] { font-size: 16px; } - + + + @@ -89,13 +91,13 @@ function init(){ function doRebootAfterUpdate() { - if (confirm("Upload completed!\nThe device will reboot now and complete the update.\nThis will take up to 180s!")) { - var stringota = "/reboot"; +/* if (confirm("Upload completed!\nThe device will reboot now and complete the update.\nThis will take up to 180s!")) {*/ + var stringota = "/reboot?task=OTA"; window.location = stringota; window.location.href = stringota; window.location.assign(stringota); window.location.replace(stringota); - } +/* }*/ } @@ -112,23 +114,28 @@ function prepareOnServer() { var nameneu = document.getElementById("newfile").value; filePath = nameneu.split(/[\\\/]/).pop(); + /* Max size of an individual file. Make sure this + * value is same as that set in file_server.c */ + var MAX_FILE_SIZE = 8000*1024; + var MAX_FILE_SIZE_STR = "8000KB"; + if (fileInput.length == 0) { - alert("No file selected!"); + firework.launch('No file selected!', 'danger', 30000); return; } else if (filePath.length == 0) { - alert("File path on server is not set!"); + firework.launch('File path on server is not set!', 'danger', 30000); return; } else if (filePath.length > 100) { - alert("Filename is to long! Max 100 characters."); + firework.launch('Filename is to long! Max 100 characters.', 'danger', 30000); return; } else if (filePath.indexOf(' ') >= 0) { - alert("File path on server cannot have spaces!"); + firework.launch('File path on server cannot have spaces!', 'danger', 30000); return; } else if (filePath[filePath.length-1] == '/') { - alert("File name not specified after path!"); + firework.launch('File name not specified after path!', 'danger', 30000); return; } else if (fileInput[0].size > MAX_FILE_SIZE) { - alert("File size must be less than " + MAX_FILE_SIZE_STR + "!"); + firework.launch("File size must be less than " + MAX_FILE_SIZE_STR + "!", 'danger', 30000); return; } @@ -148,10 +155,10 @@ function prepareOnServer() { /* keine Reaktion, damit sich das Dokument nicht ändert */ upload(); } else if (xhttp.status == 0) { - alert("Server closed the connection abruptly!"); + firework.launch('Server closed the connection abruptly!', 'danger', 30000); document.getElementById("doUpdate").disabled = false; } else { - alert(xhttp.status + " Error!\n" + xhttp.responseText); + firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000); document.getElementById("doUpdate").disabled = false; } } @@ -173,14 +180,12 @@ function upload() { if (xhttp.readyState == 4) { stopProgressTimer(); if (xhttp.status == 200) { -// alert("Upload successfull!") -// document.reload(); extract(); } else if (xhttp.status == 0) { - alert("Server closed the connection abruptly!"); + firework.launch('Server closed the connection abruptly!', 'danger', 30000); document.getElementById("doUpdate").disabled = false; } else { - alert(xhttp.status + " Error!\n" + xhttp.responseText); + firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000); document.getElementById("doUpdate").disabled = false; } } @@ -218,13 +223,13 @@ function extract() { } else { - alert("Processing done!\n\n" + xhttp.responseText); + firework.launch('Processing done', 'success', 5000); } } else if (xhttp.status == 0) { - alert("Server closed the connection abruptly!"); + firework.launch('Server closed the connection abruptly!', 'danger', 30000); UpdatePage(); } else { - alert(xhttp.status + " Error!\n" + xhttp.responseText); + firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000); UpdatePage(); } } diff --git a/sd-card/html/overview.html b/sd-card/html/overview.html index a940bd55..cf949350 100644 --- a/sd-card/html/overview.html +++ b/sd-card/html/overview.html @@ -68,7 +68,7 @@ - + + @@ -92,7 +95,7 @@ function setprevalue() { } catch (error) { - alert("Failed to get data from device!"); + firework.launch('Failed to get data from device!', 'danger', 30000); } } @@ -111,7 +114,7 @@ function loadPrevalue(_domainname) { } catch (error) { - alert("Failed to get data from device!"); + firework.launch('Failed to get data from device!', 'danger', 30000); } // Get current RAW Value @@ -138,7 +141,7 @@ function loadPrevalue(_domainname) { } catch (error) { - alert("Failed to get data from device!"); + firework.launch('Failed to get data from device!', 'danger', 30000); } } diff --git a/sd-card/html/readconfigcommon.js b/sd-card/html/readconfigcommon.js index 11a30232..f4cf862a 100644 --- a/sd-card/html/readconfigcommon.js +++ b/sd-card/html/readconfigcommon.js @@ -31,7 +31,7 @@ function createReader(file) { image.onload = function(evt) { var width = this.width; var height = this.height; - alert (width); // will produce something like 198 + //alert (width); // will produce something like 198 }; image.src = evt.target.result; }; @@ -141,7 +141,7 @@ function loadConfig(_domainname) { } catch (error) { - // alert("Deleting Config.ini failed"); +// firework.launch('Deleting Config.ini failed!', 'danger', 30000); } return true; } @@ -166,7 +166,7 @@ function FileCopyOnServer(_source, _target, _domainname = ""){ xhttp.send(); } catch (error) { -// alert("Deleting Config.ini failed"); +// firework.launch('Deleting Config.ini failed!', 'danger', 30000); } } @@ -179,10 +179,10 @@ function FileDeleteOnServer(_filename, _domainname = ""){ if (xhttp.status == 200) { okay = true; } else if (xhttp.status == 0) { -// alert("Server closed the connection on delete abruptly!"); +// firework.launch('Server closed the connection abruptly!', 'danger', 30000); // location.reload() } else { -// alert(xhttp.status + " Error!\n" + xhttp.responseText); +// firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000); // location.reload() } } @@ -194,7 +194,7 @@ function FileDeleteOnServer(_filename, _domainname = ""){ } catch (error) { -// alert("Deleting Config.ini failed"); +// firework.launch('Deleting Config.ini failed!', 'danger', 30000); } return okay; @@ -209,9 +209,9 @@ function FileSendContent(_content, _filename, _domainname = ""){ if (xhttp.status == 200) { okay = true; } else if (xhttp.status == 0) { - alert("Server closed the connection abruptly!"); + firework.launch('Server closed the connection abruptly!', 'danger', 30000); } else { - alert(xhttp.status + " Error!\n" + xhttp.responseText); + firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000); } } }; @@ -223,7 +223,7 @@ function FileSendContent(_content, _filename, _domainname = ""){ } catch (error) { -// alert("Deleting Config.ini failed"); +// firework.launch('Deleting Config.ini failed!', 'danger', 30000); } return okay; } @@ -254,7 +254,7 @@ function MakeContrastImageZW(zw, _enhance, _domainname){ xhttp.send(); } catch (error) { -// alert("Deleting Config.ini failed"); +// firework.launch('Deleting Config.ini failed!', 'danger', 30000); } } @@ -270,7 +270,7 @@ function MakeRefZW(zw, _domainname){ xhttp.send(); } catch (error) { -// alert("Deleting Config.ini failed"); +// firework.launch('Deleting Config.ini failed!', 'danger', 30000); } _filetarget2 = zw["name"].replace("/config/", "/img_tmp/"); // _filetarget2 = _filetarget2.replace(".jpg", "_org.jpg"); diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index 37b524ab..6dd6d412 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -28,7 +28,7 @@ function getNUMBERSList() { } catch (error) { - alert("Loading Hostname failed"); +// alert("Loading Hostname failed"); } datalist = datalist.split("\t"); diff --git a/sd-card/html/upload_script.html b/sd-card/html/upload_script.html index d6740322..72ef30c5 100644 --- a/sd-card/html/upload_script.html +++ b/sd-card/html/upload_script.html @@ -1,3 +1,10 @@ + + + + + + +
@@ -63,19 +70,21 @@ function upload() { /* Max size of an individual file. Make sure this * value is same as that set in file_server.c */ - var MAX_FILE_SIZE = 2000*1024; - var MAX_FILE_SIZE_STR = "2000KB"; + var MAX_FILE_SIZE = 8000*1024; + var MAX_FILE_SIZE_STR = "8000KB"; if (fileInput.length == 0) { - alert("No file selected!"); + firework.launch('No file selected!', 'danger', 30000); } else if (filePath.length == 0) { - alert("File path on server is not set!"); + firework.launch('File path on server is not set!', 'danger', 30000); + } else if (filePath.length > 100) { + firework.launch('Filename is to long! Max 100 characters.', 'danger', 30000); } else if (filePath.indexOf(' ') >= 0) { - alert("File path on server cannot have spaces!"); + firework.launch('File path on server cannot have spaces!', 'danger', 30000); } else if (filePath[filePath.length-1] == '/') { - alert("File name not specified after path!"); - } else if (fileInput[0].size > 2000*1024) { - alert("File size must be less than 2000KB!"); + firework.launch('File name not specified after path!', 'danger', 30000); + } else if (fileInput[0].size > MAX_FILE_SIZE) { + firework.launch("File size must be less than " + MAX_FILE_SIZE_STR + "!", 'danger', 30000); } else { document.getElementById("newfile").disabled = true; document.getElementById("filepath").disabled = true; @@ -90,10 +99,10 @@ function upload() { document.write(xhttp.responseText); document.close(); } else if (xhttp.status == 0) { - alert("Server closed the connection abruptly!"); + firework.launch('Server closed the connection abruptly!', 'danger', 30000); UpdatePage(false); } else { - alert(xhttp.status + " Error!\n" + xhttp.responseText); + firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000); UpdatePage(false); } } @@ -103,3 +112,6 @@ function upload() { } } + + + \ No newline at end of file diff --git a/sd-card/html/wlan_config.html b/sd-card/html/wlan_config.html index aaf2d1bf..83acf2c9 100644 --- a/sd-card/html/wlan_config.html +++ b/sd-card/html/wlan_config.html @@ -1,4 +1,11 @@ - + + + + + + + +
@@ -20,10 +27,10 @@ // var xhttp = new XMLHttpRequest(); // xhttp.onreadystatechange = function() {if (xhttp.readyState == 4) {if (xhttp.status == 200) {document.reload();}}}; -if (!file.name.includes("remote-setup")){if (!confirm("The zip file name should contain \"...remote-setup...\". Are you sure that you have downloaded the correct file?"))return;} - -if (!file.name.includes("remote-setup")){if (!confirm("The zip file name should contain \"...remote-setup...\". Are you sure that you have downloaded the correct file?"))return;} - +if (!file.name.includes("remote-setup")){ + if (!confirm("The zip file name should contain \"...remote-setup...\". Are you sure that you have downloaded the correct file?")) + return; +} function upload() { var xhttp = new XMLHttpRequest(); @@ -60,13 +67,13 @@ if (!file.name.includes("remote-setup")){if (!confirm("The zip file name should } else { - alert("Processing done!\n\n" + xhttp.responseText); + firework.launch('Processing done! (' + xhttp.responseText + ')', 'success', 5000); } } else if (xhttp.status == 0) { - alert("Server closed the connection abruptly!"); + firework.launch('Server closed the connection abruptly!', 'danger', 30000); UpdatePage(); } else { - alert(xhttp.status + " Error!\n" + xhttp.responseText); + firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000); UpdatePage(); } } @@ -103,3 +110,5 @@ if (!file.name.includes("remote-setup")){if (!confirm("The zip file name should + +
WLAN-SSIDSSID of the WLAN
WLAN-PasswordATTENTION: the password will not be encrypted during the sending.
Hostname