mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add onformat.plugin.js
This commit is contained in:
parent
a1afe94027
commit
6d5d739778
@ -4,5 +4,5 @@ var version = struct {
|
||||
host string
|
||||
self int
|
||||
}{
|
||||
"2019-09-26 17:44:10", "centos", 606,
|
||||
"2019-09-27 08:55:10", "mac", 670,
|
||||
}
|
||||
|
@ -804,6 +804,10 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
|
||||
return
|
||||
}},
|
||||
"copy": &Command{Name: "copy", Help: "查看或添加选项", Hand: func(m *Message, c *Context, key string, arg ...string) (e error) {
|
||||
skip := false
|
||||
if arg[0] == "skip" {
|
||||
skip, arg = true, arg[1:]
|
||||
}
|
||||
msg := m.Optionv("bio.msg").(*Message)
|
||||
// 去年尾参
|
||||
for i := len(arg) - 1; i >= 0; i-- {
|
||||
@ -828,7 +832,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
|
||||
args = append(args, arg[i])
|
||||
}
|
||||
}
|
||||
if j < len(msg.Meta["detail"]) {
|
||||
if !skip && j < len(msg.Meta["detail"]) {
|
||||
args = append(args, msg.Meta["detail"][j:]...)
|
||||
}
|
||||
msg.Cmdy(args)
|
||||
|
@ -865,7 +865,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
}
|
||||
|
||||
// 响应数据
|
||||
group, order := m.Option("group", kit.Select(m.Conf("route", "componet_index"), m.Option("group"))), m.Option("name")
|
||||
group, order := m.Option("group", kit.Select(m.Conf("route", "componet_index"), m.Option("group"))), m.Option("names")
|
||||
list := []interface{}{}
|
||||
|
||||
for _, v := range m.Confv("componet", group).([]interface{}) {
|
||||
|
@ -1,21 +1,21 @@
|
||||
|
||||
fun meet "第一眼" protected \
|
||||
text "love" name table imports plugin_table \
|
||||
text "date" name when \
|
||||
text "" name when init date \
|
||||
text "" name where \
|
||||
button "操作"
|
||||
|
||||
if $2 == "" || $3 == ""
|
||||
copy ssh.data show _
|
||||
copy skip ssh.data show _
|
||||
else
|
||||
copy ssh.data insert _ when _ where __
|
||||
copy ssh.data insert _ when _ where
|
||||
end
|
||||
end
|
||||
|
||||
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 "date" \
|
||||
text "" name "截止时间" init date \
|
||||
text "love" name "table" imports plugin_table \
|
||||
text "when" name "when" \
|
||||
text "where" name "where" \
|
||||
@ -24,12 +24,12 @@ kit date "日历" "index.js" "index.css" protected "cli.date" _ nature _ \
|
||||
|
||||
fun delay "以后告诉你" protected \
|
||||
text "delay" name table imports plugin_table \
|
||||
text "date" name when \
|
||||
text "" name when init date\
|
||||
text "" name what view long \
|
||||
button "记下了"
|
||||
|
||||
if $2 == "" || $3 == ""
|
||||
copy ssh.data show _
|
||||
copy skip ssh.data show _
|
||||
else
|
||||
copy ssh.data insert _ when _ what __
|
||||
end
|
||||
|
@ -1,7 +1,11 @@
|
||||
ctx = context = {__proto__: kit,
|
||||
Event: function(event, msg, proto) {
|
||||
Event: Wrap(function(event, msg, proto) {
|
||||
event = event || document.createEvent("Event")
|
||||
if (event.msg && !msg) {return event.msg}
|
||||
|
||||
var meta = arguments.callee
|
||||
var order = ++meta.order
|
||||
|
||||
event.msg = msg = msg || {}, proto = proto || {}, msg.__proto__ = proto, proto.__proto__ = {
|
||||
Push: function(key, value) {
|
||||
msg.append || (msg.append = [])
|
||||
@ -23,10 +27,12 @@ ctx = context = {__proto__: kit,
|
||||
return s
|
||||
},
|
||||
}, msg.event = event
|
||||
kit.Log("event", event.type, proto.name, msg)
|
||||
kit.Log("event", order, event.type, proto.name, msg)
|
||||
return msg
|
||||
},
|
||||
Run: function(dataset, cmd, cb) {
|
||||
}, {order: 0}),
|
||||
Run: Wrap(function(dataset, cmd, cb) {
|
||||
var meta = arguments.callee
|
||||
var order = ++meta.order
|
||||
var msg = ctx.Event(event||document.createEvent("Event"), null, {name: "ctx.run"})
|
||||
|
||||
var option = {"cmds": cmd}
|
||||
@ -42,14 +48,15 @@ ctx = context = {__proto__: kit,
|
||||
msg.option.push(k)
|
||||
msg[k] = option[k]
|
||||
}
|
||||
msg.detail = ["run"].concat(option.group).concat(option.name).concat(option.cmds)
|
||||
msg.detail = ["run", order].concat(option.group).concat(option.names).concat(option.cmds)
|
||||
msg.Order = order
|
||||
|
||||
kit.Log(msg.detail.concat([msg]))
|
||||
this.POST("", option, function(msg) {
|
||||
kit.Log("run", "result", msg.result? msg.result[0]: "", msg)
|
||||
kit.Log("run", order, "result", msg.result? msg.result[0]: "", msg)
|
||||
typeof cb == "function" && cb(msg || {})
|
||||
}, msg)
|
||||
},
|
||||
}, {order: 0}),
|
||||
Runs: function(form, cb) {
|
||||
var data = {}
|
||||
for (var key in form.dataset) {
|
||||
@ -274,32 +281,32 @@ ctx = context = {__proto__: kit,
|
||||
page.ontoast("wss open")
|
||||
}
|
||||
s.onmessage = function(event) {
|
||||
var order = ++meta.order
|
||||
try {
|
||||
var msg = JSON.parse(event.data||'{}')
|
||||
} catch (e) {
|
||||
var msg = {"result": [event.data]}
|
||||
}
|
||||
|
||||
meta.order++
|
||||
// Event入口 -1.0
|
||||
msg = ctx.Event(event, msg, {
|
||||
name: meta.order,
|
||||
Order: meta.order,
|
||||
name: document.title,
|
||||
Order: order,
|
||||
Reply: function(msg) {
|
||||
kit.Log(["wss", "result"].concat(msg.result))
|
||||
kit.Log(["wss", order, "result"].concat(msg.result).concat([msg]))
|
||||
delete(msg.event), s.send(JSON.stringify(msg))
|
||||
},
|
||||
})
|
||||
|
||||
try {
|
||||
kit.Log(["wss"].concat(msg.detail).concat([msg]))
|
||||
kit.Log(["wss", order].concat(msg.detail).concat([msg]))
|
||||
typeof cb == "function" && cb(msg)
|
||||
} catch (e) {
|
||||
msg.reply(kit.Log("err", e))
|
||||
}
|
||||
}
|
||||
s.onerror = function(event) {
|
||||
kit.Log(event)
|
||||
kit.Log("wss", "error", event)
|
||||
typeof onerror == "function" && onerror(event)
|
||||
}
|
||||
s.onclose = function(event) {
|
||||
|
@ -541,7 +541,7 @@ function Pane(page, field) {
|
||||
|
||||
var timer = ""
|
||||
var list = [], last = -1, member = {}
|
||||
var name = option.dataset.name
|
||||
var name = option.dataset.names
|
||||
var pane = Meta(field, (page[field.dataset.init] || function() {
|
||||
})(page, field, option, output) || {}, {
|
||||
Append: function(type, line, key, which, cb) {
|
||||
@ -742,11 +742,7 @@ function Plugin(page, pane, field, runs) {
|
||||
}
|
||||
}: cb)
|
||||
});
|
||||
switch (item.value) {
|
||||
case "date":
|
||||
item.name == "date" && (item.value = kit.format_date(new Date()))
|
||||
break
|
||||
}
|
||||
item.value = plugin.onformat(item.init)(item.value)
|
||||
|
||||
!item.title && item.name && (item.title = item.name)
|
||||
!item.placeholder && item.title && (item.placeholder = item.title)
|
||||
@ -947,6 +943,13 @@ function Plugin(page, pane, field, runs) {
|
||||
page.ontoast(), page.ontoast("上传进度 "+parseInt(event.loaded*100/event.total)+"%")
|
||||
})
|
||||
},
|
||||
onformat: Wrap(function(which) {
|
||||
var meta = arguments.callee
|
||||
return meta[which]||meta["none"]
|
||||
}, {
|
||||
none: function(value) {return value},
|
||||
date: function(value) {return kit.format_date(new Date())},
|
||||
}),
|
||||
ondaemon: {
|
||||
inner: function(msg, cb) {
|
||||
output.style.maxWidth = pane.target.clientWidth-20+"px"
|
||||
|
@ -14,13 +14,13 @@
|
||||
</head>
|
||||
<body>
|
||||
<fieldset class="toast"><legend></legend>
|
||||
<form class="option" data-name="toast"></form>
|
||||
<form class="option" data-names="toast"></form>
|
||||
<div class="output"></div>
|
||||
</fieldset>
|
||||
{{end}}
|
||||
{{define "fieldset"}}
|
||||
<fieldset class="{{options . "view"}}" data-init="{{options . "init"}}">
|
||||
<form class="option" data-name="{{options . "name"}}" data-group="{{options . "group"}}">
|
||||
<form class="option" data-names="{{options . "name"}}" data-group="{{options . "group"}}">
|
||||
<input style="display:none"></input>
|
||||
</form>
|
||||
<div class="output"></div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user