mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add aaa.clip
This commit is contained in:
commit
e0db2ea8b6
@ -677,6 +677,24 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心",
|
||||
return
|
||||
}},
|
||||
|
||||
"clip": &ctx.Command{Name: "clip", Help: "授权", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
h := m.Cmdx("aaa.auth", "username", m.Option("username"))
|
||||
|
||||
if len(arg) == 0 { // 会话列表
|
||||
m.Cmdy("aaa.config", "auth", h+".data.clip")
|
||||
return
|
||||
}
|
||||
|
||||
switch arg[0] {
|
||||
case "clear":
|
||||
m.Conf("auth", []string{h, "data", "clip"}, []interface{}{})
|
||||
default:
|
||||
m.Conf("auth", []string{h, "data", "clip", kit.Select("-2", arg, 1)}, arg[0])
|
||||
m.Echo("%d", len(m.Confv("auth", []string{h, "data", "clip"}).([]interface{}))-1)
|
||||
}
|
||||
return
|
||||
}},
|
||||
|
||||
"relay": &ctx.Command{Name: "relay check hash | share role", Help: "授权", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
if len(arg) == 0 { // 会话列表
|
||||
m.Cmdy("aaa.auth", "relay")
|
||||
|
@ -1599,28 +1599,31 @@ func (m *Message) Cmd(args ...interface{}) *Message {
|
||||
msg.TryCatch(msg, true, func(msg *Message) {
|
||||
msg.Log("cmd", "%s %s %v %v", c.Name, key, arg, msg.Meta["option"])
|
||||
|
||||
if args := []string{}; x.Form != nil {
|
||||
for i := 0; i < len(arg); i++ {
|
||||
if n, ok := x.Form[arg[i]]; ok {
|
||||
if n < 0 {
|
||||
n += len(arg) - i
|
||||
}
|
||||
for j := i + 1; j <= i+n && j < len(arg); j++ {
|
||||
if _, ok := x.Form[arg[j]]; ok {
|
||||
n = j - i - 1
|
||||
for _, form := range []map[string]int{map[string]int{"page.limit": 1, "page.offset": 1}, x.Form} {
|
||||
|
||||
if args := []string{}; form != nil {
|
||||
for i := 0; i < len(arg); i++ {
|
||||
if n, ok := form[arg[i]]; ok {
|
||||
if n < 0 {
|
||||
n += len(arg) - i
|
||||
}
|
||||
}
|
||||
if i+1+n > len(arg) {
|
||||
msg.Add("option", arg[i], arg[i+1:])
|
||||
for j := i + 1; j <= i+n && j < len(arg); j++ {
|
||||
if _, ok := form[arg[j]]; ok {
|
||||
n = j - i - 1
|
||||
}
|
||||
}
|
||||
if i+1+n > len(arg) {
|
||||
msg.Add("option", arg[i], arg[i+1:])
|
||||
} else {
|
||||
msg.Add("option", arg[i], arg[i+1:i+1+n])
|
||||
}
|
||||
i += n
|
||||
} else {
|
||||
msg.Add("option", arg[i], arg[i+1:i+1+n])
|
||||
args = append(args, arg[i])
|
||||
}
|
||||
i += n
|
||||
} else {
|
||||
args = append(args, arg[i])
|
||||
}
|
||||
arg = args
|
||||
}
|
||||
arg = args
|
||||
}
|
||||
|
||||
target := msg.target
|
||||
|
@ -1417,6 +1417,8 @@ func Start(args ...string) bool {
|
||||
}
|
||||
|
||||
Pulse.Option("routine", 0)
|
||||
Pulse.Option("page.limit", 10)
|
||||
Pulse.Option("page.offset", 0)
|
||||
if Index.Begin(Pulse, args...); Index.Start(Pulse, args...) {
|
||||
return Index.Close(Pulse, args...)
|
||||
}
|
||||
|
@ -1122,14 +1122,15 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
"git": &ctx.Config{Name: "git", Value: map[string]interface{}{
|
||||
"args": []interface{}{"-C", "@git_dir"},
|
||||
"info": map[string]interface{}{"cmds": []interface{}{"log", "status", "branch"}},
|
||||
"branch": map[string]interface{}{"args": []interface{}{"branch", "-v"}},
|
||||
"update": map[string]interface{}{"cmds": []interface{}{"stash", "pull", "pop"}},
|
||||
"pop": map[string]interface{}{"args": []interface{}{"stash", "pop"}},
|
||||
"commit": map[string]interface{}{"args": []interface{}{"commit", "-am"}},
|
||||
"branch": map[string]interface{}{"args": []interface{}{"branch", "-v"}},
|
||||
"status": map[string]interface{}{"args": []interface{}{"status", "-sb"}},
|
||||
"log": map[string]interface{}{"args": []interface{}{"log", "-n", "limit", "--reverse", "pretty", "date"}},
|
||||
"log": map[string]interface{}{"args": []interface{}{"log", "-n", "@page.limit", "--skip", "@page.offset", "pretty", "date"}},
|
||||
"trans": map[string]interface{}{
|
||||
"date": "--date=format:%m/%d %H:%M",
|
||||
"pretty": "--pretty=format:%h %ad %an %s",
|
||||
"limit": "10",
|
||||
},
|
||||
}, Help: "命令集合"},
|
||||
"paths": &ctx.Config{Name: "paths", Value: []interface{}{"var", "usr", "etc", "bin", ""}, Help: "文件路径"},
|
||||
@ -1235,7 +1236,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
return
|
||||
}
|
||||
|
||||
if p := m.Cmdx("nfs.path", arg[0]); p != "" {
|
||||
if p := m.Cmdx("nfs.path", arg[0]); p != "" && !m.Confs("git", arg[0]) {
|
||||
m.Option("git_dir", p)
|
||||
arg = arg[1:]
|
||||
} else {
|
||||
@ -1261,8 +1262,12 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
args = append(args, arg[1:]...)
|
||||
|
||||
for i, _ := range args {
|
||||
args[i] = m.Parse(args[i])
|
||||
args[i] = kit.Select(args[i], m.Conf("git", []string{"trans", args[i]}))
|
||||
v := m.Parse(args[i])
|
||||
if v == args[i] || v == "" {
|
||||
args[i] = kit.Select(args[i], m.Conf("git", []string{"trans", args[i]}))
|
||||
} else {
|
||||
args[i] = v
|
||||
}
|
||||
}
|
||||
|
||||
m.Cmd("cli.system", "git", args).Echo("\n\n").CopyTo(m)
|
||||
|
@ -61,20 +61,11 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"label": "content", "type": "text", "name": "content"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "pwd", "componet_help": "pwd",
|
||||
"componet_tmpl": "componet", "componet_view": "FlashList", "componet_init": "initFlashList.js",
|
||||
"componet_type": "protected", "componet_ctx": "nfs", "componet_cmd": "pwd",
|
||||
map[string]interface{}{"componet_name": "clip", "componet_help": "粘贴板",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "clip",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "button", "value": "当前", "click": "show"},
|
||||
map[string]interface{}{"type": "button", "value": "所有", "click": "show"},
|
||||
map[string]interface{}{"type": "text", "name": "text"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "dir", "componet_help": "dir",
|
||||
"componet_tmpl": "componet", "componet_view": "FlashList", "componet_init": "initFlashList.js",
|
||||
"componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "dir",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "text"},
|
||||
map[string]interface{}{"label": "content", "type": "text", "name": "content"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -85,6 +76,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "button", "value": "编译"},
|
||||
},
|
||||
"display": map[string]interface{}{"hide_append": true, "show_result": true},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "runtime", "componet_help": "runtime",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
@ -93,60 +85,79 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"type": "button", "value": "运行"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "ifconfig", "componet_help": "ifconfig",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "tcp", "componet_cmd": "ifconfig",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "button", "value": "网卡"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "context", "componet_help": "context",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "ctx", "componet_cmd": "context",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "button", "value": "模块"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "dir", "componet_help": "dir",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "dir",
|
||||
map[string]interface{}{"componet_name": "ifconfig", "componet_help": "ifconfig",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "tcp", "componet_cmd": "ifconfig",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
"exports": []interface{}{"dir", "filename"},
|
||||
"display": map[string]interface{}{
|
||||
"hide_result": true,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "git", "componet_help": "git",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "git",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"},
|
||||
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{"branch", "status", "diff", "push"}},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "git", "componet_help": "git",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "git",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"},
|
||||
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{"branch", "status", "diff", "push"}},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
map[string]interface{}{"type": "button", "value": "网卡"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "pod", "componet_help": "pod",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "remote",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
"exports": []interface{}{"pod", "key"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "cmd", "componet_help": "cmd",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
map[string]interface{}{"componet_name": "dir", "componet_help": "dir",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "dir",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "dir"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
"display": map[string]interface{}{"hide_result": true},
|
||||
"exports": []interface{}{"dir", "filename"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "git", "componet_help": "git",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "git",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "dir", "imports": "plugin_dir"},
|
||||
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{
|
||||
"branch", "status", "diff", "log", "update", "commit", "push",
|
||||
}},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "spide", "componet_help": "spide",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "web", "componet_cmd": "spide",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
"exports": []interface{}{"site", "key"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "get", "componet_help": "get",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "web", "componet_cmd": "get",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "spide", "imports": "plugin_site"},
|
||||
map[string]interface{}{"type": "text", "name": "url"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "post", "componet_help": "post",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "web", "componet_cmd": "post",
|
||||
"componet_args": []interface{}{"content_type", "application/json"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "spide", "imports": "plugin_site"},
|
||||
map[string]interface{}{"type": "text", "name": "url"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
},
|
||||
"company": []interface{}{
|
||||
map[string]interface{}{"componet_name": "status", "componet_help": "status",
|
||||
"componet_tmpl": "componet", "componet_view": "Company", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
|
||||
@ -155,26 +166,18 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "cmd", "componet_help": "cmd",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
map[string]interface{}{"componet_name": "deploy", "componet_help": "deploy",
|
||||
"componet_tmpl": "componet", "componet_view": "Company", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
|
||||
map[string]interface{}{"type": "text", "name": "cmd", "value": "gg"},
|
||||
map[string]interface{}{"type": "select", "name": "sub", "values": []interface{}{"status", "deploygo", ""}},
|
||||
map[string]interface{}{"type": "select", "name": "sub", "values": []interface{}{"deploygo"}},
|
||||
map[string]interface{}{"type": "text", "name": "sub", "imports": "plugin_dir"},
|
||||
map[string]interface{}{"type": "text", "name": "sub", "imports": "plugin_branch"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "web", "componet_help": "web",
|
||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
||||
"componet_type": "private", "componet_ctx": "web", "componet_cmd": "get",
|
||||
"componet_args": []interface{}{"zuo"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "url"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, Help: "组件列表"},
|
||||
},
|
||||
@ -321,7 +324,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
m.Add("append", "name", value["componet_name"])
|
||||
m.Add("append", "help", value["componet_help"])
|
||||
})
|
||||
m.Table()
|
||||
m.Sort("key").Table()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/skip2/go-qrcode"
|
||||
"strconv"
|
||||
// "github.com/PuerkitoBio/goquery"
|
||||
"github.com/go-cas/cas"
|
||||
"html/template"
|
||||
@ -63,7 +64,8 @@ func merge(m *ctx.Message, uri string, arg ...string) string {
|
||||
if value == "" {
|
||||
query.Del(arg[i])
|
||||
} else {
|
||||
query.Set(arg[i], value)
|
||||
// query.Set(arg[i], value)
|
||||
query.Add(arg[i], value)
|
||||
}
|
||||
}
|
||||
add.RawQuery = query.Encode()
|
||||
@ -464,7 +466,13 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
"spide": &ctx.Command{Name: "spide [which [client|cookie [name [value]]]]", Help: "爬虫配置", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
switch len(arg) {
|
||||
case 0:
|
||||
m.Cmdy("ctx.config", "spide")
|
||||
m.Confm("spide", func(key string, value map[string]interface{}) {
|
||||
m.Add("append", "key", key)
|
||||
m.Add("append", "protocol", kit.Chains(value, "client.protocol"))
|
||||
m.Add("append", "hostname", kit.Chains(value, "client.hostname"))
|
||||
m.Add("append", "path", kit.Chains(value, "client.path"))
|
||||
})
|
||||
m.Sort("key").Table()
|
||||
case 1:
|
||||
m.Cmdy("ctx.config", "spide", arg[0])
|
||||
case 2:
|
||||
@ -567,9 +575,19 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
var data interface{}
|
||||
for k, v := range uuu.Query() {
|
||||
if len(v) == 1 {
|
||||
data = kit.Chain(data, k, v[0])
|
||||
if i, e := strconv.Atoi(v[0]); e == nil {
|
||||
data = kit.Chain(data, k, i)
|
||||
} else {
|
||||
data = kit.Chain(data, k, v[0])
|
||||
}
|
||||
} else {
|
||||
data = kit.Chain(data, k, v)
|
||||
for _, val := range v {
|
||||
if i, e := strconv.Atoi(v[0]); e == nil {
|
||||
data = kit.Chain(data, []string{k, "-2"}, i)
|
||||
} else {
|
||||
data = kit.Chain(data, []string{k, "-2"}, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,12 @@ fieldset.Steam div.output tr.select {
|
||||
background-color:red;
|
||||
}
|
||||
fieldset.Steam div.create {
|
||||
clear:both;
|
||||
/* clear:both; */
|
||||
}
|
||||
fieldset.Steam div.create pre:hover {
|
||||
background-color:red;
|
||||
}
|
||||
|
||||
fieldset div.output {
|
||||
clear:both;
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ var page = Page({
|
||||
page.storm.Size(sizes.storm, height)
|
||||
|
||||
sizes.action == undefined && (sizes.action = page.action.clientHeight)
|
||||
sizes.source == undefined && (sizes.source = page.source.clientHeight)
|
||||
sizes.action == -1 && (sizes.action = height, sizes.source = 0)
|
||||
sizes.source == undefined && (sizes.source = page.source.clientHeight);
|
||||
(sizes.action == -1 || sizes.source == 0) && (sizes.action = height, sizes.source = 0)
|
||||
width -= page.river.offsetWidth+page.storm.offsetWidth
|
||||
page.action.Size(width, sizes.action)
|
||||
page.source.Size(width, sizes.source)
|
||||
@ -369,30 +369,42 @@ var page = Page({
|
||||
|
||||
var toggle = true
|
||||
pane.Action = {
|
||||
"恢复": function(event) {
|
||||
"恢复": function(event, value) {
|
||||
page.onlayout(event, page.conf.layout)
|
||||
},
|
||||
"缩小": function(event) {
|
||||
"缩小": function(event, value) {
|
||||
page.onlayout(event, {action:60, source:60})
|
||||
},
|
||||
"放大": function(event) {
|
||||
"放大": function(event, value) {
|
||||
page.onlayout(event, {action:300, source:60})
|
||||
},
|
||||
"最高": function(event) {
|
||||
"最高": function(event, value) {
|
||||
page.onlayout(event, {action: -1})
|
||||
},
|
||||
"最宽": function(event) {
|
||||
"最宽": function(event, value) {
|
||||
page.onlayout(event, {river:0, storm:0})
|
||||
},
|
||||
"最大": function(event) {
|
||||
"最大": function(event, value) {
|
||||
(toggle = !toggle)? page.onlayout(event, page.conf.layout): page.onlayout(event, {river:0, action:-1, source:60})
|
||||
page.target.Stop = !toggle
|
||||
},
|
||||
"全屏": function(event) {
|
||||
"全屏": function(event, value) {
|
||||
page.onlayout(event, {header:0, footer:0, river:0, action: -1, storm:0})
|
||||
},
|
||||
"添加": function(event, value) {
|
||||
page.plugin && page.plugin.Clone()
|
||||
},
|
||||
"删除": function(event, value) {
|
||||
page.plugin && page.plugin.Clear()
|
||||
},
|
||||
"加参": function(event, value) {
|
||||
page.plugin.Append({})
|
||||
},
|
||||
"去参": function(event, value) {
|
||||
page.input && page.plugin.Remove(page.input)
|
||||
},
|
||||
}
|
||||
return {"button": ["恢复", "缩小", "放大", "最高", "最宽", "最大", "全屏"], "action": pane.Action}
|
||||
return {"button": ["恢复", "缩小", "放大", "最高", "最宽", "最大", "全屏", "br", "添加", "删除", "加参", "去参"], "action": pane.Action}
|
||||
},
|
||||
initStorm: function(page, pane, form, output) {
|
||||
var river = "", index = -1
|
||||
@ -568,10 +580,15 @@ var page = Page({
|
||||
if (conf && conf["button"]) {
|
||||
var buttons = []
|
||||
conf.button.forEach(function(value, index) {
|
||||
buttons.push({"button": [value, function(event) {
|
||||
typeof conf["action"] == "function" && conf["action"](value, event)
|
||||
typeof conf["action"] == "object" && conf["action"][value](event)
|
||||
}]})
|
||||
if (value == "br") {
|
||||
buttons.push({type: "br"})
|
||||
} else {
|
||||
buttons.push({"button": [value, function(event) {
|
||||
typeof conf["action"] == "function" && conf["action"](value, event)
|
||||
typeof conf["action"] == "object" && conf["action"][value](event, value)
|
||||
pane.Button = value
|
||||
}]})
|
||||
}
|
||||
})
|
||||
kit.InsertChild(pane, output, "div", buttons).className = "action "+form.dataset.componet_name
|
||||
} else if (conf) {
|
||||
@ -583,13 +600,14 @@ var page = Page({
|
||||
|
||||
page.onlayout(null, page.conf.layout)
|
||||
kit.isMobile && page.action.Action["最宽"]()
|
||||
ctx.Search("layout") && page.action.Action[ctx.Search("layout")]()
|
||||
|
||||
page.footer.Order({"text": "", "ip": ""}, ["ip", "text"])
|
||||
page.footer.Order({"text": "", "ip": "", ".": "", ":":""}, ["ip", "text", ":", "."])
|
||||
kit.isMobile && page.footer.Order({"text": "", "site": "", "ip": ""}, ["ip", "text", "site"])
|
||||
page.header.Order({"user": "", "logout": "logout"}, ["logout", "user"], function(event, item, value) {
|
||||
switch (item) {
|
||||
case "title":
|
||||
ctx.Search({"river": page.river.which.get(), "storm": page.storm.which.get()})
|
||||
ctx.Search({"river": page.river.which.get(), "storm": page.storm.which.get(), "layout": page.action.Button})
|
||||
break
|
||||
case "user":
|
||||
var name = page.prompt("new name")
|
||||
|
@ -6,7 +6,19 @@ ctx = context = {
|
||||
}
|
||||
this.GET("", option, function(msg) {
|
||||
msg = msg && msg[0]
|
||||
msg && (msg.__proto__ = (page || {}))
|
||||
// msg && (msg.__proto__ = (page || {}))
|
||||
msg.Result = msg.result? msg.result.join(""): ""
|
||||
msg.Results = function() {
|
||||
var s = msg.Result
|
||||
s = s.replace(/</g, "<")
|
||||
s = s.replace(/>/g, ">")
|
||||
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\[32m/g, "<span style='color:#0f0'>")
|
||||
s = s.replace(/\033\[31m/g, "<span style='color:#f00'>")
|
||||
s = s.replace(/\033\[m/g, "</span>")
|
||||
return s
|
||||
}
|
||||
typeof cb == "function" && cb(msg || {})
|
||||
})
|
||||
},
|
||||
|
@ -31,6 +31,22 @@ fieldset div.output div.item:hover {
|
||||
fieldset div.output div.item.select {
|
||||
background-color:red;
|
||||
}
|
||||
fieldset div.output div.code {
|
||||
color:white;
|
||||
font-size:14px;
|
||||
font-family:monospace;
|
||||
background-color:#272822;
|
||||
white-space:pre;
|
||||
padding:10px;
|
||||
overflow:auto;
|
||||
border:solid 3px green;
|
||||
}
|
||||
fieldset div.output div.code span.red {
|
||||
color:red;
|
||||
}
|
||||
fieldset div.output div.code span.green {
|
||||
color:green;
|
||||
}
|
||||
|
||||
fieldset.toast {
|
||||
background-color:#ffffff00;
|
||||
|
@ -396,7 +396,7 @@ function Plugin(field, tool, args, plugin) {
|
||||
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value) {
|
||||
page.Sync("plugin_"+exports[0]).set(value)
|
||||
});
|
||||
(display.display_result || !msg.append) && msg.result && kit.AppendChild(output, [{type: "code", list: [{text: [msg.result.join(""), "pre"]}]}])
|
||||
(display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}])
|
||||
})(msg)
|
||||
})
|
||||
}
|
||||
@ -407,12 +407,28 @@ function Plugin(field, tool, args, plugin) {
|
||||
index == total-1 || (index == total-2 && event.target.parentNode.nextSibling.childNodes[1].type == "button")?
|
||||
option.Runs(event): event.target.parentNode.nextSibling.childNodes[1].focus()
|
||||
}
|
||||
field.Clone = option.Clone = function() {
|
||||
page.View(field.parentNode, "plugin", field.Meta, [], option.Run)
|
||||
}
|
||||
field.Clear = option.Clear = function() {
|
||||
field.parentNode && field.parentNode.removeChild(field)
|
||||
}
|
||||
field.Remove = option.Remove = function(who) {
|
||||
who.parentNode && who.parentNode.removeChild(who)
|
||||
}
|
||||
field.Select = option.Select = function(who) {
|
||||
page.plugin = field
|
||||
page.footer.State(".", field.id)
|
||||
}
|
||||
field.Append = option.Append = function(item) {
|
||||
var index = total
|
||||
total += 1
|
||||
|
||||
item.onfocus = function(event) {
|
||||
page.plugin = field
|
||||
page.input = event.target
|
||||
page.footer.State(".", field.id)
|
||||
page.footer.State(":", index)
|
||||
}
|
||||
item.onkeyup = function(event) {
|
||||
page.oninput(event, function(event) {
|
||||
@ -476,6 +492,8 @@ function Plugin(field, tool, args, plugin) {
|
||||
|
||||
var ui = kit.AppendChild(option, [{type: "div", list: [{type: "label", inner: item.label||""}, input]}])
|
||||
|
||||
page.plugin = field
|
||||
page.input = ui[item.name]
|
||||
item.imports && page.Sync(item.imports).change(function(value, old) {
|
||||
ui[item.name].value = value
|
||||
})
|
||||
|
@ -345,69 +345,48 @@ kit = toolkit = {
|
||||
},
|
||||
RangeTable: function(table, index, sort_asc) {
|
||||
var list = table.querySelectorAll("tr")
|
||||
var new_list = []
|
||||
|
||||
var is_time = true
|
||||
var is_number = true
|
||||
var is_time = true, is_number = true
|
||||
for (var i = 1; i < list.length; i++) {
|
||||
var value = Date.parse(list[i].childNodes[index].innerText)
|
||||
var text = list[i].childNodes[index].innerText
|
||||
var value = Date.parse(text)
|
||||
if (!(value > 0)) {
|
||||
is_time = false
|
||||
}
|
||||
|
||||
var value = parseInt(list[i].childNodes[index].innerText)
|
||||
if (!(value >= 0 || value <= 0)) {
|
||||
var value = parseInt(text)
|
||||
if (text != "" && !(value >= 0 || value <= 0)) {
|
||||
is_number = false
|
||||
}
|
||||
|
||||
new_list.push(list[i])
|
||||
}
|
||||
|
||||
var sort_order = ""
|
||||
if (is_time) {
|
||||
if (sort_asc) {
|
||||
method = function(a, b) {return Date.parse(a) > Date.parse(b)}
|
||||
sort_order = "time"
|
||||
var num_list = [], new_list = []
|
||||
for (var i = 1; i < list.length; i++) {
|
||||
var text = list[i].childNodes[index].innerText
|
||||
if (is_time) {
|
||||
num_list.push(Date.parse(text))
|
||||
} else if (is_number) {
|
||||
num_list.push(parseInt(text) || 0)
|
||||
} else {
|
||||
method = function(a, b) {return Date.parse(a) < Date.parse(b)}
|
||||
sort_order = "time_r"
|
||||
}
|
||||
} else if (is_number) {
|
||||
if (sort_asc) {
|
||||
method = function(a, b) {return parseInt(a) > parseInt(b)}
|
||||
sort_order = "int"
|
||||
} else {
|
||||
method = function(a, b) {return parseInt(a) < parseInt(b)}
|
||||
sort_order = "int_r"
|
||||
}
|
||||
} else {
|
||||
if (sort_asc) {
|
||||
method = function(a, b) {return a > b}
|
||||
sort_order = "str"
|
||||
} else {
|
||||
method = function(a, b) {return a < b}
|
||||
sort_order = "str_r"
|
||||
}
|
||||
}
|
||||
|
||||
list = new_list
|
||||
new_list = []
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
list[i].parentElement && list[i].parentElement.removeChild(list[i])
|
||||
for (var j = i+1; j < list.length; j++) {
|
||||
if (typeof method == "function" && method(list[i].childNodes[index].innerText, list[j].childNodes[index].innerText)) {
|
||||
var temp = list[i]
|
||||
list[i] = list[j]
|
||||
list[j] = temp
|
||||
}
|
||||
num_list.push(text)
|
||||
}
|
||||
new_list.push(list[i])
|
||||
}
|
||||
|
||||
for (var i = 0; i < new_list.length; i++) {
|
||||
for (var j = i+1; j < new_list.length; j++) {
|
||||
if (sort_asc? num_list[i] < num_list[j]: num_list[i] > num_list[j]) {
|
||||
var temp = num_list[i]
|
||||
num_list[i] = num_list[j]
|
||||
num_list[j] = temp
|
||||
var temp = new_list[i]
|
||||
new_list[i] = new_list[j]
|
||||
new_list[j] = temp
|
||||
}
|
||||
}
|
||||
new_list[i].parentElement && new_list[i].parentElement.removeChild(new_list[i])
|
||||
table.appendChild(new_list[i])
|
||||
}
|
||||
return sort_order
|
||||
},
|
||||
OrderTable: function(table, field, cb) {
|
||||
if (!table) {return}
|
||||
@ -584,11 +563,18 @@ kit = toolkit = {
|
||||
obj.querySelectorAll(item).forEach(function(item, index) {
|
||||
if (typeof cb == "function") {
|
||||
var value = cb(item)
|
||||
value && list.push(value)
|
||||
value != undefined && list.push(value)
|
||||
} else {
|
||||
list.push(item)
|
||||
}
|
||||
})
|
||||
for (var i = list.length-1; i >= 0; i--) {
|
||||
if (list[i] == "") {
|
||||
list.pop()
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return list
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user