forked from x/ContextOS
add Download.plugin.js
This commit is contained in:
parent
447dba33c2
commit
16f7cde6bb
@ -727,6 +727,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
format, format_time = kit.Select("%s", m.Meta["format"], 0), kit.Select("20060102", m.Meta["format"], 1)
|
format, format_time = kit.Select("%s", m.Meta["format"], 0), kit.Select("20060102", m.Meta["format"], 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
today := time.Now()
|
||||||
now := kit.Times(m.Cmd("cli.time", arg).Append("datetime"))
|
now := kit.Times(m.Cmd("cli.time", arg).Append("datetime"))
|
||||||
n := kit.Int(kit.Select("1", m.Option("count")))
|
n := kit.Int(kit.Select("1", m.Option("count")))
|
||||||
if m.Has("nature") {
|
if m.Has("nature") {
|
||||||
@ -752,6 +753,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
}
|
}
|
||||||
for month := cur.Month(); cur.Month() == month; cur = cur.AddDate(0, 0, 1) {
|
for month := cur.Month(); cur.Month() == month; cur = cur.AddDate(0, 0, 1) {
|
||||||
data := fmt.Sprintf("%d", cur.Day())
|
data := fmt.Sprintf("%d", cur.Day())
|
||||||
|
if cur.Year() == today.Year() && cur.YearDay() == today.YearDay() {
|
||||||
|
data = fmt.Sprintf(">%d<", cur.Day())
|
||||||
|
}
|
||||||
if cur.Day() == 1 {
|
if cur.Day() == 1 {
|
||||||
if cur.Month() == 1 {
|
if cur.Month() == 1 {
|
||||||
data = fmt.Sprintf("%d年", cur.Year())
|
data = fmt.Sprintf("%d年", cur.Year())
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-09-21 18:43:47", "mac", 626,
|
"2019-09-22 09:30:17", "mac", 632,
|
||||||
}
|
}
|
||||||
|
@ -449,17 +449,17 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(arg) == 1 || arg[1] == "all" {
|
if len(arg) == 1 || arg[1] == "all" {
|
||||||
m.Add("append", "key", k)
|
m.Add("append", "cmd", k)
|
||||||
m.Add("append", "name", v.Name)
|
m.Add("append", "name", v.Name)
|
||||||
} else if arg[1] == k {
|
} else if arg[1] == k {
|
||||||
m.Add("append", "key", k)
|
m.Add("append", "cmd", k)
|
||||||
m.Add("append", "name", v.Name)
|
m.Add("append", "name", v.Name)
|
||||||
m.Add("append", "help", v.Name)
|
m.Add("append", "help", v.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len(arg) == 1 || arg[1] != "all"
|
return len(arg) == 1 || arg[1] != "all"
|
||||||
})
|
})
|
||||||
m.Sort("key").Table()
|
m.Sort("cmd").Table()
|
||||||
|
|
||||||
case "help":
|
case "help":
|
||||||
m.Cmdy("ctx.help", "command", arg[1:])
|
m.Cmdy("ctx.help", "command", arg[1:])
|
||||||
|
@ -96,7 +96,14 @@ func dir(m *ctx.Message, root string, name string, level int, deep bool, dir_typ
|
|||||||
case "line":
|
case "line":
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
if d, e := ioutil.ReadDir(p); m.Assert(e) {
|
if d, e := ioutil.ReadDir(p); m.Assert(e) {
|
||||||
m.Add("append", "line", len(d))
|
count := 0
|
||||||
|
for _, f := range d {
|
||||||
|
if strings.HasPrefix(f.Name(), ".") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
m.Add("append", "line", count)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nline := 0
|
nline := 0
|
||||||
|
@ -17,7 +17,7 @@ kit publish "发布" private \
|
|||||||
|
|
||||||
kit upgrade "升级" private "ssh._route" _ "cli.upgrade" \
|
kit upgrade "升级" private "ssh._route" _ "cli.upgrade" \
|
||||||
text "" name pod imports plugin_pod \
|
text "" name pod imports plugin_pod \
|
||||||
select "" values script values plugin values restart values package values bench values portal values system action auto \
|
select "" values script values plugin values restart values package values system values portal values bench action auto \
|
||||||
text "" name see imports plugin_see \
|
text "" name see imports plugin_see \
|
||||||
button "升级"
|
button "升级"
|
||||||
|
|
||||||
@ -28,27 +28,29 @@ kit missyou "任务" private \
|
|||||||
exports you "" you
|
exports you "" you
|
||||||
|
|
||||||
kit pod "设备" private "ssh._route" _ "ssh.remote" __ \
|
kit pod "设备" private "ssh._route" _ "ssh.remote" __ \
|
||||||
text "" name pod view long \
|
text "" name pod \
|
||||||
button "行动" action auto \
|
button "查看" action auto \
|
||||||
button "返回" click Back \
|
|
||||||
exports pod pod pod
|
exports pod pod pod
|
||||||
|
|
||||||
kit ctx "模块" private "ssh._route" _ context _ list __ \
|
kit ctx "模块" private "ssh._route" _ context _ list __ \
|
||||||
text "" name pod imports plugin_pod action auto view long \
|
text "" name pod imports plugin_pod action auto \
|
||||||
text "nfs" name ctx imports plugin_ctx action auto \
|
text "cli" name ctx imports plugin_ctx action auto \
|
||||||
button "行动" \
|
button "查看" \
|
||||||
exports ctx names
|
exports ctx names
|
||||||
|
|
||||||
kit cmd "命令" private "ssh._route" _ context _ command __ \
|
kit cmd "命令" private "ssh._route" _ context _ command __ \
|
||||||
text "" name pod imports plugin_pod \
|
text "" name pod imports plugin_pod \
|
||||||
text "nfs" name ctx imports plugin_ctx \
|
text "cli" name ctx imports plugin_ctx \
|
||||||
text "pwd" name cmd \
|
text "date" name cmd imports plugin_cmd \
|
||||||
button "执行"
|
button "执行" \
|
||||||
|
button "返回" click Last \
|
||||||
|
exports cmd cmd
|
||||||
|
|
||||||
kit dir "目录" private "ssh._route" _ "nfs.dir" _ time size line path \
|
kit dir "目录" private "ssh._route" _ "nfs.dir" _ time size line path \
|
||||||
text "" name pod imports plugin_pod action auto \
|
text "" name pod imports plugin_pod action auto \
|
||||||
text "usr/script" name dir imports plugin_dir action auto view long \
|
text "usr/script" name dir imports plugin_dir action auto view long \
|
||||||
button "浏览" action auto \
|
button "浏览" action auto \
|
||||||
|
button "返回" click Last \
|
||||||
feature display "editor" \
|
feature display "editor" \
|
||||||
exports dir "" dir
|
exports dir "" dir
|
||||||
|
|
||||||
|
@ -12,4 +12,7 @@
|
|||||||
kit.classList.add(item.parentNode, "today")
|
kit.classList.add(item.parentNode, "today")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
play: function(event) {
|
||||||
|
kit.AppendChilds(output, [{type: "video", data: {src: option.url.value, autoplay: ""}}])
|
||||||
|
},
|
||||||
}}}
|
}}}
|
||||||
|
@ -35,3 +35,16 @@ fun delay "以后告诉你" private \
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun media "娱乐" private \
|
||||||
|
text "media" name table imports plugin_table \
|
||||||
|
text "电影" name title \
|
||||||
|
text "" name link \
|
||||||
|
button "记下了"
|
||||||
|
|
||||||
|
if $2 == "" || $3 == ""
|
||||||
|
copy ssh.data show _
|
||||||
|
else
|
||||||
|
copy ssh.data insert _ title _ link __
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ var page = Page({check: true,
|
|||||||
"刷新": function(event, value) {
|
"刷新": function(event, value) {
|
||||||
output.innerHTML = "", field.Pane.Show()
|
output.innerHTML = "", field.Pane.Show()
|
||||||
},
|
},
|
||||||
"清空": function(event, value) {
|
"清屏": function(event, value) {
|
||||||
kit.Selector(output, "fieldset>div.output", function(item) {
|
kit.Selector(output, "fieldset>div.output", function(item) {
|
||||||
item.innerHTML = ""
|
item.innerHTML = ""
|
||||||
})
|
})
|
||||||
@ -435,6 +435,16 @@ var page = Page({check: true,
|
|||||||
run(list)
|
run(list)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"表格": function(event, value) {
|
||||||
|
page.plugin && page.plugin.Plugin.display("table")
|
||||||
|
},
|
||||||
|
"编辑": function(event, value) {
|
||||||
|
page.plugin && page.plugin.Plugin.display("editor")
|
||||||
|
},
|
||||||
|
"绘图": function(event, value) {
|
||||||
|
page.plugin && page.plugin.Plugin.display("canvas")
|
||||||
|
},
|
||||||
|
|
||||||
"添加": function(event, value) {
|
"添加": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.Clone().Select()
|
page.plugin && page.plugin.Plugin.Clone().Select()
|
||||||
},
|
},
|
||||||
@ -447,21 +457,24 @@ var page = Page({check: true,
|
|||||||
"减参": function(event, value) {
|
"减参": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.Remove()
|
page.plugin && page.plugin.Plugin.Remove()
|
||||||
},
|
},
|
||||||
|
"执行": function(event, value) {
|
||||||
"表格": function(event, value) {
|
page.plugin && page.plugin.Plugin.Check()
|
||||||
page.plugin && page.plugin.Plugin.display("table")
|
|
||||||
},
|
},
|
||||||
"编辑": function(event, value) {
|
"下载": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.display("editor")
|
page.plugin && page.plugin.Plugin.Download()
|
||||||
},
|
},
|
||||||
"绘图": function(event, value) {
|
"清空": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.display("canvas")
|
page.plugin && page.plugin.Plugin.clear()
|
||||||
|
},
|
||||||
|
"返回": function(event, value) {
|
||||||
|
page.plugin && page.plugin.Plugin.Last()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"],
|
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"],
|
||||||
"", "刷新", "清空", "并行", "串行",
|
"", "刷新", "清屏", "并行", "串行",
|
||||||
"", ["display", "表格", "编辑", "绘图"],
|
"", ["display", "表格", "编辑", "绘图"],
|
||||||
"", "添加", "删除", "加参", "减参",
|
"", "添加", "删除", "加参", "减参",
|
||||||
|
"", "执行", "下载", "清空", "返回",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -499,7 +512,7 @@ var page = Page({check: true,
|
|||||||
"layout": page.action.Pane.Layout(),
|
"layout": page.action.Pane.Layout(),
|
||||||
})], function(msg) {
|
})], function(msg) {
|
||||||
var url = location.origin+location.pathname+"?relay="+msg.result.join("")
|
var url = location.origin+location.pathname+"?relay="+msg.result.join("")
|
||||||
page.ontoast({text: "<img src=\""+ctx.Share({"group": "index", "name": "login", cmds: ["share", url]})+"\">", height: 320, title: url, button: ["确定"], cb: function(which) {
|
page.ontoast({text: "<img src=\""+ctx.Share({"group": "index", "name": "login", cmds: ["share", url]})+"\">", height: 320, width: 320, title: url, button: ["确定"], cb: function(which) {
|
||||||
page.ontoast()
|
page.ontoast()
|
||||||
}})
|
}})
|
||||||
})
|
})
|
||||||
|
@ -713,7 +713,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
});
|
});
|
||||||
switch (item.value) {
|
switch (item.value) {
|
||||||
case "date":
|
case "date":
|
||||||
item.value = kit.format_date(new Date())
|
item.name == "date" && (item.value = kit.format_date(new Date()))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,6 +870,16 @@ function Plugin(page, pane, field, runs) {
|
|||||||
deal = arg, plugin.ondaemon[deal||"table"](plugin.msg, cb)
|
deal = arg, plugin.ondaemon[deal||"table"](plugin.msg, cb)
|
||||||
plugin.show_after(plugin.msg)
|
plugin.show_after(plugin.msg)
|
||||||
},
|
},
|
||||||
|
Download: function() {
|
||||||
|
var text = kit.Selector(output, "tr", function(tr) {
|
||||||
|
return kit.Selector(tr, "td,th", function(td) {
|
||||||
|
return td.innerText
|
||||||
|
}).join(",")
|
||||||
|
}).join("\n"), type = ".csv"
|
||||||
|
|
||||||
|
!text && (text = plugin.msg.result.join(""), type = ".txt")
|
||||||
|
page.ontoast({text:'<a href="'+URL.createObjectURL(new Blob([text]))+'" target="_blank" download="'+name+type+'">'+name+type+'</a>', width: 200})
|
||||||
|
},
|
||||||
show_after: function(msg) {},
|
show_after: function(msg) {},
|
||||||
upload: function(event) {
|
upload: function(event) {
|
||||||
ctx.Upload(option.upload.files[0], function(event, msg) {
|
ctx.Upload(option.upload.files[0], function(event, msg) {
|
||||||
@ -934,6 +944,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
onaction: {
|
onaction: {
|
||||||
onfocus: function(event, action, type, name, item) {
|
onfocus: function(event, action, type, name, item) {
|
||||||
page.input = event.target
|
page.input = event.target
|
||||||
|
plugin.Select(true)
|
||||||
},
|
},
|
||||||
onblur: function(event, action, type, name, item) {
|
onblur: function(event, action, type, name, item) {
|
||||||
page.input = undefined
|
page.input = undefined
|
||||||
@ -952,7 +963,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ondblclick: function(event, action, type, name, item) {
|
ondblclick: function(event, action, type, name, item) {
|
||||||
action.target.value = kit.History.get("txt", -1).data.trim()
|
type == "text" && (action.target.value = kit.History.get("txt", -1).data.trim())
|
||||||
},
|
},
|
||||||
onchange: function(event, action, type, name, item) {
|
onchange: function(event, action, type, name, item) {
|
||||||
type == "select" && plugin.Check(item.action == "auto"? undefined: action)
|
type == "select" && plugin.Check(item.action == "auto"? undefined: action)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user