/rssreadercamden Secret
Created
February 17, 2013 20:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajaxSetup({ | |
error:function(x,e,errorThrown) { | |
console.log(x.getStatusCode()); | |
$("#status").prepend("Error!"); | |
} | |
}); | |
//EDIT THESE LINES | |
//Title of the blog | |
//RSS url | |
var RSS = "http://www.rtl.nl/service/rss/rtlnieuws/index.xml"; | |
//Stores entries | |
var entries = []; | |
var selectedEntry = ""; | |
//listen for detail links | |
$(".contentLink").live("click", function() { | |
selectedEntry = $(this).data("entryid"); | |
}); | |
//Listen for main page | |
$("#columns").live("pageinit", function() { | |
//Set the title | |
$.get(RSS, {}, function(res, code) { | |
entries = []; | |
var xml = $(res); | |
var items = xml.find("item"); | |
$.each(items, function(i, v) { | |
entry = { | |
title:$(v).find("title").text(), | |
link:$(v).find("link").text(), | |
img:$(v).find("enclosure").attr("url"), | |
description:$.trim($(v).find("description").text()) | |
}; | |
entries.push(entry); | |
}); | |
$(window).bind('load', function() { | |
$('img').each(function() { | |
if((typeof this.naturalWidth != "undefined" && | |
this.naturalWidth == 0 ) | |
|| this.readyState == 'uninitialized' ) { | |
$(this).attr('src', 'images/leeg.png'); | |
} | |
}); }) | |
//now draw the list | |
var s = ''; | |
$.each(entries, function(i, v) { | |
s += '<li><img class="ui-li-thumb" src="' + v.img + '" height="48" border="0"><a href="#contentPage" class="contentLink" data-entryid="'+i+'" data-transition="slide">' + v.title + '</a><h7 class="ui-li-desc-columns">' + v.description + '</h7></li>'; | |
}); | |
$("#linksList").html(s); | |
$("#linksList").listview("refresh"); | |
}); | |
}); | |
//Listen for the content page to load | |
$("#contentPage").live("pageshow", function(prepage) { | |
//Set the title | |
var contentHTML = ""; | |
contentHTML += '<h3 class="titlecolumnlist" >'+entries[selectedEntry].title + '</h3>'; | |
contentHTML += '<img src="'+entries[selectedEntry].img + '" border="0">'; | |
contentHTML += entries[selectedEntry].description; | |
// contentHTML += '<br/><br/><a href="'+entries[selectedEntry].link + '" data-role="button" data-icon="star" data-iconpos="right" target="_blank">Lees verder op de website</a>'; | |
$("#entryText",this).html(contentHTML); | |
$("#entryText").listview("refresh"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment