mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
tce opt web.share
This commit is contained in:
parent
100d49f1b2
commit
8f125bbd3a
@ -74,7 +74,7 @@ func (aaa *AAA) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server
|
|||||||
"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: "用户密码,加密存储"},
|
"lark": &ctx.Config{Name: "lark", Value: map[string]interface{}{}, Help: "用户密码,加密存储"},
|
||||||
}
|
}
|
||||||
|
|
||||||
s := new(AAA)
|
s := new(AAA)
|
||||||
@ -110,13 +110,12 @@ func (aaa *AAA) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
msg := <-aaa.lark
|
msg := <-aaa.lark
|
||||||
|
from := msg.Option("username")
|
||||||
m.Log("lark", "%v", msg.Meta["detail"])
|
m.Log("lark", "%v", msg.Meta["detail"])
|
||||||
m.Travel(func(m *ctx.Message, n int) bool {
|
m.Travel(func(m *ctx.Message, n int) bool {
|
||||||
if m.Cap("username") == msg.Detail(1) {
|
if m.Cap("username") == msg.Detail(1) {
|
||||||
m.Confv("lark", -2, map[string]interface{}{
|
m.Confv("lark", strings.Join([]string{from, "-2"}, "."),
|
||||||
"from": msg.Option("username"),
|
map[string]interface{}{"time": msg.Time(), "type": "recv", "text": msg.Detail(2)})
|
||||||
"time": msg.Time(),
|
|
||||||
"text": msg.Detail(2)})
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -657,31 +656,38 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心",
|
|||||||
"lark": &ctx.Command{Name: "lark who message", Help: "散列",
|
"lark": &ctx.Command{Name: "lark who message", Help: "散列",
|
||||||
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
if aaa, ok := c.Server.(*AAA); m.Assert(ok) && aaa.lark != nil { // {{{
|
if aaa, ok := c.Server.(*AAA); m.Assert(ok) && aaa.lark != nil { // {{{
|
||||||
switch len(arg) {
|
m.Travel(func(m *ctx.Message, n int) bool {
|
||||||
case 0:
|
if n == 0 {
|
||||||
m.Travel(func(m *ctx.Message, n int) bool {
|
|
||||||
if n > 0 {
|
|
||||||
m.Add("append", "user", m.Cap("username"))
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}, c)
|
}
|
||||||
case 1:
|
if m.Cap("username") == m.Option("username") {
|
||||||
m.Travel(func(m *ctx.Message, n int) bool {
|
switch len(arg) {
|
||||||
if m.Cap("username") == arg[0] {
|
case 0:
|
||||||
for _, v := range m.Confv("lark").([]interface{}) {
|
for k, v := range m.Confv("lark").(map[string]interface{}) {
|
||||||
lark := v.(map[string]interface{})
|
for _, x := range v.([]interface{}) {
|
||||||
m.Add("append", "time", lark["time"])
|
val := x.(map[string]interface{})
|
||||||
m.Add("append", "from", lark["from"])
|
m.Add("append", "friend", k)
|
||||||
m.Add("append", "text", lark["text"])
|
m.Add("append", "time", val["time"])
|
||||||
|
m.Add("append", "type", val["type"])
|
||||||
|
m.Add("append", "text", val["text"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
case 1:
|
||||||
|
for _, v := range m.Confv("lark", arg[0]).([]interface{}) {
|
||||||
|
val := v.(map[string]interface{})
|
||||||
|
m.Add("append", "time", val["time"])
|
||||||
|
m.Add("append", "text", val["text"])
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
m.Confv("lark", strings.Join([]string{arg[0], "-2"}, "."),
|
||||||
|
map[string]interface{}{"time": m.Time(), "type": "send", "text": arg[1]})
|
||||||
|
aaa.lark <- m
|
||||||
|
m.Echo("%s send done", m.Time())
|
||||||
}
|
}
|
||||||
return true
|
return false
|
||||||
}, c)
|
}
|
||||||
case 2:
|
return true
|
||||||
aaa.lark <- m
|
})
|
||||||
m.Echo("%s send done", m.Time())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
|
@ -200,6 +200,12 @@ func Chain(m *Message, data interface{}, args ...interface{}) interface{} { // {
|
|||||||
value[index] = args[i+1]
|
value[index] = args[i+1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch p := parent.(type) {
|
||||||
|
case map[string]interface{}:
|
||||||
|
p[parent_key] = value
|
||||||
|
case []interface{}:
|
||||||
|
p[parent_index] = value
|
||||||
|
}
|
||||||
parent, data, parent_index = value, value[index], index
|
parent, data, parent_index = value, value[index], index
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1622,9 +1628,11 @@ func (m *Message) Confv(key string, args ...interface{}) interface{} { // {{{
|
|||||||
x.Value = args[0]
|
x.Value = args[0]
|
||||||
default:
|
default:
|
||||||
for i := 0; i < len(args); i += 2 {
|
for i := 0; i < len(args); i += 2 {
|
||||||
|
m.Log("fuck", "b %v", x.Value)
|
||||||
if i < len(args)-1 {
|
if i < len(args)-1 {
|
||||||
x.Value = Chain(m, x.Value, args[i], args[i+1])
|
x.Value = Chain(m, x.Value, args[i], args[i+1])
|
||||||
}
|
}
|
||||||
|
m.Log("fuck", "b %v", x.Value)
|
||||||
if i == len(args)-2 {
|
if i == len(args)-2 {
|
||||||
return Chain(m, x.Value, args[len(args)-2])
|
return Chain(m, x.Value, args[len(args)-2])
|
||||||
}
|
}
|
||||||
|
@ -277,10 +277,11 @@ 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: "路由数量"},
|
||||||
"cert": &ctx.Config{Name: "cert", Value: "etc/cert.pem", Help: "路由数量"},
|
"cert": &ctx.Config{Name: "cert", Value: "etc/cert.pem", Help: "路由数量"},
|
||||||
"key": &ctx.Config{Name: "key", Value: "etc/key.pem", Help: "路由数量"},
|
"key": &ctx.Config{Name: "key", Value: "etc/key.pem", Help: "路由数量"},
|
||||||
"root_index": &ctx.Config{Name: "root_index(true/false)", Value: "true", Help: "路由数量"},
|
"root_index": &ctx.Config{Name: "root_index(true/false)", Value: "true", Help: "路由数量"},
|
||||||
|
"auto_create": &ctx.Config{Name: "auto_create(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{}{
|
||||||
@ -313,6 +314,12 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"template": "userinfo", "title": "userinfo",
|
"template": "userinfo", "title": "userinfo",
|
||||||
},
|
},
|
||||||
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
|
"module": "aaa", "command": "lark",
|
||||||
|
"argument": []interface{}{},
|
||||||
|
"template": "append", "title": "lark_friend",
|
||||||
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"module": "aaa", "detail": []interface{}{"lark"},
|
"module": "aaa", "detail": []interface{}{"lark"},
|
||||||
"template": "detail", "title": "send_lark",
|
"template": "detail", "title": "send_lark",
|
||||||
@ -328,82 +335,81 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
"argument": []interface{}{"dir_type", "all", "dir_deep", "false", "dir_field", "time size line filename", "sort_field", "time", "sort_order", "time_r"},
|
"argument": []interface{}{"dir_type", "all", "dir_deep", "false", "dir_field", "time size line filename", "sort_field", "time", "sort_order", "time_r"},
|
||||||
"template": "append", "title": "",
|
"template": "append", "title": "",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
|
||||||
"template": "upload", "title": "upload",
|
|
||||||
},
|
|
||||||
map[string]interface{}{
|
|
||||||
"template": "create", "title": "create",
|
|
||||||
},
|
|
||||||
map[string]interface{}{
|
|
||||||
"module": "nfs", "detail": []interface{}{"pwd"},
|
|
||||||
"template": "detail", "title": "pwd",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"shy": []interface{}{
|
"shy": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{"duyu", "haojie"},
|
||||||
"template": "userinfo", "title": "userinfo",
|
"template": "userinfo", "title": "userinfo",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "aaa", "command": "lark",
|
"module": "aaa", "command": "lark",
|
||||||
"argument": []interface{}{},
|
"argument": []interface{}{},
|
||||||
"template": "append", "title": "lark_friend",
|
"template": "append", "title": "lark_friend",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"module": "aaa", "command": "lark",
|
"from": "root", "to": []interface{}{},
|
||||||
"argument": []interface{}{"shy"},
|
|
||||||
"template": "append", "title": "lark",
|
|
||||||
},
|
|
||||||
map[string]interface{}{
|
|
||||||
"module": "aaa", "detail": []interface{}{"lark"},
|
"module": "aaa", "detail": []interface{}{"lark"},
|
||||||
"template": "detail", "title": "send_lark",
|
"template": "detail", "title": "send_lark",
|
||||||
"option": map[string]interface{}{"ninput": 2},
|
"option": map[string]interface{}{"ninput": 2},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "web", "command": "/share",
|
"module": "web", "command": "/share",
|
||||||
"argument": []interface{}{},
|
"argument": []interface{}{},
|
||||||
"template": "share", "title": "share",
|
"template": "share", "title": "share",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "cli", "command": "system",
|
"module": "cli", "command": "system",
|
||||||
"argument": []interface{}{"tmux", "list-clients"},
|
"argument": []interface{}{"tmux", "list-clients"},
|
||||||
"template": "result", "title": "client",
|
"template": "result", "title": "client",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "cli", "command": "system",
|
"module": "cli", "command": "system",
|
||||||
"argument": []interface{}{"tmux", "list-sessions"},
|
"argument": []interface{}{"tmux", "list-sessions"},
|
||||||
"template": "result", "title": "session",
|
"template": "result", "title": "session",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "cli", "command": "system",
|
"module": "cli", "command": "system",
|
||||||
"argument": []interface{}{"tmux", "show-buffer"},
|
"argument": []interface{}{"tmux", "show-buffer"},
|
||||||
"template": "result", "title": "buffer",
|
"template": "result", "title": "buffer",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "nfs", "command": "git",
|
"module": "nfs", "command": "git",
|
||||||
"argument": []interface{}{},
|
"argument": []interface{}{},
|
||||||
"template": "result", "title": "git",
|
"template": "result", "title": "git",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "nfs", "command": "dir",
|
"module": "nfs", "command": "dir",
|
||||||
"argument": []interface{}{"dir_type", "all", "dir_deep", "false", "dir_field", "time size line filename", "sort_field", "time", "sort_order", "time_r"},
|
"argument": []interface{}{"dir_type", "all", "dir_deep", "false", "dir_field", "time size line filename", "sort_field", "time", "sort_order", "time_r"},
|
||||||
"template": "append", "title": "",
|
"template": "append", "title": "",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"template": "upload", "title": "upload",
|
"template": "upload", "title": "upload",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"template": "create", "title": "create",
|
"template": "create", "title": "create",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []interface{}{},
|
||||||
"module": "nfs", "detail": []interface{}{"pwd"},
|
"module": "nfs", "detail": []interface{}{"pwd"},
|
||||||
"template": "detail", "title": "pwd",
|
"template": "detail", "title": "pwd",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []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},
|
"option": map[string]interface{}{"ninput": 1},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
"from": "root", "to": []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},
|
"option": map[string]interface{}{"ninput": 1},
|
||||||
@ -1024,17 +1030,91 @@ 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.Options("friend") && m.Options("module") {
|
// if m.Options("friend") && m.Options("module") {
|
||||||
m.Copy(m.Appendv("aaa").(*ctx.Message).Find(m.Option("module")).Cmd("right", m.Option("friend"), m.Option("action"), m.Optionv("share")), "result")
|
// m.Copy(m.Appendv("aaa").(*ctx.Message).Find(m.Option("module")).Cmd("right", m.Option("friend"), m.Option("action"), m.Optionv("share")), "result")
|
||||||
if m.Confv("index", m.Option("friend")) == nil {
|
// if m.Confv("index", m.Option("friend")) == nil {
|
||||||
m.Confv("index", m.Option("friend"), m.Confv("index", m.Append("username")))
|
// m.Confv("index", m.Option("friend"), m.Confv("index", m.Append("username")))
|
||||||
|
// }
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// msg := m.Spawn().Cmd("right", "target", m.Option("module"), m.Append("username"), "show", "context")
|
||||||
|
// m.Copy(msg, "append")
|
||||||
|
if m.Options("friend") && m.Options("template") && m.Options("title") {
|
||||||
|
for i, v := range m.Confv("index", m.Option("username")).([]interface{}) {
|
||||||
|
if v == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val := v.(map[string]interface{})
|
||||||
|
if val["template"].(string) == m.Option("template") && val["title"].(string) == m.Option("title") {
|
||||||
|
if m.Option("action") == "del" {
|
||||||
|
friends := m.Confv("index", strings.Join([]string{m.Option("username"), fmt.Sprintf("%d", i), "to"}, ".")).([]interface{})
|
||||||
|
for j, x := range friends {
|
||||||
|
if x.(string) == m.Option("friend") {
|
||||||
|
m.Confv("index", strings.Join([]string{m.Option("username"), fmt.Sprintf("%d", i), "to", fmt.Sprintf("%d", j)}, "."), nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
temps := m.Confv("index", strings.Join([]string{m.Option("friend")}, ".")).([]interface{})
|
||||||
|
for j, x := range temps {
|
||||||
|
if x == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val = x.(map[string]interface{})
|
||||||
|
if val["template"].(string) == m.Option("template") && val["title"].(string) == m.Option("title") {
|
||||||
|
m.Confv("index", strings.Join([]string{m.Option("friend"), fmt.Sprintf("%d", j)}, "."), nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.Confv("index", m.Option("friend")) == nil && !m.Confs("auto_create") {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
m.Confv("index", strings.Join([]string{m.Option("username"), fmt.Sprintf("%d", i), "to", "-2"}, "."), m.Option("friend"))
|
||||||
|
|
||||||
|
item := map[string]interface{}{
|
||||||
|
"template": val["template"],
|
||||||
|
"title": val["title"],
|
||||||
|
"from": m.Option("username"),
|
||||||
|
}
|
||||||
|
if val["command"] != nil {
|
||||||
|
item["module"] = val["module"]
|
||||||
|
item["command"] = val["command"]
|
||||||
|
item["argument"] = val["argument"]
|
||||||
|
} else if val["detail"] != nil {
|
||||||
|
item["module"] = val["module"]
|
||||||
|
item["detail"] = val["detail"]
|
||||||
|
item["option"] = val["option"]
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Confv("index", strings.Join([]string{m.Option("friend"), fmt.Sprintf("%d", -2)}, "."), item)
|
||||||
|
m.Appendv("aaa").(*ctx.Message).Spawn(c).Cmd("right", m.Option("friend"), "add", "command", "/index/", "dir", m.Cap("directory"))
|
||||||
|
os.Mkdir(path.Join(m.Cap("directory"), m.Option("friend")), 0666)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
for _, v := range m.Confv("index", m.Option("username")).([]interface{}) {
|
||||||
msg := m.Spawn().Cmd("right", "target", m.Option("module"), m.Append("username"), "show", "context")
|
val := v.(map[string]interface{})
|
||||||
m.Copy(msg, "append")
|
m.Add("append", "template", val["template"])
|
||||||
|
m.Add("append", "titles", val["title"])
|
||||||
|
m.Add("append", "from", val["from"])
|
||||||
|
m.Add("append", "to", "")
|
||||||
|
if val["to"] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, u := range val["to"].([]interface{}) {
|
||||||
|
m.Add("append", "template", val["template"])
|
||||||
|
m.Add("append", "titles", val["title"])
|
||||||
|
m.Add("append", "from", val["from"])
|
||||||
|
m.Add("append", "to", u)
|
||||||
|
}
|
||||||
|
}
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
"/check": &ctx.Command{Name: "/check arg...", Help: "权限检查, cache|config|command: 接口类型, name: 接口名称, args: 其它参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"/check": &ctx.Command{Name: "/check arg...", Help: "权限检查, cache|config|command: 接口类型, name: 接口名称, args: 其它参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
@ -1089,8 +1169,15 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
[]byte{27, 91, 109}, []byte("</span>"),
|
[]byte{27, 91, 109}, []byte("</span>"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.Confv("index", arg[0]) == nil {
|
||||||
|
arg[0] = "notice"
|
||||||
|
}
|
||||||
|
|
||||||
m.Assert(tpl.ExecuteTemplate(w, "head", m))
|
m.Assert(tpl.ExecuteTemplate(w, "head", m))
|
||||||
for _, v := range m.Confv("index", arg[0]).([]interface{}) {
|
for _, v := range m.Confv("index", arg[0]).([]interface{}) {
|
||||||
|
if v == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
val := v.(map[string]interface{})
|
val := v.(map[string]interface{})
|
||||||
//命令模板
|
//命令模板
|
||||||
if detail, ok := val["detail"].([]interface{}); ok {
|
if detail, ok := val["detail"].([]interface{}); ok {
|
||||||
|
@ -30,10 +30,6 @@
|
|||||||
|
|
||||||
{{define "share"}}
|
{{define "share"}}
|
||||||
<fieldset><legend>share</legend>
|
<fieldset><legend>share</legend>
|
||||||
<form method="POST" onsubmit="return share(event, '{{option . "dir"|meta}}')">
|
|
||||||
<label>share to:</label><input type="text" name="shareto" required>
|
|
||||||
<input type="submit">
|
|
||||||
</form>
|
|
||||||
<table>
|
<table>
|
||||||
{{$msg := .}}
|
{{$msg := .}}
|
||||||
{{$ncol := append . |len}}
|
{{$ncol := append . |len}}
|
||||||
@ -44,7 +40,13 @@
|
|||||||
{{range append $msg}}
|
{{range append $msg}}
|
||||||
{{$value := append $msg . $row}}
|
{{$value := append $msg . $row}}
|
||||||
<td><code>
|
<td><code>
|
||||||
{{if eq . "value"}}
|
{{if eq . "to"}}
|
||||||
|
{{if eq $value ""}}
|
||||||
|
<input type="text" onkeyup="return share_input(event, '{{append $msg "template" $row}}', '{{append $msg "titles" $row}}', 'add')">
|
||||||
|
{{else}}
|
||||||
|
<code><a href="/" title="点击取消共享" onclick="return shareto('{{append $msg "template" $row}}', '{{append $msg "titles" $row}}', '{{$value}}','del')">{{$value}}</a></code>
|
||||||
|
{{end}}
|
||||||
|
{{else if eq . "value"}}
|
||||||
<code><a title="点击删除" href="/" onclick="deleteshare(event, '{{append $msg "friend" $row}}', '{{$value}}')">{{$value}}</a></code>
|
<code><a title="点击删除" href="/" onclick="deleteshare(event, '{{append $msg "friend" $row}}', '{{$value}}')">{{$value}}</a></code>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$value}}
|
{{$value}}
|
||||||
@ -56,34 +58,27 @@
|
|||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<script>
|
<script>
|
||||||
function share(event, dir) {
|
function share_input(event, template, title, action) {
|
||||||
if (dir.endsWith("/")) {
|
if (event.code == "Enter") {
|
||||||
dir = dir.substr(0, dir.length-1)
|
shareto(template, title, event.target.value, action);
|
||||||
}
|
}
|
||||||
var fields = event.target.elements;
|
console.log(event.code)
|
||||||
var shareto = fields["shareto"].value
|
console.log(event.key)
|
||||||
ctx.POST("/share", {
|
console.log(event)
|
||||||
module: "web",
|
|
||||||
friend: shareto,
|
|
||||||
action: "add",
|
|
||||||
share: ["command", "/index/", "dir", dir],
|
|
||||||
}, function(msg) {
|
|
||||||
ctx.Refresh();
|
|
||||||
})
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
function deleteshare(event, group, dir) {
|
|
||||||
if (!window.confirm("cancel share?")) {
|
function shareto(template, title, friend, action) {
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.POST("/share", {
|
ctx.POST("/share", {
|
||||||
module: "web",
|
module: "web",
|
||||||
friend: group,
|
template: template,
|
||||||
action: "del",
|
title: title,
|
||||||
share: ["command", "/index/", "dir"],
|
friend: friend,
|
||||||
|
action: action,
|
||||||
|
share: ["command", "/index/"],
|
||||||
}, function(msg) {
|
}, function(msg) {
|
||||||
ctx.Refresh();
|
ctx.Refresh();
|
||||||
})
|
})
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user