-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.html
80 lines (70 loc) · 1.96 KB
/
template.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:,">
<title>Enter password</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
min-block-size: 100dvb;
margin: 0;
background: hsl(216deg 50% 98%);
color: hsl(216deg 50% 10%);
display: grid;
place-items: center;
}
label {
display: block;
}
input,
button {
font-size: 1rem;
padding-inline: 4px;
padding-block: 8px 6px;
border-radius: 4px;
border: 1px solid hsl(216deg 50% 80%);
transition: filter 600ms, border 600ms;
}
:is(input, button):focus-within,
button:hover {
border: 1px solid hsl(216deg 50% 70%);
filter: drop-shadow(0 0 4px hsl(216deg 50% 80%));
transition: filter 200ms, border 200ms;
}
button {
background: hsl(216deg 50% 90%);
cursor: pointer;
}
</style>
</head>
<body>
<main>
<form>
<label for="password">Password</label>
<input type="password" name="password" id="password" required>
<button>Unlock</button>
</form>
</main>
<template id="script-injection"></template>
<script>
const input = document.querySelector('input');
document.querySelector('form').addEventListener('submit', async e => {
e.preventDefault();
const password = new FormData(e.target).get('password');
try {
const newDocument = await decrypt(content, password);
document.open();
document.write(newDocument);
document.close();
}
catch {
input.setCustomValidity('Incorrect password.');
input.reportValidity();
}
});
input.addEventListener('input', e => e.target.setCustomValidity(''));
</script>
</body>
</html>