nps/web/views/index/edit.html

111 lines
4.9 KiB
Go
Raw Normal View History

2018-12-11 08:37:12 +00:00
<div class="row tile">
<div class="col-md-6 col-md-auto">
<div>
2019-02-05 16:35:23 +00:00
<h3 class="tile-title"></h3>
2018-12-11 08:37:12 +00:00
<div class="tile-body">
<form>
<input type="hidden" name="id" value="{{.t.Id}}">
2018-12-11 08:37:12 +00:00
<div class="form-group">
<label class="control-label"></label>
2019-01-02 17:44:45 +00:00
<select class="form-control" name="type" id="type">
2019-02-15 14:59:28 +00:00
<option {{if eq "tcpServer" .t.Mode}}selected{{end}} value="tcpServer">tcp</option>
2018-12-11 08:37:12 +00:00
<option {{if eq "udpServer" .t.Mode}}selected{{end}} value="udpServer">udp</option>
<option {{if eq "socks5Server" .t.Mode}}selected{{end}} value="socks5Server">socks5
</option>
2018-12-11 08:37:12 +00:00
<option {{if eq "httpProxyServer" .t.Mode}}selected{{end}} value="httpProxyServer">http
2019-02-23 15:29:48 +00:00
<option {{if eq "secretServer" .t.Mode}}selected{{end}} value="secretServer">
2018-12-11 08:37:12 +00:00
</select>
</div>
<div class="form-group">
<label class="control-label"></label>
<input class="form-control" value="{{.t.Remark}}" type="text" name="remark" placeholder="备注">
</div>
2018-12-11 08:37:12 +00:00
<div class="form-group" id="port">
<label class="control-label"></label>
2019-02-12 19:54:00 +00:00
<input class="form-control" value="{{.t.Port}}" type="text" name="port"
2018-12-11 08:37:12 +00:00
placeholder="公网服务器对外访问端口例如8024">
</div>
<div class="form-group" id="target">
<label class="control-label">(tcpudp)</label>
<input class="form-control" value="{{.t.Target}}" type="text" name="target"
placeholder="内网隧道目标例如10.1.50.203:22">
</div>
<div class="form-group" id="client_id">
<label class="control-label">ID</label>
2019-01-26 09:27:28 +00:00
<input class="form-control" value="{{.t.Client.Id}}" type="text" name="client_id"
placeholder="客户端id">
</div>
2019-02-23 15:29:48 +00:00
<div class="form-group" id="password">
<label class="control-label"></label>
<input class="form-control" value="{{.t.Password}}" type="text" name="password"
placeholder="私密模式唯一密钥">
</div>
2018-12-11 08:37:12 +00:00
</form>
</div>
<div class="tile-footer">
&nbsp;&nbsp;<button class="btn btn-success" href="#" id="add"><i
class="fa fa-fw fa-lg fa-eye"></i>
</button>
</div>
</div>
</div>
</div>
</main>
<script>
var arr = []
2019-01-02 17:44:45 +00:00
arr["all"] = ["type", "port", "compress", "u", "p", "target"]
2019-02-15 14:59:28 +00:00
arr["tcpServer"] = ["type", "port", "target", "u", "p", "compress"]
2018-12-11 08:37:12 +00:00
arr["udpServer"] = ["type", "port", "target", "compress"]
2019-01-09 12:33:00 +00:00
arr["socks5Server"] = ["type", "port", "compress", "u", "p"]
2018-12-30 14:36:15 +00:00
arr["httpProxyServer"] = ["type", "port", "compress", "u", "p"]
2019-02-23 15:29:48 +00:00
arr["secretServer"] = ["type", "target", "compress", "u", "p","password"]
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: "/index/edit",
data: $("form").serializeArray(),
success: function (res) {
alert(res.msg)
if (res.status) {
history.back(-1)
}
}
})
})
})
</script>