Skip to content

Instantly share code, notes, and snippets.

@kuilbop
Created February 17, 2013 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuilbop/8a81a63f58d49ba2255a to your computer and use it in GitHub Desktop.
Save kuilbop/8a81a63f58d49ba2255a to your computer and use it in GitHub Desktop.
$.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