-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
69 lines (62 loc) · 2.01 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
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<style>
#banner {
background: #ff6600;
border-radius: 6px;
padding: 20px;
margin: 10px;
color: #fff;
font-size: 29px;
font-family: "Helvetica Neue";
font-weight: 100;
}
</style>
<html lang="en">
<head>
<div id="banner">
<span id="banner-message">Hacker News Feed</span>
</div>
<meta charset="utf-8">
<link href="./bootstrap.css" rel="stylesheet">
</head>
<body>
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-PZWSZ2"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PZWSZ2');</script>
<!-- End Google Tag Manager -->
<table id="feed" class="table table-striped"> </table>
<script src="http://cdn.pubnub.com/pubnub.min.js"></script>
<script>
function createTable(json) {
var table = document.getElementById("feed");
table.innerHTML = "";
for (var i = 0; i < 30; i++) {
var row = table.insertRow(i);
var obj = json[i];
cell1 = row.insertCell(0);
cell2 = row.insertCell(1);
cell3 = row.insertCell(2);
cell1.innerHTML = obj["rank"];
cell2.innerHTML = '<a href="'+obj["link"]+'" target="_blank">'+obj["title"]+'</a>';
cell3.innerHTML = '<a href="'+obj["comments"]+'" target="_blank">'+"Comments"+'</a>';
}
}
function pubSub(){
var pubnub = PUBNUB.init({
publish_key: "demo",
subscribe_key: "demo"
});
pubnub.subscribe({
channel: "hacker-news",
message: createTable
});
}
pubSub();
</script>
</body>
</html>