1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-26 09:14:06 +08:00
2018-08-17 19:01:03 +08:00

123 lines
2.7 KiB
HTML

{{define "head"}}
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>{{option .Meta "title"}}</title>
<style>
legend {
font-size:16px;
font-weight:bold;
}
th {
cursor:pointer;
background-color:lightgreen;
}
td {
padding-left: 10px;
padding-right: 20px;
}
code {
font-size:14px;
}
</style>
</head>
<body>
{{end}}
{{define "code"}}
<pre><code>{{.}}</code></pre>
{{end}}
{{define "notice"}}
<fieldset class="notice"><legend>notice</legend>
{{template "code" result .Meta}}
</fieldset>
<style>
.notice {color:red}
</style>
{{end}}
{{define "detail"}}
{{$key := append . "title"|meta}}
<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>
<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>
</fieldset>
<script>
function input(event, module, details, input, results) {
if (event.code == "Enter") {
action(event, module, details, input, results);
}
}
function action(event, module, details, input, results) {
var input = document.getElementsByClassName(input)[0];
if (input.value != "") {
details = [details, input.value];
}
ctx.POST("", {module:module, details:details}, function(msg) {
var result = document.getElementsByClassName(results)[0];
result.innerHTML = msg.result || msg.message || msg;
})
return false;
}
</script>
{{end}}
{{define "result"}}
<fieldset><legend>{{option . "title"}}</legend>
{{template "code" result .Meta|unscaped}}
</fieldset>
{{end}}
{{define "append_link"}}
<a onclick="return jump('{{.}}')" href="{{.}}">{{.}}</a>
<script>
function jump(to) {
location.href = location.href + "/" +to;
return false
}
</script>
{{end}}
{{define "append"}}
<fieldset><legend>{{append . "title"}}</legend>
<table class="append">
{{$msg := .}}
{{$ncol := append . |len}}
{{$nrow := append . 0|append .|len}}
<tr>{{range append .}}<th><code onclick="sort_table('{{.}}')">{{.}}</code></th>{{end}}</tr>
{{range $row, $val := append . 0|append .}}
<tr>
{{range append $msg}}
{{$value := append $msg . $row}}
<td><code>
{{if eq . "filename"}}
{{template "append_link" $value}}
{{else}}
{{$value}}
{{end}}
</code></td>
{{end}}
</tr>
{{end}}
</table>
</fieldset>
<script>
var sort_field="";
function sort_table(field) {
sort_field = field;
console.log(sort_field);
}
</script>
{{end}}
{{define "main"}}
welcome to context world!
{{end}}
{{define "tail"}}
<script src="/library/context.js"></script>
</body>
{{end}}