Browse Source

构建表单提交

master
453530270@qq.com 2 years ago
parent
commit
cafa1a4249
  1. 2
      fssc/internal/handler/handler.go
  2. 45
      fssc/web/wbconsole.tmpl

2
fssc/internal/handler/handler.go

@ -161,7 +161,7 @@ func SendZip(w http.ResponseWriter, r *http.Request) {
fmt.Println("archive is not exist!!!")
}
// 执行完 跳转到 首页
//http.Redirect(w, r, "/", http.StatusFound)
http.Redirect(w, r, "/console", http.StatusFound)
}
// 发送拦截

45
fssc/web/wbconsole.tmpl

@ -104,14 +104,13 @@
<a href="?p={{b64en $.UrlPath}}&f={{b64en .Name }}&file=0">{{ .Name }}</a>
{{ else }}
<span class="icon file-icon"></span>
<a href="?p={{b64en $.UrlPath}}&f={{b64en .Name}}&file=1">{{ .Name }}</a>
<a href="javascript:void(0);" οnclick="gosync('{{b64en .Name}}','{{b64en $.UrlPath}}')">{{.Name}}</a>
{{ end }}
</div>
<div class="col-md-4">
{{ if .IsDir }} <!-- 空白 --> {{else}}
<a href="/up?p={{b64en $.UrlPath}}&f={{b64en .Name}}&s={{b64en $.Loip}}" title="更新{{ .Name }}" class="btn btn-primary btn-sm">同步</a>
{{ if .IsDir }} <!-- 空白 todo 发送文件夹 --> {{else}}
<a href="javascript:void(0);" class="btn btn-primary btn-sm" οnclick="gosync('{{b64en .Name}}','{{b64en $.UrlPath}}')">同步</a>
{{end}}
</div>
</li>
@ -162,7 +161,7 @@
$(function(){
// read sessionStorage
var oscip = sessionStorage.getItem("scip")
var oscip = sessionStorage.getItem("scip");
if(oscip!=""){
$("#scip").val(oscip);
scip = oscip;
@ -171,7 +170,7 @@
// click function
$("#entsip").on("click",function(){
tgfs()
tgfs();
})
// 目标服务器的文件信息
@ -185,15 +184,15 @@
// 目标站
$("#mbip").text("目标站("+scip+")");
// 获取信息
gescinfo(scip)
gescinfo(scip);
//
$("#rstatus").append(html)
$("#rstatus").append(html);
}
// 获取目标服务器的信息
var gescinfo=function(scip){
// 客户端的状态地址
var url="http://"+scip+":9099/sc?p="+urlpath
var url="http://"+scip+":9099/sc?p="+urlpath;
//
var html="";
$.getJSON(url,function(res){
@ -226,9 +225,35 @@
// write log
var writelog=function(html){
var hprex="<li class=\"list-group-item\">"+html+"</li>";
$("#rstatus").append(hprex)
$("#rstatus").append(hprex);
}
//同步文件
var gosync=function(file,path){
alert(file);
// 创建一个新的表单元素
var form = $('<form></form>');
// 设置表单的action属性为服务器的URL
form.attr('action', './sup');
// 设置表单的method属性为POST
form.attr('method', 'post');
// 添加一个隐藏的输入元素
form.append($('<input type="hidden" name="sip" value="'+scip+'">'));
form.append($('<input type="hidden" name="bpath" value="'+path+'">'));
form.append($('<input type="hidden" name="bfile" value="'+file+'">'));
// 将表单添加到body中
$('body').append(form);
// 提交表单
form.submit();
// 移除
$('body').remove(form);
}
//全选按钮设置点击事件
$("#slall").click(function () {
//1、循环设置其它多选框选中状态,跟标识用的变量一样

Loading…
Cancel
Save