1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00
2018-08-19 21:31:41 +08:00

95 lines
2.4 KiB
HTML

{{define "login"}}
<fieldset><legend>login</legend>
<form method="POST" action="/login">
<label>username:</label><input type="text" name="username" required autofocus>
<label>password:</label><input type="password" name="password" required>
<input type="submit">
</form>
</fieldset>
{{end}}
{{define "userinfo"}}
<fieldset><legend>userinfo</legend>
welcome <span class="username">{{option . "username"}}</span> to context world
<button onclick="return logout(event)">logout</button>
</fieldset>
<style>
.username {
color:red;
font-weight:bold;
}
</style>
<script>
function logout(event) {
ctx.Cookie("sessid", ";path=/");
ctx.Refresh();
return false;
}
</script>
{{end}}
{{define "share"}}
<fieldset><legend>share</legend>
<table>
{{$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 . "to"}}
{{if eq $value ""}}
<input type="text" onkeyup="return share_input(event, '{{append $msg "template" $row}}', '{{append $msg "titles" $row}}', 'add')">
{{else}}
<code><a href="/" title="点击取消共享" onclick="return shareto('{{append $msg "template" $row}}', '{{append $msg "titles" $row}}', '{{$value}}','del')">{{$value}}</a></code>
{{end}}
{{else if eq . "value"}}
<code><a title="点击删除" href="/" onclick="deleteshare(event, '{{append $msg "friend" $row}}', '{{$value}}')">{{$value}}</a></code>
{{else}}
{{$value}}
{{end}}
</code></td>
{{end}}
</tr>
{{end}}
</table>
</fieldset>
<script>
function share_input(event, template, title, action) {
if (event.code == "Enter") {
shareto(template, title, event.target.value, action);
}
console.log(event.code)
console.log(event.key)
console.log(event)
}
function shareto(template, title, friend, action) {
ctx.POST("/share", {
module: "web",
template: template,
title: title,
friend: friend,
action: action,
share: ["command", "/index/"],
}, function(msg) {
ctx.Refresh();
})
return false
}
</script>
{{end}}
{{$msg := .}}
{{$meta := .Meta}}
{{template "head" $meta}}
{{if meta $meta.notice}}
{{template "notice" $meta}}
{{end}}
{{template "login" $meta}}
{{template "tail" $meta}}