mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
mac add travel.config.value
This commit is contained in:
parent
f4fb06bd68
commit
98c1a63871
@ -557,7 +557,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
case "cache":
|
case "cache":
|
||||||
m.Echo(msg.Cap(m.Option("name")))
|
m.Echo(msg.Cap(m.Option("name")))
|
||||||
case "config":
|
case "config":
|
||||||
if m.Options("value") {
|
if m.Has("value") {
|
||||||
m.Echo(msg.Conf(m.Option("name"), m.Option("value")))
|
m.Echo(msg.Conf(m.Option("name"), m.Option("value")))
|
||||||
} else {
|
} else {
|
||||||
m.Echo(msg.Conf(m.Option("name")))
|
m.Echo(msg.Conf(m.Option("name")))
|
||||||
|
@ -102,10 +102,10 @@ ctx = {
|
|||||||
typeof cb == "function" && cb(value);
|
typeof cb == "function" && cb(value);
|
||||||
});
|
});
|
||||||
},//}}}
|
},//}}}
|
||||||
Conf: function(conf, value, cb) {//{{{
|
Conf: function(name, value, cb) {//{{{
|
||||||
if (typeof conf == "function") {
|
if (typeof name == "function") {
|
||||||
value = conf;
|
value = name;
|
||||||
conf = undefined;
|
name = undefined;
|
||||||
}
|
}
|
||||||
if (typeof value == "function") {
|
if (typeof value == "function") {
|
||||||
cb = value;
|
cb = value;
|
||||||
|
@ -42,25 +42,41 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "cache"}}
|
{{define "cache"}}
|
||||||
|
{{$meta := .}}
|
||||||
<fieldset><legend>cache</legend>
|
<fieldset><legend>cache</legend>
|
||||||
<table>
|
<table>
|
||||||
<colgroup>{{range .append}}<col class="{{.}}">{{end}}</colgroup>
|
<colgroup>{{range .append}}<col class="{{.}}">{{end}}</colgroup>
|
||||||
<tr>{{range .append}}<th class="{{.}}" onclick="list('{{.}}')">{{.}}</th>{{end}}</tr>
|
<tr>{{range .append}}<th class="{{.}}" onclick="list('{{.}}')">{{.}}</th>{{end}}</tr>
|
||||||
{{$l := index .append|len}}
|
{{$l := index .append|len}}
|
||||||
{{if gt $l 0}}
|
{{if gt $l 0}}
|
||||||
{{$meta := .}} {{$first := index .append 0}}
|
{{$first := index .append 0}}
|
||||||
{{range $i, $k := index . $first}}
|
{{range $i, $k := index . $first}}
|
||||||
<tr>
|
<tr>
|
||||||
{{range $key := index $meta "append"}}
|
{{range $key := index $meta "append"}}
|
||||||
<td class="{{$key}}">
|
{{$content := index $meta $key $i}}
|
||||||
<code>{{index $meta $key $i}}</code>
|
<td class="{{$key}}">
|
||||||
</td>
|
<code>{{$content}}</code>
|
||||||
|
</td>
|
||||||
|
{{end}}
|
||||||
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</tr>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<script>
|
||||||
|
function cache(event, key, value) {
|
||||||
|
console.log(event);
|
||||||
|
switch (event.type) {
|
||||||
|
case "keydown":
|
||||||
|
if (event.key != "Enter") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = event.target.value;
|
||||||
|
ctx.Cap(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "config"}}
|
{{define "config"}}
|
||||||
@ -74,10 +90,9 @@
|
|||||||
{{range $i, $k := index . $first}}
|
{{range $i, $k := index . $first}}
|
||||||
<tr>{{$config := index $meta "key" $i}}
|
<tr>{{$config := index $meta "key" $i}}
|
||||||
{{range $key := index $meta "append"}}
|
{{range $key := index $meta "append"}}
|
||||||
{{if eq $key "input"}}
|
{{if eq $key "value"}}
|
||||||
<td class="{{$key}}">
|
<td class="{{$key}}">
|
||||||
<input type="text" name="{{$config}}" onkeydown="return Config(event, '{{$config}}')">
|
<input type="text" value="{{index $meta $key $i}}" onkeydown="return Config(event, '{{$config}}')">
|
||||||
<code>{{index $meta $key $i}}</code>
|
|
||||||
</td>
|
</td>
|
||||||
{{else}}
|
{{else}}
|
||||||
<td class="{{$key}}">
|
<td class="{{$key}}">
|
||||||
@ -92,8 +107,8 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<script>
|
<script>
|
||||||
function Config(event, name) {
|
function Config(event, name) {
|
||||||
if (event.keyCode == 13) {
|
if (event.type=="keydown" && event.key == "Enter") {
|
||||||
ctx.Conf(name, event.currentTarget.value, function(msg) {ctx.Refresh()});
|
ctx.Conf(name, event.target.value, function(msg) {alert("ok")});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,19 +146,6 @@
|
|||||||
<pre class="result"><code id="result2"></code></pre>
|
<pre class="result"><code id="result2"></code></pre>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<script>
|
<script>
|
||||||
function Result(msg, command) {
|
|
||||||
var result = document.getElementById("result"+command);
|
|
||||||
result.innerHTML = msg.result.join("");
|
|
||||||
|
|
||||||
var append = document.getElementById("append"+command);
|
|
||||||
var tr = document.createElement("tr");
|
|
||||||
append.appendChild(tr)
|
|
||||||
for (var k in msg.append) {
|
|
||||||
var th = document.createElement("th");
|
|
||||||
th.innerHTML = k;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function show(msg, command) {
|
function show(msg, command) {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
if (msg.result) {
|
if (msg.result) {
|
||||||
@ -239,18 +241,6 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Command(event, name) {
|
|
||||||
if (event.keyCode == 13) {
|
|
||||||
var direct = document.getElementById("direct");
|
|
||||||
if (name) {
|
|
||||||
direct.value = name;
|
|
||||||
ctx.Cmd(name, event.currentTarget.value, Result);
|
|
||||||
} else {
|
|
||||||
ctx.Cmd(event.currentTarget.value, "", Result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Direct(event, name, value) {
|
function Direct(event, name, value) {
|
||||||
debugger;
|
debugger;
|
||||||
console.log(event)
|
console.log(event)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user