mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
opt nfs.grep
This commit is contained in:
parent
4faa91b114
commit
a66a4f1606
@ -18,7 +18,7 @@ Plug 'easymotion/vim-easymotion'
|
||||
Plug 'gcmt/taboo.vim'
|
||||
set sessionoptions+=tabpages,globals
|
||||
|
||||
Plug 'vim-scripts/taglist.vim'
|
||||
" Plug 'vim-scripts/taglist.vim'
|
||||
let g:Tlist_WinWidth=45
|
||||
let g:Tlist_Exit_OnlyWindow=1
|
||||
let g:Tlist_Enable_Fold_Column=0
|
||||
@ -144,6 +144,7 @@ nnoremap df :FZF<CR>
|
||||
inoremap df _
|
||||
inoremap jk <Esc>
|
||||
cnoremap jk <CR>
|
||||
cnoremap wa wa<CR>
|
||||
"}}}
|
||||
" 编程配置{{{
|
||||
set keywordprg=man\ -a
|
||||
@ -193,7 +194,10 @@ autocmd BufNewFile,BufReadPost *.js call Config("js")
|
||||
|
||||
command! RR wa | source ~/.vimrc |e
|
||||
command! SS mksession! etc/session.vim
|
||||
source ~/.vim_local
|
||||
|
||||
if filereadable("~/.vim_local")
|
||||
source ~/.vim_local
|
||||
endif
|
||||
|
||||
let g:colorscheme=1
|
||||
let g:colorlist = [ "ron", "torte", "darkblue", "peachpuff" ]
|
||||
|
@ -49,7 +49,7 @@ call Keys("Statment", ["label", "goto"])
|
||||
" call Keys("SubCommand", ["import", "export", "load", "save"])
|
||||
|
||||
" context ctx
|
||||
call Keys("Argument", ["list", "map"])
|
||||
" call Keys("Argument", ["list", "map"])
|
||||
" context mdb
|
||||
call Keys("Argument", ["dbname", "dbhelp"])
|
||||
" context aaa
|
||||
|
@ -167,6 +167,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
},
|
||||
"plugin": map[string]interface{}{
|
||||
"path": "src/plugin", "template": "usr/template/plugin",
|
||||
"list": []interface{}{"local.shy", "index.shy", "index.css", "index.js"},
|
||||
}, "script": map[string]interface{}{
|
||||
"path": "usr/script",
|
||||
}, "trash": map[string]interface{}{
|
||||
@ -979,8 +980,8 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
p := path.Join(m.Conf("project", "plugin.path"), arg[0])
|
||||
q := path.Join(m.Conf("publish", "path"), arg[0])
|
||||
if _, e := os.Stat(p); e == nil && m.Assert(os.MkdirAll(q, 0777)) {
|
||||
m.Confm("project", "plugin.list", func(index int, value map[string]interface{}) {
|
||||
m.Cmd("nfs.copy", path.Join(q, kit.Format(value["name"])), path.Join(p, kit.Format(value["name"])))
|
||||
m.Confm("project", "plugin.list", func(index int, value string) {
|
||||
m.Cmd("nfs.copy", path.Join(q, value), path.Join(p, value))
|
||||
})
|
||||
for _, v := range arg[1:] {
|
||||
m.Cmd("nfs.copy", path.Join(q, v), path.Join(p, v))
|
||||
|
@ -7,5 +7,5 @@ var version = struct {
|
||||
self int
|
||||
}{
|
||||
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
|
||||
`2019-10-08 12:46:50`, `centos`, 623,
|
||||
`2019-10-09 20:58:29`, `centos`, 630,
|
||||
}
|
||||
|
@ -539,9 +539,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
"buf": &ctx.Config{Name: "buf", Value: map[string]interface{}{
|
||||
"size": "81920",
|
||||
}, Help: "文件缓存"},
|
||||
"grep": &ctx.Config{Name: "grep", Value: map[string]interface{}{
|
||||
"list": []interface{}{},
|
||||
}, Help: "文件搜索"},
|
||||
"grep": &ctx.Config{Name: "grep", Value: map[string]interface{}{}, Help: "文件搜索"},
|
||||
"git": &ctx.Config{Name: "git", Value: map[string]interface{}{
|
||||
"args": []interface{}{},
|
||||
"info": map[string]interface{}{"cmds": []interface{}{"log", "status", "branch"}},
|
||||
@ -883,19 +881,18 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
}
|
||||
return
|
||||
}},
|
||||
"grep": &ctx.Command{Name: "grep", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
"grep": &ctx.Command{Name: "grep head|tail|hold|more table arg", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
hold := false
|
||||
if len(arg) > 0 {
|
||||
switch arg[0] {
|
||||
case "add":
|
||||
m.Confv("grep", "list.-2", map[string]interface{}{
|
||||
"pos": 0, "offset": 0, "file": arg[1],
|
||||
m.Confv("grep", []string{arg[1], "list", "-2"}, map[string]interface{}{
|
||||
"pos": 0, "offset": 0, "file": arg[2],
|
||||
})
|
||||
return
|
||||
|
||||
case "head":
|
||||
m.Confm("grep", "list", func(index int, value map[string]interface{}) {
|
||||
if len(arg) == 1 {
|
||||
m.Confm("grep", []string{arg[1], "list"}, func(index int, value map[string]interface{}) {
|
||||
if len(arg) == 2 {
|
||||
value["offset"] = 0
|
||||
value["pos"] = 0
|
||||
}
|
||||
@ -903,8 +900,8 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
return
|
||||
|
||||
case "tail":
|
||||
m.Confm("grep", "list", func(index int, value map[string]interface{}) {
|
||||
if len(arg) == 1 {
|
||||
m.Confm("grep", []string{arg[1], "list"}, func(index int, value map[string]interface{}) {
|
||||
if len(arg) == 2 {
|
||||
value["pos"] = -1
|
||||
value["offset"] = 0
|
||||
}
|
||||
@ -913,10 +910,12 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
|
||||
case "hold":
|
||||
hold, arg = true, arg[1:]
|
||||
}
|
||||
|
||||
case "more":
|
||||
hold, arg = false, arg[1:]
|
||||
}
|
||||
|
||||
m.Confm("grep", "list", func(index int, value map[string]interface{}) {
|
||||
m.Confm("grep", []string{arg[0], "list"}, func(index int, value map[string]interface{}) {
|
||||
f, e := os.Open(kit.Format(value["file"]))
|
||||
if e != nil {
|
||||
m.Log("warn", "%v", e)
|
||||
@ -924,38 +923,38 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
// s, e := f.Stat()
|
||||
// m.Assert(e)
|
||||
s, e := f.Stat()
|
||||
if e != nil {
|
||||
m.Log("warn", "%v", e)
|
||||
return
|
||||
}
|
||||
|
||||
offset := kit.Int(value["offset"])
|
||||
begin, e := f.Seek(int64(kit.Int(value["pos"])), 0)
|
||||
if kit.Int(value["pos"]) == -1 {
|
||||
begin, e = f.Seek(0, 2)
|
||||
}
|
||||
m.Assert(e)
|
||||
file := path.Base(kit.Format(value["file"]))
|
||||
|
||||
n := 0
|
||||
offset := kit.Int(value["offset"])
|
||||
bio := bufio.NewScanner(f)
|
||||
for i := 0; i < m.Optioni("table.limit") && bio.Scan(); i++ {
|
||||
text := bio.Text()
|
||||
if len(arg) == 0 || strings.Contains(text, arg[0]) {
|
||||
m.Add("append", "index", index)
|
||||
m.Add("append", "file", path.Base(kit.Format(value["file"])))
|
||||
// m.Add("append", "pos",begin+int64(n))
|
||||
// m.Add("append", "len",len(text))
|
||||
// m.Add("append", "end",s.Size())
|
||||
if len(arg) == 1 || strings.Contains(text, arg[1]) {
|
||||
m.Add("append", "file", file)
|
||||
m.Add("append", "pos", fmt.Sprintf("%d%%", (begin+int64(len(text)+1))*100/s.Size()))
|
||||
m.Add("append", "line", offset)
|
||||
m.Add("append", "text", text)
|
||||
} else {
|
||||
i--
|
||||
}
|
||||
n += len(text) + 1
|
||||
begin += int64(len(text)) + 1
|
||||
offset += 1
|
||||
}
|
||||
|
||||
if !hold {
|
||||
value["offset"] = offset
|
||||
value["pos"] = begin + int64(n)
|
||||
value["pos"] = begin
|
||||
}
|
||||
})
|
||||
m.Table()
|
||||
|
@ -29,7 +29,7 @@ kit missyou "任务" private "ssh._route" _ "cli.missyou" \
|
||||
exports you "" you
|
||||
|
||||
kit pod "设备" private "ssh._route" _ "ssh.remote" __ \
|
||||
text "" name pod imports plugin_pod action auto \
|
||||
text "" name pod \
|
||||
button "查看" action auto \
|
||||
button "返回" cb Last \
|
||||
exports pod pod pod
|
||||
@ -59,5 +59,5 @@ kit git "版本" private "ssh._route" _ "nfs.git" __ \
|
||||
text "" name pod imports plugin_pod action auto \
|
||||
select "" values status values diff commit values values log values init action auto \
|
||||
text "" name txt action auto \
|
||||
button "查看" action auto
|
||||
button "查看"
|
||||
|
||||
|
@ -22,7 +22,7 @@ fun maps "每一面" "maps.js" "index.css" protected \
|
||||
button "本地" cb Current \
|
||||
text "北京市" name city view tiny \
|
||||
text "弘源首著" name where \
|
||||
button "搜索" cb Search action auto \
|
||||
button "搜索" cb Search \
|
||||
button "记录" cb Record \
|
||||
button "展示" cb Flashs \
|
||||
exports index ""
|
||||
|
@ -38,14 +38,12 @@ return {
|
||||
}
|
||||
var l = map.getCenter()
|
||||
plugin.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")
|
||||
})
|
||||
"longitude", trunc(l.lng), "latitude", trunc(l.lat), "scale", map.getZoom()])
|
||||
},
|
||||
Flashs: function() {var plugin = field.Plugin
|
||||
plugin.initMap(), plugin.Run(event, [option.table.value], function(msg) {
|
||||
kit.List(ctx.Table(msg), plugin.place, 1000)
|
||||
})
|
||||
kit.List(msg.Table(), plugin.place, 1000)
|
||||
}, true)
|
||||
},
|
||||
place: function(line) {
|
||||
var p = new BMap.Point(line.longitude, line.latitude)
|
||||
|
@ -1,11 +1,25 @@
|
||||
|
||||
kit buffer "粘贴板" public buf \
|
||||
kit buffer "粘贴板" private buf \
|
||||
text "0" name index imports plugin_tmux_bindex action auto \
|
||||
text "" name txt action auto \
|
||||
button "查看" action auto \
|
||||
button "返回" cb Last \
|
||||
exports tmux_bindex cur
|
||||
|
||||
fun list "列表" "" "" private \
|
||||
text "docker" name table imports plugin_table \
|
||||
text "" name txt \
|
||||
text "" name cmd view long \
|
||||
button "记录" \
|
||||
exports tmux_cmd cmd
|
||||
|
||||
if $2 == "" || $3 == ""
|
||||
copy skip ssh.data show _ fields id txt cmd
|
||||
else
|
||||
copy ssh.data insert _ txt _ cmd __
|
||||
end
|
||||
end
|
||||
|
||||
kit session "会话" private mux \
|
||||
button "查看" action auto \
|
||||
exports tmux_sess name
|
||||
@ -31,7 +45,7 @@ kit cmd "命令" private mux _ _ _ r \
|
||||
text "context" imports plugin_tmux_sess \
|
||||
text "docker" imports plugin_tmux_wins \
|
||||
text "4" imports plugin_tmux_pane view tiny \
|
||||
text "pwd" view full \
|
||||
text "pwd" view full imports plugin_tmux_cmd \
|
||||
button "执行"
|
||||
|
||||
kit json "解析" private "nfs.json" \
|
||||
|
@ -125,10 +125,10 @@ var page = Page({
|
||||
page.onlayout(event, {header:0, footer:0, river:0, storm:0, action: -1})
|
||||
},
|
||||
},
|
||||
Button: shy({"user": "", "title": ""}, ["user"], function(key, value) {var meta = arguments.callee.meta
|
||||
Button: shy({"title": "github.com/shylinux/context", "user": ""}, ["user"], function(key, value) {var meta = arguments.callee.meta
|
||||
return kit.isNone(key)? meta: kit.isNone(value)? meta[key]: (meta[key] = value, page.header.Pane.Show())
|
||||
}),
|
||||
Status: shy({"ncmd": "0", "ntxt": "0"}, ["ncmd", "ntxt"], function(key, value) {var meta = arguments.callee.meta
|
||||
Status: shy({title: '<a href="mailto:shylinux@163.com">shylinux@163.com</a>', "ncmd": "0", "ntxt": "0"}, ["ncmd", "ntxt"], function(key, value) {var meta = arguments.callee.meta
|
||||
return kit.isNone(key)? meta: kit.isNone(value)? meta[key]: (meta[key] = value, page.footer.Pane.Show())
|
||||
}),
|
||||
|
||||
@ -582,11 +582,8 @@ var page = Page({
|
||||
}
|
||||
},
|
||||
init: function(page) {
|
||||
page.Button("user", page.who.get())
|
||||
page.Button("title", "github.com/shylinux/context")
|
||||
page.Status("title", '<a href="mailto:shylinux@163.com">shylinux@163.com</a>')
|
||||
page.river.Pane.Show()
|
||||
page.Action[ctx.Search("layout") || (kit.device.isMobile? page.conf.first: page.conf.mobile)]()
|
||||
page.river.Pane.Show()
|
||||
page.WSS()
|
||||
},
|
||||
})
|
||||
|
@ -27,6 +27,11 @@ legend {
|
||||
.select {
|
||||
}
|
||||
|
||||
fieldset>form.option {
|
||||
padding:0 5px;
|
||||
margin-right:3px;
|
||||
float:left;
|
||||
}
|
||||
fieldset>form.option div {
|
||||
margin-right:3px;
|
||||
float:left;
|
||||
@ -40,24 +45,24 @@ fieldset>form.option div.clear {
|
||||
fieldset>form.option label {
|
||||
margin-right:3px;
|
||||
}
|
||||
fieldset>form.option div.cmd input.args {
|
||||
fieldset>form.option input.args.cmd {
|
||||
color:white;
|
||||
background-color: black;
|
||||
width:160px;
|
||||
}
|
||||
fieldset>form.option div.char input.args {
|
||||
fieldset>form.option input.args.char {
|
||||
width:20px;
|
||||
}
|
||||
fieldset>form.option div.tiny input.args {
|
||||
fieldset>form.option input.args.tiny {
|
||||
width:40px;
|
||||
}
|
||||
fieldset>form.option div input.args {
|
||||
fieldset>form.option input.args {
|
||||
width:80px;
|
||||
}
|
||||
fieldset>form.option div.long input.args {
|
||||
fieldset>form.option input.args.long {
|
||||
width:240px;
|
||||
}
|
||||
fieldset>form.option div.full input.args {
|
||||
fieldset>form.option input.args.full {
|
||||
width:480px;
|
||||
}
|
||||
fieldset>div.action {
|
||||
@ -298,6 +303,9 @@ fieldset.Header>div.output>div.title:hover {
|
||||
fieldset.Header>div.output>div.state {
|
||||
float:right;
|
||||
}
|
||||
fieldset.Header>div.output>div.state div.item {
|
||||
padding:0;
|
||||
}
|
||||
fieldset.Header>div.output>div.state>div {
|
||||
cursor:pointer;
|
||||
margin-left:5px;
|
||||
|
@ -94,7 +94,7 @@ function Meta(zone, target, obj) {
|
||||
case "field": text = JSON.parse(line.text)
|
||||
case "plugin": if (!text.name) {return {}}
|
||||
var id = "plugin"+meta.ID()
|
||||
list.push({view: ["item", "fieldset"], data: {id: id, draggable: true}, list: [
|
||||
list.push({view: ["item", "fieldset"], data: {id: id, draggable: false}, list: [
|
||||
{text: [text.name+"("+text.help+")", "legend"]},
|
||||
{view: ["option", "form"], list: [{type: "input", style: {"display": "none"}}]},
|
||||
{view: ["output", "div"]},
|
||||
@ -102,7 +102,7 @@ function Meta(zone, target, obj) {
|
||||
break
|
||||
}
|
||||
|
||||
var ui = kit.AppendChild(output, item? list: [{view: ["item"], data: {id: "item"+meta.ID(), draggable: true}, list:list}])
|
||||
var ui = kit.AppendChild(output, item? list: [{view: ["item"], data: {id: "item"+meta.ID(), draggable: false}, list:list}])
|
||||
return ui.item.Meta = text, ui
|
||||
}),
|
||||
Include: shy("加载脚本", function(src, cb) {src = kit.List(src)
|
||||
@ -131,8 +131,7 @@ function Page(page) {
|
||||
page = Meta([document.title], document.body, page, {check: true,
|
||||
onload: function(event) {
|
||||
// Event入口 0
|
||||
page.Event(event, {})
|
||||
if (page.check && !ctx.Cookie("sessid")) {
|
||||
if (page.Event(event, {}) && page.check && !ctx.Cookie("sessid")) {
|
||||
// 用户登录
|
||||
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
||||
page.Pane(page, field)
|
||||
@ -147,30 +146,11 @@ function Page(page) {
|
||||
}): page.init(page)
|
||||
}
|
||||
|
||||
// 微信接口
|
||||
kit.device.isWeiXin && page.login.Pane.Run(event, ["weixin"], function(msg) {
|
||||
msg.appid[0] && page.Include(["https://res.wx.qq.com/open/js/jweixin-1.4.0.js"], function(event) {
|
||||
wx.error(function(res){})
|
||||
wx.ready(function(){
|
||||
page.scanQRCode = function(cb) {
|
||||
|
||||
}
|
||||
page.getLocation = function(cb) {
|
||||
wx.getLocation({success: cb})
|
||||
}
|
||||
page.openLocation = function(latitude, longitude, name) {
|
||||
wx.openLocation({latitude: parseFloat(latitude), longitude: parseFloat(longitude), name:name||"here"})
|
||||
}
|
||||
}), wx.config({jsApiList: ["closeWindow", "scanQRCode", "getLocation", "openLocation"],
|
||||
appId: msg.appid[0], nonceStr: msg.nonce[0], timestamp: msg.timestamp[0], signature: msg.signature[0]})
|
||||
})
|
||||
})
|
||||
|
||||
// 事件回调
|
||||
window.onresize = function(event) {
|
||||
page.onlayout(event)
|
||||
}, document.body.onkeydown = function(event) {
|
||||
page.oncontrol(event) || page.onscroll(event)
|
||||
// page.oncontrol(event) || page.onscroll(event)
|
||||
}, document.body.onkeyup = function(event) {
|
||||
}, document.body.oncontextmenu = function(event) {
|
||||
}, document.body.onmousewheel = function(event) {
|
||||
@ -472,7 +452,7 @@ function Page(page) {
|
||||
Head: function() {if (kit.isNone(last)) {return}
|
||||
caption.style.width = last.offsetWidth+"px"
|
||||
kit.Selector(last, "td", function(item, index) {
|
||||
head.childNodes[index].style.width = item.offsetWidth-14+"px"
|
||||
head.childNodes[index] && (head.childNodes[index].style.width = item.offsetWidth-14+"px")
|
||||
})
|
||||
},
|
||||
Show: function() {layout || (layout = field.Pane.Action.meta["最大"](), 1)
|
||||
@ -526,9 +506,24 @@ function Page(page) {
|
||||
}]}, {type: "br"},
|
||||
])
|
||||
|
||||
if (kit.device.isWeiXin) {
|
||||
kit.AppendChild(output, [])
|
||||
// 微信接口
|
||||
kit.device.isWeiXin && page.login.Pane.Run(event, ["weixin"], function(msg) {
|
||||
msg.appid[0] && page.Include(["https://res.wx.qq.com/open/js/jweixin-1.4.0.js"], function(event) {
|
||||
wx.error(function(res){})
|
||||
wx.ready(function(){
|
||||
page.scanQRCode = function(cb) {
|
||||
|
||||
}
|
||||
page.getLocation = function(cb) {
|
||||
wx.getLocation({success: cb})
|
||||
}
|
||||
page.openLocation = function(latitude, longitude, name) {
|
||||
wx.openLocation({latitude: parseFloat(latitude), longitude: parseFloat(longitude), name:name||"here"})
|
||||
}
|
||||
}), wx.config({jsApiList: ["closeWindow", "scanQRCode", "getLocation", "openLocation"],
|
||||
appId: msg.appid[0], nonceStr: msg.nonce[0], timestamp: msg.timestamp[0], signature: msg.signature[0]})
|
||||
})
|
||||
})
|
||||
return {
|
||||
Login: function(username, password, cb) {
|
||||
field.Pane.Run(event, [username, password], function(msg) {cb(msg.result && msg.result[0] || "")})
|
||||
@ -537,28 +532,28 @@ function Page(page) {
|
||||
}
|
||||
},
|
||||
initHeader: function(page, field, option, output) {
|
||||
var cb = function(event, item, value) {
|
||||
kit._call(page.Action[item], [event, item, value, page])
|
||||
}
|
||||
var cb = function(event, item, value) {kit._call(page.Action[item], [event, item, value, page])}
|
||||
field.onclick = function(event) {page.pane && page.pane.scrollTo(0, 0)}
|
||||
page.who.change(function(value, old) {page.Button("user", value)})
|
||||
|
||||
return {
|
||||
Show: function() {var meta = page.Button.meta, list = page.Button.list
|
||||
kit.AppendChilds(output, [
|
||||
{"view": ["title", "div", meta.title], click: cb},
|
||||
{"view": ["state"], list: list.map(function(item) {return {text: [meta[item], "div", "item"], click: cb}})},
|
||||
{"view": ["title", "div", meta.title], click: function(event) {
|
||||
cb(event, "title", meta.title)
|
||||
}},
|
||||
{"view": ["state"], list: list.map(function(item) {return {text: [meta[item], "div", "item"], click: function(event) {
|
||||
cb(event, item, meta[item])
|
||||
}}})},
|
||||
])
|
||||
},
|
||||
Help: function() {return []},
|
||||
}
|
||||
},
|
||||
initFooter: function(page, field, option, output) {
|
||||
var state = {title: "<a href='mailto:shylinux@163.com'>shylinux@163.com</>"}, list = [], cb = function(event, item, value) {
|
||||
kit._call(page.Action[item], [event, item, value, page])
|
||||
}
|
||||
var cb = function(event, item, value) {kit._call(page.Action[item], [event, item, value, page])}
|
||||
var ui = kit.AppendChilds(output, [
|
||||
{"view": ["title", "div", state.title]},
|
||||
{"view": ["title", "div", page.Status.meta.title]},
|
||||
{"view": ["state"]},
|
||||
{"view": ["magic"], list: [{label: "0", name: "count"}, {input: ["magics", function(event) {
|
||||
if (event.key == "Enter" || event.ctrlKey && event.key == "j") {
|
||||
@ -596,10 +591,9 @@ function Page(page) {
|
||||
ui && kit.size(ui.magics, (width - ui.count.offsetWidth - ui.first.offsetWidth - ui.state.offsetWidth - 40), height-6)
|
||||
},
|
||||
Show: function() {var meta = page.Status.meta, list = page.Status.list
|
||||
kit.AppendChilds(output, [
|
||||
{"view": ["title", "div", meta.title], click: cb},
|
||||
{"view": ["state"], list: list.map(function(item) {return {text: [item+":"+meta[item], "div", "item"], click: cb}})},
|
||||
])
|
||||
kit.AppendChilds(ui.state, list.map(function(item) {return {text: [item+":"+meta[item], "div", "item"], click: function(event) {
|
||||
cb(event, item, meta[item])
|
||||
}}}))
|
||||
field.Pane.Size(field.clientWidth, field.clientHeight)
|
||||
},
|
||||
Help: function() {return []},
|
||||
@ -651,6 +645,7 @@ function Pane(page, field) {
|
||||
ui.item.ondragstart = function(event) {if (event.target != ui.item) {return}
|
||||
event.dataTransfer.setData("item", event.target.id)
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
}
|
||||
ui.item.ondragover = function(event) {if (event.target != ui.item) {return}
|
||||
event.stopPropagation()
|
||||
@ -1038,7 +1033,8 @@ function Plugin(page, pane, field, inits, runs) {
|
||||
item.autocomplete = "off"
|
||||
break
|
||||
}
|
||||
return Inputs(plugin, input, item, plugin.View(option, "input", input)[input.name]).target
|
||||
kit.classList.add(item, item.view)
|
||||
return Inputs(plugin, input, item, plugin.View(option, "input", input)[input.name], option).target
|
||||
}),
|
||||
Select: shy("选择控件", function(target, focus) {field.onclick(event)
|
||||
page.input = target = target || option.querySelectorAll("input")[1]
|
||||
@ -1127,6 +1123,14 @@ function Plugin(page, pane, field, inits, runs) {
|
||||
return kit.notNone(key)? (option[key]? option[key].value: ""):
|
||||
kit.Selector(option, ".args", function(item, index) {return item.value})
|
||||
},
|
||||
upload: function(event) {
|
||||
ctx.Upload({river: meta.river, table: plugin.Option("table")}, option.upload.files[0], function(event, msg) {
|
||||
Output(plugin, "table", msg, null, output, option)
|
||||
plugin.ontoast("上传成功")
|
||||
}, function(event) {
|
||||
plugin.ontoast("上传进度 "+parseInt(event.loaded*100/event.total)+"%")
|
||||
})
|
||||
},
|
||||
Delay: shy("延时命令", function(time, event, text) {plugin.ontoast(text, "", -1)
|
||||
return setTimeout(function() {plugin.Runs(event)}, time)
|
||||
}),
|
||||
@ -1162,6 +1166,38 @@ function Plugin(page, pane, field, inits, runs) {
|
||||
type != meta.type && plugin.Save(meta.type, output), meta.type = type
|
||||
!plugin.Load(type, output) && Output(plugin, type || feature.display, msg || plugin.msg, cb, output, option)
|
||||
}),
|
||||
onexport: shy("导出数据", {
|
||||
"": function(value, name, line) {
|
||||
return value
|
||||
},
|
||||
see: function(value, name, line) {
|
||||
return value.split("/")[0]
|
||||
},
|
||||
you: function(value, name, line) {
|
||||
event.Plugin = plugin
|
||||
|
||||
line.you && name == "status" && (line.status == "start"? function() {
|
||||
plugin.Delay(3000, event, line.you+" stop...") && plugin.Run(event, [option.pod.value, line.you, "stop"])
|
||||
}(): plugin.Run(event, [option.pod.value, line.you], function(msg) {
|
||||
plugin.Delay(3000, event, line.you+" start...")
|
||||
}))
|
||||
return name == "status" || line.status == "stop" ? undefined: line.you
|
||||
},
|
||||
pod: function(value, name, line, list) {
|
||||
return (option[list[0]].value? option[list[0]].value+".": "")+line.pod
|
||||
},
|
||||
dir: function(value, name, line) {
|
||||
name != "path" && (value = line.path)
|
||||
return value
|
||||
},
|
||||
tip: function(value, name, line) {
|
||||
return option.tip.value + value
|
||||
},
|
||||
}, JSON.parse(meta.exports||'["",""]'), function(event, value, name, line) {
|
||||
var meta = arguments.callee.meta
|
||||
var list = arguments.callee.list
|
||||
;(!list[1] || list[1] == name) && page.Sync("plugin_"+list[0]).set(meta[list[2]||""](value, name, line, list))
|
||||
}),
|
||||
onchoice: shy("菜单列表", {
|
||||
"返回": "Last",
|
||||
"添加": "Clone",
|
||||
@ -1181,10 +1217,11 @@ function Plugin(page, pane, field, inits, runs) {
|
||||
|
||||
kit.Log("init", "plugin", name, plugin)
|
||||
plugin.which = plugin.Sync("input")
|
||||
page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
||||
plugin.Appends(inputs)
|
||||
return page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
||||
return plugin
|
||||
}
|
||||
function Inputs(plugin, meta, item, target) {
|
||||
function Inputs(plugin, meta, item, target, option) {
|
||||
var plug = meta.plug, name = meta.name, type = item.type
|
||||
var input = Meta(plugin.Zone(name), target, item, {
|
||||
getLocation: function(event) {
|
||||
@ -1217,14 +1254,6 @@ function Inputs(plugin, meta, item, target) {
|
||||
return (target.value = args[0]) || plugin.Zone("value", args[0])
|
||||
},
|
||||
|
||||
upload: function(event) {
|
||||
ctx.Upload({river: meta.river, table: plugin.Option("table")}, option.upload.files[0], function(event, msg) {
|
||||
Output(plugin, "table", msg, null, output, option)
|
||||
plugin.ontoast("上传成功")
|
||||
}, function(event) {
|
||||
plugin.ontoast("上传进度 "+parseInt(event.loaded*100/event.total)+"%")
|
||||
})
|
||||
},
|
||||
onformat: shy("数据转换", {
|
||||
none: function(value) {return value||""},
|
||||
date: function(value) {return kit.time()},
|
||||
@ -1367,38 +1396,6 @@ function Output(plugin, type, msg, cb, target, option) {
|
||||
plugin.ontoast({text:'<a href="'+URL.createObjectURL(new Blob([text]))+'" target="_blank" download="'+name+type+'">'+name+type+'</a>', title: "下载中...", width: 200})
|
||||
kit.Selector(page.toast, "a", function(item) {item.click()})
|
||||
},
|
||||
onexport: shy("导出数据", {
|
||||
"": function(value, name, line) {
|
||||
return value
|
||||
},
|
||||
see: function(value, name, line) {
|
||||
return value.split("/")[0]
|
||||
},
|
||||
you: function(value, name, line) {
|
||||
event.Plugin = plugin
|
||||
|
||||
line.you && name == "status" && (line.status == "start"? function() {
|
||||
plugin.Delay(3000, event, line.you+" stop...") && plugin.Run(event, [option.pod.value, line.you, "stop"])
|
||||
}(): plugin.Run(event, [option.pod.value, line.you], function(msg) {
|
||||
plugin.Delay(3000, event, line.you+" start...")
|
||||
}))
|
||||
return name == "status" || line.status == "stop" ? undefined: line.you
|
||||
},
|
||||
pod: function(value, name, line, list) {
|
||||
return (option[list[0]].value? option[list[0]].value+".": "")+line.pod
|
||||
},
|
||||
dir: function(value, name, line) {
|
||||
name != "path" && (value = line.path)
|
||||
return value
|
||||
},
|
||||
tip: function(value, name, line) {
|
||||
return option.tip.value + value
|
||||
},
|
||||
}, JSON.parse(exports||'["",""]'), function(event, value, name, line) {
|
||||
var meta = arguments.callee.meta
|
||||
var list = arguments.callee.list
|
||||
;(!list[1] || list[1] == name) && page.Sync("plugin_"+list[0]).set(meta[list[2]||""](value, name, line, list))
|
||||
}),
|
||||
onimport: shy("导入数据", {
|
||||
_table: function(msg, list) {
|
||||
return list && list.length > 0 && kit.OrderTable(kit.AppendTable(kit.AppendChild(target, "table"), msg.Table(), list), "", output.onexport)
|
||||
|
Loading…
x
Reference in New Issue
Block a user