nps/web/views/index/edit.html

142 lines
7.0 KiB
Go
Executable File
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<div class="row tile">
<div class="col-md-6 col-md-auto">
<div>
<h3 class="tile-title"></h3>
<div class="tile-body">
<form>
<input type="hidden" name="id" value="{{.t.Id}}">
<div class="form-group">
<label class="control-label"></label>
<select class="form-control" name="type" id="type">
<option {{if eq "tunnelServer" .t.Mode}}selected{{end}} value="tunnelServer">tcp</option>
<option {{if eq "udpServer" .t.Mode}}selected{{end}} value="udpServer">udp</option>
<option {{if eq "socks5Server" .t.Mode}}selected{{end}} value="socks5Server">socks5
</option>
<option {{if eq "httpProxyServer" .t.Mode}}selected{{end}} value="httpProxyServer">http
</select>
</div>
<div class="form-group">
<label class="control-label"></label>
<input class="form-control" value="{{.t.Remark}}" type="text" name="remark" placeholder="备注">
</div>
<div class="form-group" id="port">
<label class="control-label"></label>
<input class="form-control" value="{{.t.TcpPort}}" type="text" name="port"
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>
<input class="form-control" value="{{.t.Client.Id}}" type="text" name="client_id"
placeholder="客户端id">
</div>
<div class="form-group" id="use_client">
<label class="control-label">使</label>
<select class="form-control" name="use_client">
<option {{if eq false .t.UseClientCnf}}selected{{end}} value="0"></option>
<option {{if eq true .t.UseClientCnf}}selected{{end}} value="1"></option>
</select>
</div>
<div class="form-group" id="compress">
<label class="control-label">()</label>
<select class="form-control" name="compress">
<option {{if eq "" .t.Config.Compress}}selected{{end}} value=""></option>
<option {{if eq "snappy" .t.Config.Compress}}selected{{end}} value="snappy">snappy</option>
</select>
</div>
<div class="form-group" id="crypt">
<label class="control-label">()</label>
<select class="form-control" name="crypt">
<option {{if eq false .t.Config.Crypt}}selected{{end}} value="0"></option>
<option {{if eq true .t.Config.Crypt}}selected{{end}} value="1"></option>
</select>
</div>
<div class="form-group" id="mux">
<label class="control-label">TCP()</label>
<select class="form-control" name="mux">
<option {{if eq false .t.Config.Mux}}selected{{end}} value="0"></option>
<option {{if eq true .t.Config.Mux}}selected{{end}} value="1"></option>
</select>
</div>
<div class="form-group" id="u">
<label class="control-label">(socks5,web穿)</label>
<input class="form-control" value="{{.t.Config.U}}" type="text" name="u"
placeholder="不填则无需验证">
</div>
<div class="form-group" id="p">
<label class="control-label">(socks5,web穿)</label>
<input class="form-control" value="{{.t.Config.P}}" type="text" name="p"
placeholder="不填则无需验证">
</div>
</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 = []
arr["all"] = ["type", "port", "compress", "u", "p", "target"]
arr["tunnelServer"] = ["type", "port", "target", "u", "p", "compress"]
arr["udpServer"] = ["type", "port", "target", "compress"]
arr["socks5Server"] = ["type", "port", "compress", "u", "p"]
arr["httpProxyServer"] = ["type", "port", "compress", "u", "p"]
arrClientHide = ["compress", "u", "p", "crypt", "mux"]
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")
}
}
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")
}
}
}
$(function () {
resetForm()
resetClientCnf()
$("#type").on("change", function () {
resetForm()
resetClientCnf()
})
$("#use_client").on("change", function () {
resetForm()
resetClientCnf()
})
$("#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>