1
0
forked from x/ContextOS

add love.delay

This commit is contained in:
shaoying 2019-09-20 21:18:43 +08:00
parent 935c845a8b
commit c599beac02
8 changed files with 32 additions and 21 deletions

View File

@ -707,18 +707,18 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
return
}},
"date": &ctx.Command{Name: "date", Help: "日历", Form: map[string]int{"space": 1, "format": 2, "count": 1, "nature": 1, "cmd": -1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if m.Has("cmd") {
m.Log("fino", "what %v", m.Meta["cmd"])
if m.Has("cmd") { // TODO 这是个漏洞
m.Cmdy(m.Meta["cmd"])
return
}
show := map[int]string{0: "周日", 1: "周一", 2: "周二", 3: "周三", 4: "周四", 5: "周五", 6: "周六"}
space := m.Options("space")
format, format_time := "", ""
if m.Has("format") {
format, format_time = kit.Select("%s", m.Meta["format"], 0), kit.Select("20060102", m.Meta["format"], 1)
}
space := m.Options("space")
now := kit.Times(m.Cmd("cli.time", arg).Append("datetime"))
n := kit.Int(kit.Select("1", m.Option("count")))
if m.Has("nature") {

View File

@ -4,5 +4,5 @@ var version = struct {
host string
self int
}{
"2019-09-19 19:02:39", "centos", 562,
"2019-09-20 16:49:11", "centos", 563,
}

View File

@ -1076,7 +1076,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
}},
"json": &ctx.Command{Name: "json str", Help: "导入数据", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
var data interface{}
m.Assert(json.Unmarshal([]byte(arg[0]), &data))
m.Assert(json.Unmarshal([]byte(kit.Select("{}", arg, 0)), &data))
if b, e := json.MarshalIndent(data, "", " "); m.Assert(e) {
m.Echo(string(b))
}

View File

@ -1,2 +1,4 @@
fieldset.item.demo div.output {
fieldset.item.love.date table td.today {
border:solid 2px red;
}

View File

@ -2,17 +2,14 @@
show: function(event) {
run(event, ["", "", "cmd", "ssh.data", "show", option.table.value], function(msg) {ctx.Table(msg, function(value) {
kit.Selector(output, ".s"+value[option.when.value].split(" ")[0].split("-").join(""), function(item) {
item.parentNode.style.backgroundColor = "red"
kit.classList.add(item.parentNode, "select")
item.parentNode.title = value[option.where.value]
})
})})
},
show_after: function(msg) {
var now = kit.format_date(new Date())
kit.Selector(output, ".s"+now.split(" ")[0].split("-").join(""), function(item) {
item.parentNode.style.backgroundColor = "red"
item.innerText = "TODAY"
item.parentNode.title = "today"
kit.Selector(output, ".s"+ kit.format_date().split(" ")[0].split("-").join(""), function(item) {
kit.classList.add(item.parentNode, "today")
})
},
}}}

View File

@ -16,7 +16,7 @@ fun meet "第一眼" private \
copy ssh.data insert _ when _ where __
end
kit date "日历" "index.js" protected "cli.date" _ nature _ \
kit date "日历" "index.js" "index.css" protected "cli.date" _ nature _ \
\ space true format '<span class="%s">%s</span>' "s20060102" \
text "2019-07-08" name "起始时间" \
text "date" name "截止时间" \
@ -26,3 +26,16 @@ kit date "日历" "index.js" protected "cli.date" _ nature _ \
button "查看" action auto \
button "显示" click show
fun delay "以后告诉你" private \
text "delay" name table imports plugin_table \
text "date" name when \
text "" name what view long \
button "记下了"
if $2 == "" || $3 == ""
copy ssh.data show _
return
end
copy ssh.data insert _ when _ what __
end

View File

@ -75,16 +75,14 @@ function Meta(target, obj) {
var text = JSON.parse(line.text)
case "plugin":
if (!text.name) {
return {}
}
if (!text.name) {return {}}
var id = "plugin"+this.ID()
list.push({view: ["item", "fieldset", "", "field"], data: {id: id, Run: cb}, list: [
{text: [text.name+"("+text.help+")", "legend"]},
{view: ["option", "form", "", "option"], list: [{type: "input", style: {"display": "none"}}]},
{view: ["output", "div", "", "output"]},
{script: ""+id+".Script="+(text.init||"{}")},
{styles: text.view},
text.view?{styles: text.view}:null, text.init?{script: ""+id+".Script = "+text.init}:null,
]})
break
}
@ -699,7 +697,7 @@ function Plugin(page, pane, field, runs) {
var display = JSON.parse(meta.display||'{}')
var exports = JSON.parse(meta.exports||'["",""]')
var deal = (feature && feature.display) || "table"
kit.classList.add(field, feature.style)
kit.classList.add(field, meta.group, name, feature.style)
var history = []
var run = function(event, cmds, cbs) {

View File

@ -48,9 +48,9 @@ kit = toolkit = {
// HTML节点操作
classList: {
add: function(obj) {
var list = obj.className.split(" ")
var list = obj.className? obj.className.split(" "): []
for (var i = 1; i < arguments.length; i++) {
list.push(arguments[i])
arguments[i] && list.push(arguments[i])
}
return obj.className = list.join(" ")
},
@ -650,6 +650,7 @@ kit = toolkit = {
return Math.sqrt(Math.pow(x1-x0, 2)+Math.pow(y1-y0, 2))
},
format_date: function(arg) {
arg = arg || new Date()
var date = arg.getDate()
if (date < 10) {
date = "0"+date