×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    281

    Bug in Nokia example code (rss reading jquery.jfeed.js)

    Hello developers,

    I found an error in example code from Nokia. The code is used in several example projects, and it is in the code for reading a feed.
    It is for example in the news reader example, in the file "jquery.jfeed.js"

    I think the bug will cause that the feed reader does not accept gif as media, but instead other types.

    Look at this:


    Code:
    if(media.length > 0 && jQuery.inArray(media.eq(0).attr('type'), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png'])) {
    ...
    }

    Problem is that the jQuery-Method inArray() returns -1 if not found. Otherwise it returns the index of the found element. So it returns 0 for "image/gif" and this evaluates to false.
    See api.jquery.com/jQuery.inArray/

    The $.inArray() method is similar to JavaScript's native .indexOf() method in that it returns -1 when it doesn't find a match. If the first element within the array matches value, $.inArray() returns 0.

    Because JavaScript treats 0 as loosely equal to false (i.e. 0 == false, but 0 !== false), if we're checking for the presence of value within array, we need to check if it's not equal to (or greater than) -1.
    So the code need to be corrected to

    Code:
    if(media.length > 0 && (jQuery.inArray(media.eq(0).attr('type'), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png'])) > -1 ) {
    Regards

    Karsten Meier

  2. #2
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    281

    Re: Bug in Nokia example code (rss reading jquery.jfeed.js)

    I see this bug still in WebTools 3.0.1 released today, at least in the "NewsReader" example.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Bug in Nokia example code (rss reading jquery.jfeed.js)

    Thank you for the report, I hope that internal moderators (Ilkka and Jason saw this report according to the bottom of the page) forwarded the issue somewhere.
    The presence of the bug in the new version is pretty normal, releasing a tool is (hopefully) a more detailed process than "hey, it builds at last, I just zip it and push it on the Web site". So it was probably ready for time, gone under some testing and/or waiting for Nokia World.

Similar Threads

  1. Jquery Ajax response in Nokia 501
    By samdonly1 in forum Nokia Asha Web Apps
    Replies: 1
    Last Post: 2013-06-03, 19:07
  2. [moved] Emdeding Jquery Mobile on Nokia Asha web app tools
    By ngugi in forum Nokia Asha Web Apps
    Replies: 3
    Last Post: 2013-05-23, 14:03
  3. Got jquery mobile working on nokia..
    By bnolan in forum Symbian
    Replies: 3
    Last Post: 2010-12-07, 22:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •