mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04: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'
|
Plug 'gcmt/taboo.vim'
|
||||||
set sessionoptions+=tabpages,globals
|
set sessionoptions+=tabpages,globals
|
||||||
|
|
||||||
Plug 'vim-scripts/taglist.vim'
|
" Plug 'vim-scripts/taglist.vim'
|
||||||
let g:Tlist_WinWidth=45
|
let g:Tlist_WinWidth=45
|
||||||
let g:Tlist_Exit_OnlyWindow=1
|
let g:Tlist_Exit_OnlyWindow=1
|
||||||
let g:Tlist_Enable_Fold_Column=0
|
let g:Tlist_Enable_Fold_Column=0
|
||||||
@ -144,6 +144,7 @@ nnoremap df :FZF<CR>
|
|||||||
inoremap df _
|
inoremap df _
|
||||||
inoremap jk <Esc>
|
inoremap jk <Esc>
|
||||||
cnoremap jk <CR>
|
cnoremap jk <CR>
|
||||||
|
cnoremap wa wa<CR>
|
||||||
"}}}
|
"}}}
|
||||||
" 编程配置{{{
|
" 编程配置{{{
|
||||||
set keywordprg=man\ -a
|
set keywordprg=man\ -a
|
||||||
@ -193,7 +194,10 @@ autocmd BufNewFile,BufReadPost *.js call Config("js")
|
|||||||
|
|
||||||
command! RR wa | source ~/.vimrc |e
|
command! RR wa | source ~/.vimrc |e
|
||||||
command! SS mksession! etc/session.vim
|
command! SS mksession! etc/session.vim
|
||||||
|
|
||||||
|
if filereadable("~/.vim_local")
|
||||||
source ~/.vim_local
|
source ~/.vim_local
|
||||||
|
endif
|
||||||
|
|
||||||
let g:colorscheme=1
|
let g:colorscheme=1
|
||||||
let g:colorlist = [ "ron", "torte", "darkblue", "peachpuff" ]
|
let g:colorlist = [ "ron", "torte", "darkblue", "peachpuff" ]
|
||||||
|
@ -49,7 +49,7 @@ call Keys("Statment", ["label", "goto"])
|
|||||||
" call Keys("SubCommand", ["import", "export", "load", "save"])
|
" call Keys("SubCommand", ["import", "export", "load", "save"])
|
||||||
|
|
||||||
" context ctx
|
" context ctx
|
||||||
call Keys("Argument", ["list", "map"])
|
" call Keys("Argument", ["list", "map"])
|
||||||
" context mdb
|
" context mdb
|
||||||
call Keys("Argument", ["dbname", "dbhelp"])
|
call Keys("Argument", ["dbname", "dbhelp"])
|
||||||
" context aaa
|
" context aaa
|
||||||
|
@ -167,6 +167,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
},
|
},
|
||||||
"plugin": map[string]interface{}{
|
"plugin": map[string]interface{}{
|
||||||
"path": "src/plugin", "template": "usr/template/plugin",
|
"path": "src/plugin", "template": "usr/template/plugin",
|
||||||
|
"list": []interface{}{"local.shy", "index.shy", "index.css", "index.js"},
|
||||||
}, "script": map[string]interface{}{
|
}, "script": map[string]interface{}{
|
||||||
"path": "usr/script",
|
"path": "usr/script",
|
||||||
}, "trash": map[string]interface{}{
|
}, "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])
|
p := path.Join(m.Conf("project", "plugin.path"), arg[0])
|
||||||
q := path.Join(m.Conf("publish", "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)) {
|
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.Confm("project", "plugin.list", func(index int, value string) {
|
||||||
m.Cmd("nfs.copy", path.Join(q, kit.Format(value["name"])), path.Join(p, kit.Format(value["name"])))
|
m.Cmd("nfs.copy", path.Join(q, value), path.Join(p, value))
|
||||||
})
|
})
|
||||||
for _, v := range arg[1:] {
|
for _, v := range arg[1:] {
|
||||||
m.Cmd("nfs.copy", path.Join(q, v), path.Join(p, v))
|
m.Cmd("nfs.copy", path.Join(q, v), path.Join(p, v))
|
||||||
|
@ -7,5 +7,5 @@ var version = struct {
|
|||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
|
[]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{}{
|
"buf": &ctx.Config{Name: "buf", Value: map[string]interface{}{
|
||||||
"size": "81920",
|
"size": "81920",
|
||||||
}, Help: "文件缓存"},
|
}, Help: "文件缓存"},
|
||||||
"grep": &ctx.Config{Name: "grep", Value: map[string]interface{}{
|
"grep": &ctx.Config{Name: "grep", Value: map[string]interface{}{}, Help: "文件搜索"},
|
||||||
"list": []interface{}{},
|
|
||||||
}, Help: "文件搜索"},
|
|
||||||
"git": &ctx.Config{Name: "git", Value: map[string]interface{}{
|
"git": &ctx.Config{Name: "git", Value: map[string]interface{}{
|
||||||
"args": []interface{}{},
|
"args": []interface{}{},
|
||||||
"info": map[string]interface{}{"cmds": []interface{}{"log", "status", "branch"}},
|
"info": map[string]interface{}{"cmds": []interface{}{"log", "status", "branch"}},
|
||||||
@ -883,19 +881,18 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
}
|
}
|
||||||
return
|
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
|
hold := false
|
||||||
if len(arg) > 0 {
|
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "add":
|
case "add":
|
||||||
m.Confv("grep", "list.-2", map[string]interface{}{
|
m.Confv("grep", []string{arg[1], "list", "-2"}, map[string]interface{}{
|
||||||
"pos": 0, "offset": 0, "file": arg[1],
|
"pos": 0, "offset": 0, "file": arg[2],
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
|
||||||
case "head":
|
case "head":
|
||||||
m.Confm("grep", "list", func(index int, value map[string]interface{}) {
|
m.Confm("grep", []string{arg[1], "list"}, func(index int, value map[string]interface{}) {
|
||||||
if len(arg) == 1 {
|
if len(arg) == 2 {
|
||||||
value["offset"] = 0
|
value["offset"] = 0
|
||||||
value["pos"] = 0
|
value["pos"] = 0
|
||||||
}
|
}
|
||||||
@ -903,8 +900,8 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
return
|
return
|
||||||
|
|
||||||
case "tail":
|
case "tail":
|
||||||
m.Confm("grep", "list", func(index int, value map[string]interface{}) {
|
m.Confm("grep", []string{arg[1], "list"}, func(index int, value map[string]interface{}) {
|
||||||
if len(arg) == 1 {
|
if len(arg) == 2 {
|
||||||
value["pos"] = -1
|
value["pos"] = -1
|
||||||
value["offset"] = 0
|
value["offset"] = 0
|
||||||
}
|
}
|
||||||
@ -913,10 +910,12 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
|
|
||||||
case "hold":
|
case "hold":
|
||||||
hold, arg = true, arg[1:]
|
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"]))
|
f, e := os.Open(kit.Format(value["file"]))
|
||||||
if e != nil {
|
if e != nil {
|
||||||
m.Log("warn", "%v", e)
|
m.Log("warn", "%v", e)
|
||||||
@ -924,38 +923,38 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
// s, e := f.Stat()
|
s, e := f.Stat()
|
||||||
// m.Assert(e)
|
if e != nil {
|
||||||
|
m.Log("warn", "%v", e)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
offset := kit.Int(value["offset"])
|
||||||
begin, e := f.Seek(int64(kit.Int(value["pos"])), 0)
|
begin, e := f.Seek(int64(kit.Int(value["pos"])), 0)
|
||||||
if kit.Int(value["pos"]) == -1 {
|
if kit.Int(value["pos"]) == -1 {
|
||||||
begin, e = f.Seek(0, 2)
|
begin, e = f.Seek(0, 2)
|
||||||
}
|
}
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
|
file := path.Base(kit.Format(value["file"]))
|
||||||
|
|
||||||
n := 0
|
|
||||||
offset := kit.Int(value["offset"])
|
|
||||||
bio := bufio.NewScanner(f)
|
bio := bufio.NewScanner(f)
|
||||||
for i := 0; i < m.Optioni("table.limit") && bio.Scan(); i++ {
|
for i := 0; i < m.Optioni("table.limit") && bio.Scan(); i++ {
|
||||||
text := bio.Text()
|
text := bio.Text()
|
||||||
if len(arg) == 0 || strings.Contains(text, arg[0]) {
|
if len(arg) == 1 || strings.Contains(text, arg[1]) {
|
||||||
m.Add("append", "index", index)
|
m.Add("append", "file", file)
|
||||||
m.Add("append", "file", path.Base(kit.Format(value["file"])))
|
m.Add("append", "pos", fmt.Sprintf("%d%%", (begin+int64(len(text)+1))*100/s.Size()))
|
||||||
// m.Add("append", "pos",begin+int64(n))
|
|
||||||
// m.Add("append", "len",len(text))
|
|
||||||
// m.Add("append", "end",s.Size())
|
|
||||||
m.Add("append", "line", offset)
|
m.Add("append", "line", offset)
|
||||||
m.Add("append", "text", text)
|
m.Add("append", "text", text)
|
||||||
} else {
|
} else {
|
||||||
i--
|
i--
|
||||||
}
|
}
|
||||||
n += len(text) + 1
|
begin += int64(len(text)) + 1
|
||||||
offset += 1
|
offset += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if !hold {
|
if !hold {
|
||||||
value["offset"] = offset
|
value["offset"] = offset
|
||||||
value["pos"] = begin + int64(n)
|
value["pos"] = begin
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
m.Table()
|
m.Table()
|
||||||
|
@ -29,7 +29,7 @@ kit missyou "任务" private "ssh._route" _ "cli.missyou" \
|
|||||||
exports you "" you
|
exports you "" you
|
||||||
|
|
||||||
kit pod "设备" private "ssh._route" _ "ssh.remote" __ \
|
kit pod "设备" private "ssh._route" _ "ssh.remote" __ \
|
||||||
text "" name pod imports plugin_pod action auto \
|
text "" name pod \
|
||||||
button "查看" action auto \
|
button "查看" action auto \
|
||||||
button "返回" cb Last \
|
button "返回" cb Last \
|
||||||
exports pod pod pod
|
exports pod pod pod
|
||||||
@ -59,5 +59,5 @@ kit git "版本" private "ssh._route" _ "nfs.git" __ \
|
|||||||
text "" name pod imports plugin_pod action auto \
|
text "" name pod imports plugin_pod action auto \
|
||||||
select "" values status values diff commit values values log values init action auto \
|
select "" values status values diff commit values values log values init action auto \
|
||||||
text "" name txt 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 \
|
button "本地" cb Current \
|
||||||
text "北京市" name city view tiny \
|
text "北京市" name city view tiny \
|
||||||
text "弘源首著" name where \
|
text "弘源首著" name where \
|
||||||
button "搜索" cb Search action auto \
|
button "搜索" cb Search \
|
||||||
button "记录" cb Record \
|
button "记录" cb Record \
|
||||||
button "展示" cb Flashs \
|
button "展示" cb Flashs \
|
||||||
exports index ""
|
exports index ""
|
||||||
|
@ -38,14 +38,12 @@ return {
|
|||||||
}
|
}
|
||||||
var l = map.getCenter()
|
var l = map.getCenter()
|
||||||
plugin.Run(event, [option.table.value, option.when.value, option.what.value, option.city.value, option.where.value,
|
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) {
|
"longitude", trunc(l.lng), "latitude", trunc(l.lat), "scale", map.getZoom()])
|
||||||
plugin.msg = msg, plugin.display("table")
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
Flashs: function() {var plugin = field.Plugin
|
Flashs: function() {var plugin = field.Plugin
|
||||||
plugin.initMap(), plugin.Run(event, [option.table.value], function(msg) {
|
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) {
|
place: function(line) {
|
||||||
var p = new BMap.Point(line.longitude, line.latitude)
|
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 "0" name index imports plugin_tmux_bindex action auto \
|
||||||
text "" name txt action auto \
|
text "" name txt action auto \
|
||||||
button "查看" action auto \
|
button "查看" action auto \
|
||||||
button "返回" cb Last \
|
button "返回" cb Last \
|
||||||
exports tmux_bindex cur
|
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 \
|
kit session "会话" private mux \
|
||||||
button "查看" action auto \
|
button "查看" action auto \
|
||||||
exports tmux_sess name
|
exports tmux_sess name
|
||||||
@ -31,7 +45,7 @@ kit cmd "命令" private mux _ _ _ r \
|
|||||||
text "context" imports plugin_tmux_sess \
|
text "context" imports plugin_tmux_sess \
|
||||||
text "docker" imports plugin_tmux_wins \
|
text "docker" imports plugin_tmux_wins \
|
||||||
text "4" imports plugin_tmux_pane view tiny \
|
text "4" imports plugin_tmux_pane view tiny \
|
||||||
text "pwd" view full \
|
text "pwd" view full imports plugin_tmux_cmd \
|
||||||
button "执行"
|
button "执行"
|
||||||
|
|
||||||
kit json "解析" private "nfs.json" \
|
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})
|
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())
|
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())
|
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) {
|
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.Action[ctx.Search("layout") || (kit.device.isMobile? page.conf.first: page.conf.mobile)]()
|
||||||
|
page.river.Pane.Show()
|
||||||
page.WSS()
|
page.WSS()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -27,6 +27,11 @@ legend {
|
|||||||
.select {
|
.select {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset>form.option {
|
||||||
|
padding:0 5px;
|
||||||
|
margin-right:3px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
fieldset>form.option div {
|
fieldset>form.option div {
|
||||||
margin-right:3px;
|
margin-right:3px;
|
||||||
float:left;
|
float:left;
|
||||||
@ -40,24 +45,24 @@ fieldset>form.option div.clear {
|
|||||||
fieldset>form.option label {
|
fieldset>form.option label {
|
||||||
margin-right:3px;
|
margin-right:3px;
|
||||||
}
|
}
|
||||||
fieldset>form.option div.cmd input.args {
|
fieldset>form.option input.args.cmd {
|
||||||
color:white;
|
color:white;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
width:160px;
|
width:160px;
|
||||||
}
|
}
|
||||||
fieldset>form.option div.char input.args {
|
fieldset>form.option input.args.char {
|
||||||
width:20px;
|
width:20px;
|
||||||
}
|
}
|
||||||
fieldset>form.option div.tiny input.args {
|
fieldset>form.option input.args.tiny {
|
||||||
width:40px;
|
width:40px;
|
||||||
}
|
}
|
||||||
fieldset>form.option div input.args {
|
fieldset>form.option input.args {
|
||||||
width:80px;
|
width:80px;
|
||||||
}
|
}
|
||||||
fieldset>form.option div.long input.args {
|
fieldset>form.option input.args.long {
|
||||||
width:240px;
|
width:240px;
|
||||||
}
|
}
|
||||||
fieldset>form.option div.full input.args {
|
fieldset>form.option input.args.full {
|
||||||
width:480px;
|
width:480px;
|
||||||
}
|
}
|
||||||
fieldset>div.action {
|
fieldset>div.action {
|
||||||
@ -298,6 +303,9 @@ fieldset.Header>div.output>div.title:hover {
|
|||||||
fieldset.Header>div.output>div.state {
|
fieldset.Header>div.output>div.state {
|
||||||
float:right;
|
float:right;
|
||||||
}
|
}
|
||||||
|
fieldset.Header>div.output>div.state div.item {
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
fieldset.Header>div.output>div.state>div {
|
fieldset.Header>div.output>div.state>div {
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
margin-left:5px;
|
margin-left:5px;
|
||||||
|
@ -94,7 +94,7 @@ function Meta(zone, target, obj) {
|
|||||||
case "field": text = JSON.parse(line.text)
|
case "field": text = JSON.parse(line.text)
|
||||||
case "plugin": if (!text.name) {return {}}
|
case "plugin": if (!text.name) {return {}}
|
||||||
var id = "plugin"+meta.ID()
|
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"]},
|
{text: [text.name+"("+text.help+")", "legend"]},
|
||||||
{view: ["option", "form"], list: [{type: "input", style: {"display": "none"}}]},
|
{view: ["option", "form"], list: [{type: "input", style: {"display": "none"}}]},
|
||||||
{view: ["output", "div"]},
|
{view: ["output", "div"]},
|
||||||
@ -102,7 +102,7 @@ function Meta(zone, target, obj) {
|
|||||||
break
|
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
|
return ui.item.Meta = text, ui
|
||||||
}),
|
}),
|
||||||
Include: shy("加载脚本", function(src, cb) {src = kit.List(src)
|
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,
|
page = Meta([document.title], document.body, page, {check: true,
|
||||||
onload: function(event) {
|
onload: function(event) {
|
||||||
// Event入口 0
|
// Event入口 0
|
||||||
page.Event(event, {})
|
if (page.Event(event, {}) && page.check && !ctx.Cookie("sessid")) {
|
||||||
if (page.check && !ctx.Cookie("sessid")) {
|
|
||||||
// 用户登录
|
// 用户登录
|
||||||
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
||||||
page.Pane(page, field)
|
page.Pane(page, field)
|
||||||
@ -147,30 +146,11 @@ function Page(page) {
|
|||||||
}): page.init(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) {
|
window.onresize = function(event) {
|
||||||
page.onlayout(event)
|
page.onlayout(event)
|
||||||
}, document.body.onkeydown = function(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.onkeyup = function(event) {
|
||||||
}, document.body.oncontextmenu = function(event) {
|
}, document.body.oncontextmenu = function(event) {
|
||||||
}, document.body.onmousewheel = function(event) {
|
}, document.body.onmousewheel = function(event) {
|
||||||
@ -472,7 +452,7 @@ function Page(page) {
|
|||||||
Head: function() {if (kit.isNone(last)) {return}
|
Head: function() {if (kit.isNone(last)) {return}
|
||||||
caption.style.width = last.offsetWidth+"px"
|
caption.style.width = last.offsetWidth+"px"
|
||||||
kit.Selector(last, "td", function(item, index) {
|
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)
|
Show: function() {layout || (layout = field.Pane.Action.meta["最大"](), 1)
|
||||||
@ -526,9 +506,24 @@ function Page(page) {
|
|||||||
}]}, {type: "br"},
|
}]}, {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 {
|
return {
|
||||||
Login: function(username, password, cb) {
|
Login: function(username, password, cb) {
|
||||||
field.Pane.Run(event, [username, password], function(msg) {cb(msg.result && msg.result[0] || "")})
|
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) {
|
initHeader: function(page, field, option, output) {
|
||||||
var cb = function(event, item, value) {
|
var cb = function(event, item, value) {kit._call(page.Action[item], [event, item, value, page])}
|
||||||
kit._call(page.Action[item], [event, item, value, page])
|
|
||||||
}
|
|
||||||
field.onclick = function(event) {page.pane && page.pane.scrollTo(0, 0)}
|
field.onclick = function(event) {page.pane && page.pane.scrollTo(0, 0)}
|
||||||
page.who.change(function(value, old) {page.Button("user", value)})
|
page.who.change(function(value, old) {page.Button("user", value)})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Show: function() {var meta = page.Button.meta, list = page.Button.list
|
Show: function() {var meta = page.Button.meta, list = page.Button.list
|
||||||
kit.AppendChilds(output, [
|
kit.AppendChilds(output, [
|
||||||
{"view": ["title", "div", meta.title], click: cb},
|
{"view": ["title", "div", meta.title], click: function(event) {
|
||||||
{"view": ["state"], list: list.map(function(item) {return {text: [meta[item], "div", "item"], click: cb}})},
|
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 []},
|
Help: function() {return []},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initFooter: function(page, field, option, output) {
|
initFooter: function(page, field, option, output) {
|
||||||
var state = {title: "<a href='mailto:shylinux@163.com'>shylinux@163.com</>"}, list = [], cb = function(event, item, value) {
|
var cb = function(event, item, value) {kit._call(page.Action[item], [event, item, value, page])}
|
||||||
kit._call(page.Action[item], [event, item, value, page])
|
|
||||||
}
|
|
||||||
var ui = kit.AppendChilds(output, [
|
var ui = kit.AppendChilds(output, [
|
||||||
{"view": ["title", "div", state.title]},
|
{"view": ["title", "div", page.Status.meta.title]},
|
||||||
{"view": ["state"]},
|
{"view": ["state"]},
|
||||||
{"view": ["magic"], list: [{label: "0", name: "count"}, {input: ["magics", function(event) {
|
{"view": ["magic"], list: [{label: "0", name: "count"}, {input: ["magics", function(event) {
|
||||||
if (event.key == "Enter" || event.ctrlKey && event.key == "j") {
|
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)
|
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
|
Show: function() {var meta = page.Status.meta, list = page.Status.list
|
||||||
kit.AppendChilds(output, [
|
kit.AppendChilds(ui.state, list.map(function(item) {return {text: [item+":"+meta[item], "div", "item"], click: function(event) {
|
||||||
{"view": ["title", "div", meta.title], click: cb},
|
cb(event, item, meta[item])
|
||||||
{"view": ["state"], list: list.map(function(item) {return {text: [item+":"+meta[item], "div", "item"], click: cb}})},
|
}}}))
|
||||||
])
|
|
||||||
field.Pane.Size(field.clientWidth, field.clientHeight)
|
field.Pane.Size(field.clientWidth, field.clientHeight)
|
||||||
},
|
},
|
||||||
Help: function() {return []},
|
Help: function() {return []},
|
||||||
@ -651,6 +645,7 @@ function Pane(page, field) {
|
|||||||
ui.item.ondragstart = function(event) {if (event.target != ui.item) {return}
|
ui.item.ondragstart = function(event) {if (event.target != ui.item) {return}
|
||||||
event.dataTransfer.setData("item", event.target.id)
|
event.dataTransfer.setData("item", event.target.id)
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
ui.item.ondragover = function(event) {if (event.target != ui.item) {return}
|
ui.item.ondragover = function(event) {if (event.target != ui.item) {return}
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
@ -1038,7 +1033,8 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
item.autocomplete = "off"
|
item.autocomplete = "off"
|
||||||
break
|
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)
|
Select: shy("选择控件", function(target, focus) {field.onclick(event)
|
||||||
page.input = target = target || option.querySelectorAll("input")[1]
|
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: ""):
|
return kit.notNone(key)? (option[key]? option[key].value: ""):
|
||||||
kit.Selector(option, ".args", function(item, index) {return item.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)
|
Delay: shy("延时命令", function(time, event, text) {plugin.ontoast(text, "", -1)
|
||||||
return setTimeout(function() {plugin.Runs(event)}, time)
|
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
|
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)
|
!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("菜单列表", {
|
onchoice: shy("菜单列表", {
|
||||||
"返回": "Last",
|
"返回": "Last",
|
||||||
"添加": "Clone",
|
"添加": "Clone",
|
||||||
@ -1181,10 +1217,11 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
|
|
||||||
kit.Log("init", "plugin", name, plugin)
|
kit.Log("init", "plugin", name, plugin)
|
||||||
plugin.which = plugin.Sync("input")
|
plugin.which = plugin.Sync("input")
|
||||||
|
page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
||||||
plugin.Appends(inputs)
|
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 plug = meta.plug, name = meta.name, type = item.type
|
||||||
var input = Meta(plugin.Zone(name), target, item, {
|
var input = Meta(plugin.Zone(name), target, item, {
|
||||||
getLocation: function(event) {
|
getLocation: function(event) {
|
||||||
@ -1217,14 +1254,6 @@ function Inputs(plugin, meta, item, target) {
|
|||||||
return (target.value = args[0]) || plugin.Zone("value", args[0])
|
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("数据转换", {
|
onformat: shy("数据转换", {
|
||||||
none: function(value) {return value||""},
|
none: function(value) {return value||""},
|
||||||
date: function(value) {return kit.time()},
|
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})
|
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()})
|
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("导入数据", {
|
onimport: shy("导入数据", {
|
||||||
_table: function(msg, list) {
|
_table: function(msg, list) {
|
||||||
return list && list.length > 0 && kit.OrderTable(kit.AppendTable(kit.AppendChild(target, "table"), msg.Table(), list), "", output.onexport)
|
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