Dane nie mogą nadpisywać się.
Dane o aktualnej temperaturze pobierane są za pomocą pliku js i wyświetlane na stronie w php.
Plik js
/*! e-dom Weather wtyczka do jQuery e-dom Weather jQuery plugin ver 1.0 Kod oparty na przykładach Jamesa Fleetinga i jego wtyczki 'Simple Weather' The code is based partially on the examples of James Fleeting and his 'Simple Weather' plugin dodatkowe informacje na: more info at: www.edom-plc.pl */ (function( $ ){ $.extend({ GetWeatherForecast: function(options) { var options = $.extend({ location: 'PLXX0023', unit: 'c', success: function(data){} }, options); $.getJSON("http://query.yahooapis.com/v1/public/yql?"+ "q=select * from rss where url='"+ encodeURIComponent('http://xml.weather.yahoo.com/forecastrss/'+options.location+'_'+options.unit+'.xml')+ "'&format=json&diagnostics=false&callback=?", function(data){ if (data != null) { if (data.query.results != null) { for (var i=0; i<data.query.results.item.forecast.length; i++) { forecast[i]=data.query.results.item.forecast[i]; } // End FOR options.success(forecast) } } }, //End of Success Handling function(e) { alert(e.message); } //End of Error Handling ); //End of getJSON }, //End of GetWeatherForecast function GetCurrentWeather: function(options) { var options = $.extend({ location: 'PLXX0023', unit: 'c', success: function(data){} }, options); $.getJSON("http://query.yahooapis.com/v1/public/yql?"+ "q=select * from weather.forecast where location in ('"+options.location+"') and u='"+options.unit+"'"+ "&format=json&diagnostics=false&callback=?", function(data){ if (data != null) { if (data.query.results != null) { var result=data.query.results.channel; var weather={ city: result.location.city, wind_speed: result.wind.speed, humidity: result.atmosphere.humidity, pressure: result.atmosphere.pressure, visibility: result.atmosphere.visibility, sunrise: result.astronomy.sunrise, sunset: result.astronomy.sunset, code: result.item.condition.code, temp: result.item.condition.temp, text: result.item.condition.text, } var WindDirection = parseInt(result.wind.direction); if (WindDirection>=0&&WindDirection<=360) { var WindDirectionTable = ["N","NNE","NE","ENE","E","ESE", "SE", "SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"]; }; var AtmosphereRising = parseInt(result.atmosphere.rising); if (AtmosphereRising>=0&&AtmosphereRising<=2) { weather.rising = ["→", "↑", "↓"][AtmosphereRising]; } options.success(weather) } } }, //End of Success Handling function(e) { alert(e.message); } //End of Error Handling ); //End of getJSON } //End of GetCurrentWeather function }); })( jQuery );
Plik php do wyświetlania
<?php ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <title>Example Weather</title> <link type="text/css" href="css/jquery.e-dom.css" rel="stylesheet" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script> <script type="text/javascript" src="js/jquery.e-dom.weather.js" charset="utf-8"></script> <script type="text/javascript"> $(window).load(function(){ $.GetCurrentWeather({ location: 'PLXX0023', unit: 'c', success: function(weather) { //define what you do with the data obtained by the function var html = '<table><tr><td><img width="35px" style="padding-bottom:10px;" src="http://djdandi.nazwa.pl/PHP-Fusion-9.00/themes/Brzanek/pogoda2015/ikony/'+weather.code+'.png"></td>'; html+='<td align="center"><p style="font-size: 14px; color: #336666; font-family: tahoma; text-shadow: rgba(250, 250, 250, 0.2) 2px 2px 0;">'+weather.temp+'°C Stargard'; html+='</td></tr></table>'; $('#Example3Div').append(html); } //End of the success function });//End of GetCurrentWeather }); // End of Window Load </script> </head> <body> <table border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td id="Example3Div" style="width: 150px;"></td> </tr> </table> </body> </html> <?php ?>
Czy znacie na to jakieś rozwiązanie?