mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 17:24:05 +08:00
opt toolkit.js
This commit is contained in:
parent
6b6d1f3b8c
commit
2bdd44814e
@ -1,7 +1,8 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
var Template = []interface{}{
|
var Template = []interface{}{
|
||||||
map[string]interface{}{"name": "index.go", "text": `package main
|
map[string]interface{}{"name": "index.go", "text":
|
||||||
|
`package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"contexts/cli"
|
"contexts/cli"
|
||||||
@ -17,7 +18,7 @@ var Index = &ctx.Context{Name: "test", Help: "测试工具",
|
|||||||
Configs: map[string]*ctx.Config{
|
Configs: map[string]*ctx.Config{
|
||||||
"_index": &ctx.Config{Name: "index", Value: []interface{}{
|
"_index": &ctx.Config{Name: "index", Value: []interface{}{
|
||||||
map[string]interface{}{"name": "demo", "help": "demo",
|
map[string]interface{}{"name": "demo", "help": "demo",
|
||||||
"tmpl": "componet", "view": "componet", "init": "",
|
"tmpl": "componet", "view": "", "init": "",
|
||||||
"type": "public", "ctx": "demo", "cmd": "demo",
|
"type": "public", "ctx": "demo", "cmd": "demo",
|
||||||
"args": []interface{}{}, "inputs": []interface{}{
|
"args": []interface{}{}, "inputs": []interface{}{
|
||||||
map[string]interface{}{"type": "text", "name": "pod", "value": "hello world"},
|
map[string]interface{}{"type": "text", "name": "pod", "value": "hello world"},
|
||||||
@ -37,16 +38,20 @@ var Index = &ctx.Context{Name: "test", Help: "测试工具",
|
|||||||
func main() {
|
func main() {
|
||||||
fmt.Print(cli.Index.Plugin(Index, os.Args[1:]))
|
fmt.Print(cli.Index.Plugin(Index, os.Args[1:]))
|
||||||
}
|
}
|
||||||
`}, map[string]interface{}{"name": "index.shy", "text": `
|
`}, map[string]interface{}{"name": "index.shy", "text":
|
||||||
fun hello world "" "" \
|
`fun hello world "" "" public \
|
||||||
public \
|
|
||||||
text "" \
|
text "" \
|
||||||
button "执行"
|
button "执行"
|
||||||
copy pwd
|
copy pwd
|
||||||
end
|
end
|
||||||
`}, map[string]interface{}{"name": "index.js", "text": `
|
`}, map[string]interface{}{"name": "index.css", "text":
|
||||||
{init: function(page, pane, field, option, output) {
|
`fieldset.item.demo div.output {
|
||||||
kit.Log("hello world")
|
}
|
||||||
}}
|
`}, map[string]interface{}{"name": "index.js", "text":
|
||||||
`}, map[string]interface{}{"name": "local.shy", "text": ` `},
|
`{init: function(run, field, option, output) {
|
||||||
|
kit.Log("hello world")
|
||||||
|
return {}
|
||||||
|
}}
|
||||||
|
`}, map[string]interface{}{"name": "local.shy", "text":
|
||||||
|
``},
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-09-10 22:40:18", "com.mac", 491,
|
"2019-09-11 22:06:20", "centos", 522,
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,10 @@ func (m *Message) Set(meta string, arg ...interface{}) *Message {
|
|||||||
}
|
}
|
||||||
case "option", "append":
|
case "option", "append":
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
delete(m.Meta, kit.Format(arg[0]))
|
for _, k := range arg {
|
||||||
|
delete(m.Data, kit.Format(k))
|
||||||
|
delete(m.Meta, kit.Format(k))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, k := range m.Meta[meta] {
|
for _, k := range m.Meta[meta] {
|
||||||
delete(m.Data, k)
|
delete(m.Data, k)
|
||||||
|
@ -360,7 +360,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
args = append(args, msg.Parse(v))
|
args = append(args, msg.Parse(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Log("time", "check: %v", m.Format("cost"))
|
msg.Log("time", "check: %v", m.Format("cost"))
|
||||||
|
msg.Log("time", "check: %v %v %v", tool["componet_cmd"], args, arg)
|
||||||
msg.Cmd(tool["componet_cmd"], args, arg).CopyTo(m)
|
msg.Cmd(tool["componet_cmd"], args, arg).CopyTo(m)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -371,7 +372,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
|
|
||||||
m.Push("name", value["componet_name"])
|
m.Push("name", value["componet_name"])
|
||||||
m.Push("help", value["componet_help"])
|
m.Push("help", value["componet_help"])
|
||||||
m.Push("view", value["componet_view"])
|
|
||||||
if kit.Right(value["componet_init"]) {
|
if kit.Right(value["componet_init"]) {
|
||||||
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.project", "plugin.path"), arg[0], kit.Format(value["componet_init"])), -1)
|
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.project", "plugin.path"), arg[0], kit.Format(value["componet_init"])), -1)
|
||||||
if script == "" {
|
if script == "" {
|
||||||
@ -381,6 +381,15 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
} else {
|
} else {
|
||||||
m.Push("init", "")
|
m.Push("init", "")
|
||||||
}
|
}
|
||||||
|
if kit.Right(value["componet_view"]) {
|
||||||
|
script := m.Cmdx("nfs.load", path.Join(m.Conf("cli.project", "plugin.path"), arg[0], kit.Format(value["componet_view"])), -1)
|
||||||
|
if script == "" {
|
||||||
|
script = m.Cmdx("nfs.load", path.Join("usr/librarys/plugin", kit.Format(value["componet_view"])), -1)
|
||||||
|
}
|
||||||
|
m.Push("view", script)
|
||||||
|
} else {
|
||||||
|
m.Push("view", "")
|
||||||
|
}
|
||||||
m.Push("inputs", kit.Format(value["inputs"]))
|
m.Push("inputs", kit.Format(value["inputs"]))
|
||||||
m.Push("feature", kit.Format(value["feature"]))
|
m.Push("feature", kit.Format(value["feature"]))
|
||||||
m.Push("exports", kit.Format(value["exports"]))
|
m.Push("exports", kit.Format(value["exports"]))
|
||||||
|
@ -1094,7 +1094,7 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
p.Data = self
|
p.Data = self
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"kit": &ctx.Command{Name: "kit name help [init [show]] [public|protected|private] cmd arg... [input value [key val]...]...", Help: "小功能", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"kit": &ctx.Command{Name: "kit name help [init [view]] [public|protected|private] cmd arg... [input value [key val]...]...", Help: "小功能", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
m.Log("info", "_index: %v", arg)
|
m.Log("info", "_index: %v", arg)
|
||||||
|
|
||||||
args := []interface{}{}
|
args := []interface{}{}
|
||||||
@ -1102,18 +1102,18 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
exports := []interface{}{}
|
exports := []interface{}{}
|
||||||
feature := map[string]interface{}{}
|
feature := map[string]interface{}{}
|
||||||
|
|
||||||
view, init, show, cmd := "", "", "", ""
|
init, view, right, cmd := "", "", "", ""
|
||||||
begin := 3
|
begin := 3
|
||||||
|
|
||||||
switch arg[3] {
|
switch arg[3] {
|
||||||
case "private", "protected", "public":
|
case "private", "protected", "public":
|
||||||
begin, show, cmd = 5, arg[3], arg[4]
|
begin, right, cmd = 5, arg[3], arg[4]
|
||||||
default:
|
default:
|
||||||
switch arg[4] {
|
switch arg[4] {
|
||||||
case "private", "protected", "public":
|
case "private", "protected", "public":
|
||||||
begin, init, show, cmd = 6, arg[3], arg[4], arg[5]
|
begin, init, right, cmd = 6, arg[3], arg[4], arg[5]
|
||||||
default:
|
default:
|
||||||
begin, init, view, show, cmd = 7, arg[3], arg[4], arg[5], arg[6]
|
begin, init, view, right, cmd = 7, arg[3], arg[4], arg[5], arg[6]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,7 +1172,7 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
"componet_help": kit.Select("", arg, 2),
|
"componet_help": kit.Select("", arg, 2),
|
||||||
"componet_view": view,
|
"componet_view": view,
|
||||||
"componet_init": init,
|
"componet_init": init,
|
||||||
"componet_type": show,
|
"componet_type": right,
|
||||||
|
|
||||||
"componet_ctx": m.Cap("module"),
|
"componet_ctx": m.Cap("module"),
|
||||||
"componet_cmd": cmd,
|
"componet_cmd": cmd,
|
||||||
|
@ -298,6 +298,7 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
|||||||
// 命令列表
|
// 命令列表
|
||||||
m.Set("option", "name")
|
m.Set("option", "name")
|
||||||
m.Set("option", "init")
|
m.Set("option", "init")
|
||||||
|
m.Set("option", "view")
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
m.Confm("flow", []string{rid, "tool", arg[0], "list"}, func(index int, tool map[string]interface{}) {
|
m.Confm("flow", []string{rid, "tool", arg[0], "list"}, func(index int, tool map[string]interface{}) {
|
||||||
m.Push("river", rid)
|
m.Push("river", rid)
|
||||||
|
5
src/plugin/mind/index.css
Normal file
5
src/plugin/mind/index.css
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
fieldset.item.mind div.output table td {
|
||||||
|
text-align:center;
|
||||||
|
min-width:16px;
|
||||||
|
height:16px;
|
||||||
|
}
|
@ -15,14 +15,6 @@ var Index = &ctx.Context{Name: "mind", Help: "思维导图",
|
|||||||
Configs: map[string]*ctx.Config{},
|
Configs: map[string]*ctx.Config{},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"doc": {Name: "doc", Help: "文档", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"doc": {Name: "doc", Help: "文档", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
switch len(arg) {
|
|
||||||
case 0:
|
|
||||||
m.Cmdy("ssh.data", "show", "doc")
|
|
||||||
case 1:
|
|
||||||
m.Cmdy("ssh.data", "show", "doc", arg[0])
|
|
||||||
case 2:
|
|
||||||
m.Cmdy("ssh.data", "insert", "doc", "title", arg[0], "content", arg[1])
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"xls": {Name: "xls", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"xls": {Name: "xls", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
@ -74,7 +66,6 @@ var Index = &ctx.Context{Name: "mind", Help: "思维导图",
|
|||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"ppt": {Name: "ppt", Help: "文稿", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"ppt": {Name: "ppt", Help: "文稿", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
m.Echo(kit.Select("hello world", arg, 0))
|
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
@ -1,28 +1,20 @@
|
|||||||
{init: function(run, field, option, output) {
|
{init: function(run, field, option, output) {return {
|
||||||
return {
|
|
||||||
ondaemon: {
|
ondaemon: {
|
||||||
table: function(msg, cb) {
|
table: function(msg, cb) {if (msg.event.type == "blur") {return}
|
||||||
if (msg.event.type == "blur") {return}
|
|
||||||
var plugin = field.Plugin
|
var plugin = field.Plugin
|
||||||
output.innerHTML = "", msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), "", function(event, value, name, line, index) {
|
output.innerHTML = "", msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), "", function(event, value, name, line, index) {
|
||||||
if (name == "id") {
|
if (name == "id") {
|
||||||
page.Sync("plugin_"+plugin.exports[0]).set(plugin.onexport[plugin.exports[2]||""](value, name, line))
|
page.Sync("plugin_"+plugin.exports[0]).set(plugin.onexport[plugin.exports[2]||""](value, name, line))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var td = event.target
|
var td = event.target
|
||||||
function submit(event) {
|
function submit(event) {
|
||||||
td.innerText = event.target.value
|
(td.innerText = event.target.value) != value && plugin.Run(event, [option.title.value, name, index-1, event.target.value], plugin.Check)
|
||||||
if (event.target.value != value) {
|
|
||||||
plugin.Run(event, [option.title.value, name, index-1, event.target.value], function() {
|
|
||||||
plugin.Check()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
kit.AppendChilds(td, [{type: "input", value: value, data: {onblur: function(event) {
|
kit.AppendChilds(td, [{type: "input", value: value, data: {onblur: submit, onkeyup: function(event) {
|
||||||
submit(event)
|
|
||||||
}, onkeyup: function(event) {
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case "Enter":
|
case "Enter":
|
||||||
break
|
|
||||||
case "Tab":
|
case "Tab":
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@ -30,15 +22,11 @@
|
|||||||
}
|
}
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
}, onkeydown: function(event) {
|
}, onkeydown: function(event) {
|
||||||
console.log(event.key)
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case "Enter":
|
case "Enter":
|
||||||
if (event.shiftKey) {
|
td.parentNode[event.shiftKey?"previousSibling":"nextSibling"].querySelector("td").click()
|
||||||
td.parentNode.previousSibling.querySelector("td").click()
|
|
||||||
} else {
|
|
||||||
td.parentNode.nextSibling.querySelector("td").click()
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
case "Tab":
|
case "Tab":
|
||||||
if (event.shiftKey) {
|
if (event.shiftKey) {
|
||||||
@ -62,10 +50,7 @@
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}}}]).first.focus()
|
}}}]).first.focus()
|
||||||
}
|
}
|
||||||
})
|
}), typeof cb == "function" && cb(msg)
|
||||||
typeof cb == "function" && cb(msg)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}}}
|
||||||
}
|
|
||||||
}}
|
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
|
kit xls "表格" "index.js" "index.css" private \
|
||||||
kit doc "文档" private \
|
|
||||||
text "" name title imports plugin_doc_id action auto \
|
|
||||||
text "" name content \
|
|
||||||
button "执行" \
|
|
||||||
button "返回" click Last \
|
|
||||||
exports doc_id id
|
|
||||||
|
|
||||||
kit xls "表格" "index.js" private \
|
|
||||||
text "" name title imports plugin_xls_id action auto \
|
text "" name title imports plugin_xls_id action auto \
|
||||||
text "" name content \
|
text "" name content \
|
||||||
button "执行" \
|
button "执行" \
|
||||||
button "返回" click Last \
|
button "返回" click Last \
|
||||||
feature style "output full" \
|
feature style "mind" \
|
||||||
exports xls_id id
|
exports xls_id id
|
||||||
|
@ -6,7 +6,7 @@ var page = Page({
|
|||||||
kit.isWindows && (document.body.style.overflow = "hidden")
|
kit.isWindows && (document.body.style.overflow = "hidden")
|
||||||
|
|
||||||
var height = document.body.clientHeight-page.conf.border
|
var height = document.body.clientHeight-page.conf.border
|
||||||
var width = document.body.clientWidth-page.conf.border-2
|
var width = document.body.clientWidth-page.conf.border
|
||||||
page.conf.height = height
|
page.conf.height = height
|
||||||
page.conf.width = width
|
page.conf.width = width
|
||||||
|
|
||||||
@ -586,6 +586,8 @@ var page = Page({
|
|||||||
page.onaction[item] && page.onaction[item](event, item, value, page)
|
page.onaction[item] && page.onaction[item](event, item, value, page)
|
||||||
})
|
})
|
||||||
page.river.Pane.Show(), page.pane = page.action, page.plugin = kit.Selector(page.action, "fieldset")[0]
|
page.river.Pane.Show(), page.pane = page.action, page.plugin = kit.Selector(page.action, "fieldset")[0]
|
||||||
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.isMobile? "办公": "工作")
|
page.onlayout(event)
|
||||||
|
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.device.isMobile? "办公": "工作")
|
||||||
|
page.onlayout(event)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -227,6 +227,9 @@ fieldset.Footer>div.output div.state div {
|
|||||||
fieldset.item {
|
fieldset.item {
|
||||||
float:left;
|
float:left;
|
||||||
}
|
}
|
||||||
|
fieldset.item.select {
|
||||||
|
background-color:gold;
|
||||||
|
}
|
||||||
fieldset.item>div.output {
|
fieldset.item>div.output {
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
}
|
}
|
||||||
@ -253,13 +256,6 @@ fieldset.item>div.output>div.status>input.cmd {
|
|||||||
font-size:16px;
|
font-size:16px;
|
||||||
width:250px;
|
width:250px;
|
||||||
}
|
}
|
||||||
fieldset.item div.output.full table td {
|
|
||||||
height:16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldset.item.select {
|
|
||||||
background-color:gold;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldset table {
|
fieldset table {
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
@ -287,7 +283,6 @@ fieldset table th.order {
|
|||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
fieldset table td {
|
fieldset table td {
|
||||||
min-height:16px;
|
|
||||||
max-width:1200px;
|
max-width:1200px;
|
||||||
font-family:monospace;
|
font-family:monospace;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
|
@ -79,11 +79,12 @@ function Meta(target, obj) {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
var id = "plugin"+this.ID()
|
var id = "plugin"+this.ID()
|
||||||
list.push({view: [text.view+" item", "fieldset", "", "field"], data: {id: id, Run: cb}, list: [
|
list.push({view: ["item", "fieldset", "", "field"], data: {id: id, Run: cb}, list: [
|
||||||
{text: [text.name+"("+text.help+")", "legend"]},
|
{text: [text.name+"("+text.help+")", "legend"]},
|
||||||
{view: ["option", "form", "", "option"], list: [{type: "input", style: {"display": "none"}}]},
|
{view: ["option", "form", "", "option"], list: [{type: "input", style: {"display": "none"}}]},
|
||||||
{view: ["output", "div", "", "output"]},
|
{view: ["output", "div", "", "output"]},
|
||||||
{script: ""+id+".Script="+(text.init||"{}")},
|
{script: ""+id+".Script="+(text.init||"{}")},
|
||||||
|
{styles: text.view},
|
||||||
]})
|
]})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ function Page(page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (page.check) {
|
if (page.check) {
|
||||||
false && kit.isWeiXin? page.login.Pane.Run(["weixin"], function(msg) {
|
false && kit.device.isWeiXin? page.login.Pane.Run(["weixin"], function(msg) {
|
||||||
page.Include([
|
page.Include([
|
||||||
"https://res.wx.qq.com/open/js/jweixin-1.4.0.js",
|
"https://res.wx.qq.com/open/js/jweixin-1.4.0.js",
|
||||||
"/static/librarys/weixin.js",
|
"/static/librarys/weixin.js",
|
||||||
@ -578,8 +579,8 @@ function Pane(page, field) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
Select: function(index, key) {
|
Select: function(index, key) {
|
||||||
-1 < last && last < list.length && (list[last].className = "item")
|
-1 < last && last < list.length && (kit.classList.del(list[last], "select"))
|
||||||
last = index, list[index] && (list[index].className = "item select")
|
last = index, list[index] && (kit.classList.add(list[index], "select"))
|
||||||
key && pane.which.set(key)
|
key && pane.which.set(key)
|
||||||
},
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
@ -685,10 +686,6 @@ function Pane(page, field) {
|
|||||||
return page[name] = field, pane.Field = field, field.Pane = pane
|
return page[name] = field, pane.Field = field, field.Pane = pane
|
||||||
}
|
}
|
||||||
function Plugin(page, pane, field, runs) {
|
function Plugin(page, pane, field, runs) {
|
||||||
var run = function(event, cmds, cbs) {
|
|
||||||
event.Plugin = plugin, runs(event, cmds, cbs)
|
|
||||||
}
|
|
||||||
|
|
||||||
var option = field.querySelector("form.option")
|
var option = field.querySelector("form.option")
|
||||||
var action = field.querySelector("div.action")
|
var action = field.querySelector("div.action")
|
||||||
var output = field.querySelector("div.output")
|
var output = field.querySelector("div.output")
|
||||||
@ -697,14 +694,16 @@ function Plugin(page, pane, field, runs) {
|
|||||||
var name = meta.name
|
var name = meta.name
|
||||||
var args = meta.args || []
|
var args = meta.args || []
|
||||||
var inputs = JSON.parse(meta.inputs || "[]")
|
var inputs = JSON.parse(meta.inputs || "[]")
|
||||||
var display = JSON.parse(meta.display||'{}')
|
|
||||||
var feature = JSON.parse(meta.feature||'{}')
|
var feature = JSON.parse(meta.feature||'{}')
|
||||||
var display = JSON.parse(meta.display||'{}')
|
var display = JSON.parse(meta.display||'{}')
|
||||||
var exports = JSON.parse(meta.exports||'["",""]')
|
var exports = JSON.parse(meta.exports||'["",""]')
|
||||||
var deal = (feature && feature.display) || "table"
|
var deal = (feature && feature.display) || "table"
|
||||||
var history = []
|
kit.classList.add(field, feature.style)
|
||||||
output.className = (feature.style || "") + " output"
|
|
||||||
|
|
||||||
|
var history = []
|
||||||
|
var run = function(event, cmds, cbs) {
|
||||||
|
event.Plugin = plugin, runs(event, cmds, cbs)
|
||||||
|
}
|
||||||
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
||||||
})(run, field, option, output)||{}, {
|
})(run, field, option, output)||{}, {
|
||||||
Append: function(item, name, value) {
|
Append: function(item, name, value) {
|
||||||
@ -733,6 +732,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
case "textarea":
|
case "textarea":
|
||||||
input.type = "textarea", item.style = "height:100px;"+"width:"+(pane.target.clientWidth-30)+"px"
|
input.type = "textarea", item.style = "height:100px;"+"width:"+(pane.target.clientWidth-30)+"px"
|
||||||
item.className = "args"
|
item.className = "args"
|
||||||
|
// no break
|
||||||
case "text":
|
case "text":
|
||||||
item.className = "args"
|
item.className = "args"
|
||||||
item.autocomplete = "off"
|
item.autocomplete = "off"
|
||||||
@ -763,8 +763,8 @@ function Plugin(page, pane, field, runs) {
|
|||||||
field.parentNode.removeChild(field)
|
field.parentNode.removeChild(field)
|
||||||
},
|
},
|
||||||
Select: function(silent) {
|
Select: function(silent) {
|
||||||
page.plugin && (page.plugin.className = "item")
|
page.plugin && (kit.classList.del(page.plugin, "select"))
|
||||||
page.plugin = field, field.className = "item select"
|
page.plugin = field, kit.classList.add(field, "select")
|
||||||
!silent && (option.querySelectorAll("input")[1].focus())
|
!silent && (option.querySelectorAll("input")[1].focus())
|
||||||
},
|
},
|
||||||
Reveal: function(msg) {
|
Reveal: function(msg) {
|
||||||
@ -938,7 +938,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
action.target.value = kit.History.get("txt", -1).data.trim()
|
action.target.value = kit.History.get("txt", -1).data.trim()
|
||||||
},
|
},
|
||||||
onchange: function(event, action, type, name, item) {
|
onchange: function(event, action, type, name, item) {
|
||||||
plugin.Check(item.action == "auto"? undefined: action)
|
type == "select" && plugin.Check(item.action == "auto"? undefined: action)
|
||||||
},
|
},
|
||||||
onkeyup: function(event, action, type, name, item) {
|
onkeyup: function(event, action, type, name, item) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
@ -1012,8 +1012,6 @@ function Plugin(page, pane, field, runs) {
|
|||||||
exports: JSON.parse(meta.exports||'["",""]'),
|
exports: JSON.parse(meta.exports||'["",""]'),
|
||||||
})
|
})
|
||||||
|
|
||||||
inputs.map(function(item) {
|
inputs.map(plugin.Append)
|
||||||
plugin.Append(item, item.name, item.value)
|
|
||||||
})
|
|
||||||
return page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
return page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,35 @@
|
|||||||
kit = toolkit = {
|
kit = toolkit = {
|
||||||
isMobile: navigator.userAgent.indexOf("Mobile") > -1,
|
// 用户终端
|
||||||
|
device: {
|
||||||
isWeiXin: navigator.userAgent.indexOf("MicroMessenger") > -1,
|
isWeiXin: navigator.userAgent.indexOf("MicroMessenger") > -1,
|
||||||
|
isMobile: navigator.userAgent.indexOf("Mobile") > -1,
|
||||||
|
isIPhone: navigator.userAgent.indexOf("iPhone") > -1,
|
||||||
isMacOSX: navigator.userAgent.indexOf("Mac OS X") > -1,
|
isMacOSX: navigator.userAgent.indexOf("Mac OS X") > -1,
|
||||||
isWindows: navigator.userAgent.indexOf("Windows") > -1,
|
isWindows: navigator.userAgent.indexOf("Windows") > -1,
|
||||||
isIPhone: navigator.userAgent.indexOf("iPhone") > -1,
|
},
|
||||||
isSpace: function(c) {
|
alert: function(text) {
|
||||||
return c == " " || c == "Enter"
|
alert(JSON.stringify(text))
|
||||||
|
},
|
||||||
|
prompt: function(text) {
|
||||||
|
return prompt(text)
|
||||||
|
},
|
||||||
|
confirm: function(text) {
|
||||||
|
return confirm(text)
|
||||||
|
},
|
||||||
|
reload: function() {
|
||||||
|
location.reload()
|
||||||
|
},
|
||||||
|
// 操作日志
|
||||||
|
Log: function() {
|
||||||
|
var args = []
|
||||||
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
args.push(arguments[i])
|
||||||
|
}
|
||||||
|
console.log(arguments.length == 1? args[0]: args)
|
||||||
|
return args
|
||||||
|
},
|
||||||
|
Delay: function(time, cb) {
|
||||||
|
return setTimeout(cb, time)
|
||||||
},
|
},
|
||||||
History: {dir: [], pod: [], ctx: [], cmd: [], txt: [], key: [], lay: [],
|
History: {dir: [], pod: [], ctx: [], cmd: [], txt: [], key: [], lay: [],
|
||||||
add: function(type, data) {
|
add: function(type, data) {
|
||||||
@ -20,18 +44,28 @@ kit = toolkit = {
|
|||||||
return index == undefined? this[type]: this[type][(index+len)%len]
|
return index == undefined? this[type]: this[type][(index+len)%len]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Log: function() {
|
|
||||||
var args = []
|
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
|
||||||
args.push(arguments[i])
|
|
||||||
}
|
|
||||||
console.log(arguments.length == 1? args[0]: args)
|
|
||||||
return args
|
|
||||||
},
|
|
||||||
Delay: function(time, cb) {
|
|
||||||
return setTimeout(cb, time)
|
|
||||||
},
|
|
||||||
|
|
||||||
|
// HTML节点操作
|
||||||
|
classList: {
|
||||||
|
add: function(obj) {
|
||||||
|
var list = obj.className.split(" ")
|
||||||
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
|
list.push(arguments[i])
|
||||||
|
}
|
||||||
|
return obj.className = list.join(" ")
|
||||||
|
},
|
||||||
|
del: function(obj) {
|
||||||
|
var res = []
|
||||||
|
var list = arguments
|
||||||
|
obj.className.split(" ").forEach(function(item) {
|
||||||
|
for (var i = 1; i < list.length; i++) {
|
||||||
|
if (item == list[i]) {return}
|
||||||
|
}
|
||||||
|
res.push(item)
|
||||||
|
})
|
||||||
|
return obj.className = res.join(" ")
|
||||||
|
},
|
||||||
|
},
|
||||||
ModifyView: function(which, args) {
|
ModifyView: function(which, args) {
|
||||||
var height = document.body.clientHeight-4
|
var height = document.body.clientHeight-4
|
||||||
var width = document.body.clientWidth-4
|
var width = document.body.clientWidth-4
|
||||||
@ -267,6 +301,9 @@ kit = toolkit = {
|
|||||||
|
|
||||||
} else if (child.styles) {
|
} else if (child.styles) {
|
||||||
var str = []
|
var str = []
|
||||||
|
if (typeof child.styles == "string") {
|
||||||
|
str.push(child.styles)
|
||||||
|
} else {
|
||||||
for (var key in child.styles) {
|
for (var key in child.styles) {
|
||||||
str.push(key)
|
str.push(key)
|
||||||
str.push(" {")
|
str.push(" {")
|
||||||
@ -278,6 +315,7 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
str.push("}\n")
|
str.push("}\n")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
child.data["innerHTML"] = str.join("")
|
child.data["innerHTML"] = str.join("")
|
||||||
child.data["type"] = "text/css"
|
child.data["type"] = "text/css"
|
||||||
child.type = "style"
|
child.type = "style"
|
||||||
@ -301,7 +339,7 @@ kit = toolkit = {
|
|||||||
this.AppendChild(elm, children)
|
this.AppendChild(elm, children)
|
||||||
return parent.insertBefore(elm, position || parent.firstElementChild)
|
return parent.insertBefore(elm, position || parent.firstElementChild)
|
||||||
},
|
},
|
||||||
|
// HTML控件操作
|
||||||
AppendAction: function(parent, list, cb) {
|
AppendAction: function(parent, list, cb) {
|
||||||
var result = []
|
var result = []
|
||||||
list.forEach(function(item, index) {
|
list.forEach(function(item, index) {
|
||||||
@ -411,8 +449,8 @@ kit = toolkit = {
|
|||||||
var target = event.target
|
var target = event.target
|
||||||
var dataset = target.dataset
|
var dataset = target.dataset
|
||||||
var head = target.parentElement.parentElement.querySelector("tr")
|
var head = target.parentElement.parentElement.querySelector("tr")
|
||||||
kit.Selector(table, "tr.select", function(item) {item.className = ""})
|
// kit.Selector(table, "tr.select", function(item) {item.className = ""})
|
||||||
kit.Selector(table, "td.select", function(item) {item.className = ""})
|
// kit.Selector(table, "td.select", function(item) {item.className = ""})
|
||||||
kit.Selector(table, "tr", function(item, i) {item == target.parentElement && (index = i)})
|
kit.Selector(table, "tr", function(item, i) {item == target.parentElement && (index = i)})
|
||||||
|
|
||||||
target.parentElement.childNodes.forEach(function(item, i) {
|
target.parentElement.childNodes.forEach(function(item, i) {
|
||||||
@ -425,8 +463,8 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
var name = head.childNodes[i].innerText
|
var name = head.childNodes[i].innerText
|
||||||
if (name.startsWith(field)) {
|
if (name.startsWith(field)) {
|
||||||
item.className = "select"
|
// item.className = "select"
|
||||||
item.parentElement.className = "select"
|
// item.parentElement.className = "select"
|
||||||
typeof cb == "function" && cb(event, item.innerText, name, item.parentNode.Meta, index)
|
typeof cb == "function" && cb(event, item.innerText, name, item.parentNode.Meta, index)
|
||||||
}
|
}
|
||||||
kit.CopyText()
|
kit.CopyText()
|
||||||
@ -434,6 +472,18 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// HTML显示文本
|
||||||
|
Color: function(s) {
|
||||||
|
s = s.replace(/\033\[1m/g, "<span style='font-weight:bold'>")
|
||||||
|
s = s.replace(/\033\[36m/g, "<span style='color:#0ff'>")
|
||||||
|
s = s.replace(/\033\[33m/g, "<span style='color:#ff0'>")
|
||||||
|
s = s.replace(/\033\[32m/g, "<span style='color:#0f0'>")
|
||||||
|
s = s.replace(/\033\[32;1m/g, "<span style='color:#0f0'>")
|
||||||
|
s = s.replace(/\033\[31m/g, "<span style='color:#f00'>")
|
||||||
|
s = s.replace(/\033\[0m/g, "</span>")
|
||||||
|
s = s.replace(/\033\[m/g, "</span>")
|
||||||
|
return s
|
||||||
|
},
|
||||||
OrderCode: function(code) {
|
OrderCode: function(code) {
|
||||||
if (!code) {return}
|
if (!code) {return}
|
||||||
|
|
||||||
@ -497,18 +547,7 @@ kit = toolkit = {
|
|||||||
Position: function(which) {
|
Position: function(which) {
|
||||||
return (parseInt((which.scrollTop + which.clientHeight) / which.scrollHeight * 100)||0)+"%"
|
return (parseInt((which.scrollTop + which.clientHeight) / which.scrollHeight * 100)||0)+"%"
|
||||||
},
|
},
|
||||||
Color: function(s) {
|
// HTML输入文本
|
||||||
s = s.replace(/\033\[1m/g, "<span style='font-weight:bold'>")
|
|
||||||
s = s.replace(/\033\[36m/g, "<span style='color:#0ff'>")
|
|
||||||
s = s.replace(/\033\[33m/g, "<span style='color:#ff0'>")
|
|
||||||
s = s.replace(/\033\[32m/g, "<span style='color:#0f0'>")
|
|
||||||
s = s.replace(/\033\[32;1m/g, "<span style='color:#0f0'>")
|
|
||||||
s = s.replace(/\033\[31m/g, "<span style='color:#f00'>")
|
|
||||||
s = s.replace(/\033\[0m/g, "</span>")
|
|
||||||
s = s.replace(/\033\[m/g, "</span>")
|
|
||||||
return s
|
|
||||||
},
|
|
||||||
|
|
||||||
CopyText: function(text) {
|
CopyText: function(text) {
|
||||||
text = window.getSelection().toString()
|
text = window.getSelection().toString()
|
||||||
if (text == "") {return}
|
if (text == "") {return}
|
||||||
@ -530,6 +569,7 @@ kit = toolkit = {
|
|||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 数据容器迭代
|
||||||
Selector: function(obj, item, cb) {
|
Selector: function(obj, item, cb) {
|
||||||
var list = []
|
var list = []
|
||||||
obj.querySelectorAll(item).forEach(function(item, index, array) {
|
obj.querySelectorAll(item).forEach(function(item, index, array) {
|
||||||
@ -549,10 +589,6 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
Format: function(objs) {
|
|
||||||
return JSON.stringify(objs)
|
|
||||||
wa
|
|
||||||
},
|
|
||||||
List: function(obj, cb, interval, cbs) {
|
List: function(obj, cb, interval, cbs) {
|
||||||
if (interval) {
|
if (interval) {
|
||||||
function loop(i) {
|
function loop(i) {
|
||||||
@ -576,21 +612,21 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
alert: function(text) {
|
// 数据类型转换
|
||||||
alert(JSON.stringify(text))
|
isSpace: function(c) {
|
||||||
|
return c == " " || c == "Enter"
|
||||||
},
|
},
|
||||||
prompt: function(text) {
|
right: function(arg) {
|
||||||
return prompt(text)
|
if (arg == "true") {
|
||||||
},
|
return true
|
||||||
confirm: function(text) {
|
}
|
||||||
return confirm(text)
|
if (arg == "false") {
|
||||||
},
|
return false
|
||||||
reload: function() {
|
}
|
||||||
location.reload()
|
if (arg) {
|
||||||
},
|
return true
|
||||||
|
}
|
||||||
distance: function(x0, y0, x1, y1) {
|
return false
|
||||||
return Math.sqrt(Math.pow(x1-x0, 2)+Math.pow(y1-y0, 2))
|
|
||||||
},
|
},
|
||||||
number: function(d, n) {
|
number: function(d, n) {
|
||||||
var result = []
|
var result = []
|
||||||
@ -606,28 +642,8 @@ kit = toolkit = {
|
|||||||
result.reverse()
|
result.reverse()
|
||||||
return result.join("")
|
return result.join("")
|
||||||
},
|
},
|
||||||
right: function(arg) {
|
distance: function(x0, y0, x1, y1) {
|
||||||
if (arg == "true") {
|
return Math.sqrt(Math.pow(x1-x0, 2)+Math.pow(y1-y0, 2))
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (arg == "false") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (arg) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
time: function(t, fmt) {
|
|
||||||
var now = t? new Date(t): new Date()
|
|
||||||
fmt = fmt || "%y-%m-%d %H:%M:%S"
|
|
||||||
fmt = fmt.replace("%y", now.getFullYear())
|
|
||||||
fmt = fmt.replace("%m", kit.number(now.getMonth()+1, 2))
|
|
||||||
fmt = fmt.replace("%d", kit.number(now.getDate(), 2))
|
|
||||||
fmt = fmt.replace("%H", kit.number(now.getHours(), 2))
|
|
||||||
fmt = fmt.replace("%M", kit.number(now.getMinutes(), 2))
|
|
||||||
fmt = fmt.replace("%S", kit.number(now.getSeconds(), 2))
|
|
||||||
return fmt
|
|
||||||
},
|
},
|
||||||
format_date: function(arg) {
|
format_date: function(arg) {
|
||||||
var date = arg.getDate()
|
var date = arg.getDate()
|
||||||
@ -652,6 +668,20 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
return arg.getFullYear()+"-"+month+"-"+date+" "+hour+":"+minute+":"+second
|
return arg.getFullYear()+"-"+month+"-"+date+" "+hour+":"+minute+":"+second
|
||||||
},
|
},
|
||||||
|
Format: function(objs) {
|
||||||
|
return JSON.stringify(objs)
|
||||||
|
},
|
||||||
|
time: function(t, fmt) {
|
||||||
|
var now = t? new Date(t): new Date()
|
||||||
|
fmt = fmt || "%y-%m-%d %H:%M:%S"
|
||||||
|
fmt = fmt.replace("%y", now.getFullYear())
|
||||||
|
fmt = fmt.replace("%m", kit.number(now.getMonth()+1, 2))
|
||||||
|
fmt = fmt.replace("%d", kit.number(now.getDate(), 2))
|
||||||
|
fmt = fmt.replace("%H", kit.number(now.getHours(), 2))
|
||||||
|
fmt = fmt.replace("%M", kit.number(now.getMinutes(), 2))
|
||||||
|
fmt = fmt.replace("%S", kit.number(now.getSeconds(), 2))
|
||||||
|
return fmt
|
||||||
|
},
|
||||||
size: function(obj, width, height) {
|
size: function(obj, width, height) {
|
||||||
obj.style.width = width+"px"
|
obj.style.width = width+"px"
|
||||||
obj.style.height = height+"px"
|
obj.style.height = height+"px"
|
||||||
@ -670,73 +700,6 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
return res || true
|
return res || true
|
||||||
},
|
},
|
||||||
|
|
||||||
OrderForm: function(page, field, option, append, result) {
|
|
||||||
if (!option) {return}
|
|
||||||
option.ondaemon = option.ondaemon || function(msg) {
|
|
||||||
append.innerHTML = ""
|
|
||||||
msg && msg.append && kit.AppendTable(append, ctx.Table(msg), msg.append, function(value, key, row, index, event) {
|
|
||||||
typeof option.daemon_action[key] == "function" && option.daemon_action[key](value, key, row, index, event)
|
|
||||||
})
|
|
||||||
result && (result.innerText = (msg && msg.result)? msg.result.join(""): "")
|
|
||||||
}
|
|
||||||
|
|
||||||
option.querySelectorAll("select").forEach(function(select, index, array) {
|
|
||||||
select.onchange = select.onchange || function(event) {
|
|
||||||
if (index == array.length-1) {
|
|
||||||
ctx.Runs(page, option)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (array[index+1].type == "button") {
|
|
||||||
array[index+1].click()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
array[index+1].focus()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
option.querySelectorAll("input").forEach(function(input, index, array) {
|
|
||||||
switch (input.type) {
|
|
||||||
case "button":
|
|
||||||
input.onclick = input.onclick || function(event) {
|
|
||||||
if (index == array.length-1) {
|
|
||||||
if (input.value == "login") {
|
|
||||||
ctx.Runs(page, option, function(msg) {
|
|
||||||
if (document.referrer) {
|
|
||||||
location.href = document.referrer
|
|
||||||
} else {
|
|
||||||
ctx.Search("group", "")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Runs(page, option)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (array[index+1].type == "button") {
|
|
||||||
array[index+1].click()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
array[index+1].focus()
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
input.onkeyup = input.onkeyup || function(event) {
|
|
||||||
if (event.key != "Enter") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (index == array.length-1) {
|
|
||||||
ctx.Runs(page, option)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (array[index+1].type == "button") {
|
|
||||||
array[index+1].click()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
array[index+1].focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Editor(run, plugin, option, output, width, height, space, msg) {
|
function Editor(run, plugin, option, output, width, height, space, msg) {
|
||||||
@ -1491,4 +1454,3 @@ function Canvas(plugin, option, output, width, height, space, msg) {
|
|||||||
return what.reset().refresh()
|
return what.reset().refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ var page = Page({
|
|||||||
page.Conf("menu.display", value || (page.Conf("menu.display")? "": "none"))
|
page.Conf("menu.display", value || (page.Conf("menu.display")? "": "none"))
|
||||||
},
|
},
|
||||||
Size: function(width, height) {
|
Size: function(width, height) {
|
||||||
if (kit.isMobile) {
|
if (kit.device.isMobile) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (page.Conf("menu.float")) {
|
if (page.Conf("menu.float")) {
|
||||||
@ -120,7 +120,7 @@ var page = Page({
|
|||||||
page.Conf("menu.display", "", function(value, old) {
|
page.Conf("menu.display", "", function(value, old) {
|
||||||
ui.menu.style.display = value
|
ui.menu.style.display = value
|
||||||
})
|
})
|
||||||
page.Conf("menu.float", !kit.isMobile, function(value, old) {
|
page.Conf("menu.float", !kit.device.isMobile, function(value, old) {
|
||||||
page.onlayout()
|
page.onlayout()
|
||||||
})
|
})
|
||||||
page.Conf("menu.scroll", true, function(value, old) {
|
page.Conf("menu.scroll", true, function(value, old) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user