-
Notifications
You must be signed in to change notification settings - Fork 37
/
hnpolls_pith.html
45 lines (45 loc) · 1.39 KB
/
hnpolls_pith.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
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="initial-scale=1.0, minimum-scale=0.25">
<style>
body {
font-family: sans-serif;
font-size: 1em;
}
td {
padding: 4px;
vertical-align: top;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #121212;
color: #888;
}
}
</style>
<title>HN Polls</title>
</head>
<body>
<h1>HN Polls</h1>
<div id=app>Loading...</div>
<br>
<div>Source code on <a href=https://github.com/gabrielsroka/gabrielsroka.github.io/blob/master/hnpolls_pith.html target=_blank>GitHub</a></div>
<div>Using the <a href=https://hn.algolia.com/api target=_blank>HN Search API</a></div>
<script type='text/pith'>
tab = 4
# see https://hn.algolia.com/api
page = new URLSearchParams(location.search).get('page') || 0
polls = await getJson(`https://hn.algolia.com/api/v1/search_by_date?tags=poll&page=${page}`)
if polls.message
app.innerHTML = polls.message
else
app.innerHTML = `<table id=table><thead></thead><tbody></tbody></table><br><a href=?page=${+page + 1}>Next ></a>`
| 'Title<th>Created At<th>Author<th>Points<th>Num Comments'
for p in polls.hits
d = p.created_at.replace(/(T|\.000Z)/g, ' ')
+ `<a href=hnpoll.html?id=${p.objectID} target=_blank>${p.title}</a><td>${d}<td>${p.author}<td align=right>${p.points}<td align=right>${p.num_comments}`
</script>
<script src=/pith.js></script>
</body>
</html>