Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MOBILE APP DEVELOPERS: Check out my code?

    I am in a Mobile App Dev class. Our current project is to create a webapp that allows a user to search for zip,city,etc and get back weather and news.

    I am having some issues in that my code is not working.

    Anyone have a moment to check it out?

    <!-- -->
    <!DOCTYPE html>

    <html lang="en-us">
    <head>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">


    <script type="text/javascript">

    function geo()
    {
    navigator.geolocation.getCurrentPosition(function(position) {
    do_something(position.coords.latitude, position.coords.longitude);});
    }

    function top_stories(o)
    {
    var items = o.query.results.item;
    var output = '';
    var no_items=items.length;
    for(var i=0;i<no_items;i++)
    {
    var title = items[i].title;
    var link = items[i].link;
    var desc = items[i].description;
    output += "<h3><a href='" + link + "'>"+title+"</a></h3>";// + desc + "<hr/>";
    }
    // Place news stories in div tag
    document.getElementById('results').innerHTML = output;
    }

    function cb_weather(yql)
    {
    var temp = yql.query.results.channel.item.description;
    var region = yql.query.results.channel.location.city +", "+ yql.query.results.channel.location.region;
    document.write("<H3>"+ region +"</H3>" +temp);
    }

    function save(zipcode)
    {
    localStorage.zipcode = zipcode.value;
    alert("Zip code is " + localStorage.zipcode);

    }

    </script>









    <title>Mobile Local</title>
    </head>
    <body>
    <div data-role="page" id="menu">


    <div data-role="header" data-theme="b">
    <h1>Mobile Local</h1>
    <a data-role="button" class="ui-btn-left" onclick="geo();">Locate Me!</a>
    </div>

    <div data-role="fieldcontain" data-inline="true">
    <label for="name">Enter your location:</label>
    <input type="text" name="zipcode" id="zipcode" value="" />
    <a data-role="button" onclick="save(zipcode); return false;" value="Save Data" />Search</a>
    </div>

    <div data-role="content" id='weather'>
    <script id="weather" src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D02446&format=json&callback=cb_weathe r'></script>
    </div>

    <div data-role="content" id='results' onload="geo()">
    <script src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%20%3D%20"http%3A%2F%2Fnews.google.com%2Fnews%3Fgeo%3D024 46%26output%3Drss"&format=json&diagnostics=true&callback=top_stories'></script>
    </div>

    </div>

    </body>
    </html>

  • #2
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for any and all help!

  • #3
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i assume i need to edit the URL in the lower body and then feed those results into the page but i am lost in how to execute that

    i feel like i may be overthinking this

  • #4
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    First of all, you have errors in your Javascript. Use a Javascript debugger (like Firebug for Firefox, or the built-in ones in Chrome or Safari) in order to get rid of those.

    Once there are no more errors, and you are still having problems, please don't just state "my code is not working" — explain how exactly the actual result of your code differs from the expected result.


  •  

    Posting Permissions

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