snipplrCallback({"id":51140,"title":"jquery-mobile-on-the-playbook-webworks-sdk","source":"
<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN"<\/span><\/div><\/li> "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd"><\/span><\/div><\/li> <html<\/span><\/a> xmlns=<\/span>"http:\/\/www.w3.org\/1999\/xhtml"<\/span>><\/span><\/div><\/li> <head<\/span><\/a>><\/span><\/div><\/li> <meta<\/span><\/a> http-equiv<\/span>=<\/span>"Content-Type"<\/span> content<\/span>=<\/span>"text\/html; charset=UTF-8"<\/span> \/<\/span>><\/span><\/div><\/li> <title<\/span><\/a>><\/span>Landmark Finder<\/<\/span>title<\/span><\/a>><\/span><\/div><\/li> <link<\/span><\/a> rel<\/span>=<\/span>"stylesheet"<\/span> href<\/span>=<\/span>"jquery.mobile-1.0a3.min.css"<\/span> \/<\/span>><\/span><\/div><\/li> <script<\/span><\/a> src<\/span>=<\/span>"jquery-1.5.min.js"<\/span>><\/<\/span>script<\/span><\/a>><\/span><\/div><\/li> <script<\/span><\/a> src<\/span>=<\/span>"jquery.mobile-1.0a3.min.js"<\/span>><\/<\/span>script<\/span><\/a>><\/span><\/div><\/li> <script<\/span><\/a> type<\/span>=<\/span>"application\/javascript"<\/span>><\/span><\/div><\/li> $(document).ready(function(){<\/div><\/li> \t\/\/ Add a click listener on the button to get the location data<\/div><\/li> \t$('#getLocation').click(function(){<\/div><\/li> \t\tif (navigator.geolocation) {<\/div><\/li> \t\t\tnavigator.geolocation.getCurrentPosition(onSuccess, onError);<\/div><\/li> \t\t} else {<\/div><\/li> \t\t\t\/\/ If location is not supported on this platform, disable it<\/div><\/li> \t\t\t$('#getLocation').value = "Geolocation not supported";<\/div><\/li> \t\t\t$('#getLocation').unbind('click');<\/div><\/li> \t\t}\t\t<\/div><\/li> \t});<\/div><\/li> });<\/div><\/li> <\/div><\/li> \/\/ create the geonames namespace for calling the API<\/div><\/li> var geonames = {};<\/div><\/li> \tgeonames.baseURL = "http:\/\/ws.geonames.org\/";<\/div><\/li> \tgeonames.method = "findNearbyWikipediaJSON";<\/div><\/li> \tgeonames.search = function(lat,lng){<\/div><\/li> <\/div><\/li> \t\/\/ get the data in JSON format from Geonames<\/div><\/li> \t$.getJSON(geonames.baseURL + geonames.method + '?formatted=true&lat=' + lat + <\/span><\/div><\/li> '&lng=' + lng + '&style=full&radius=10&maxRows=25&username=ryanstewart',function(data){<\/span><\/div><\/li> <\/div><\/li> \t\t\/\/ Loop through each item in the result and add it to the DOM<\/span><\/div><\/li> \t\t$.each(data.geonames, function() {<\/span><\/div><\/li> \t\t\t$('<li><\/li>')<\/span><\/div><\/li> \t\t\t.hide()<\/span><\/div><\/li> \t\t\t.append('<a href="http:\/\/'+this.wikipediaUrl+'"><\/span><\/div><\/li> <h2>'+this.title+'<\/h2><\/a><br \/><p>'+ this.summary + '<\/p><span class="ui-li-aside"><\/span><\/div><\/li> <h5>'+this.distance+' (km)<\/h5><\/span>')<\/span><\/div><\/li> \t\t\t.appendTo('#wikiList')<\/span><\/div><\/li> \t\t\t.show();<\/span><\/div><\/li> \t\t});<\/div><\/li> \t\t\/\/ Once the data is added to the DOM, make the transition<\/div><\/li> \t\t$.mobile.changePage('#dashboard',"slide",false,true);<\/div><\/li> <\/div><\/li> \t\t\/\/ refresh the list to make sure the theme applies properly<\/div><\/li> \t\t$('#wikiList').listview('refresh');<\/div><\/li> <\/div><\/li> <\/div><\/li> \t});<\/div><\/li> };<\/div><\/li> <\/div><\/li> \/\/ Success function for Geolocation call<\/div><\/li> function onSuccess(position)<\/div><\/li> {<\/div><\/li> \talert('getting position');<\/div><\/li> \tgeonames.search(position.coords.latitude,position.coords.longitude);<\/div><\/li> }<\/div><\/li> <\/div><\/li> \/\/ Error function for Geolocation call<\/div><\/li>