config.html 2.8 KB

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