1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shaoying 2019-09-30 15:32:50 +08:00
parent df5d390820
commit 79ef6c8718
10 changed files with 183 additions and 85 deletions

View File

@ -719,10 +719,6 @@ 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") { // TODO 这是个漏洞
m.Cmdy(m.Meta["cmd"])
return
}
show := map[int]string{0: "周日", 1: "周一", 2: "周二", 3: "周三", 4: "周四", 5: "周五", 6: "周六"}
space := m.Options("space")

View File

@ -1,8 +1,11 @@
package cli
var version = struct {
init []string
time string
host string
self int
}{
"2019-09-29 22:27:58", "mac", 612,
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
`2019-09-30 15:01:56`, `centos`, 622,
}

View File

@ -399,7 +399,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}
return
}},
"data": {Name: "data show|save|create|insert", Help: "数据", Form: map[string]int{"format": 1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
"data": {Name: "data show|save|create|insert", Help: "数据", Form: map[string]int{"format": 1, "fields": -1}, Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) == 0 {
arg = append(arg, "show")
}
@ -433,7 +433,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}
sort.Strings(keys)
m.Meta["append"] = []string{"id", "when"}
if m.Meta["append"] = []string{"id", "when"}; m.Has("fields") {
keys = kit.Trans(m.Optionv("fields"))
}
m.Confm("flow", []string{m.Option("river"), "data", arg[1], "list"}, func(index int, value map[string]interface{}) {
for _, k := range keys {
m.Push(k, kit.Format(value[k]))
@ -445,13 +447,25 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
switch m.Option("format") {
case "object":
m.Confm("flow", []string{m.Option("river"), "data", arg[1], "list", kit.Format(index)}, func(key string, value string) {
m.Push(key, value)
if key != "extra" {
m.Push(key, value)
}
})
m.Confm("flow", []string{m.Option("river"), "data", arg[1], "list", kit.Format(index), "extra"}, func(key string, value string) {
m.Push("extra."+key, value)
})
default:
m.Confm("flow", []string{m.Option("river"), "data", arg[1], "list", kit.Format(index)}, func(key string, value string) {
m.Push("key", key)
if key != "extra" {
m.Push("key", key)
m.Push("value", value)
}
})
m.Confm("flow", []string{m.Option("river"), "data", arg[1], "list", kit.Format(index), "extra"}, func(key string, value string) {
m.Push("key", "extra."+key)
m.Push("value", value)
})
m.Sort("key")
}
}
m.Table()
@ -529,10 +543,14 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
m.Cmdy("ssh.data", "save", arg[1])
case "update":
index := kit.Int(arg[2]) - 1
for i := 3; i < len(arg)-1; i += 2 {
m.Confv("flow", []string{m.Option("river"), "data", arg[1], "list", kit.Format(index), arg[i]}, arg[i+1])
table, index, prefix, arg := arg[1], kit.Int(arg[2])-1, "", arg[3:]
if arg[0] == "extra" {
prefix, arg = "extra.", arg[1:]
}
for i := 0; i < len(arg)-1; i += 2 {
m.Confv("flow", []string{m.Option("river"), "data", table, "list", kit.Format(index), prefix + arg[i]}, arg[i+1])
}
m.Cmdy("ssh.data", "show", table, index+1)
case "import":
if len(arg) < 3 {
m.Cmdy("ssh.data", "show", arg)

View File

@ -3,24 +3,17 @@ fieldset.item.love.date table td.today {
border:solid 2px red;
}
fieldset.item.love.date table td {
word-break:break-all;
text-align:center;
min-width:40px;
}
fieldset.item.love.days div.day {
opacity:0;
padding:8px;
border:solid 2px cyan;
margin:8px;
border:solid 2px cyan;
padding:8px;
opacity:0;
float:left;
}
fieldset.item.love.days div.day span.day {
font-size:18px;
font-weight:bold;
font-style:italic;
margin-right:5px;
}
fieldset.item.love.days span.what {
font-size:24px;
}
@ -32,3 +25,8 @@ fieldset.item.love.days span.day1 {
font-size:32px;
color:green;
}
fieldset.item.love.media table td {
text-align:center;
min-width:60px;
}

View File

@ -1,13 +1,20 @@
{init: function(run, field, option, output) {
return {
show: function(event) {
run(event, ["", "", "cmd", "ssh.data", "show", option.table.value], function(msg) {
kit.List(ctx.Table(msg), function(value) {
kit.Selector(output, ".s"+value[option.when.value].split(" ")[0].split("-").join(""), function(item) {
kit.classList.add(item.parentNode, "select")
item.parentNode.title = value[option.where.value]
})
}, 200)
data: function(event) {var plugin = field.Plugin
run(event, [option.table.value], function(msg) {
plugin.msg = msg, plugin.display("table")
})
},
show: function(event) {var plugin = field.Plugin
plugin.Check(undefined, function(msg) {
run(event, [option.table.value], function(msg) {
kit.List(ctx.Table(msg), function(line) {
kit.Selector(output, ".s"+line.when.split(" ")[0].split("-").join(""), function(item) {
kit.classList.add(item.parentNode, "select")
item.parentNode.title = line.what
})
}, 200)
})
})
},
show_after: function(msg) {
@ -15,29 +22,55 @@ return {
kit.classList.add(item.parentNode, "today")
})
},
onexport: {"": function(value, name, line) {var plugin = field.Plugin
switch (field.Meta.name) {
case "days": plugin.flash(line, function(list) {
return kit.AppendChilds(output, list)
}); break
case "date":
plugin.Check(undefined, function(msg) {
kit.Selector(output, ".s"+line.when.split(" ")[0].split("-").join(""), function(item) {
kit.classList.add(item.parentNode, "select")
item.parentNode.title = line.what
})
})
break
case "detail":
plugin.Change(event.target, function(value) {
run(event, ["update", option.table.value, option.index.value, line.key, value], function(msg) {
kit.Log("ok")
})
})
break
}
return line.id
}},
flash: function(line, cb, index, array) {var plugin = field.Plugin
var now = new Date()
var day = new Date(line.when)
var mis = parseInt((day.getTime() - now.getTime()) / 1000 / 3600 / 24)
if (array && index == array.length-1) {
mis = 999999
}
var list = kit.Span()
list.span(["距", "day"], line.when.split(" ")[0])
list.span(["在", "day"], line.where)
list.span([line.what, "what"])
list.span(mis>0? "还有": "过去", [mis, mis>0? "day1": "day0"], "天")
kit.Opacity(cb([{text: [list.join(""), "div", "day"]}]).last)
},
Order: function(t, cb, cbs) {var plugin = field.Plugin
var msg = plugin.msg, now = new Date()
kit.List(ctx.Table(msg).concat([{when: "9999-01-08", what: "最后一次爱你", where: "北京市"}]), function(line, index, array) {
var day = new Date(line.when)
var mis = parseInt((day.getTime() - now.getTime()) / 1000 / 3600 / 24)
if (index == array.length-1) {
mis = 999999
}
var list = kit.Span()
list.span(["距", "day"], line.when.split(" ")[0])
list.span(["在", "day"], line.where)
list.span([line.what, "what"])
list.span(mis>0? "还有": "过去", [mis, mis>0? "day1": "day0"], "天")
kit.Opacity(cb(output, [{text: [list.join(""), "div", "day"]}]).last)
kit.List(ctx.Table(plugin.msg).concat([{when: "9999-01-08", what: "最后一次爱你", where: "北京市"}]), function(line, index, array) {
plugin.flash(line, cb, index, array)
}, t, cbs)
},
Flash: function(event) {var plugin = field.Plugin
plugin.Order(1000, function(output, list) {
plugin.Order(1000, function(list) {
return kit.AppendChilds(output, list)
}, function() {
output.innerHTML = "", plugin.Order(400, function(output, list) {
output.innerHTML = "", plugin.Order(400, function(list) {
return kit.AppendChild(output, list)
})
})

View File

@ -1,29 +1,36 @@
kit date "每一天" "index.js" "index.css" protected "cli.date" _ nature _ \
\ space true format '<span class="%s">%s</span>' "s20060102" \
fun date "每一天" "index.js" "index.css" protected \
text "love" name "table" imports plugin_table view tiny \
text "2019-07-08" name "起始时间" \
text "" name "截止时间" init date \
text "love" name "table" imports plugin_table view tiny \
text "when" name "when" view tiny \
text "where" name "where" view tiny \
button "查看" action auto \
button "显示" cb show
button "日历" action auto \
button "记录" cb data \
button "展示" cb show \
exports index ""
if $2 == "" || $3 == ""
copy skip ssh.data show _ fields id when where what
else
copy skip cli.date $2 nature $3 space true format '<span class="%s">%s</span>' "s20060102"
end
end
fun maps "每一面" "maps.js" "index.css" protected \
text "love" name table imports plugin_table \
text "" name when init date \
text "" name what view long \
button "本地" cb Current \
text "北京市" name city view tiny \
text "弘源首著" name where \
button "本地" cb Current \
button "搜索" cb Search action auto \
button "记录" cb Record \
button "展示" cb Flashs
button "展示" cb Flashs \
exports index ""
if $2 == "" || $3 == ""
copy skip ssh.data show _
else
copy ssh.data insert _ when _ what _ city _ where _ longitude _ latitude _ scale _
copy ssh.data insert _ when _ what _ city _ where _
end
end
@ -32,15 +39,34 @@ fun days "每一次" "index.js" "index.css" protected \
text "" name when init date \
text "" name what view long \
button "记录" \
button "展示" cb Flash
button "展示" cb Flash \
exports index ""
if $2 == "" || $3 == ""
copy skip ssh.data show _
copy skip ssh.data show _ fields id when where what
else
copy ssh.data insert _ when _ what __
end
end
fun detail "详情" "index.js" protected \
text "love" name table imports plugin_table \
text "1" name index imports plugin_index action auto view tiny \
button "查看"
if $1 == "update"
copy ssh.data
else
copy ssh.data show
end
end
kit note "回忆" "index.js" protected "ssh.data" update _ _ extra \
text "love" name table imports plugin_table \
text "1" name index imports plugin_index action auto view tiny \
text "" name field \
text "" name value \
button "添加"
fun delay "以后告诉你" protected \
text "delay" name table imports plugin_table \
text "" name when init date\
@ -56,14 +82,15 @@ end
fun media "娱乐" private \
text "media" name table imports plugin_table \
text "电影" name title \
text "" name link \
select "电影" values "电影" values "音乐" values "电视剧" \
text "" name title \
text "" name link view long \
button "记下了"
if $2 == "" || $3 == ""
copy ssh.data show _
if $2 == "" || $3 == "" || $4 == ""
copy skip ssh.data show $1 fields id type name link
else
copy ssh.data insert _ title _ link __
copy ssh.data insert _ type _ name _ link __
end
end

View File

@ -2,14 +2,17 @@
var id
return {
initMap: function() {var plugin = field.Plugin
var width = field.parentNode.clientWidth-40
!id && (id = plugin.id+"map"+plugin.ID())
var width = field.parentNode.clientWidth-40
kit.AppendChilds(output, [{type: "div", data: {id: id}, style: {width: width+"px", height: width*(kit.device.isMobile? 7: 3)/5}}])
map = new BMap.Map(id)
map.addControl(new BMap.NavigationControl())
map.addControl(new BMap.ScaleControl())
map.addControl(new BMap.OverviewMapControl())
map.addControl(new BMap.MapTypeControl())
return map
},
Current: function() {
var geo = new BMap.Geolocation()
@ -34,27 +37,29 @@ return {
return parseInt(value*len)/parseFloat(len)
}
var l = map.getCenter()
run(event, [option.table.value, option.when.value, option.what.value, option.city.value, option.where.value, trunc(l.lng), trunc(l.lat), map.getZoom()], function(msg) {
run(event, [option.table.value, option.when.value, option.what.value, option.city.value, option.where.value,
"longitude", trunc(l.lng), "latitude", trunc(l.lat), "scale", map.getZoom()], function(msg) {
plugin.msg = msg, plugin.display("table")
})
},
Flashs: function() {var plugin = field.Plugin
plugin.initMap(), run(event, [option.table.value], function(msg) {
kit.List(ctx.Table(msg), function(line, index) {
var p = new BMap.Point(line.longitude, line.latitude)
map.centerAndZoom(p, line.scale)
var info = new BMap.InfoWindow(line.when+"<br/>"+line.where, {width: 200, height: 100, title: line.what})
map.openInfoWindow(info, map.getCenter())
output.style.opacity = 0
kit.Opacity(output)
}, 1000)
kit.List(ctx.Table(msg), plugin.place, 1000)
})
},
Demo: function() {
var info = new BMap.InfoWindow("hello"+"<br/>"+"world", {width: 200, height: 100, title: "haha"})
map.openInfoWindow(info, map.getCenter())
},
place: function(line) {
var p = new BMap.Point(line.longitude, line.latitude)
map.centerAndZoom(p, line.scale)
var info = new BMap.InfoWindow(line.when+"<br/>"+line.where, {width: 200, height: 100, title: line.what})
map.openInfoWindow(info, map.getCenter())
output.style.opacity = 0
kit.Opacity(output)
},
onexport: {"": function(value, name, line) {var plugin = field.Plugin
plugin.initMap(), plugin.place(line)
return line.id
}},
}}}

View File

@ -20,8 +20,10 @@ var page = Page({check: true,
width -= page.river.offsetWidth+page.storm.offsetWidth
sizes.action == -1 && (sizes.action = kit.device.isMobile? "": height, sizes.target = 0, sizes.source = 0)
sizes.action == undefined && (sizes.action = page.action.clientHeight)
sizes.action == undefined && (sizes.action = page.action.offsetHeight-page.conf.border)
sizes.source == undefined && (sizes.source = page.source.clientHeight)
sizes.target == undefined && (sizes.target = page.target.clientHeight)
sizes.source == 0 && sizes.target == 0 && (sizes.action = height)
page.action.Pane.Size(width, sizes.action)
page.source.Pane.Size(width, sizes.source)
height -= sizes.target==0? height: page.source.offsetHeight+page.action.offsetHeight
@ -704,6 +706,6 @@ var page = Page({check: true,
page.onaction[item] && page.onaction[item](event, item, value, page)
})
page.river.Pane.Show()
// page.WSS()
page.WSS()
},
})

View File

@ -731,6 +731,19 @@ function Plugin(page, pane, field, runs) {
var name = "args"+kit.Selector(option, "input.args.temp").length
plugin.Append({type: "text", name: name, className: "args temp"}).focus()
},
Change: function(target, cb) {
var value = target.value
function reset(event) {
value != event.target.value && kit._call(cb, [event.target.value, value])
target.innerHTML = event.target.value
}
kit.AppendChilds(target, [{type: "input", value: target.innerText, data: {
onblur: reset,
onkeydown: function(event) {
page.oninput(event), event.key == "Enter" && reset(event)
},
}}]).last.focus()
},
Append: function(item, name, value) {
kit.Item(plugin.onaction, function(k, cb) {
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
@ -949,14 +962,14 @@ function Plugin(page, pane, field, runs) {
inner: function(msg, cb) {
output.style.maxWidth = pane.target.clientWidth-20+"px"
output.style.maxHeight = pane.target.clientHeight-60+"px"
output.innerHTML = "", msg.append? kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value, name, line) {
output.innerHTML = "", msg.append? kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1]||"", function(event, value, name, line) {
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
}): (output.innerHTML = msg.result.join(""))
typeof cb == "function" && cb(msg)
},
table: function(msg, cb) {
output.innerHTML = ""
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value, name, line) {
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1]||"", function(event, value, name, line) {
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
});
(display.show_result || !msg.append) && msg.result && kit.OrderCode(kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}]).first)
@ -970,7 +983,7 @@ function Plugin(page, pane, field, runs) {
},
},
onexport: {
"": function(value, name) {
"": function(value, name, line) {
return value
},
see: function(value, name, line) {

View File

@ -597,6 +597,7 @@ kit = toolkit = {__proto__: document,
}
return true
},
// HTML修改文本
// 数据容器迭代
Selector: function(obj, item, cb, interval, cbs) {
@ -774,6 +775,8 @@ kit = toolkit = {__proto__: document,
},
_call: function(cb, arg) {
var res
if (typeof cb != "function") {return}
switch (arg.length) {
case 0: res = cb(); break
case 1: res = cb(arg[0]); break