edit.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <div class="row tile">
  2. <div class="col-md-6 col-md-auto">
  3. <div>
  4. <h3 class="tile-title">修改</h3>
  5. <div class="tile-body">
  6. <form>
  7. <input type="hidden" name="id" value="{{.t.Id}}">
  8. <div class="form-group">
  9. <label class="control-label">模式</label>
  10. <select class="form-control" name="type" id="type">
  11. <option {{if eq "tcpServer" .t.Mode}}selected{{end}} value="tcpServer">tcp隧道</option>
  12. <option {{if eq "udpServer" .t.Mode}}selected{{end}} value="udpServer">udp隧道</option>
  13. <option {{if eq "socks5Server" .t.Mode}}selected{{end}} value="socks5Server">socks5代理
  14. </option>
  15. <option {{if eq "httpProxyServer" .t.Mode}}selected{{end}} value="httpProxyServer">http代理
  16. <option {{if eq "secretServer" .t.Mode}}selected{{end}} value="secretServer">私密代理
  17. </select>
  18. </div>
  19. <div class="form-group">
  20. <label class="control-label">备注</label>
  21. <input class="form-control" value="{{.t.Remark}}" type="text" name="remark" placeholder="备注">
  22. </div>
  23. <div class="form-group" id="port">
  24. <label class="control-label">监听的端口</label>
  25. <input class="form-control" value="{{.t.Port}}" type="text" name="port"
  26. placeholder="公网服务器对外访问端口,例如8024">
  27. </div>
  28. <div class="form-group" id="target">
  29. <label class="control-label">内网目标(仅tcp、udp隧道模式需填写)</label>
  30. <input class="form-control" value="{{.t.Target}}" type="text" name="target"
  31. placeholder="内网隧道目标,例如10.1.50.203:22">
  32. </div>
  33. <div class="form-group" id="client_id">
  34. <label class="control-label">客户端ID</label>
  35. <input class="form-control" value="{{.t.Client.Id}}" type="text" name="client_id"
  36. placeholder="客户端id">
  37. </div>
  38. <div class="form-group" id="password">
  39. <label class="control-label">私密模式唯一密钥</label>
  40. <input class="form-control" value="{{.t.Password}}" type="text" name="password"
  41. placeholder="私密模式唯一密钥">
  42. </div>
  43. </form>
  44. </div>
  45. <div class="tile-footer">
  46. &nbsp;&nbsp;<button class="btn btn-success" href="#" id="add"><i
  47. class="fa fa-fw fa-lg fa-eye"></i>保存
  48. </button>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </main>
  54. <script>
  55. var arr = []
  56. arr["all"] = ["type", "port", "compress", "u", "p", "target"]
  57. arr["tcpServer"] = ["type", "port", "target", "u", "p", "compress"]
  58. arr["udpServer"] = ["type", "port", "target", "compress"]
  59. arr["socks5Server"] = ["type", "port", "compress", "u", "p"]
  60. arr["httpProxyServer"] = ["type", "port", "compress", "u", "p"]
  61. arr["secretServer"] = ["type", "target", "compress", "u", "p","password"]
  62. arrClientHide = ["compress", "u", "p", "crypt", "mux"]
  63. function resetForm() {
  64. for (var i = 0; i < arr["all"].length; i++) {
  65. $("#" + arr["all"][i]).css("display", "none")
  66. }
  67. o = $("#type option:selected").val()
  68. for (var i = 0; i < arr[o].length; i++) {
  69. $("#" + arr[o][i]).css("display", "block")
  70. }
  71. }
  72. function resetClientCnf() {
  73. for (var i = 0; i < arrClientHide.length; i++) {
  74. $("#" + arrClientHide[i]).css("display", "block")
  75. }
  76. op = $("#use_client option:selected").val()
  77. if (op == 1) {
  78. for (var i = 0; i < arrClientHide.length; i++) {
  79. $("#" + arrClientHide[i]).css("display", "none")
  80. }
  81. }
  82. }
  83. $(function () {
  84. resetForm()
  85. resetClientCnf()
  86. $("#type").on("change", function () {
  87. resetForm()
  88. resetClientCnf()
  89. })
  90. $("#use_client").on("change", function () {
  91. resetForm()
  92. resetClientCnf()
  93. })
  94. $("#add").on("click", function () {
  95. $.ajax({
  96. type: "POST",
  97. url: "/index/edit",
  98. data: $("form").serializeArray(),
  99. success: function (res) {
  100. alert(res.msg)
  101. if (res.status) {
  102. history.back(-1)
  103. }
  104. }
  105. })
  106. })
  107. })
  108. </script>