mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
98 lines
2.1 KiB
HTML
98 lines
2.1 KiB
HTML
{{define "login"}}
|
|
<fieldset><legend>login</legend>
|
|
<form method="POST" action="/login" onsubmit="return login(event)">
|
|
<label>username:</label><input type="text" name="username" value="{{index .username 0}}" required autofocus>
|
|
<label>password:</label><input type="password" name="password" required>
|
|
<input type="submit">
|
|
</form>
|
|
</fieldset>
|
|
<script>
|
|
function login(event) {
|
|
var fields = event.target.elements;
|
|
ctx.POST("/login", {
|
|
username: fields["username"].value,
|
|
password: fields["password"].value
|
|
}, function(msg) {
|
|
if (ctx.Cookie("sessid")) {
|
|
ctx.Refresh()
|
|
}
|
|
})
|
|
return false;
|
|
}
|
|
</script>
|
|
{{end}}
|
|
|
|
{{define "userinfo"}}
|
|
<fieldset><legend>userinfo</legend>
|
|
welcome {{index .username 0}}
|
|
<button onclick="return logout(event)">logout</button>
|
|
</fieldset>
|
|
<script>
|
|
function logout(event) {
|
|
ctx.Cookie("sessid", "");
|
|
ctx.Refresh();
|
|
return false;
|
|
}
|
|
</script>
|
|
{{end}}
|
|
|
|
{{define "share"}}
|
|
<fieldset><legend>share</legend>
|
|
<form method="POST" onsubmit="return share(event)">
|
|
<label>share to:</label><input type="text" name="shareto" required>
|
|
<input type="submit">
|
|
</form>
|
|
<table>
|
|
<colgroup>
|
|
{{range .append}}
|
|
<col class="{{.}}">
|
|
{{end}}
|
|
</colgroup>
|
|
<tr>
|
|
{{range .append}}
|
|
<th class="{{.}}">{{.}}</th>
|
|
{{end}}
|
|
</tr>
|
|
|
|
{{$meta := .}}
|
|
{{if .append}}
|
|
{{$first := index .append 0}}
|
|
{{range $i, $k := index . $first}}
|
|
<tr>
|
|
{{range $key := index $meta "append"}}
|
|
<td class="{{$key}}">
|
|
{{if eq $key "delete"}}
|
|
<button onclick="return deleteshare(event, '{{index $meta "value" $i}}', '{{index $meta "group" $i}}')">delete</button>
|
|
{{else}}
|
|
<code>{{index $meta $key $i}}</code>
|
|
{{end}}
|
|
</td>
|
|
{{end}}
|
|
</tr>
|
|
{{end}}
|
|
{{end}}
|
|
</table>
|
|
</fieldset>
|
|
<script>
|
|
function share(event) {
|
|
var fields = event.target.elements;
|
|
var shareto = fields["shareto"].value
|
|
ctx.POST("/upload", {
|
|
shareto: shareto,
|
|
sharefile: file,
|
|
}, function(msg) {
|
|
ctx.Refresh();
|
|
})
|
|
return false;
|
|
}
|
|
function deleteshare(event, file, group) {
|
|
ctx.POST("/upload", {
|
|
notshareto: group,
|
|
sharefile: file,
|
|
}, function(msg) {
|
|
ctx.Refresh();
|
|
})
|
|
}
|
|
</script>
|
|
{{end}}
|