/
opensuse-news.js
45 lines (35 loc) · 1.23 KB
/
opensuse-news.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
// XML news reader
$(function () {
$.ajax({
url: 'https://news.opensuse.org/feed.xml', //change to: opensuse.xml if you are testing locally
dataType: "xml",
success: function(xmldata) {
$(xmldata).find('item').each(function(){
$title = $(this).find('title').text();
$link = $(this).find('link').text();
$description = $(this).find('description').text();
//insert the data in the slider
$titleHTML = '<h3 class="opensuse-blue strong-title">'
+ $title
+ '</h3>';
$linkHTML = '<a href="'
+ $link
+ '">'
+ $titleHTML
+ '</a>';
$descriptionHTML = '<p class="opensuse-blue">'
+ $description
+ '</p>';
$newsSlider = '<div class="row">'
+ '<div class="col-sm-8 col-sm-offset-2 text-center">'
+ $linkHTML
+ $descriptionHTML
+ '</div>'
+ '</div>';
// add the items to the OWL carousel
var owl = $('#owl-slide-news')
owl.data('owlCarousel').addItem($newsSlider)
})
}
})
});