edit_config_neu.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <html>
  2. <body>
  3. <table>
  4. <tr><td>Config.ini:</td></tr>
  5. <tr>
  6. <td colspan="3">
  7. <textarea id="inputTextToSave" cols="80" rows="25"></textarea>
  8. </td>
  9. </tr>
  10. <tr>
  11. <td><button onclick="saveTextAsFile()">Update Config.ini</button></td>
  12. </tr>
  13. </table>
  14. <script type="text/javascript" src="./readconfig.js"></script>
  15. <script type="text/javascript">
  16. function LoadConfigNeu() {
  17. loadConfigJS();
  18. document.getElementById("inputTextToSave").value = getConfig();
  19. }
  20. function saveTextAsFile()
  21. {
  22. if (confirm("Are you sure you want to update \"config.ini\"?")) {
  23. var xhttp = new XMLHttpRequest();
  24. /* first delete the old firmware */
  25. xhttp.onreadystatechange = function() {
  26. if (xhttp.readyState == 4) {
  27. if (xhttp.status == 200) {
  28. /* keine Reaktion, damit sich das Dokument nicht ändert */
  29. } else if (xhttp.status == 0) {
  30. alert("Server closed the connection abruptly!");
  31. location.reload()
  32. } else {
  33. alert(xhttp.status + " Error!\n" + xhttp.responseText);
  34. location.reload()
  35. }
  36. }
  37. };
  38. xhttp.open("POST", "/delete/config/config.ini", false);
  39. xhttp.send();
  40. /* ----------------------------- */
  41. var textToSave = document.getElementById("inputTextToSave").value;
  42. xhttp.onreadystatechange = function() {
  43. if (xhttp.readyState == 4) {
  44. if (xhttp.status == 200) {
  45. alert("Update \"config.ini\" successfull!\n\nTo make it active you need to reboot.")
  46. document.reload();
  47. } else if (xhttp.status == 0) {
  48. alert("Server closed the connection abruptly!");
  49. location.reload()
  50. } else {
  51. alert(xhttp.status + " Error!\n" + xhttp.responseText);
  52. location.reload()
  53. }
  54. }
  55. };
  56. upload_path = "/upload/config/config.ini";
  57. xhttp.open("POST", upload_path, true);
  58. xhttp.send(textToSave);
  59. }
  60. }
  61. LoadConfigNeu();
  62. </script>
  63. </body>
  64. </html>