facebook

MobiBike-News – RSS Reader Example

  1. MobiOne Archive
  2.  > 
  3. Examples, HOW-TOs
Viewing 11 posts - 46 through 56 (of 56 total)
  • Author
    Posts
  • #340832 Reply

    StephenBrown
    Member

    Any thoughts as to how I could create the array manually, in the same format as when there is more then one item returned. I’ve tried this but it isn’t working.

    This is how it is when more than 1 item is returned.
    $.getJSON( url, function( data ){
    events = data.query.results.rss;

    When only one item is returned I have tried this but it doesn’t work.

    $.getJSON( url, function( data ){
    if (data.query.count == 1)
    {
    events = [
    {
    channel: [
    {
    item: [
    {pubDate: data.query.results.rss.channel.item.pubDate},
    {title: data.query.results.rss.channel.item.title},
    {link: data.query.results.rss.channel.item.link},
    {description: [
    {content: data.query.results.rss.channel.item.description.content}
    ]
    }
    ]
    }
    ]
    }
    ];
    }
    else
    {
    events = data.query.results.rss;
    }

    #340851 Reply

    StephenBrown
    Member

    Finally have it working. I ended up building the array manually if there is only one item in the RSS feed.

    phoneui.showActivityDialog(‘Loading events…’);
    $.getJSON( url, function( data ){
    if (data.query.count == 1)
    {
    events =[
    {
    channel:
    {
    item:
    {
    pubDate: data.query.results.rss.channel.item.pubDate,
    title: data.query.results.rss.channel.item.title,
    link: data.query.results.rss.channel.item.link,
    description:
    {
    content: data.query.results.rss.channel.item.description.content
    }
    }
    }
    }
    ];
    }
    else
    {
    events = data.query.results.rss;
    }

    #340855 Reply

    StephenBrown
    Member

    And then I thought I’d check for when no items are returned. Thinking I could check for count = 0 I was surprised to find out that count = 1 for when no items are found. So I had to check if a field was undefined to branch appropriately. For the non-existent link for the showFullEvent function I just test if link is not equal to “no link” and don’t open the URL.

    phoneui.showActivityDialog(‘Loading events…’);
    $.getJSON( url, function( data ){
    if (data.query.count == 1) {
    if (typeof data.query.results.rss.channel.item === ‘undefined’)
    {
    events =[ { channel: { item: {
    pubDate: addMinutes(new Date(), -30),
    title: “No Upcoming Events”,
    link: “no link”,
    description:
    {content: “Check back again soon…”} } } } ];
    }
    else
    {
    events =[ { channel: { item: {
    pubDate: data.query.results.rss.channel.item.pubDate,
    title: data.query.results.rss.channel.item.title,
    link: data.query.results.rss.channel.item.link,
    description:
    {content: data.query.results.rss.channel.item.description.content} } } } ];
    }
    }
    else
    {
    events = data.query.results.rss;
    }

    And the function…

    function showFullEvent() {
    var url = events[curEventIdx].channel.item.link;
    if (url != “no link”) {
    window.open(url,”_blank”); }

    #340920 Reply

    Hi sjrowny,

    Can you post a small version of your project, some details about it, the code you have already written and where you are stuck. Then we can review it and provide you some feedback.

    #340964 Reply

    StephenBrown
    Member

    Thanks for replying, but I have got it all working. The code I used is in the last few posts.

    So all is good. The app is working well.

    #340967 Reply

    Hi sjrowny,

    Thanks for your follow up. Let us know if you need further assistance.

    #341109 Reply

    jeremy450
    Member

    Hi there

    I was wondering is there a way to add a icon to the rss feed?

    I mean it goes something like

    ——————————-
    _______
    | | Title
    | Icon | Description
    |______| Date

    ——————————-

    the icon is already in the app

    regards

    Jeremy

    #343013 Reply

    ayubsamar
    Member

    an anybody tell me the story or link me to where it is

    urdu news

    #343019 Reply

    support-michael
    Keymaster

    @ayubsamar, et al,
    We are developing an experimental componentized approach for an RSS reader. I hope to have more info in 2-3 weeks. If it all works out then we can replace of this shenanigan custom list stuff with a super simple approach.

    #347666 Reply

    hi,i make a app with rss and yql and i connect my rss with my database data is well coming when there is more then one record in rss but if there is only record coming in rss it is not show in app only loading is done record not shown.i cant solve this issue
    can anyone help please
    i will be very thankful to you

    #347667 Reply

    hi,i make a app with rss and yql and i connect my rss with my database data is well coming when there is more then one record in rss but if there is only record coming in rss it is not show in app only loading is done record not shown.i cant solve this issue
    can anyone help please
    i will be very thankful to you

Viewing 11 posts - 46 through 56 (of 56 total)
Reply To: MobiBike-News – RSS Reader Example

You must be logged in to post in the forum log in