-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathapp.js
More file actions
66 lines (58 loc) · 1.58 KB
/
app.js
File metadata and controls
66 lines (58 loc) · 1.58 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
var allFeeds = [{
name: 'CSS Tricks',
url: 'http://feeds.feedburner.com/CssTricks'
}, {
name: 'HTML5 Rocks',
url: 'http://feeds.feedburner.com/html5rocks'
}, {
name: 'Linear Digressions',
url: 'http://feeds.feedburner.com/udacity-linear-digressions'
}];
function init() {
loadFeed(0);
$('body').removeClass('menu-hidden');
}
/* This function performs everything necessary to load a
* feed using the rss2json API.
* This function all supports a callback as the second parameter
* which will be called after everything has run successfully.
*/
function loadFeed(id, cb) {
$.ajax({
type: "GET",
url: 'https://api.rss2json.com/v1/api.json',
data: {
rss_url: 'http://feeds.feedburner.com/CssTricks'
},
success: function (result, status) {
if (cb) {
cb( /*something*/ );
}
},
error: function (result, status, err) {
//run only the callback without attempting to parse result due to error
if (cb) {
cb();
}
},
dataType: "json"
});
}
window.onload = init;
$(function () {
var feedList = $('.feed-list'),
feedItemTemplate = Handlebars.compile($('.tpl-feed-list-item').html()),
menuIcon = $('.menu-icon-link');
allFeeds.forEach(function (feed) {
feedList.append(feedItemTemplate(feed));
});
feedList.on('click', function () {
var item = $(this);
$('body').addClass( /*A class here*/ );
loadFeed(item.data('id'));
return false;
});
/* When the menu icon is clicked on, we need to toggle a class
* on the body to perform the hiding/showing of our menu.
*/
}());