mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add button
This commit is contained in:
parent
2c9479bca6
commit
842fbdba61
@ -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...)
|
||||
}
|
||||
|
@ -1127,11 +1127,10 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
"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: "文件路径"},
|
||||
@ -1245,7 +1244,6 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
m.Assert(e)
|
||||
m.Option("git_dir", wd)
|
||||
}
|
||||
m.Log("fuck", "what %v", arg[0])
|
||||
|
||||
cmds := []string{}
|
||||
if v := m.Confv("git", []string{arg[0], "cmds"}); v != nil {
|
||||
@ -1264,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)
|
||||
|
@ -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)
|
||||
@ -391,8 +391,20 @@ var page = Page({
|
||||
"全屏": 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,11 +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, value)
|
||||
pane.Button = value
|
||||
}]})
|
||||
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) {
|
||||
@ -586,7 +602,7 @@ var page = Page({
|
||||
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) {
|
||||
|
@ -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
|
||||
})
|
||||
|
@ -563,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