edit.html 4.4 KB

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