-
Notifications
You must be signed in to change notification settings - Fork 3
/
feeder.js
63 lines (55 loc) · 1.15 KB
/
feeder.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
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
function feeder()
{
var feedAddresses = [
"http://jtorn.wordpress.com/feed",
"http://fraseraddison.wordpress.com/feed",
"http://kmouse.wordpress.com/feed"];
var count = 0;
//google.load('feeds','1');
google.load('feeds', '1', {callback : onGoogleReady});
function onGoogleReady()
{
//var callback = populateRSSFeed('feed');
var callback = getFeed();
for (i = 0; i < feedAddresses.length; i++)
{
var address = feedAddresses[i];
console.log("Retrieving feed from "+address+" ...");
initializeRSSFeed(callback, address);
}
}
google.setOnLoadCallback(onGoogleReady);
function initializeRSSFeed(callback, targetFeed)
{
var feed = new google.feeds.Feed(targetFeed);
feed.load(callback);
}
function getFeed()
{
return function callback(result)
{
if (!result.error)
{
console.log("Feed retrieved.");
fireFeed(result.feed);
}
else
console.log("Feed retrieval failed!");
}
}
function fireFeed(feed)
{
//console.log(feed);
var event = new CustomEvent(
"newFeed",
{
detail: {
message: feed
},
bubbles: true,
cancelable: true
}
);
document.dispatchEvent(event);
}
}