wlan_config.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <html>
  2. <head>
  3. <link href="firework.css?v=$COMMIT_HASH" rel="stylesheet">
  4. <script type="text/javascript" src="jquery-3.6.0.min.js?v=$COMMIT_HASH"></script>
  5. <script type="text/javascript" src="firework.js?v=$COMMIT_HASH"></script>
  6. </head>
  7. <body>
  8. <table>
  9. <tr><td>WLAN-SSID</td><td><input type="text" name="ssid" id="ssid"></td><td>SSID of the WLAN</td></tr>
  10. <tr><td>WLAN-Password</td><td><input type="text" name="password" id="password"></td><td>ATTENTION: the password will not be encrypted during the sending.</td>
  11. </tr><tr><td> Hostname</td><td><input type="text" name="hostname" id="hostname"></td><td></td>
  12. </tr><tr><td>Fixed IP</td><td><input type="text" name="ip" id="ip"></td><td>Leave emtpy if set by router</td></tr>
  13. <tr><td>gateway</td><td><input type="text" name="gateway" id="gateway"></td><td>Leave emtpy if set by router</td></tr>
  14. <tr><td>netmask</td><td><input type="text" name="netmask" id="netmask"></td><td>Leave emtpy if set by router</td>
  15. </tr><tr><td>DNS</td><td><input type="text" name="dns" id="dns"></td><td>Leave emtpy if set by router</td></tr>
  16. <tr><td>RSSI Threashold</td><td><input type="number" name="name" id="threashold" min="-100" max="0" step="1" value = "0"></td><td>WLAN Mesh Parameter: Threashold for RSSI value to check for start switching access point in a mesh system.Possible values: -100 to 0, 0 = disabled - Value will be transfered to wlan.ini at next startup)</td></tr>
  17. </table>
  18. <button class="button" type="button" onclick="wr()">Write wlan.ini</button>
  19. <input id="newfile" type="file">
  20. <button class="button" style="width:300px" id="doUpdate" type="button" onclick="upload()">Upload Files</button>
  21. <script language="JavaScript">function wr(){
  22. api = "/config?"+"ssid"+document.getElementById("ssid").value+"&pwd="+document.getElementById("password").value;+"&hn="+document.getElementById("hostname").value;+"&ip="+document.getElementById("ip").value;+"&gw="+document.getElementById("gateway").value;+"&nm="+document.getElementById("netmask").value;+"&dns="+document.getElementById("dns").value;+"&rssi="+document.getElementById("threashold").value;
  23. fetch(api);}
  24. // var xhttp = new XMLHttpRequest();
  25. // xhttp.onreadystatechange = function() {if (xhttp.readyState == 4) {if (xhttp.status == 200) {document.reload();}}};
  26. if (!file.name.includes("remote-setup")){
  27. if (!confirm("The zip file name should contain \"...remote-setup...\". Are you sure that you have downloaded the correct file?"))
  28. return;
  29. }
  30. function upload() {
  31. var xhttp = new XMLHttpRequest();
  32. xhttp.onreadystatechange = function() {
  33. if (xhttp.readyState == 4) {stopProgressTimer();if (xhttp.status == 200) {extract();} }};
  34. var filePath = document.getElementById("newfile").value.split(/[\\\/]/).pop();
  35. var file = document.getElementById("newfile").files[0];
  36. if (!file.name.includes("remote-setup"))
  37. {
  38. if (!confirm("The zip file name should contain \"...remote-setup...\". Are you sure that you have downloaded the correct file?"))
  39. return;
  40. }
  41. var upload_path = "/upload/firmware/" + filePath; xhttp.open("POST", upload_path, true); xhttp.send(file);}
  42. function extract() {
  43. document.getElementById("status").innerText = "Status: Processing on device (takes up to 3 minutes)...";
  44. var xhttp = new XMLHttpRequest();
  45. /* first delete the old firmware */
  46. xhttp.onreadystatechange = function() {
  47. if (xhttp.readyState == 4) {
  48. stopProgressTimer();
  49. if (xhttp.status == 200) {
  50. document.getElementById("status").innerText = "Status: Update completed!";
  51. document.getElementById("doUpdate").disabled = true;
  52. document.getElementById("newfile").disabled = false;
  53. document.cookie = "page=overview.html?v=$COMMIT_HASH" + "; path=/"; // Make sure after the reboot we go to the overview page
  54. if (xhttp.responseText.startsWith("reboot"))
  55. {
  56. doRebootAfterUpdate();
  57. }
  58. else
  59. {
  60. firework.launch('Processing done! (' + xhttp.responseText + ')', 'success', 5000);
  61. }
  62. } else if (xhttp.status == 0) {
  63. firework.launch('Server closed the connection abruptly!', 'danger', 30000);
  64. UpdatePage();
  65. } else {
  66. firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000);
  67. UpdatePage();
  68. }
  69. }
  70. };
  71. startProgressTimer("Extraction");
  72. var nameneu = document.getElementById("newfile").value;
  73. filePath = nameneu.split(/[\\\/]/).pop();
  74. var _toDo = domainname + "/ota?task=update&file=" + filePath;
  75. xhttp.open("GET", _toDo, true);
  76. xhttp.send();
  77. }
  78. function startProgressTimer(step) {
  79. console.log(step + "...");
  80. document.getElementById('progress').innerHTML = "(0s)";
  81. action_runtime = 0;
  82. progressTimerHandle = setInterval(function() {
  83. action_runtime += 1;
  84. console.log("Progress: " + action_runtime + "s");
  85. document.getElementById('progress').innerHTML = "(" + action_runtime + "s)";
  86. }, 1000);
  87. }
  88. function stopProgressTimer() {
  89. clearInterval(progressTimerHandle);
  90. document.getElementById('progress').innerHTML = "";
  91. }
  92. </script>
  93. </html>
  94. </body>