2022-01-08 10:54:24 -05:00
|
|
|
{{define "theme-mdui/viewpassword"}}
|
|
|
|
<!doctype html>
|
|
|
|
<html lang="zh-CN">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
|
|
<title>{{.Title}}</title>
|
|
|
|
|
|
|
|
<!-- MDUI CSS -->
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mdui@1.0.2/dist/css/mdui.min.css"/>
|
|
|
|
<link rel="stylesheet" href="/static/theme-mdui/mdui.css" type="text/css">
|
|
|
|
{{if ts .CustomCode}}
|
|
|
|
{{.CustomCode|safe}}
|
|
|
|
{{end}}
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div class="mdui-container" id="container">
|
2022-01-10 05:36:38 -05:00
|
|
|
<div class="mdui-dialog mdui-dialog-prompt mdui-dialog-open">
|
|
|
|
<div class="mdui-dialog-title">验证查看密码</div>
|
|
|
|
|
|
|
|
<div class="mdui-dialog-content">
|
|
|
|
<div class="mdui-textfield">
|
|
|
|
<i class="mdui-icon material-icons">lock</i>
|
|
|
|
<label class="mdui-textfield-label">密码</label>
|
|
|
|
<input class="mdui-textfield-input" type="password" id="password">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mdui-dialog-actions">
|
|
|
|
<button class="mdui-btn mdui-ripple mdui-text-color-primary" id="confimBtn">验证</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-08 10:54:24 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/mdui@1.0.2/dist/js/mdui.min.js"></script>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script>
|
|
|
|
<script>
|
2022-01-10 05:36:38 -05:00
|
|
|
var $input = mdui.$('#container').find('.mdui-textfield-input');
|
|
|
|
var $dialog = new mdui.Dialog(mdui.$('.mdui-dialog'));
|
|
|
|
var onConfirm = async function() {
|
|
|
|
var pwd = $input.val();
|
2022-01-08 10:54:24 -05:00
|
|
|
const res = await fetch("/view-password", {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {'Content-Type': 'application/json'},
|
|
|
|
redirect: 'follow',
|
|
|
|
body: JSON.stringify({ Password: pwd }),
|
|
|
|
});
|
|
|
|
if (res.ok) {
|
|
|
|
if (res.redirected) {
|
|
|
|
window.location.href = res.url;
|
|
|
|
} else {
|
|
|
|
mdui.snackbar({
|
|
|
|
message: '密码错误',
|
|
|
|
position: 'top',
|
2022-01-10 05:36:38 -05:00
|
|
|
timeout: 2000,
|
2022-01-08 10:54:24 -05:00
|
|
|
});
|
|
|
|
mdui.mutation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-10 05:36:38 -05:00
|
|
|
mdui.updateTextFields($input);
|
|
|
|
$input.on('keydown', function (event) {
|
|
|
|
if (event.keyCode === 13) {
|
|
|
|
var value = $input.val();
|
|
|
|
onConfirm(value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return;
|
2022-01-08 10:54:24 -05:00
|
|
|
});
|
2022-01-10 05:36:38 -05:00
|
|
|
document.getElementById('confimBtn').addEventListener('click', onConfirm);
|
2022-01-08 10:54:24 -05:00
|
|
|
|
2022-01-10 05:36:38 -05:00
|
|
|
$dialog.open();
|
|
|
|
$input[0].focus();
|
2022-01-08 10:54:24 -05:00
|
|
|
mdui.mutation();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
{{end}}
|