|
|||
iPhone Wetter-Widget, wer kann helfen
Hallo Zusammen,
ich kopiere hier mal einen Code rein. Vielleicht kann sich das mal einer anschauen. Hier wird über den Städtecode das Yahoowetter angezeigt. Leider gibt es keinen Code für meinen Wohnort und daher hab ich den nächst grösseren Ort gewählt in meiner Nähe gewählt, klappt auch super. Nun würde ich gern wissen ob ich das Wetter weiterhin so anzeigen kann aber den Ortsnamen der erscheint ändern kann, also nur für die Anzeige meinen Wohnort, das Wetter weiterhin vom Ort in meiner Nähe. Und noch eine andere Frage, hier wird das Yahoowetter genutzt, ich würd lieber das Applewetter nutzen (accuweather), kann mir das jemand anpassen? Denn bei Apple gibt es meinen Wohnort, würde also den ersten Teil erübrigen Danke schon einmal für die Hilfe, Gruss Jörn <html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style> body { background-color: transparent; margin: 0; padding: 0; height: 480px; width: 344px; } img { position: absolute; Top: -6px; Left: -12px; widt: 344px; height: auto; } </style> </head> <div id="WeatherBox"> <img src="./Private/WeatherBox.png" width="344px" /> </div> <div id="Wallpaper"> <img src="./Private/Wallpaper.png" width="344px" /> </div> <body style="color: black"> <?xml version="1.0" encoding="UTF-16"?> <base href="Private/"/> <script type="text/javascript"> // The location field should be a relatively machine-legible string // if using the default, Apple/AccuWeather parser (originally from Leopard's Weather.wdgt) var locale = "GMXX0079" //e.g. 'North Attleboro, Massachusetts'|'Moscow, Russia'|'Ledyard, AT'|'London, UK' // Set to 'false' if you'd prefer Farenheit var isCelsius = true //true|false // Use 'Real Feel' temperatures where possible, taking into account Wind Chill, Humidity etc. var useRealFeel = false //true|false /*������������������������������������������������� �������������������������������������������� ���*/ //Enable Wallpaper and/or Lock Screen var enableWallpaper = true; //true|false var enableLockScreen = false; //true|false [Currently, it is suggested that the lockScreen is disabled.] // Supplied styles are 'originalBubble', 'myopia', 'iconOnly' and 'split'. // (Add your own to the CSS folder!) var stylesheetWall = 'blackweather' //'originalBubble'|'blackweather'|'iconOnly'|'split' |'oneLine' var stylesheetLock = 'iconOnly' //See above. // The only supplied icon set is 'klear' // Images must follow the same naming schema as the 'springboard' set var iconSetWall = 'Icon' //'springboard'|'Lockscreen' var iconExtWall = ".png" //'.png'|.'gif' etc. var iconSetLock = 'Icon' //See above. var iconExtLock = '.png' //See above. /*������������������������������������������������� �������������������������������������������� ���*/ // The other available source is 'yahooWeather' which for the 'locale' // requires a US zip or location code (e.g. UKXX0085 or CHXX000 from Yahoo! Weather - Weather Forecasts | Maps | News var source = 'yahooWeather' //'appleAccuweatherStolen'|'yahooWeather' // Please endeavour to set this to a sensible value if you really must change it... var updateInterval = 25 //Minutes var postal; var demoMode = false; var enabled; if (location.href.indexOf("LockBackground") == -1){ stylesheet = stylesheetWall; iconSet = iconSetWall; iconExt = iconExtWall; enabled = enableWallpaper; }else{ stylesheet = stylesheetLock; iconSet = iconSetLock; iconExt = iconExtLock; enabled = enableLockScreen; } if(enabled == true){ if(iconSet == null || iconSet == 'null' || iconSet == ""){ var iconSet = stylesheet; } var headID = document.getElementsByTagName("head")[0]; var styleNode = document.createElement('link'); styleNode.type = 'text/css'; styleNode.rel = 'stylesheet'; styleNode.href = 'Stylesheets/'+stylesheet+'.css'; headID.appendChild(styleNode); var scriptNode = document.createElement('script'); scriptNode.type = 'text/javascript'; scriptNode.src = 'Sources/'+source+'.js'; headID.appendChild(scriptNode); } function onLoad(){ if (enabled == true){ if (demoMode == true){ document.getElementById("weatherIcon").src="IconSe ts/"+iconSet+"/"+"cloudy1"+iconExt; document.getElementById("city").innerText="Somewhe re"; document.getElementById("desc").innerText="Partly Cloudy"; document.getElementById("temp").innerText="100º"; }else{ document.getElementById("weatherIcon").src="IconSe ts/"+iconSet+"/"+"dunno"+iconExt; validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal) } }else{ document.getElementsByTagName("body")[0].innerText=''; } } function convertTemp(num) { if (isCelsius == true) return Math.round ((num - 32) * 5 / 9); else 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").classN ame = ""; weatherRefresherTemp(); }else{ document.getElementById("city").innerText="Not Found"; document.getElementById("WeatherContainer").classN ame = "errorLocaleNotFound"; } }else{ document.getElementById("city").innerText=obj.erro rString; document.getElementById("WeatherContainer").classN ame = "errorLocaleValidate"; setTimeout('validateWeatherLocation(escape(locale) .replace(/^%u/g, "%"), setPostal)', Math.round(1000*60*5)); } } function dealWithWeather(obj){ if (obj.error == false){ document.getElementById("city").innerText=obj.city ; document.getElementById("desc").innerText=obj.desc ription.toLowerCase(); if(useRealFeel == true){ tempValue = convertTemp(obj.realFeel); }else{ tempValue = convertTemp(obj.temp) } document.getElementById("temp").innerText=tempValu e+"º"; document.getElementById("weatherIcon").src="IconSe ts/"+iconSet+"/"+MiniIcons[obj.icon]+iconExt; document.getElementById("WeatherContainer").classN ame = ""; }else{ document.getElementById("WeatherContainer").classN ame = "errorWeatherDataFetch"; } } function weatherRefresherTemp(){ fetchWeatherData(dealWithWeather,postal); setTimeout(weatherRefresherTemp, 60*1000*updateInterval); } var MiniIcons = [ "tornado", //0 tornado "tstorm3", //1 tropical storm "tornado", //2 hurricane "tstorm3", //3 severe thunderstorms "shower3", //4 thunderstorms "sleet", //5 mixed rain and snow "sleet", //6 mixed rain and sleet "sleet", //7 mixed snow and sleet "sleet", //8 freezing drizzle "light_rain", //9 drizzle "sleet", //10 freezing rain "shower2", //11 showers "shower2", //12 showers "snow1", //13 snow flurries "snow2", //14 light snow showers "snow4", //15 blowing snow "snow4", //16 snow "hail", //17 hail "sleet", //18 sleet "mist", //19 dust "fog", //20 foggy "fog", //21 haze "fog", //22 smoky "cloudy1", //23 blustery "wind", //24 windy "ice", //25 cold "cloudy", //26 cloudy "cloudy4_night", //27 mostly cloudy (night) "cloudy", //28 mostly cloudy (day) "cloudy2_night", //29 partly cloudy (night) "cloudy2", //30 partly cloudy (day) "sunny_night", //31 clear (night) "sunny", //32 sunny "cloudy2_night", //33 fair (night) "cloudy4", //34 fair (day) "hail", //35 mixed rain and hail "hot", //36 hot "tstorm1", //37 isolated thunderstorms "shower3", //38 scattered thunderstorms "shower3", //39 scattered thunderstorms "showers", //40 scattered showers "snow5", //41 heavy snow "snow3", //42 scattered snow showers "snow5", //43 heavy snow "cloudy1", //44 partly cloudy "storm1", //45 thundershowers "snow2", //46 snow showers "tstorm2", //47 isolated thundershowers "dunno", //3200 not available ] 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="http://weather.yahooapis.com/forecastrss?u=f&p=" //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"); xml_request.open("GET", url+zip); xml_request.setRequestHeader("Cache-Control", "no-cache"); xml_request.send(null); 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"); obj.city = findChild(effectiveRoot, "yweather:location").getAttribute("city"); obj.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");//Only accounts for windChill conditionTag = findChild(findChild(effectiveRoot, "item"), "yweather:condition"); obj.temp = conditionTag.getAttribute("temp"); obj.icon = conditionTag.getAttribute("code"); obj.description = conditionTag.getAttribute("text"); callback (obj); }else{ 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); } </script> </head> <body onload="onLoad()"> <div id="WeatherContainer"> <div id="TextContainer"> <div id="city" style="font-size:14px; padding-bottom:10px;">Loading SilverWeather...</div> <div id="temp" style="margin-top:1px;">-º</div> <div id="desc" style="font-size:14px;">-</div> </div> <img id="weatherIcon" src=""/> </div> </body></html> |
Sponsored Links |
Themen-Optionen | |
Ansicht | |
|
|
Ähnliche Themen | ||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
Layout wird auf iPad / iPhone falsch dargestellt | Bubble | Grafik, Design, Typografie | 13 | 05.02.2013 11:49 |
Weiche für iPhone und co. + richtig testen? | Tony-S | CSS | 2 | 09.01.2012 21:11 |
css speziell für iphone | Sand10 | CSS | 11 | 27.09.2011 16:51 |
css und iphone Textgröße | stefanovic | CSS | 3 | 11.02.2010 00:10 |
Wetter auf der Page | paracelsus | Offtopic | 23 | 03.03.2008 01:34 |