-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_document.go
More file actions
118 lines (97 loc) · 2.39 KB
/
Copy pathhtml_document.go
File metadata and controls
118 lines (97 loc) · 2.39 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package htmldump
import (
"fmt"
"io"
)
type htmlDocument struct {
writer io.Writer
body string
}
func (doc *htmlDocument) save() (int, error) {
num, err := io.WriteString(doc.writer, doc.body)
if err != nil {
werr := fmt.Errorf("[(doc *htmlDocument) save()] writing to io.Writer error: %w", err)
return 0, werr
}
return num, nil
}
// Add HTML table row to the document body.
func (doc *htmlDocument) add(str string) *htmlDocument {
doc.body += str + "\n"
return doc
}
func newHTMLDocument(writer io.Writer) *htmlDocument {
doc := &htmlDocument{
writer: writer,
body: ``,
}
doc.body += `<!DOCTYPE html>
<html>
<head>
<style>
.styled-table {
border-collapse: collapse;
margin: 25px 0;
font-size: 0.9em;
font-family: sans-serif;
min-width: 400px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
border: 2px solid rgb(150, 150, 150);
border-top: none;
}
.styled-table caption {
text-align: left;
font-size: 1.5em;
font-weight: bold;
padding: 7px;
background-color: rgb(220, 220, 220);
border-top: 2px solid rgb(150, 150, 150);
border-left: 2px solid rgb(150, 150, 150);
border-right: 2px solid rgb(150, 150, 150);
border-bottom: none;
}
.styled-table thead tr {
white-space: nowrap;
background-color: #009879;
color: #ffffff;
text-align: center;
}
.styled-table thead tr th {
border: 1px solid #006e58;
}
.styled-table thead tr:first-of-type {
border-top: 2px solid #009879;
}
.styled-table thead tr:last-of-type {
border-bottom: 2px solid #009879;
}
.styled-table tbody tr {
border-bottom: 1px solid #dddddd;
}
.styled-table tbody tr td.key{
color: #006650;
font-weight: bold;
}
.styled-table tbody tr td{
border-right: 1px solid #dddddd;
}
.styled-table tbody tr:nth-child(even) {background: rgb(230, 230, 230)}
.styled-table tbody tr:nth-child(odd) {background: rgb(250, 250, 250)}
.styled-table th,
.styled-table td {
padding: 4px 7px;
}
.styled-table tbody tr:hover {
color: #006650;
}
</style>
</head>
<body>
<script>
setInterval(function () {
location.reload();
}, 2000);
</script>
`
return doc
}