banip.tpl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>欢迎页面-X-admin2.0</title>
  6. <link rel="stylesheet" href="./static/css/font.css">
  7. <link rel="stylesheet" href="./static/css/xadmin.css">
  8. <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  9. <script src="./static/lib/layui/layui.js" charset="utf-8"></script>
  10. <script type="text/javascript" src="./static/js/xadmin.js"></script>
  11. </head>
  12. <body>
  13. <input type="text" id="token" value={{.token}} hidden=true>
  14. <input id="ip" name="ip" placeholder="IP" type="text" lay-verify="required" class="layui-input">
  15. <br>
  16. <input class="layui-btn" type="button" onclick="addBanIP()" value=新增>
  17. <br>
  18. <br>
  19. <table class="radio-table" border="1">
  20. <thead>
  21. <th style="width:128px;">IP</th>
  22. <th style="width:128px;">操作</th>
  23. </thead>
  24. <tbody>
  25. {{range .ipList}}
  26. <tr>
  27. <td style = "text-align:center;">{{.IP}}</td>
  28. <td style = "text-align:center;">
  29. <input class="layui-btn" type="button" onclick="submitDelete({{.IP}})" value=删除>
  30. </td>
  31. </tr>
  32. {{end}}
  33. </tbody>
  34. </table>
  35. <script language="JavaScript">
  36. function addBanIP () {
  37. var token = document.getElementById("token").value;
  38. var ip = document.getElementById("ip").value;
  39. var text = "token=" + encodeURI(token);
  40. text += "&ip=" + encodeURI(ip);
  41. $.ajax({
  42. type:"post",
  43. url:"/banip?" + text,
  44. success:function (data) {
  45. // alert(data.status);
  46. if (data.status){
  47. window.location.href="/banip";
  48. }else{
  49. if (data.info){
  50. alert(data.info);
  51. }else{
  52. window.location.href="/accountlogin";
  53. }
  54. }
  55. }
  56. });
  57. }
  58. function submitDelete(ip) {
  59. var token = document.getElementById("token").value;
  60. var text = "token=" + encodeURI(token);
  61. text += "&ip=" + encodeURI(ip);
  62. $.ajax({
  63. type:"delete",
  64. url:"/banip?" + text,
  65. success:function (data) {
  66. // alert(data.status);
  67. if (data.status){
  68. window.location.href="/banip";
  69. }else{
  70. if (data.info){
  71. alert(data.info);
  72. }else{
  73. window.location.href="/accountlogin";
  74. }
  75. }
  76. }
  77. });
  78. }
  79. </script>
  80. </body>
  81. </html>