-
Notifications
You must be signed in to change notification settings - Fork 11
/
FeedReader.js
27 lines (23 loc) · 1006 Bytes
/
FeedReader.js
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
let API = "https://api.rss2json.com/v1/api.json?rss_url=";
let userFeedURLs = localStorage.getItem('userFeedURLs');
userFeedURLs = userFeedURLs.split(",")
userFeedURLs.forEach(userUrl => {
$.ajax({
type: 'GET',
url: API + userUrl,
dataType: 'jsonp',
success: function (data) {
console.log(data);
data.items.forEach(item => {
var content = document.getElementById('content');
var newItem = "";
newItem += "<div class=\"container\" id=\"item\"><a href=\"" + item.link + "\"><h1>" + item.title + "</h1></a>" + "<h4> from " + data.feed.title + "</h4>";
if (item.author != "")
newItem += "<h4> By " + item.author + "</h4>";
newItem += "<h4>Published Date: " + item.pubDate + "</h4>";
newItem += item.description + "<hr></div>";
content.insertAdjacentHTML('beforeend', newItem);
});
}
});
});