edit.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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" langtag="info-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" langtag="info-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. {{if eq true .allow_multi_ip}}
  31. <div class="form-group" id="server_ip">
  32. <label class="col-sm-2 control-label" langtag="info-server-ip">服务端ip</label>
  33. <div class="col-sm-10">
  34. <input class="form-control" type="text" value="{{.t.ServerIp}}" name="server_ip"
  35. placeholder="such as 0.0.0.0">
  36. </div>
  37. </div>
  38. {{end}}
  39. <div class="form-group" id="port">
  40. <label class="col-sm-2 control-label" langtag="info-server-port">服务端端口</label>
  41. <div class="col-sm-10">
  42. <input value="{{.t.Port}}" class="form-control" type="text" name="port"
  43. placeholder="such as 8024">
  44. </div>
  45. </div>
  46. <div class="form-group" id="target">
  47. <label class="col-sm-2 control-label" langtag="info-target">内网目标(ip:端口)</label>
  48. <div class="col-sm-10">
  49. <textarea class="form-control" name="target" rows="4" placeholder="10.1.50.203:22
  50. 10.1.50.202:22">{{.t.Target.TargetStr}}</textarea>
  51. <span class="help-block m-b-none">can only fill in ports if it is local machine proxy, only tcp supports load balancing
  52. </span></div>
  53. </div>
  54. <div class="form-group" id="client_id">
  55. <label class="col-sm-2 control-label" langtag="info-client-id">客户端id</label>
  56. <div class="col-sm-10">
  57. <input value="{{.t.Client.Id}}" value="{{.client_id}}" class="form-control" type="text"
  58. name="client_id"
  59. placeholder="id of client">
  60. </div>
  61. </div>
  62. <div class="form-group" id="local_path">
  63. <label class="col-sm-2 control-label" langtag="info-local-path">本地路径</label>
  64. <div class="col-sm-10">
  65. <input value="{{.t.LocalPath}}" class="form-control" type="text" name="local_path"
  66. placeholder="such as /tmp">
  67. </div>
  68. </div>
  69. <div class="form-group" id="strip_pre">
  70. <label class="col-sm-2 control-label" langtag="info-strip-pre">访问前缀</label>
  71. <div class="col-sm-10">
  72. <input value="{{.t.StripPre}}" class="form-control" type="text" name="strip_pre"
  73. placeholder="such as static">
  74. </div>
  75. </div>
  76. <div class="form-group" id="password">
  77. <label class="col-sm-2 control-label" langtag="info-unique-vkey">唯一验证密钥</label>
  78. <div class="col-sm-10">
  79. <input value="{{.t.Password}}" class="form-control" type="text" name="password"
  80. placeholder="unique identification key">
  81. <span class="help-block m-b-none">when p2p or secret</span>
  82. </div>
  83. </div>
  84. <div class="hr-line-dashed"></div>
  85. <div class="form-group">
  86. <div class="col-sm-4 col-sm-offset-2">
  87. <button class="btn btn-success" href="#" id="add"><i
  88. class="fa fa-fw fa-lg fa-eye"></i><span langtag="info-save">保存</span>
  89. </button>
  90. </div>
  91. </div>
  92. </form>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <script>
  98. var arr = []
  99. arr["all"] = ["type", "port", "compress", "u", "p", "target", "password", "local_path", "strip_pre"]
  100. arr["tcp"] = ["type", "port", "target", "u", "p", "compress"]
  101. arr["udp"] = ["type", "port", "target", "compress"]
  102. arr["socks5"] = ["type", "port", "compress", "u", "p"]
  103. arr["httpProxy"] = ["type", "port", "compress", "u", "p"]
  104. arr["secret"] = ["type", "target", "compress", "u", "p", "password"]
  105. arr["p2p"] = ["type", "password"]
  106. arr["file"] = ["type", "port", "local_path", "strip_pre"]
  107. arrClientHide = ["compress", "u", "p", "crypt", "mux"]
  108. function resetForm() {
  109. for (var i = 0; i < arr["all"].length; i++) {
  110. $("#" + arr["all"][i]).css("display", "none")
  111. }
  112. o = $("#type option:selected").val()
  113. for (var i = 0; i < arr[o].length; i++) {
  114. $("#" + arr[o][i]).css("display", "block")
  115. }
  116. }
  117. function resetClientCnf() {
  118. for (var i = 0; i < arrClientHide.length; i++) {
  119. $("#" + arrClientHide[i]).css("display", "block")
  120. }
  121. op = $("#use_client option:selected").val()
  122. if (op == 1) {
  123. for (var i = 0; i < arrClientHide.length; i++) {
  124. $("#" + arrClientHide[i]).css("display", "none")
  125. }
  126. }
  127. }
  128. $(function () {
  129. resetForm()
  130. resetClientCnf()
  131. $("#type").on("change", function () {
  132. resetForm()
  133. resetClientCnf()
  134. })
  135. $("#use_client").on("change", function () {
  136. resetForm()
  137. resetClientCnf()
  138. })
  139. $("#add").on("click", function () {
  140. $.ajax({
  141. type: "POST",
  142. url: "/index/edit",
  143. data: $("form").serializeArray(),
  144. success: function (res) {
  145. alert(res.msg)
  146. if (res.status) {
  147. history.back(-1)
  148. }
  149. }
  150. })
  151. })
  152. })
  153. </script>