/
atom.js
49 lines (42 loc) · 1.08 KB
/
atom.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
(function($) {
$.fn.lifestream.feeds.atom = function( config, callback ) {
var template = $.extend({},
{
posted: 'posted <a href="${link.href}">${title.content}</a>'
},
config.template),
/**
* Parse the input from atom feed
*/
parseAtom = function( input ) {
var output = [], list = [], i = 0, j = 0, url = '';
if(input.query && input.query.count && input.query.count > 0) {
list = input.query.results.feed.entry;
j = list.length;
for( ; i<j; i++) {
var item = list[i];
output.push({
url: item.link.href,
date: new Date( item.updated ),
config: config,
html: $.tmpl( template.posted, item )
});
}
}
return output;
};
$.ajax({
url: $.fn.lifestream.createYqlUrl('select * from xml where url="' +
config.user + '"'),
dataType: 'jsonp',
success: function( data ) {
callback(parseAtom(data));
}
});
// Expose the template.
// We use this to check which templates are available
return {
"template" : template
};
};
})(jQuery);