mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
100 lines
2.3 KiB
HTML
100 lines
2.3 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>
|
|
<form method="POST" onsubmit="return share(event, '{{cap . "directory"}}{{option . "dir"|meta}}')">
|
|
<label>share to:</label><input type="text" name="shareto" required>
|
|
<input type="submit">
|
|
</form>
|
|
<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 . "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(event, dir) {
|
|
if (dir.endsWith("/")) {
|
|
dir = dir.substr(0, dir.length-1)
|
|
}
|
|
var fields = event.target.elements;
|
|
var shareto = fields["shareto"].value
|
|
ctx.POST("/share", {
|
|
module: "web",
|
|
friend: shareto,
|
|
action: "add",
|
|
share: ["command", "/index/", "dir", dir],
|
|
}, function(msg) {
|
|
ctx.Refresh();
|
|
})
|
|
return false;
|
|
}
|
|
function deleteshare(event, group, dir) {
|
|
if (!window.confirm("cancel share?")) {
|
|
return
|
|
}
|
|
ctx.POST("/share", {
|
|
module: "web",
|
|
friend: group,
|
|
action: "del",
|
|
share: ["command", "/index/", "dir"],
|
|
}, function(msg) {
|
|
ctx.Refresh();
|
|
})
|
|
}
|
|
</script>
|
|
{{end}}
|
|
|
|
{{$msg := .}}
|
|
{{$meta := .Meta}}
|
|
|
|
{{template "head" $meta}}
|
|
{{if meta $meta.notice}}
|
|
{{template "notice" $meta}}
|
|
{{end}}
|
|
{{template "login" $meta}}
|
|
{{template "tail" $meta}}
|