start-ffhh/js/main.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-09-10 16:49:19 +02:00
var rss = [
'hamburg.freifunk.net'
];
2014-09-12 15:45:34 +02:00
var MAX_RSS = 5;
2014-09-10 16:49:19 +02:00
$(document).ready(function() {
2014-09-12 15:45:34 +02:00
var i = 0;
2014-09-10 16:49:19 +02:00
rss.forEach(function(feed) {
$.get('/feeds/' + feed + '.rss', function(data) {
2014-09-10 17:19:25 +02:00
$(data).find('item').forEach(function(entry) {
2014-09-12 15:45:34 +02:00
if(i >= MAX_RSS) return;
2014-09-10 17:19:25 +02:00
var title = $(entry).find('title').text();
var link = $(entry).find('link').text();
2014-09-10 16:49:19 +02:00
var item = $('<a>')
2014-09-12 15:44:22 +02:00
.attr('class', 'css-truncate')
2014-09-10 16:49:19 +02:00
.attr('href', link)
.attr('target', '_blank')
.text(title);
$('#news').append($('<li>').append(item));
2014-09-12 15:45:34 +02:00
i++;
2014-09-10 16:49:19 +02:00
});
2014-09-12 15:57:50 +02:00
$(data).find('entry').forEach(function(entry) {
if(i >= MAX_RSS) return;
var title = $(entry).find('title').text();
var link = $(entry).find('link').attr('href');
var item = $('<a>')
.attr('class', 'css-truncate')
.attr('href', link)
.attr('target', '_blank')
.text(title);
$('#news').append($('<li>').append(item));
i++;
});
2014-09-10 16:49:19 +02:00
});
});
});