-
Notifications
You must be signed in to change notification settings - Fork 0
/
home_template.go
69 lines (59 loc) · 1.64 KB
/
home_template.go
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
package main
import "html/template"
var homeTemplate *template.Template
func init() {
homeTemplate = template.Must(template.New("home").Parse(`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>txt-ink</title>
<style>
@import url('https://fonts.googleapis.com/css?family=Quattrocento:700&display=swap');
body, textarea, button {
font-size: 200%;
font-family: 'Quattrocento', serif;
font-weight: bold;
line-height: 1.5em;
}
body {
margin: 0;
padding: 1em;
background-color: white;
}
textarea {
width: 100%;
font-size: 1em;
resize: none;
border: none;
display: block;
}
button {
display: block;
background: none;
box-shadow: none;
border: 2px solid #000;
border-radius: 3px;
font-size: 100%;
width: 100%;
background-color: #cdeaff;
}
</style>
</head>
<body>
<form id="messageForm" action="/message" method="post">
<textarea id="textArea" name="message" autofocus="true" rows="3" placeholder="{{.Message}}"></textarea>
<button id="sendButton" type="submit">send</button>
</form>
<script type="text/javascript">
messageForm = document.getElementById("messageForm")
textArea = document.getElementById("textArea")
textArea.addEventListener("keypress", function(e) {
if (event.which === 13) {
event.preventDefault();
messageForm.dispatchEvent(new Event("submit", {cancelable: true}));
}
});
</script>
</body>
</html>`))
}