mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
mac add web.travel.value
This commit is contained in:
parent
228b5bf36c
commit
f313b20ce1
@ -2296,6 +2296,8 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
|
||||
"detail_index": &Config{Name: "detail_index", Value: "0", Help: "参数的索引"},
|
||||
"result_index": &Config{Name: "result_index", Value: "-2", Help: "返回值的索引"},
|
||||
|
||||
"list_help": &Config{Name: "list_help", Value: "list command", Help: "返回值的索引"},
|
||||
},
|
||||
Commands: map[string]*Command{
|
||||
"help": &Command{Name: "help topic", Help: "帮助", Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||
@ -2788,7 +2790,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
"command": &Command{
|
||||
Name: "command [all|add cmd arg...|list [begin [end]]|test [begin [end]]|delete cmd]",
|
||||
Help: "查看或修改命令",
|
||||
Form: map[string]int{"condition": -1},
|
||||
Form: map[string]int{"condition": -1, "list_help": 1},
|
||||
Hand: func(m *Message, c *Context, key string, arg ...string) {
|
||||
if len(arg) == 0 { // {{{
|
||||
keys := []string{}
|
||||
@ -2832,7 +2834,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
||||
}
|
||||
m.target.Commands[m.Cap("list_count")] = &Command{
|
||||
Name: strings.Join(arg[1:], " "),
|
||||
Help: "list_command",
|
||||
Help: m.Confx("list_help"),
|
||||
Hand: func(m *Message, c *Context, key string, args ...string) {
|
||||
list := []string{}
|
||||
j := 0
|
||||
|
@ -557,7 +557,11 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
msg = msg.Spawn(msg.Target())
|
||||
msg.Detail(0, m.Option("name"))
|
||||
if m.Options("value") {
|
||||
msg.Add("detail", m.Option("value"))
|
||||
value := []string{}
|
||||
json.Unmarshal([]byte(m.Option("value")), &value)
|
||||
if len(value) > 0 {
|
||||
msg.Add("detail", value[0], value[1:]...)
|
||||
}
|
||||
}
|
||||
|
||||
msg.Cmd()
|
||||
|
@ -140,7 +140,7 @@ ctx = {
|
||||
args.name = cmd
|
||||
}
|
||||
if (value != undefined) {
|
||||
args.value = value
|
||||
args.value = JSON.stringify(value)
|
||||
}
|
||||
|
||||
this.POST("", args, cb);
|
||||
|
@ -108,19 +108,19 @@
|
||||
{{if gt $l 0}}
|
||||
{{$first := index .append 0}}
|
||||
{{range $i, $k := index . $first}}
|
||||
<div>
|
||||
{{$command := index $meta "key" $i}}
|
||||
{{range $key := index $meta "append"}}
|
||||
<div class="{{$key}}">
|
||||
{{if eq $key "input"}}
|
||||
<input type="text" name="{{$command}}" onkeydown="return Command(event, '{{$command}}')">
|
||||
{{else if eq $key "key"}}
|
||||
<code><a href="" onclick="return Shell(event, '{{$command}}')">{{$command}}</a></code>
|
||||
{{else}}
|
||||
<code>{{index $meta $key $i}}</code>
|
||||
{{end}}
|
||||
<div>
|
||||
<div>
|
||||
<code>
|
||||
{{$command}}:
|
||||
<a href="" onclick="return shell(event, '{{$command}}')">{{index $meta "name" $i}}</a>
|
||||
{{index $meta "help" $i}}
|
||||
</code>
|
||||
</div>
|
||||
{{end}}
|
||||
<div id="argument_{{$command}}">
|
||||
<button onclick="return Argument(event, 'add', '{{$command}}')">add</button>
|
||||
<button onclick="return Argument(event, 'del', '{{$command}}')">del</button>
|
||||
</div>
|
||||
<pre class="result" hidden><code id="result_{{$command}}"></code></pre>
|
||||
<table id="append_{{$command}}" hidden></table>
|
||||
</div>
|
||||
@ -128,7 +128,7 @@
|
||||
{{end}}
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset><legend><input id="direct" type="text" onkeydown="return Shell(event)"></legend>
|
||||
<fieldset><legend><input id="direct" type="text" onkeydown="return shell(event)"></legend>
|
||||
<pre class="result"><code id="result2"></code></pre>
|
||||
</fieldset>
|
||||
<script>
|
||||
@ -180,7 +180,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
function Shell(event, command) {
|
||||
function Argument(event, action, command) {
|
||||
var argument = document.getElementById("argument_"+command);
|
||||
switch (action) {
|
||||
case "add":
|
||||
var arg = document.createElement("input");
|
||||
arg.type = "text";
|
||||
argument.appendChild(arg);
|
||||
break;
|
||||
case "del":
|
||||
var arg = argument.lastElementChild;
|
||||
if (arg.type == "text") {
|
||||
argument.removeChild(arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function shell(event, command) {
|
||||
console.log(event);
|
||||
switch (event.type) {
|
||||
case "keydown":
|
||||
@ -190,17 +207,25 @@
|
||||
command = event.target.value
|
||||
// no break
|
||||
case "click":
|
||||
var detail = [];
|
||||
var result = document.getElementById("result_"+command);
|
||||
var append = document.getElementById("append_"+command);
|
||||
if (!result) {
|
||||
var result = document.getElementById("result2");
|
||||
} else {
|
||||
var div = document.getElementById("argument_"+command);
|
||||
var input = div.getElementsByTagName("input");
|
||||
for (var i in input) {
|
||||
if (input[i].value) {
|
||||
detail.push(input[i].value);
|
||||
}
|
||||
}
|
||||
result = result.parentElement;
|
||||
result.hidden = !result.hidden;
|
||||
append.hidden = result.hidden;
|
||||
}
|
||||
if (!result.hidden) {
|
||||
ctx.Cmd(command, null, function(msg) {
|
||||
ctx.Cmd(command, detail, function(msg) {
|
||||
show(msg, command);
|
||||
if (!msg.result) {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user