1
0
forked from x/ContextOS
2019-04-21 13:41:31 +08:00

93 lines
4.3 KiB
Cheetah

{{define "toolkit"}}
<fieldset class="{{options . "componet_view"}}" data-init="{{options . "componet_init"}}">
<div>{{options . "componet_name"}}({{options . "componet_help"}})</div>
</fieldset>
{{end}}
{{define "componet"}}
<fieldset class="{{options . "componet_view"}}" data-init="{{options . "componet_init"}}">
<legend title="{{options . "componet_help"}}">{{options . "componet_name"}}({{options . "componet_help"}})</legend>
{{$msg := .}}
<form class="option {{options . "componet_name"}}"
data-componet_name="{{options . "componet_name"}}"
data-componet_group="{{options . "componet_group"}}"
{{$form_type := options . "form_type"}} {{if eq $form_type "upload"}}
method="POST" action="/upload" enctype="multipart/form-data" target="_blank"
{{end}}>
<input style="display:none"></input>
{{range $index, $input := option . "inputs"}}
<div>{{$type := index $input "type"}} {{$value := index $input "value" | parse $msg}}
{{if index $input "label"}}
<label>{{index $input "label"}} : </label>
{{end}}
{{if eq $type "button"}}
<input type="button" value="{{$value}}">
{{else if eq $type "submit"}}
<input type="submit" value="{{$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"}}">
{{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="{{$value}}" class="{{index $input "class"}}">
{{else if eq $type "textarea"}}
<textarea rows="{{index $input "rows"}}" cols="{{index $input "cols"}}"
name="{{index $input "name"}}" class="{{index $input "class"}}">{{$value}}</textarea>
{{else}}
<input name="{{index $input "name"}}" value="{{$value}}" class="{{index $input "class"}}">
{{end}}</div>
{{end}}
<hr/>
</form>
{{if index .Meta "display_append"}} {{options . "display_append"}} {{else}}
<table class="append {{options . "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"}} {{options . "display_result"}} {{else}}
<code class="result {{options . "componet_name"}}"><pre>{{result .Meta}}</pre></code>
{{end}}
{{if index .Meta "display_div"}} {{options . "display_div"}} {{else}}
<div class="result {{options . "componet_name"}}"></div>
{{end}}
</fieldset>
{{end}}
{{define "mp"}}
<script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script src="/static/librarys/wexin.js"></script>
<script>
{{$token := cmd . "context chat js_token"}}
wx.config({
debug: true,
appId: {{append $token "appid"|meta}},
timestamp: {{append $token "timestamp"|meta}},
nonceStr: {{append $token "nonce"|meta}},
signature: {{append $token "signature"|meta}},
jsApiList: [
"scanQRCode",
"chooseImage",
"closeWindow",
"openAddress",
],
})
wx.ready(function(){})
wx.error(function(res){})
</script>
{{end}}