config.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link rel="stylesheet" href="max80.css" />
  5. <title class="config">MAX80: Configuration</title>
  6. <script src="max80.js"></script>
  7. </head>
  8. <body>
  9. <script>inc("head.html")</script>
  10. <h1 class="config">Configuration</h1>
  11. <form id="setconfig" action="sys/setconfig" method="post" onsubmit="uploadform()">
  12. <fieldset class="network">
  13. <legend>Network</legend>
  14. <label class="wifi-ssid">
  15. <span>Network name (SSID):</span>
  16. <input type="text" name="wifi.ssid" />
  17. </label>
  18. <label class="wifi-psk">
  19. <span>Network password (PSK):</span>
  20. <input class="mono" type="password" name="wifi.psk" />
  21. <button type="button" class="show" onclick="showpwd()"><span class="show">show</span><span class="hide">hide</span></button>
  22. </label>
  23. </fieldset>
  24. <fieldset class="datetime">
  25. <legend>Date and Time</legend>
  26. <label class="tz">
  27. <span>Time zone:</span>
  28. <select name="tzname" id="tzname" onchange="tzn()">
  29. </select>
  30. <input type="text" name="TZ" oninput="tzt()" />
  31. </label>
  32. <label class="sntp-enabled">
  33. <span>Synchronize time from network:</span>
  34. <input type="checkbox" name="sntp.enabled" />
  35. </label>
  36. <label class="sntp-server">
  37. <span>NTP server:</span>
  38. <input type="text" name="sntp.server" />
  39. </label>
  40. <label class="ip4-dhcp-sntp">
  41. <span>Use DHCP-provided NTP server:</span>
  42. <input type="checkbox" name="ip4.dhcp.nosntp" value="0" />
  43. </label>
  44. </fieldset>
  45. <button class="submit" type="submit" disabled>Update configuration</button>
  46. <br />
  47. <output></output>
  48. </form>
  49. <script>
  50. function tzn() {
  51. const tz = event.target.selectedOptions[0].dataset.tz;
  52. if (tz) sib(event.target,'input').value = tz;
  53. }
  54. function tzt() { sib(event.target,'select').value = ''; }
  55. fetchconfig('tz.txt')
  56. .then(map => {
  57. function cln(z) {
  58. return ('tz/'+z).replaceAll('/','_ ')
  59. .replaceAll(/[^\w ]+/g,'-');
  60. }
  61. var elem = getelem('tzname');
  62. var grp = elem;
  63. map.set('',''); map.set('UTC','UTC0');
  64. var zones = Array.from(map.keys());
  65. zones = zones.filter(v => v && v != 'UTC').sort();
  66. zones.unshift('','UTC');
  67. for (const z of zones) {
  68. const zz = z.match(/^(?:(\S+?)\/)?(\S*)$/,z);
  69. if (!zz) { continue; }
  70. if (zz[1] && zz[1] != grp.label) {
  71. grp = document.createElement('OPTGROUP');
  72. grp.label = zz[1];
  73. grp.className = cln(zz[1]);
  74. elem.append(grp);
  75. } else if (!zz[1]) {
  76. grp = elem;
  77. }
  78. const pz = zz[2].replaceAll('_',' ').replaceAll('/',': ');
  79. var opt = new Option(pz, z);
  80. opt.className = cln(z);
  81. opt.dataset.tz = map.get(z);
  82. grp.append(opt);
  83. }
  84. translate(elem);
  85. })
  86. .finally(() => {loadform('setconfig','sys/getconfig');} );
  87. </script>
  88. </body>
  89. </html>