nps/web/views/index/edit.html

174 lines
8.5 KiB
Go
Raw Normal View History

2018-12-11 08:37:12 +00:00
<div class="row tile">
<div class="col-md-12 col-md-auto">
<div class="ibox float-e-margins">
<h3 class="ibox-title"></h3>
<div class="ibox-content">
<form class="form-horizontal">
<input type="hidden" name="id" value="{{.t.Id}}">
2018-12-11 08:37:12 +00:00
<div class="form-group">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-mode"> </label>
<div class="col-sm-10">
<select class="form-control" name="type" id="type">
<option {{if eq "tcp" .t.Mode}}selected{{end}} value="tcp">tcp</option>
<option {{if eq "udp" .t.Mode}}selected{{end}} value="udp">udp</option>
<option {{if eq "socks5" .t.Mode}}selected{{end}} value="socks5">socks5
</option>
2019-03-02 09:43:21 +00:00
<option {{if eq "httpProxy" .t.Mode}}selected{{end}} value="httpProxy">http</option>
<option {{if eq "secret" .t.Mode}}selected{{end}} value="secret">secret</option>
<option {{if eq "p2p" .t.Mode}}selected{{end}} value="p2p">p2p</option>
<option {{if eq "file" .t.Mode}}selected{{end}} value="file">file</option>
</select>
</div>
2018-12-11 08:37:12 +00:00
</div>
<div class="form-group">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-remark"></label>
<div class="col-sm-10">
<input value="{{.t.Remark}}" class="form-control" type="text" name="remark"
placeholder="empty means to be unrestricted">
</div>
</div>
2019-04-04 09:46:06 +00:00
{{if eq true .allow_multi_ip}}
<div class="form-group" id="server_ip">
<label class="col-sm-2 control-label" langtag="info-server-ip">ip</label>
<div class="col-sm-10">
<input class="form-control" type="text" value="{{.t.ServerIp}}" name="server_ip"
placeholder="such as 0.0.0.0">
</div>
</div>
2019-04-04 09:46:06 +00:00
{{end}}
2018-12-11 08:37:12 +00:00
<div class="form-group" id="port">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-server-port"></label>
<div class="col-sm-10">
2019-03-02 09:43:21 +00:00
<input value="{{.t.Port}}" class="form-control" type="text" name="port"
placeholder="such as 8024">
</div>
2018-12-11 08:37:12 +00:00
</div>
2019-04-08 09:01:08 +00:00
{{if eq true .allow_local_proxy}}
<div class="form-group" id="local_proxy">
<label class="control-label col-sm-2" langtag="info-local-proxy"></label>
<div class="col-sm-10">
<select class="form-control" name="local_proxy">
<option {{if eq false .t.Target.LocalProxy}}selected{{end}} value="0">no</option>
<option {{if eq true .t.Target.LocalProxy}}selected{{end}} value="1">yes</option>
</select>
</div>
</div>
{{end}}
2018-12-11 08:37:12 +00:00
<div class="form-group" id="target">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-target">(ip:)</label>
<div class="col-sm-10">
2019-03-07 10:07:53 +00:00
<textarea class="form-control" name="target" rows="4" placeholder="10.1.50.203:22
2019-03-29 02:41:57 +00:00
10.1.50.202:22">{{.t.Target.TargetStr}}</textarea>
2019-03-07 10:07:53 +00:00
<span class="help-block m-b-none">can only fill in ports if it is local machine proxy, only tcp supports load balancing
2019-03-23 14:19:59 +00:00
</span></div>
2018-12-11 08:37:12 +00:00
</div>
<div class="form-group" id="client_id">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-client-id">id</label>
<div class="col-sm-10">
2019-03-02 09:43:21 +00:00
<input value="{{.t.Client.Id}}" value="{{.client_id}}" class="form-control" type="text"
name="client_id"
placeholder="id of client">
</div>
</div>
2019-03-02 09:43:21 +00:00
<div class="form-group" id="local_path">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-local-path"></label>
2019-03-02 09:43:21 +00:00
<div class="col-sm-10">
<input value="{{.t.LocalPath}}" class="form-control" type="text" name="local_path"
placeholder="such as /tmp">
</div>
</div>
<div class="form-group" id="strip_pre">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-strip-pre">访</label>
2019-03-02 09:43:21 +00:00
<div class="col-sm-10">
<input value="{{.t.StripPre}}" class="form-control" type="text" name="strip_pre"
placeholder="such as static">
</div>
</div>
2019-02-23 15:29:48 +00:00
<div class="form-group" id="password">
2019-03-23 14:19:59 +00:00
<label class="col-sm-2 control-label" langtag="info-unique-vkey"></label>
<div class="col-sm-10">
<input value="{{.t.Password}}" class="form-control" type="text" name="password"
placeholder="unique identification key">
<span class="help-block m-b-none">when p2p or secret</span>
</div>
2019-02-23 15:29:48 +00:00
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
2019-12-21 07:35:55 +00:00
<button class="btn btn-success" type="button" id="add"><i
2019-03-29 02:41:57 +00:00
class="fa fa-fw fa-lg fa-eye"></i><span langtag="info-save"></span>
2019-03-02 09:43:21 +00:00
</button>
</div>
</div>
2018-12-11 08:37:12 +00:00
</form>
</div>
</div>
</div>
</div>
<script>
var arr = []
2019-04-08 09:01:08 +00:00
arr["all"] = ["type", "port", "compress", "u", "p", "target", "password", "local_path", "strip_pre", "local_proxy"]
arr["tcp"] = ["type", "port", "target", "u", "p", "compress", "local_proxy"]
arr["udp"] = ["type", "port", "target", "compress", "local_proxy"]
arr["socks5"] = ["type", "port", "compress", "u", "p"]
arr["httpProxy"] = ["type", "port", "compress", "u", "p"]
2019-03-02 09:43:21 +00:00
arr["secret"] = ["type", "target", "compress", "u", "p", "password"]
2019-04-13 11:48:34 +00:00
arr["p2p"] = ["type", "target", "password"]
2019-03-02 09:43:21 +00:00
arr["file"] = ["type", "port", "local_path", "strip_pre"]
arrClientHide = ["compress", "u", "p", "crypt", "mux"]
2018-12-11 08:37:12 +00:00
function resetForm() {
for (var i = 0; i < arr["all"].length; i++) {
$("#" + arr["all"][i]).css("display", "none")
}
o = $("#type option:selected").val()
for (var i = 0; i < arr[o].length; i++) {
$("#" + arr[o][i]).css("display", "block")
}
}
2019-01-02 17:44:45 +00:00
function resetClientCnf() {
for (var i = 0; i < arrClientHide.length; i++) {
$("#" + arrClientHide[i]).css("display", "block")
}
op = $("#use_client option:selected").val()
if (op == 1) {
for (var i = 0; i < arrClientHide.length; i++) {
$("#" + arrClientHide[i]).css("display", "none")
}
}
}
2018-12-11 08:37:12 +00:00
$(function () {
resetForm()
resetClientCnf()
2018-12-11 08:37:12 +00:00
$("#type").on("change", function () {
resetForm()
resetClientCnf()
})
$("#use_client").on("change", function () {
resetForm()
resetClientCnf()
2018-12-11 08:37:12 +00:00
})
$("#add").on("click", function () {
$.ajax({
type: "POST",
url: "{{.web_base_url}}/index/edit",
2018-12-11 08:37:12 +00:00
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)
if (res.status) {
history.back(-1)
}
}
})
})
})
</script>