edit.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <div class="row tile">
  2. <div class="col-md-12 col-md-auto">
  3. <div class="ibox float-e-margins">
  4. <h3 class="ibox-title">编辑</h3>
  5. <div class="ibox-content">
  6. <form class="form-horizontal">
  7. <input type="hidden" name="id" value="{{.t.Id}}">
  8. <div class="form-group">
  9. <label class="col-sm-2 control-label">mode </label>
  10. <div class="col-sm-10">
  11. <select class="form-control" name="type" id="type">
  12. <option {{if eq "tcp" .t.Mode}}selected{{end}} value="tcp">tcp</option>
  13. <option {{if eq "udp" .t.Mode}}selected{{end}} value="udp">udp</option>
  14. <option {{if eq "socks5" .t.Mode}}selected{{end}} value="socks5">socks5
  15. </option>
  16. <option {{if eq "httpProxy" .t.Mode}}selected{{end}} value="httpProxy">http</option>
  17. <option {{if eq "secret" .t.Mode}}selected{{end}} value="secret">secret</option>
  18. <option {{if eq "p2p" .t.Mode}}selected{{end}} value="p2p">p2p</option>
  19. <option {{if eq "file" .t.Mode}}selected{{end}} value="file">file</option>
  20. </select>
  21. </div>
  22. </div>
  23. <div class="form-group">
  24. <label class="col-sm-2 control-label">remark</label>
  25. <div class="col-sm-10">
  26. <input value="{{.t.Remark}}" class="form-control" type="text" name="remark"
  27. placeholder="empty means to be unrestricted">
  28. </div>
  29. </div>
  30. <div class="form-group" id="port">
  31. <label class="col-sm-2 control-label">port of server</label>
  32. <div class="col-sm-10">
  33. <input value="{{.t.Port}}" class="form-control" type="text" name="port"
  34. placeholder="such as 8024">
  35. </div>
  36. </div>
  37. <div class="form-group" id="target">
  38. <label class="col-sm-2 control-label">target of Intranet(ip:port)</label>
  39. <div class="col-sm-10">
  40. <input value="{{.t.Target}}" class="form-control" type="text" name="target"
  41. placeholder="such as 10.1.50.203:22 ">
  42. <span class="help-block m-b-none">can only fill in ports if it is local machine proxy</span>
  43. </div>
  44. </div>
  45. <div class="form-group" id="client_id">
  46. <label class="col-sm-2 control-label">id of client</label>
  47. <div class="col-sm-10">
  48. <input value="{{.t.Client.Id}}" value="{{.client_id}}" class="form-control" type="text"
  49. name="client_id"
  50. placeholder="id of client">
  51. </div>
  52. </div>
  53. <div class="form-group" id="local_path">
  54. <label class="col-sm-2 control-label">local path</label>
  55. <div class="col-sm-10">
  56. <input value="{{.t.LocalPath}}" class="form-control" type="text" name="local_path"
  57. placeholder="such as /tmp">
  58. </div>
  59. </div>
  60. <div class="form-group" id="strip_pre">
  61. <label class="col-sm-2 control-label">strip pre</label>
  62. <div class="col-sm-10">
  63. <input value="{{.t.StripPre}}" class="form-control" type="text" name="strip_pre"
  64. placeholder="such as static">
  65. </div>
  66. </div>
  67. <div class="form-group" id="password">
  68. <label class="col-sm-2 control-label">unique identification key</label>
  69. <div class="col-sm-10">
  70. <input value="{{.t.Password}}" class="form-control" type="text" name="password"
  71. placeholder="unique identification key">
  72. <span class="help-block m-b-none">when p2p or secret</span>
  73. </div>
  74. </div>
  75. <div class="hr-line-dashed"></div>
  76. <div class="form-group">
  77. <div class="col-sm-4 col-sm-offset-2">
  78. <button class="btn btn-success" href="#" id="add"><i
  79. class="fa fa-fw fa-lg fa-eye"></i>save
  80. </button>
  81. </div>
  82. </div>
  83. </form>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <script>
  89. var arr = []
  90. arr["all"] = ["type", "port", "compress", "u", "p", "target", "password", "local_path", "strip_pre"]
  91. arr["tcp"] = ["type", "port", "target", "u", "p", "compress"]
  92. arr["udp"] = ["type", "port", "target", "compress"]
  93. arr["socks5"] = ["type", "port", "compress", "u", "p"]
  94. arr["httpProxy"] = ["type", "port", "compress", "u", "p"]
  95. arr["secret"] = ["type", "target", "compress", "u", "p", "password"]
  96. arr["p2p"] = ["type", "password"]
  97. arr["file"] = ["type", "port", "local_path", "strip_pre"]
  98. arrClientHide = ["compress", "u", "p", "crypt", "mux"]
  99. function resetForm() {
  100. for (var i = 0; i < arr["all"].length; i++) {
  101. $("#" + arr["all"][i]).css("display", "none")
  102. }
  103. o = $("#type option:selected").val()
  104. for (var i = 0; i < arr[o].length; i++) {
  105. $("#" + arr[o][i]).css("display", "block")
  106. }
  107. }
  108. function resetClientCnf() {
  109. for (var i = 0; i < arrClientHide.length; i++) {
  110. $("#" + arrClientHide[i]).css("display", "block")
  111. }
  112. op = $("#use_client option:selected").val()
  113. if (op == 1) {
  114. for (var i = 0; i < arrClientHide.length; i++) {
  115. $("#" + arrClientHide[i]).css("display", "none")
  116. }
  117. }
  118. }
  119. $(function () {
  120. resetForm()
  121. resetClientCnf()
  122. $("#type").on("change", function () {
  123. resetForm()
  124. resetClientCnf()
  125. })
  126. $("#use_client").on("change", function () {
  127. resetForm()
  128. resetClientCnf()
  129. })
  130. $("#add").on("click", function () {
  131. $.ajax({
  132. type: "POST",
  133. url: "/index/edit",
  134. data: $("form").serializeArray(),
  135. success: function (res) {
  136. alert(res.msg)
  137. if (res.status) {
  138. history.back(-1)
  139. }
  140. }
  141. })
  142. })
  143. })
  144. </script>