/
fancy.js
47 lines (39 loc) · 1.11 KB
/
fancy.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
(function($) {
'use strict';
$.fn.lifestream.feeds.fancy = function( config, callback ) {
var template = $.extend({},
{
fancied: 'fancy\'d <a href="${link}">${title}</a>'
},
config.template),
parseFancy = function( input ) {
var output = [], i = 0, j;
if(input.query && input.query.count && input.query.count > 0) {
j = input.query.count;
for( ; i<j; i++) {
var item = input.query.results.item[i];
output.push({
date: new Date(item.pubDate),
config: config,
html: $.tmpl( template.fancied, item )
});
}
}
return output;
};
$.ajax({
url: $.fn.lifestream.createYqlUrl('SELECT * FROM xml ' +
'WHERE url="http://www.fancy.com/rss/' + config.user +
'" AND itemPath="/rss/channel/item"'),
dataType: 'jsonp',
success: function( data ) {
callback(parseFancy(data));
}
});
// Expose the template.
// We use this to check which templates are available
return {
"template" : template
};
};
})(jQuery);