wifi.htm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
  5. <title>ESP WiFi</title>
  6. <script>
  7. function g(i){return document.getElementById(i);};
  8. function p(t,l){if(confirm(t)) window.location=l;};
  9. function E(s){return document.createElement(s)};
  10. var S="setAttribute",A="appendChild",H="innerHTML",X,wl;
  11. function scan(){
  12. if(X) return;
  13. X=new XMLHttpRequest(),wl=document.getElementById('wl');
  14. wl[H]="Scanning...";
  15. X.onreadystatechange=function(){
  16. if (this.readyState==4&&this.status==200) {
  17. X=0;
  18. wl[H]="";
  19. this.responseText.split("\n").forEach(function (e) {
  20. let t=e.split(","), s=t.slice(2).join(',');
  21. var d=E('div'),i=E('a'),c=E('a');
  22. i[S]('class','s'); c[S]('class','q');
  23. i.onclick=function(){g('s').value=s;g('p').focus();};
  24. i[A](document.createTextNode(s));
  25. c[H]=t[0]+"%"+(parseInt(t[1])?"\uD83D\uDD12":"\u26A0");
  26. wl[A](i); wl[A](c);
  27. wl[A](document.createElement('br'));
  28. });
  29. }
  30. };
  31. X.open("GET","wifi/list",true);
  32. X.send();
  33. };
  34. </script>
  35. <style>
  36. input {
  37. padding:5px;
  38. font-size:1em;
  39. width:95%;
  40. filter:invert(100%);
  41. }
  42. body {
  43. text-align:center;
  44. font-family:verdana;
  45. background-color:black;
  46. color:white;
  47. }
  48. a {
  49. color:#1fa3ec;
  50. }
  51. button {
  52. border:0;
  53. border-radius:0.3em;
  54. background-color:#1fa3ec;
  55. color:#fff;
  56. line-height:2.4em;
  57. font-size:1.2em;
  58. width:100%;
  59. display:block;
  60. }
  61. .q {
  62. float:right;
  63. }
  64. .s {
  65. display:inline-block;
  66. width:14em;
  67. overflow:hidden;
  68. text-overflow:ellipsis;
  69. white-space:nowrap;
  70. }
  71. #wl{
  72. line-height:1.5em;
  73. }
  74. </style>
  75. </head>
  76. <body>
  77. <div style='text-align:left;display:inline-block;width:320px;padding:5px'>
  78. <button onclick="scan()">&#x21bb; Scan</button>
  79. <p id='wl'></p>
  80. <form method='post' action='/wifi/connect'>
  81. <input id='s' name='n' length=32 placeholder='SSID'>
  82. <br>
  83. <input id='p' name='p' length=64 type='password' placeholder='password'>
  84. <br>
  85. <br>
  86. <button type='submit'>Connect</button>
  87. </form>
  88. <br>
  89. <br>
  90. <button onclick="p('Start WPS?','/wifi/wps')">WPS Setup</button>
  91. <br>
  92. <button onclick="p('Start AP mode?','/wifi/ap')">AP Mode</button>
  93. <br>
  94. <button onclick="p('Reboot device?','/wifi/rst')">Reboot</button>
  95. <br>
  96. <a href="javascript:history.back()">Back</a> |
  97. <a href="/">Home</a>
  98. </div>
  99. </body>
  100. </html>