forked from jsomers/hacker-classics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
139 lines (121 loc) · 5.22 KB
/
index.html
File metadata and controls
139 lines (121 loc) · 5.22 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="https://news.ycombinator.com/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="https://news.ycombinator.com/news.css">
<title>Philosophy Hacker News</title>
<style>
.about {
padding: 10px;
}
.about p a:visited {
color: #000000;
}
</style>
</head>
<script>
var getJSON = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function () {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
var hostname = function (url) {
var a = document.createElement('a');
a.href = url;
var index = (a.hostname.indexOf(".co.") == -1 ? -2 : -3);
return a.hostname.split(".").slice(index).join(".");
}
var ago = function (timestamp) {
var d = new Date(timestamp);
var arr = d.toDateString().split(" ").slice(1, 4);
return `on ${arr[0]} ${arr[1]}, ${arr[2]}`;
}
getJSON("stories.json", function (err, data) {
var seen_titles = {};
document.getElementById("loader").style.display = 'none';
var html = `
<table id="hnmain" border="0" cellpadding="0" cellspacing="0" width="85%" bgcolor="#f6f6ef">
<tr><td bgcolor="#00dd22">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding:2px"><tr>
<td style="width:18px;padding-right:4px"><a href="https://news.ycombinator.com"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Le_Penseur_by_Rodin_%28Kunsthalle_Bielefeld%29_2014-04-10.JPG/250px-Le_Penseur_by_Rodin_%28Kunsthalle_Bielefeld%29_2014-04-10.JPG" width="18" height="18" style="border:1px white solid;"></a></td>
<td style="line-height:12pt; height:10px;"><span class="pagetop">
<b class="hnname"><a href="/">Philosophy Hacker News</a></b>
<a target="_blank" href="https://news.ycombinator.com/newest">new</a> |
<a target="_blank" href="https://news.ycombinator.com/newcomments">comments</a> |
<a target="_blank" href="https://news.ycombinator.com/show">show</a> |
<a target="_blank" href="https://news.ycombinator.com/ask">ask</a> |
<a target="_blank" href="https://news.ycombinator.com/jobs">jobs</a> |
<a target="_blank" href="https://news.ycombinator.com/submit">submit</a>
</span></td>
</tr></table>
</td></tr>
<tr style="height:10px"></tr>
<tr><td><table border="0" cellpadding="0" cellspacing="0" class="itemlist">
`;
let allStories = [];
for (var topic in data) {
allStories = allStories.concat(data[topic]);
}
allStories.sort((a, b) => b.points - a.points);
for (var i in allStories) {
var story = allStories[i];
if (seen_titles[story.title]) continue;
seen_titles[story.title] = 1;
var story_url = story.url || ("https://news.ycombinator.com/item?id=" + story.objectID);
var domain_display = story.url ? 'inline' : 'none';
var domain = hostname(story_url);
html += `
<tr class='athing' id='${i}'>
<td align="right" valign="top" class="title"><span class="rank">§.</span></td>
<td valign="top" class="votelinks"><center> </center></td>
<td class="title">
<a href="${story_url}" target="_blank" class="storylink">${story.title}</a>
<span class="sitebit comhead" style="display: ${domain_display}"> (<a href="https://news.ycombinator.com/from?site=${domain}" target="_blank"><span class="sitestr">${domain}</span></a>)</span>
</td>
</tr>
<tr><td colspan="2"></td><td class="subtext">
<span class="score" id="score_${i}">${story.points} points</span> by <a href="https://news.ycombinator.com/user?id=${story.author}" class="hnuser">${story.author}</a>
<span class="age"><a href="https://news.ycombinator.com/item?id=${story.objectID}" target="_blank">${ago(story.created_at)}</a></span> <span id="unv_16413917"></span> |
<a href="https://news.ycombinator.com/item?id=${story.objectID}" target="_blank">${story.num_comments} comments</a>
</td></tr>
<tr class="spacer" style="height:5px"></tr>
`;
};
html += '</table></td></tr></table></td></tr>';
document.getElementById("placeholder").innerHTML = html;
// Restore previous scroll position from localStorage on load
if (localStorage.hc_scroll_y) {
window.scrollTo(window.scrollX, parseInt(localStorage.hc_scroll_y));
}
// Save scroll position
window.addEventListener(
'scroll',
() => {
localStorage.hc_scroll_y = window.scrollY;
},
{ passive: true }
);
})
</script>
<div class="about">
<p>A fork of <a href="https://jsomers.net/hn/">Hacker Classics</a> by <a
href="https://github.com/jsomers/hacker-classics">jsomers</a>.</p>
<p>Filters for discussions with "philosophy", "history" and "literature" in the title bur not "engineer", "tech", "software" and "programming". Ranked by points (minimum 50).
</p>
</div>
<center>
<span id="placeholder"></span>
<img src="loader.gif" id="loader">
</center>
</html>