index.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>WDKL NET BRIDGE</title>
  6. </head>
  7. <style>
  8. fieldset{
  9. margin-top: 30px;
  10. border-radius: 15px;
  11. border: 1px solid #ccc;
  12. }
  13. label{
  14. display: inline-block;
  15. width: 100px;
  16. text-align: right;
  17. margin-right: 30px;
  18. }
  19. input{
  20. margin-top: 10px;
  21. }
  22. input[type=submit] {
  23. margin-left: 10%;
  24. width: 200px;
  25. background-color: #4CAF50;
  26. color: white;
  27. padding: 14px 20px;
  28. margin: 8px 0;
  29. border: none;
  30. border-radius: 4px;
  31. cursor: pointer;
  32. }
  33. input[type=submit]:hover {
  34. background-color: #45a049;
  35. }
  36. </style>
  37. <body>
  38. <div>
  39. <h1>WDKL NET BRIDGE</h1>
  40. <p>mac : %s</p>
  41. </div>
  42. <form action="/setting" method="POST" onsubmit="return validate();">
  43. <fieldset>
  44. <legend>DEVICE</legend>
  45. <label>DHCP?</label>
  46. YES<input onclick="ipSetting(false);" type="radio" name="dhcp" value="1" style="margin-right: 1rem;" checked>
  47. NO<input onclick="ipSetting(true);" type="radio" name="dhcp" value="0">
  48. <br>
  49. <div id="ip_panel" style="display: none;">
  50. <label>IP</label>
  51. <input type="text" name="ip" id="ip" value="%s">
  52. <br>
  53. <label>NETMASK</label>
  54. <input type="text" name="netmask" id="netmask" value="%s">
  55. <br>
  56. <label>GATEWAY</label>
  57. <input type="text" name="gateway" id="gateway" value="%s">
  58. <br>
  59. <label>DNS1</label>
  60. <input type="text" name="dns1" id="dns1" value="%s">
  61. <br>
  62. <label>DNS2</label>
  63. <input type="text" name="dns2" id="dns2" value="%s">
  64. </div>
  65. </fieldset>
  66. <fieldset>
  67. <legend>SERVER</legend>
  68. <label>SERVER IP</label>
  69. <input type="text" name="server_ip" id="server_ip" value="%s">
  70. </fieldset>
  71. <input type="submit" value="submit">
  72. </form>
  73. <script>
  74. function ipSetting(show){
  75. console.log("xxx" + show);
  76. document.getElementById("ip_panel").style.display = show?"block":"none";
  77. }
  78. function validate() {
  79. console.log(document.getElementById("ip_panel").style.display);
  80. var regexIP = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]).){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
  81. var regexNetmask = /^(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)$/;
  82. var ip = document.getElementById("ip").value;
  83. var netmask = document.getElementById("netmask").value;
  84. var gateway = document.getElementById("gateway").value;
  85. var dns1 = document.getElementById("dns1").value;
  86. var dns2 = document.getElementById("dns2").value;
  87. var server_ip = document.getElementById("server_ip").value;
  88. if (document.getElementById("ip_panel").style.display == "none"){
  89. if (server_ip == ""){
  90. alert("server ip must input");
  91. document.getElementById("server_ip").focus();
  92. return false;
  93. } else if (!regexIP.test(server_ip)){
  94. alert("server ip wrong input");
  95. document.getElementById("server_ip").focus();
  96. return false;
  97. }
  98. return true;
  99. } else {
  100. if (ip == ""){
  101. alert("ip must input");
  102. document.getElementById("ip").focus();
  103. return false;
  104. } else if (netmask == ""){
  105. alert("netmask must input");
  106. document.getElementById("netmask").focus();
  107. return false;
  108. } else if (gateway == ""){
  109. alert("gateway must input");
  110. document.getElementById("gateway").focus();
  111. return false;
  112. } else if (server_ip == ""){
  113. alert("server_ip must input");
  114. document.getElementById("server_ip").focus();
  115. return false;
  116. }
  117. if (!regexIP.test(ip)){
  118. alert("ip wrong input");
  119. document.getElementById("ip").focus();
  120. return false;
  121. } else if (!regexNetmask.test(netmask)){
  122. alert("netmask wrong input");
  123. document.getElementById("netmask").focus();
  124. return false;
  125. } else if (!regexIP.test(gateway)){
  126. alert("gateway wrong input");
  127. document.getElementById("gateway").focus();
  128. return false;
  129. } else if (!regexIP.test(server_ip)){
  130. alert("server_ip wrong input");
  131. document.getElementById("server_ip").focus();
  132. return false;
  133. } else if (dns1!="" && !regexIP.test(dns1)){
  134. alert("dns1 wrong input");
  135. document.getElementById("dns1").focus();
  136. return false;
  137. } else if (dns2!="" && !regexIP.test(dns2)){
  138. alert("dns2 wrong input");
  139. document.getElementById("dns2").focus();
  140. return false;
  141. }
  142. return true;
  143. }
  144. }
  145. </script>
  146. </body>
  147. </html>