Results 1 to 4 of 4

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.

Thread: Weather Script...

  1. #1
    Default Weather Script...
    ok, i have a few different weather scripts.. all from free themes.

    i am trying to make a new theme and cant get the same scripts to work on mine. problem is that most of them are all over the place, with unneeded functions, etc

    does anyone have a simple get weather script?

    (ps.. are there any scripts that can be tested on a reg browser? all of these use webkit only code/functions)


    here is the code i am using... its the xml_loaded that never calls.
    var locale = "XXXXXX" //put your code in here to test
    	var isCelsius = false
    	var updateInterval = 5
    	var postal;
    	var demoMode = false;
    	var enabled;
    function onLoad(){
    		validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)
    function convertTemp(num)
    	if (isCelsius == true)
    		return Math.round ((num - 32) * 5 / 9);
    		return num;
    function setPostal(obj){
    	if (obj.error == false){
    		if(obj.cities.length > 0){
    			postal = escape(obj.cities[0].zip).replace(/^%u/g, "%");
    			//document.getElementById("WeatherContainer").className = "";
    			document.getElementById("city").innerText="Not Found";
    			//document.getElementById("WeatherContainer").className = "errorLocaleNotFound";
    		//document.getElementById("WeatherContainer").className = "errorLocaleValidate";
    		setTimeout('validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)', Math.round(1000*60*5));
    function dealWithWeather(obj){
    	if (obj.error == false){
    		if(useRealFeel == true){
    				tempValue = convertTemp(obj.realFeel);
    				tempValue = convertTemp(obj.temp);
    		document.getElementById("city").innerHTML="Location: " +;
    		document.getElementById("cond").innerHTML="Ambient Temp: " + tempValue + "°"
    			document.getElementById("city").innerHTML = "errorWeatherDataFetch";
    function weatherRefresherTemp(){
    var MiniIcons =
    					"tornado",							//0 	tornado X
    					"tropical_storm",				//1 	tropical storm X
    					"hurricane",						//2 	hurricane X
    					"severe_thunderstorms",	//3 	severe thunderstorms X
    					"thunderstorms",				//4 	thunderstorms X
    					"rain_snow",						//5 	mixed rain and snow X
    					"rain_sleet",						//6 	mixed rain and sleet X
    					"snow_sleet",						//7 	mixed snow and sleet X
    					"freezing_drizzle",			//8 	freezing drizzle X
    					"light_rain",						//9 	drizzle X
    					"freezing_rain",				//10 	freezing rain X
    					"light_rain",						//11 	showers X
    					"showers",							//12 	showers X
    					"snow_flurries",				//13 	snow flurries X
    					"light_snow",						//14 	light snow showers X
    					"blowing_snow",					//15 	blowing snow X
    					"snow",									//16 	snow X
    					"hail",									//17 	hail X
    					"sleet",								//18 	sleet X
    					"dust",									//19 	dust X
    					"fog",									//20 	foggy X
    					"haze",									//21 	haze X
    					"smoky",								//22 	smoky X
    					"blustery",							//23 	blustery X
    					"windy",								//24 	windy X
    					"overcast",							//25 	cold X
    					"cloudy",								//26 	cloudy X
    					"mostly_cloudy_night",	//27 	mostly cloudy (night) X
    					"mostly_cloudy",				//28 	mostly cloudy (day) X
    					"partly_cloudy_night",	//29 	partly cloudy (night) X
    					"partly_cloudy",				//30 	partly cloudy (day) X
    					"clear",								//31 	clear (night) X
    					"clear",								//32 	sunny X
    					"fair_night",						//33 	fair (night) X
    					"fair",									//34 	fair (day) X
    					"rain_hail",						//35 	mixed rain and hail X
    					"hot",									//36 	hot X
    					"iso_thnderstrm",				//37 	isolated thunderstorms X
    					"sctrd_thnderstrm",			//38 	scattered thunderstorms X
    					"sctrd_thnderstrm",			//39 	scattered thunderstorms X
    					"sctrd_showers",				//40 	scattered showers X
    					"heavy_snow",						//41 	heavy snow X
    					"snow3",								//42 	scattered snow showers
    					"heavy_snow",						//43 	heavy snow X
    					"partly_cloudy",				//44 	partly cloudy X
    					"thundershowers",				//45 	thundershowers X
    					"light_snow",						//46 	snow showers X
    					"iso_thundershowers",		//47 	isolated thundershowers X
    					"dunno",								//3200 not available X
    function constructError (string)
    	return {error:true, errorString:string};
    function findChild (element, nodeName)
    	var child;
    	for (child = element.firstChild; child != null; child = child.nextSibling)
    		if (child.nodeName == nodeName)
    			return child;
    	return null;
    function fetchWeatherData (callback, zip)
    		url="" //u=Farenheit, because accuWeather sucks
    		var xml_request = new XMLHttpRequest();
    		xml_request.onload = function(e) {xml_loaded(e, xml_request, callback);}
    		xml_request.overrideMimeType("text/xml");"GET", url+zip);
    		xml_request.setRequestHeader("Cache-Control", "no-cache");
    		return xml_request;
    function xml_loaded (event, request, callback){
    	if (request.responseXML)
    			var obj = {error:false, errorString:null};
    			var effectiveRoot = findChild(findChild(request.responseXML, "rss"), "channel"); = findChild(effectiveRoot, "yweather:location").getAttribute("city");
    			obj.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");
    			obj.sunrise = findChild(effectiveRoot, "yweather:astronomy").getAttribute("sunrise");
    			obj.sunset = findChild(effectiveRoot, "yweather:astronomy").getAttribute("sunset");
    			conditionTag = findChild(findChild(effectiveRoot, "item"), "yweather:condition");
    			obj.temp = conditionTag.getAttribute("temp");
    			obj.icon = conditionTag.getAttribute("code");
    			obj.description = conditionTag.getAttribute("text");
    			callback (obj);
    			callback ({error:true, errorString:"XML request failed. no responseXML"});
    function validateWeatherLocation (location, callback)
    		var obj = {error:false, errorString:null, cities: new Array};
    		obj.cities[0] = {zip: location}; //Not very clever, are we?
    		callback (obj);

  2. #2
    Safari and Chrome can be used to test those pages.
    Also Dreamweaver CS 5.5 shows you what you theme looks like as it runs it in split display and live view.
    Nothing is impossible only miracles take a bit longer!

  3. #3
    well, the working version (on the iphone - from the other theme) did not work in chrome. I will try safari. ($150 for dreamweaver is a bit steep to just see if a theme works lol)

  4. #4
    Yes it is a lot of money, but if you use it a lot then it really helps as it displays any immediate change in the code.
    btw I noticed that your script use the yahoo weather url
    whereas my script uses this url
    The thing is though that my url does not work in any browser, but it works on the iPhone .... and Dreamweaver CS 5.5!
    Before DW CS 5.5 I used DW 8 and that also would not display that url, so I had to edit the code in DW 8 then upload to the iPhone, respring and check. So it was hours of this cycle, edit code, upload to iPhone, respring and check.
    I tried your url or something like this (PC version url) and they worked in Safari, but not on the iPhone.
    Now it is soooooo much better with DW CS 5.5.
    I am working on an animated weather lockscreen theme, but it is not a simple one, currently it has 150 folder with almost 800 files and is about 10 MB big. HERE is a little preview of it.
    Last edited by rasputin007; 2012-02-04 at 11:05 PM.

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