Go Back   CodingForums.com > :: Client side development > General web building > Building for mobile devices

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-16-2011, 05:22 PM   PM User | #1
inamorata
New to the CF scene

 
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
inamorata is an unknown quantity at this point
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?

Quote:
<!-- -->
<!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>
inamorata is offline   Reply With Quote
Old 02-16-2011, 05:23 PM   PM User | #2
inamorata
New to the CF scene

 
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
inamorata is an unknown quantity at this point
Thank you for any and all help!
inamorata is offline   Reply With Quote
Old 02-16-2011, 05:24 PM   PM User | #3
inamorata
New to the CF scene

 
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
inamorata is an unknown quantity at this point
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
inamorata is offline   Reply With Quote
Old 02-16-2011, 06:33 PM   PM User | #4
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
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.
venegal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:26 PM.


Advertisement
Log in to turn off these ads.