1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-06-27 02:17:31 +08:00

vps add aaa.lark

This commit is contained in:
shylinux 2018-08-19 09:18:49 +08:00
parent 2a7c0dfe65
commit 6b93a52249
6 changed files with 179 additions and 40 deletions

View File

@ -38,6 +38,7 @@ type AAA struct {
encrypt cipher.BlockMode encrypt cipher.BlockMode
decrypt cipher.BlockMode decrypt cipher.BlockMode
lark chan *ctx.Message
sessions map[string]*ctx.Message sessions map[string]*ctx.Message
*ctx.Context *ctx.Context
} }
@ -72,7 +73,9 @@ func (aaa *AAA) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server
"sessid": &ctx.Cache{Name: "sessid", Value: arg[2], Help: "会话令牌"}, "sessid": &ctx.Cache{Name: "sessid", Value: arg[2], Help: "会话令牌"},
"expire": &ctx.Cache{Name: "expire", Value: fmt.Sprintf("%d", int64(m.Confi("expire"))+time.Now().Unix()), Help: "会话超时"}, "expire": &ctx.Cache{Name: "expire", Value: fmt.Sprintf("%d", int64(m.Confi("expire"))+time.Now().Unix()), Help: "会话超时"},
} }
c.Configs = map[string]*ctx.Config{} c.Configs = map[string]*ctx.Config{
"lark": &ctx.Config{Name: "lark", Value: []interface{}{}, Help: "用户密码,加密存储"},
}
s := new(AAA) s := new(AAA)
s.Context = c s.Context = c
@ -102,6 +105,24 @@ func (aaa *AAA) Begin(m *ctx.Message, arg ...string) ctx.Server { // {{{
func (aaa *AAA) Start(m *ctx.Message, arg ...string) bool { // {{{ func (aaa *AAA) Start(m *ctx.Message, arg ...string) bool { // {{{
aaa.sessions[m.Cap("sessid")] = m aaa.sessions[m.Cap("sessid")] = m
m.Log("info", "%d login %s", m.Capi("nuser", 1), m.Cap("stream", arg[0])) m.Log("info", "%d login %s", m.Capi("nuser", 1), m.Cap("stream", arg[0]))
if arg[0] == "lark" {
aaa.lark = make(chan *ctx.Message)
for {
msg := <-aaa.lark
m.Log("lark", "%v", msg.Meta["detail"])
m.Travel(func(m *ctx.Message, n int) bool {
if m.Cap("username") == msg.Detail(1) {
m.Confv("lark", -2, map[string]interface{}{
"from": msg.Option("username"),
"time": msg.Time(),
"text": msg.Detail(2)})
}
return true
})
}
return true
}
return false return false
} }
@ -633,6 +654,37 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心",
} }
// }}} // }}}
}}, }},
"lark": &ctx.Command{Name: "lark who message", Help: "散列",
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
if aaa, ok := c.Server.(*AAA); m.Assert(ok) && aaa.lark != nil { // {{{
switch len(arg) {
case 0:
m.Travel(func(m *ctx.Message, n int) bool {
if n > 0 {
m.Add("append", "user", m.Cap("username"))
}
return true
}, c)
case 1:
m.Travel(func(m *ctx.Message, n int) bool {
if m.Cap("username") == arg[0] {
for _, v := range m.Confv("lark").([]interface{}) {
lark := v.(map[string]interface{})
m.Add("append", "time", lark["time"])
m.Add("append", "from", lark["from"])
m.Add("append", "text", lark["text"])
}
return false
}
return true
}, c)
case 2:
aaa.lark <- m
m.Echo("%s send done", m.Time())
}
}
// }}}
}},
}, },
} }

View File

