edit_config_old.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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">
  15. function loadConfig() {
  16. var xhr = new XMLHttpRequest();
  17. xhr.onload = function () {
  18. // alert(this.responseText);
  19. document.getElementById("inputTextToSave").value = this.responseText;
  20. };
  21. url = '/fileserver/config/config.ini';
  22. xhr.open('GET', url);
  23. xhr.send();
  24. }
  25. function saveTextAsFile()
  26. {
  27. if (confirm("Are you sure you want to update \"config.ini\"?")) {
  28. var xhttp = new XMLHttpRequest();
  29. /* first delete the old firmware */
  30. xhttp.onreadystatechange = function() {
  31. if (xhttp.readyState == 4) {
  32. if (xhttp.status == 200) {
  33. /* keine Reaktion, damit sich das Dokument nicht ändert */
  34. } else if (xhttp.status == 0) {
  35. alert("Server closed the connection abruptly!");
  36. location.reload()
  37. } else {
  38. alert(xhttp.status + " Error!\n" + xhttp.responseText);
  39. location.reload()
  40. }
  41. }
  42. };
  43. xhttp.open("POST", "/delete/config/config.ini", false);
  44. xhttp.send();
  45. /* ----------------------------- */
  46. var textToSave = document.getElementById("inputTextToSave").value;
  47. xhttp.onreadystatechange = function() {
  48. if (xhttp.readyState == 4) {
  49. if (xhttp.status == 200) {
  50. alert("Update \"config.ini\" successfull!\n\nTo make it active you need to reboot.")
  51. document.reload();
  52. } else if (xhttp.status == 0) {
  53. alert("Server closed the connection abruptly!");
  54. location.reload()
  55. } else {
  56. alert(xhttp.status + " Error!\n" + xhttp.responseText);
  57. location.reload()
  58. }
  59. }
  60. };
  61. upload_path = "/upload/config/config.ini";
  62. xhttp.open("POST", upload_path, true);
  63. xhttp.send(textToSave);
  64. }
  65. }
  66. loadConfig();
  67. </script>
  68. </body>
  69. </html>