config.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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" />
  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">Time zone:</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. function tzn(e,p) {
  49. var tz = e.target.selectedOptions[0].dataset.tz;
  50. if (tz) { getelem(p).value = tz; }
  51. }
  52. function tzt(e,p) { getelem(p).value = ''; }
  53. fetchconfig('tz.txt')
  54. .then(map => {
  55. function cln(z) { return ('tz/'+z).replaceAll('/','_ ')
  56. .replaceAll(/[^\w ]+/g,'-'); }
  57. var elem = getelem('tzname');
  58. var grp = elem;
  59. map.set('',''); map.set('UTC','UTC0');
  60. var zones = Array.from(map.keys());
  61. zones = zones.filter(v => v && v != 'UTC').sort();
  62. zones.unshift('','UTC');
  63. for (const z of zones) {
  64. const zz = z.match(/^(?:(\S+?)\/)?(\S*)$/,z);
  65. if (!zz) { continue; }
  66. if (zz[1] && zz[1] != grp.label) {
  67. grp = document.createElement('OPTGROUP');
  68. grp.label = zz[1];
  69. grp.className = cln(zz[1]);
  70. elem.append(grp);
  71. } else if (!zz[1]) {
  72. grp = elem;
  73. }
  74. const pz = zz[2].replaceAll('_',' ').replaceAll('/',': ');
  75. var opt = new Option(pz, z);
  76. opt.className = cln(z);
  77. opt.dataset.tz = map.get(z);
  78. grp.append(opt);
  79. }
  80. })
  81. .finally(() => {loadform('setconfig','sys/getconfig')});
  82. </script>
  83. <script>translate()</script>
  84. </body>
  85. </html>