1
0
forked from x/ContextOS
2018-12-27 18:46:14 +08:00

303 lines
9.7 KiB
Cheetah

{{define "head"}}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.7">
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
<title>code</title>
<style>
html, body {
height:100%;
width:100%;
margin:0px;
background-color:#d8d8d8;
}
fieldset {
margin-top:8px;
}
legend {
font-size:16px;
font-weight:bold;
font-family:monospace;
}
</style>
<style>
div.workflow {
color:#e6dd37;
font-size:14px;
font-family:monospace;
background-color:#498bb1a8;
border:solid 3px red;
width:60px;
height:20px;
overflow:scroll;
position:fixed;
top:{{conf . "docker_view" "top"}}px;
left:{{conf . "docker_view" "left"}}px;
}
div.workflow:hover, div.workflow.max {
width:{{conf . "docker_view" "width"}}px;
height:{{conf . "docker_view" "height"}}px;
}
div.workflow div:hover, div.workflow li li:hover {
background-color:red;
}
div.workflow div.stick, div.workflow li li.stick {
background-color:red;
}
div.workflow li>label.result{
background-color:rgba(0,0,0,0.2);
padding:0 5px;
border:2px solid green;
margin-left: 10px;
}
div.workflow li>input {
background-color:rgba(0,0,0,0.2);
}
form.option div {
float:left;
}
textarea.clipboard {
color:white;
background-color:#272822;
width:600px;
}
form.option div {
float:left;
}
form.option hr {
clear:both;
}
form.option label.keymap {
color:red;
display:none;
}
form.option label.keymap.show {
display:inline;
}
form.option input {
margin-right:10px;
}
form.option input.cmd {
color:white;
background-color:#272822;
padding-left:10px;
width:600px;
}
form.option input.file_cmd {
color:white;
background-color:#272822;
padding-left:10px;
width:400px;
}
form.option input.file_name {
width:200px;
}
form.option.exec input {
color:white;
background-color:#272822;
padding-left:10px;
width:600px;
}
form.option select {
margin-right:10px;
}
table.append {
font-size:14px;
overflow: auto;
}
table.append th {
font-family:monospace;
background-color:lightgreen;
cursor:pointer;
}
table.append th.order {
background-color:red;
cursor:pointer;
}
table.append td {
font-family:monospace;
padding-left: 10px;
padding-right: 20px;
}
table.append td.clip {
background-color:red;
}
code.result pre {
color:white;
font-size:14px;
background-color:#272822;
overflow:scroll;
padding:5px;
border:solid 2px green;
border-left:solid 4px green;
margin:0;
}
code.result pre.clipboard {
height:2em;
}
</style>
</head>
<body onkeydown="return onaction(event, 'scroll')" onkeyup="return onaction(event, 'keymap')">
<script>
{{$id := option . "bench"|option}}
var bench ={{conf . "bench" $id}}
</script>
{{end}}
{{define "void"}}{{end}}
{{define "detail"}}{{detail .}}{{end}}
{{define "option"}}{{option .}}{{end}}
{{define "append"}}{{append .}}{{end}}
{{define "result"}}{{result .}}{{end}}
{{define "clipboard"}}
<fieldset><legend>clipboard</legend>
<datalist id="clipstack"></datalist>
<datalist id="clistack"></datalist>
<textarea class="clipboard"></textarea>
</fieldset>
{{end}}
{{define "docker"}}
{{$key := option . "bench"}}
{{$username := option . "username"|option}}
{{$bench := conf . "bench" $key}}
<div class="workflow">
<div>&nbsp;bench (Ctrl+B)</div>
<ul class="docker">
<li><div>粘贴板</div>
<ul class="txt">
<li data-action="save_txt">+ 保存粘贴板(Ctrl+S)</li>
<li data-action="create_txt">+ 添加粘贴板(Ctrl+Y)</li>
<li data-action="quick_txt">+ 快捷粘贴板(Ctrl+P)</li>
</ul>
</li>
<li><div>命令行</div>
<ul class="cmd">
{{range $name, $cmd := conf . "toolkit"}}
<li>{{$name}} <input type="text" data-cmd="{{$name}}" onkeyup="onaction(event, 'toolkit')"><label class="result"></label></li>
{{end}}
<li class="stick" data-action="shrink_cmd">+ 折叠命令行(Ctrl+Z)</li>
<li data-action="create_cmd">+ 添加命令行(Ctrl+M)</li>
{{if $bench}}
{{range $index, $cmd := index $bench "commands"}}
<li class="command{{$index}}" data-cmd="{{$index}}">{{index $cmd "now"|option}} {{$index}}: {{index $cmd "cmd"|option}}</li>
{{end}}
{{end}}
</ul>
</li>
<li><div>工作流</div>
<ul class="fly">
<li data-action="refresh_fly">+ 刷新工作流(Ctrl+R)</li>
<li data-action="create_fly">+ 添加工作流(Ctrl+T)</li>
{{range $key, $item := conf . "bench"}}
<li data-key="{{$key}}">{{index $item "modify_time"}} {{index $item "comment"}}({{slice $key 0 6}})</li>
{{end}}
<li data-action="rename_fly">+ 命名工作流</li>
<li data-action="remove_fly">+ 删除工作流</li>
</ul>
</li>
</ul>
</div>
{{end}}
{{define "componet"}}
<fieldset><legend title="{{option .Meta "componet_help"}}">{{option .Meta "componet_help"}}({{option .Meta "componet_ctx"}}.{{option .Meta "componet_cmd"}})</legend>
{{$form_type := option . "form_type"|meta}}
{{if eq $form_type "upload"}}
{{end}}
<form class="option {{option .Meta "componet_name"}}"
data-componet_group="{{option . "componet_group"|meta}}"
data-componet_name="{{option . "componet_name"|meta}}"
data-componet_bench="{{option . "bench"|meta}}"
{{if eq $form_type "upload"}}
method="POST" action="/upload" enctype="multipart/form-data"
onsubmit="onaction(event,'upload')"
{{end}}
>
<input style="display:none"></input>
{{range $index, $input := option . "inputs"}}
<div>
{{$type := index $input "type"}}
{{if index $input "label"}}
<label>{{index $input "label"}} : </label>
{{end}}
{{if eq $type "button"}}
<input type="button" onclick="return onaction(event, 'command')" value="{{index $input "value"}}">
{{else if eq $type "submit"}}
<input type="submit" value="{{index $input "value"}}">
{{else if eq $type "file"}}
<input type="file" name="{{index $input "name"}}">
{{else if eq $type "choice"}}
{{$default_value := index $input "value"}}
<select name="{{index $input "name"}}" onchange="return onaction(event, 'command')">
{{range $index, $value := index $input "choice"}}
{{$val := index $value "value"}}
{{if eq $default_value $val}}
<option value="{{index $value "value"}}" selected>{{index $value "name"}}</option>
{{else}}
<option value="{{index $value "value"}}">{{index $value "name"}}</option>
{{end}}
{{end}}
</select>
{{else if eq $type "password"}}
<input
type="password"
name="{{index $input "name"}}"
value="{{index $input "value"}}"
class="{{index $input "class"}}"
onclick="return onaction(event, 'click')"
onkeyup="return onaction(event, 'input')">
{{else}}
<input
name="{{index $input "name"}}"
value="{{index $input "value"}}"
class="{{index $input "class"}}"
{{if index $input "clipstack"}}
list="{{index $input "clipstack"}}"
{{else}}
list="clipstack"
{{end}}
onclick="return onaction(event, 'click')"
onkeyup="return onaction(event, 'input')">
{{end}}
</div>
{{end}}
<hr/>
</form>
{{if eq $form_type "upload"}}
{{end}}
{{if index .Meta "display_append"}}
{{option .Meta "display_append"}}
{{else}}
<table class="append {{option .Meta "componet_name"}}">
{{$msg := .}}
<tr>{{range $field := append .}}<th>{{$field}}</th>{{end}}</tr>
{{range $line := table .}}
<tr>{{range $field := append $msg}}<td>{{index $line $field|unescape}}</td>{{end}}</tr>
{{end}}
</table>
{{end}}
{{if index .Meta "display_result"}}
{{option .Meta "display_result"}}
{{else}}
<code class="result {{option .Meta "componet_name"}}"><pre>{{result .Meta}}</pre></code>
{{end}}
</fieldset>
{{end}}
{{define "tail"}}
<script src="/librarys/context.js"></script>
<script src="/librarys/code.js"></script>
</body>
{{end}}