-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
61 lines (54 loc) · 1.84 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
60
61
<!DOCTYPE html>
<html>
<head>
<script src="http://j.mp/jqymin"></script>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<title>reddit listen</title>
</head>
<body>
<div id="main">
<div id="content" data-hires="true">
<ul id="reddit-webdev_top">
<li class="title">/webdev Beliebt</li>
</ul>
<ul id="reddit-webdev_new">
<li class="title">/webdev Neu</li>
</ul>
</div>
</div>
<script>
function getReddit(subreddit,url) {
var reddits = '';
$.getJSON(
url,
function foo(data)
{
//var str = JSON.stringify(data, undefined, 2);
//document.body.appendChild(document.createElement('pre')).innerHTML = str;
$.each(
data.data.children.slice(0, 10),
function (i, post) {
var day = moment.utc(post.data.created_utc, 'X').format('DD.MM.YY')
console.log(day);
var votes = post.data.ups - post.data.downs;
reddits += '<dl><dt>'+day+'</dt><dd><a href="'+ post.data.url +'" target="_blank"> ' + post.data.title + '</a> - <a href="http://www.reddit.com/'+post.data.permalink+'" target="_blank">reddit</a></dd></dl>';
}
)
$("#reddit-"+subreddit).append('<li>'+reddits+'</li>');
}
)
.success(function() { })
.error(function() { })
.complete(function() { });
}
</script>
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://momentjs.com/downloads/moment-with-locales.js"></script>
<script>
$(document).ready(function() {
getReddit('webdev_top','http://www.reddit.com/r/webdev.json');
getReddit('webdev_new','http://www.reddit.com/r/webdev/new.json');
});
</script>
</body>
</html>