@ -195,6 +195,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
}, },
Configs: map[string]*ctx.Config{ Configs: map[string]*ctx.Config{
"init.shy": &ctx.Config{Name: "init.shy", Value: "etc/init.shy", Help: "启动脚本"}, "init.shy": &ctx.Config{Name: "init.shy", Value: "etc/init.shy", Help: "启动脚本"},
"exit.shy": &ctx.Config{Name: "exit.shy", Value: "etc/exit.shy", Help: "启动脚本"},
"cli_name": &ctx.Config{Name: "cli_name", Value: "shell", Help: "模块命名", Hand: func(m *ctx.Message, x *ctx.Config, arg ...string) string { "cli_name": &ctx.Config{Name: "cli_name", Value: "shell", Help: "模块命名", Hand: func(m *ctx.Message, x *ctx.Config, arg ...string) string {
if len(arg) > 0 { // {{{ if len(arg) > 0 { // {{{
return arg[0] return arg[0]
@ -227,6 +228,10 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
m.Start(m.Confx("cli_name", arg, 2), m.Confx("cli_help", arg, 3), key, arg[0]) m.Start(m.Confx("cli_name", arg, 2), m.Confx("cli_help", arg, 3), key, arg[0])
if len(arg) < 2 || arg[1] != "async" { if len(arg) < 2 || arg[1] != "async" {
m.Wait() m.Wait()
m.Target().Close(m)
if arg[0] == "stdio" {
m.Spawn().Cmd("source", m.Conf("exit.shy"))
}
} }
}}, }},
"label": &ctx.Command{Name: "label name", Help: "记录当前脚本的位置, name: 位置名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { "label": &ctx.Command{Name: "label name", Help: "记录当前脚本的位置, name: 位置名", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
@ -331,9 +336,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
} }
if len(arg) > 0 { if len(arg) > 0 {
if i, e := strconv.Atoi(arg[0]); e == nil { if i, e := strconv.ParseInt(arg[0], 10, 64); e == nil {
m.Option("time_format", m.Conf("time_format")) m.Option("time_format", m.Conf("time_format"))
t = time.Unix(int64(i/m.Confi("time_unit")), 0) t = time.Unix(int64(i/int64(m.Confi("time_unit"))), 0)
arg = arg[1:] arg = arg[1:]
} else if n, e := time.ParseInLocation(m.Confx("time_format"), arg[0], time.Local); e == nil { } else if n, e := time.ParseInLocation(m.Confx("time_format"), arg[0], time.Local); e == nil {
m.Option("parse", arg[0]) m.Option("parse", arg[0])

View File

@ -73,7 +73,7 @@ func Trans(arg ...interface{}) []string { // {{{
} }
// }}} // }}}
func Chain(data interface{}, args ...interface{}) interface{} { // {{{ func Chain(m *Message, data interface{}, args ...interface{}) interface{} { // {{{
if len(args) == 1 { if len(args) == 1 {
if arg, ok := args[0].([]string); ok { if arg, ok := args[0].([]string); ok {
args = args[:0] args = args[:0]
@ -87,7 +87,7 @@ func Chain(data interface{}, args ...interface{}) interface{} { // {{{
for i := 0; i < len(args); i += 2 { for i := 0; i < len(args); i += 2 {
var parent interface{} var parent interface{}
parent_key, parent_index := "", 0 parent_key, parent_index := "", 0
data = root data, root = root, nil
keys := []string{} keys := []string{}
switch arg := args[i].(type) { switch arg := args[i].(type) {
@ -200,8 +200,7 @@ func Chain(data interface{}, args ...interface{}) interface{} { // {{{
value[index] = args[i+1] value[index] = args[i+1]
} }
} }
parent, data, parent_index = value, value[index], index
parent, data, parent_index = data, value[index], index
} }
if root == nil { if root == nil {
@ -330,7 +329,7 @@ func (c *Context) Begin(m *Message, arg ...string) *Context { // {{{
// }}} // }}}
func (c *Context) Start(m *Message, arg ...string) bool { // {{{ func (c *Context) Start(m *Message, arg ...string) bool { // {{{
if len(arg) > 0 { if len(arg) > 0 {
m.Meta["detail"] = arg m.Set("detail", arg...)
} }
c.requests = append(c.requests, m) c.requests = append(c.requests, m)
@ -459,6 +458,11 @@ func (m *Message) Code() int { // {{{
return m.code return m.code
} }
// }}}
func (m *Message) Time() string { // {{{
return m.time.Format("2006-01-02 15:04:05")
}
// }}} // }}}
func (m *Message) Message() *Message { // {{{ func (m *Message) Message() *Message { // {{{
return m.message return m.message
@ -1607,7 +1611,7 @@ func (m *Message) Confv(key string, args ...interface{}) interface{} { // {{{
switch x.Value.(type) { switch x.Value.(type) {
case string: case string:
x.Value = fmt.Sprintf("%v", args[0]) x.Value = fmt.Sprintf("%v", arg[0])
case bool: case bool:
x.Value = Right(fmt.Sprintf("%v", args[0])) x.Value = Right(fmt.Sprintf("%v", args[0]))
case int: case int:
@ -1619,13 +1623,13 @@ func (m *Message) Confv(key string, args ...interface{}) interface{} { // {{{
default: default:
for i := 0; i < len(args); i += 2 { for i := 0; i < len(args); i += 2 {
if i < len(args)-1 { if i < len(args)-1 {
x.Value = Chain(x.Value, args[i], args[i+1]) x.Value = Chain(m, x.Value, args[i], args[i+1])
} }
if i == len(args)-2 { if i == len(args)-2 {
return Chain(x.Value, args[len(args)-2]) return Chain(m, x.Value, args[len(args)-2])
} }
if i == len(args)-1 { if i == len(args)-1 {
return Chain(x.Value, args[len(args)-1]) return Chain(m, x.Value, args[len(args)-1])
} }
} }
} }
@ -1653,8 +1657,8 @@ func (m *Message) Confv(key string, args ...interface{}) interface{} { // {{{
m.target.Configs[key] = &Config{Name: key, Value: arg[0], Help: "auto make", Hand: hand} m.target.Configs[key] = &Config{Name: key, Value: arg[0], Help: "auto make", Hand: hand}
return m.Conf(key, arg[0]) return m.Conf(key, arg[0])
} }
m.target.Configs[key] = &Config{Name: key, Value: Chain(nil, args), Help: "auto make", Hand: hand} m.target.Configs[key] = &Config{Name: key, Value: Chain(m, nil, args), Help: "auto make", Hand: hand}
return Chain(key, args[len(args)-2+(len(args)%2)]) return Chain(m, key, args[len(args)-2+(len(args)%2)])
} }
// }}} // }}}
@ -1701,10 +1705,10 @@ func (m *Message) Conf(key string, args ...interface{}) string { // {{{
values := "" values := ""
for i := 0; i < len(args); i += 2 { for i := 0; i < len(args); i += 2 {
if i < len(args)-1 { if i < len(args)-1 {
x.Value = Chain(x.Value, args[i], args[i+1]) x.Value = Chain(m, x.Value, args[i], args[i+1])
} }
if val := Chain(x.Value, args[i]); val != nil { if val := Chain(m, x.Value, args[i]); val != nil {
values = fmt.Sprintf("%v", val) values = fmt.Sprintf("%v", val)
} }
} }
@ -1739,10 +1743,10 @@ func (m *Message) Conf(key string, args ...interface{}) string { // {{{
var value interface{} var value interface{}
for i := 0; i < len(args)-1; i += 2 { for i := 0; i < len(args)-1; i += 2 {
value = Chain(value, args[i], args[i+1]) value = Chain(m, value, args[i], args[i+1])
} }
m.target.Configs[key] = &Config{Name: key, Value: value, Help: "auto make", Hand: hand} m.target.Configs[key] = &Config{Name: key, Value: value, Help: "auto make", Hand: hand}
if val := Chain(key, args[len(args)-2]); val != nil { if val := Chain(m, key, args[len(args)-2]); val != nil {
return fmt.Sprintf("%v", val) return fmt.Sprintf("%v", val)
} }
} }
@ -2208,6 +2212,25 @@ var CGI = template.FuncMap{
"unscaped": func(str string) interface{} { // {{{ "unscaped": func(str string) interface{} { // {{{
return template.HTML(str) return template.HTML(str)
}, // }}} }, // }}}
"list": func(arg interface{}) interface{} { // {{{
n := 0
switch v := arg.(type) {
case string:
i, e := strconv.Atoi(v)
if e == nil {
n = i
}
case int:
n = v
}
list := make([]int, n)
for i := 0; i < n; i++ {
list[i] = i
}
return list
}, // }}}
} }
var Pulse = &Message{code: 0, time: time.Now(), source: Index, target: Index, Meta: map[string][]string{}} var Pulse = &Message{code: 0, time: time.Now(), source: Index, target: Index, Meta: map[string][]string{}}
@ -3017,6 +3040,11 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
for _, v := range arg { for _, v := range arg {
have[v] = true have[v] = true
} }
case "export":
action, arg = arg[0], arg[1:]
for _, v := range arg {
have[v] = true
}
} }
} }
@ -3034,7 +3062,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
m.BackTrace(func(m *Message) bool { m.BackTrace(func(m *Message) bool {
for k, v := range m.target.Configs { for k, v := range m.target.Configs {
switch action { switch action {
case "save": case "save", "export":
if len(have) == 0 || have[k] { if len(have) == 0 || have[k] {
save[k] = v.Value save[k] = v.Value
} }
@ -3113,7 +3141,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
m.Echo(m.Conf(arg[0])) m.Echo(m.Conf(arg[0]))
} }
default: default:
m.Echo(m.Conf(arg[0], arg[1:])) m.Echo("%v", m.Confv(arg[0], arg[1:]))
return false return false
} }
} }
@ -3121,7 +3149,8 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
return all return all
}).Sort("key", sort).Table() }).Sort("key", sort).Table()
if action == "save" { switch action {
case "save":
f, e := os.Create(which) f, e := os.Create(which)
m.Assert(e) m.Assert(e)
defer f.Close() defer f.Close()
@ -3129,6 +3158,10 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
buf, e := json.MarshalIndent(save, "", " ") buf, e := json.MarshalIndent(save, "", " ")
m.Assert(e) m.Assert(e)
f.Write(buf) f.Write(buf)
case "export":
buf, e := json.MarshalIndent(save, "", " ")
m.Assert(e)
m.Echo("%s", string(buf))
} }
// }}} // }}}
}}, }},
@ -3385,7 +3418,6 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
m.Add("append", "value", "") m.Add("append", "value", "")
for a, s := range c.Shares { for a, s := range c.Shares {
for _, v := range s { for _, v := range s {
m.Log("fuck", "fuck %v %v %v %v", friend, command, a, v)
m.Add("append", "friend", friend) m.Add("append", "friend", friend)
m.Add("append", "key", command) m.Add("append", "key", command)
m.Add("append", "arg", a) m.Add("append", "arg", a)
@ -3430,7 +3462,9 @@ func Start(args ...string) {
Pulse.Options("log", true) Pulse.Options("log", true)
log := Pulse.Sess("log", false) log := Pulse.Sess("log", false)
log.target.Start(log) log.target.Start(log)
aaa := Pulse.Sess("aaa", false)
aaa.target.Start(aaa, "lark")
Pulse.Options("terminal_color", true) Pulse.Options("terminal_color", true)
Pulse.Sess("cli", false).Cmd("source", "stdio").Wait() Pulse.Sess("cli", false).Cmd("source", "stdio")
} }

View File

@ -391,6 +391,12 @@ func (nfs *NFS) Read(p []byte) (n int, err error) { // {{{
switch ev.Key { switch ev.Key {
case termbox.KeyCtrlC: case termbox.KeyCtrlC:
termbox.Close() termbox.Close()
nfs.out = nil
b := []byte("return\n")
n = len(b)
copy(p, b)
return
os.Exit(1) os.Exit(1)
case termbox.KeyCtrlV: case termbox.KeyCtrlV:

View File

@ -139,7 +139,11 @@ func (web *WEB) ServeHTTP(w http.ResponseWriter, r *http.Request) { // {{{
m.Log("info", "") m.Log("info", "")
} }
web.ServeMux.ServeHTTP(w, r) if r.URL.Path == "/" && m.Confs("root_index") {
http.Redirect(w, r, "/index/", http.StatusFound)
} else {
web.ServeMux.ServeHTTP(w, r)
}
if m.Confs("logheaders") { if m.Confs("logheaders") {
for k, v := range w.Header() { for k, v := range w.Header() {
@ -273,8 +277,10 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
"nroute": &ctx.Cache{Name: "nroute", Value: "0", Help: "路由数量"}, "nroute": &ctx.Cache{Name: "nroute", Value: "0", Help: "路由数量"},
}, },
Configs: map[string]*ctx.Config{ Configs: map[string]*ctx.Config{
"cmd": &ctx.Config{Name: "cmd", Value: "tmux", Help: "路由数量"}, "cmd": &ctx.Config{Name: "cmd", Value: "tmux", Help: "路由数量"},
"check_right": &ctx.Config{Name: "check_right(true/false)", Value: "false", Help: "路由数量"}, "cert": &ctx.Config{Name: "cert", Value: "etc/cert.pem", Help: "路由数量"},
"key": &ctx.Config{Name: "key", Value: "etc/key.pem", Help: "路由数量"},
"root_index": &ctx.Config{Name: "root_index(true/false)", Value: "true", Help: "路由数量"},
"check": &ctx.Config{Name: "check", Value: map[string]interface{}{ "check": &ctx.Config{Name: "check", Value: map[string]interface{}{
"login": []interface{}{ "login": []interface{}{
map[string]interface{}{ map[string]interface{}{
@ -303,10 +309,40 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
}, },
}, Help: "执行条件"}, }, Help: "执行条件"},
"index": &ctx.Config{Name: "index", Value: map[string]interface{}{ "index": &ctx.Config{Name: "index", Value: map[string]interface{}{
"duyu": []interface{}{
map[string]interface{}{
"template": "userinfo", "title": "userinfo",
},
map[string]interface{}{
"module": "aaa", "detail": []interface{}{"lark"},
"template": "detail", "title": "send_lark",
"option": map[string]interface{}{"ninput": 2},
},
map[string]interface{}{
"module": "aaa", "command": "lark",
"argument": []interface{}{"duyu"},
"template": "append", "title": "lark",
},
},
"shy": []interface{}{ "shy": []interface{}{
map[string]interface{}{ map[string]interface{}{
"template": "userinfo", "title": "userinfo", "template": "userinfo", "title": "userinfo",
}, },
map[string]interface{}{
"module": "aaa", "command": "lark",
"argument": []interface{}{},
"template": "append", "title": "lark_friend",
},
map[string]interface{}{
"module": "aaa", "command": "lark",
"argument": []interface{}{"shy"},
"template": "append", "title": "lark",
},
map[string]interface{}{
"module": "aaa", "detail": []interface{}{"lark"},
"template": "detail", "title": "send_lark",
"option": map[string]interface{}{"ninput": 2},
},
map[string]interface{}{ map[string]interface{}{
"module": "web", "command": "/share", "module": "web", "command": "/share",
"argument": []interface{}{}, "argument": []interface{}{},
@ -350,10 +386,12 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
map[string]interface{}{ map[string]interface{}{
"module": "cli", "detail": []interface{}{"time"}, "module": "cli", "detail": []interface{}{"time"},
"template": "detail", "title": "time", "template": "detail", "title": "time",
"option": map[string]interface{}{"ninput": 1},
}, },
map[string]interface{}{ map[string]interface{}{
"module": "nfs", "detail": []interface{}{"json"}, "module": "nfs", "detail": []interface{}{"json"},
"template": "detail", "title": "json", "template": "detail", "title": "json",
"option": map[string]interface{}{"ninput": 1},
}, },
}, },
"xujianing": []interface{}{ "xujianing": []interface{}{
@ -662,6 +700,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
m.Copy(check, "append") m.Copy(check, "append")
return return
} }
m.Option("username", m.Append("username"))
//执行命令 //执行命令
if m.Has("details") { if m.Has("details") {
@ -689,7 +728,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
//浏览目录 //浏览目录
m.Append("template", m.Append("username")) m.Append("template", m.Append("username"))
m.Option("title", "index") m.Option("title", "index")
m.Option("username", m.Append("username"))
// }}} // }}}
}}, }},
"/travel": &ctx.Command{Name: "/travel", Help: "文件上传", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { "/travel": &ctx.Command{Name: "/travel", Help: "文件上传", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
@ -1019,6 +1057,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
"/render": &ctx.Command{Name: "/render index", Help: "模板响应, main: 模板入口, tmpl: 附加模板", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { "/render": &ctx.Command{Name: "/render index", Help: "模板响应, main: 模板入口, tmpl: 附加模板", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
w := m.Optionv("response").(http.ResponseWriter) // {{{ w := m.Optionv("response").(http.ResponseWriter) // {{{
w.Header().Add("Content-Type", "text/html") w.Header().Add("Content-Type", "text/html")
m.Optioni("ninput", 0)
tpl := template.New("render").Funcs(ctx.CGI) tpl := template.New("render").Funcs(ctx.CGI)
tpl = template.Must(tpl.ParseGlob(path.Join(m.Conf("template_dir"), m.Conf("common_tmpl")))) tpl = template.Must(tpl.ParseGlob(path.Join(m.Conf("template_dir"), m.Conf("common_tmpl"))))
@ -1038,6 +1077,12 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
msg := m.Spawn().Add("detail", detail[0].(string), detail[1:]) msg := m.Spawn().Add("detail", detail[0].(string), detail[1:])
msg.Option("module", val["module"]) msg.Option("module", val["module"])
msg.Option("title", val["title"]) msg.Option("title", val["title"])
if option, ok := val["option"].(map[string]interface{}); ok {
for k, v := range option {
msg.Option(k, v)
}
}
m.Assert(tpl.ExecuteTemplate(w, val["template"].(string), msg)) m.Assert(tpl.ExecuteTemplate(w, val["template"].(string), msg))
continue continue
} }
@ -1114,14 +1159,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
m.Spawn().Cmd("open", url) m.Spawn().Cmd("open", url)
} }
}}, }},
"add_income": &ctx.Command{Name: "add_income", Help: "浏览器网页", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
// for _, uid := range []string{"98010402293", "96287507642", "98896063791", "98683626189", "95780886494", "95780886494", "98629824072"} {
for _, uid := range []string{"97661734361"} {
for t := 1530777074000; t < 1533268176000; t += 172800000 {
m.Spawn().Cmd("5", "teacher_uid", uid, "valid_time", t, "description_public", "hello")
}
}
}},
}, },
} }

View File

@ -39,9 +39,12 @@
{{define "detail"}} {{define "detail"}}
{{$key := append . "title"|meta}} {{$key := append . "title"|meta}}
{{$msg := .}}
<fieldset><legend>{{append . "title"|meta}}</legend> <fieldset><legend>{{append . "title"|meta}}</legend>
<input type="text" class="{{$key}}_input" value="" onkeyup="return input(event, '{{option .Meta "module"}}', '{{detail .Meta}}', '{{$key}}_input', '{{$key}}_result')"></input> {{range option . "ninput"|meta|list}}
<a onclick="return action(event, '{{option .Meta "module"}}', '{{detail .Meta}}', '{{$key}}_input', '{{$key}}_result')" href="/">{{template "code" detail .Meta}}</a> <input type="text" class="{{$key}}_input" value="" onkeyup="return input(event, '{{option $msg.Meta "module"}}', ['{{detail $msg.Meta}}'], '{{$key}}_input', '{{$key}}_result')"></input>
{{end}}
<a onclick="return action(event, '{{option .Meta "module"}}', ['{{detail .Meta}}'], '{{$key}}_input', '{{$key}}_result')" href="/">{{template "code" detail .Meta}}</a>
<pre><code class="{{$key}}_result"></code></pre> <pre><code class="{{$key}}_result"></code></pre>
</fieldset> </fieldset>
<script> <script>
@ -51,9 +54,11 @@ function input(event, module, details, input, results) {
} }
} }
function action(event, module, details, input, results) { function action(event, module, details, input, results) {
var input = document.getElementsByClassName(input)[0]; var input = document.getElementsByClassName(input);
if (input.value != "") { for (var i = 0; i < input.length; i++ ){
details = [details, input.value]; if (input[i].value != "") {
details.push(input[i].value)
}
} }
ctx.POST("", {module:module, details:details}, function(msg) { ctx.POST("", {module:module, details:details}, function(msg) {
var result = document.getElementsByClassName(results)[0]; var result = document.getElementsByClassName(results)[0];