-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
59 lines (56 loc) · 2.42 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="/htmx.min.js"></script>
<link rel="stylesheet" href="/index.css" />
</head>
<body>
<script>
function convertToLocalTime(sinceEpoch) {
let date = new Date(sinceEpoch * 1000);
let userLocale = navigator.language || 'en-US';
return date.toLocaleDateString(userLocale, {
year: '2-digit', month: "2-digit",
day: "numeric"
}) + ", " + date.toLocaleTimeString(userLocale, {hour: 'numeric', minute: "numeric"});
}
function time_convert() {
let elems = document.querySelectorAll(".time");
elems.forEach((element) => {
if (/^[0-9]+$/.test(element.innerHTML)) {
element.innerHTML = convertToLocalTime(parseInt(element.innerHTML));
}
});
}
document.body.addEventListener("htmx:oobAfterSwap", time_convert);
</script>
<div style="display: flex; flex-direction: column; height:95vh;width:100%">
<div id="entries" hx-get="/entries" hx-trigger="load"></div>
<p style="text-align: center">Feel free to leave a message!</p>
<form id="inputForm" hx-post hx-swap="none" hx-on::after-request="this.reset(); time_convert()">
<div style="display: flex; width: calc(100% - 5px); gap: 20px">
<div style="display: flex; flex-direction: column; flex-basis: 100%">
<div style="display: flex; flex-direction: row; gap: 10px; align-items: center;">
<label for=" name">Name:<span style="color: red">*</span></label>
<input type="color" name="color" id="color" required value="#000000" />
</div>
<input type="text" id="name" name="name" autocomplete="off" required style="width: 100%" />
</div>
<div style="display: flex; flex-direction: column; flex-basis: 100%">
<label for="domain">Domain:</label>
<input type="text" id="domain" name="domain" autocomplete="off" style="width: 100%" />
</div>
</div>
<div>
<div style="display: flex; flex-direction: column; width: calc(100% - 5px);">
<label for="message">Message:<span style="color: red">*</span></label>
<textarea id="message" name="message" maxlength="1000" size=200
style="width: 100%; height:3.5em; margin-bottom:4px;" autocomplete="off" required></textarea>
<button type="submit">Submit</button>
</div>
</form>
</div>
</body>
</html>