Nowadays when one wants to check the weather - instead of looking through the window, they type in the address of The Weather Chanel’s web page or look at the MSN Weather gadget. A PLC visualization should also present information about current and the expected weather.
Below you will find a description of a simple ‘plugin’, which supports obtaining and presenting information from Yahoo Weather.
The code is inspired by and partially based on James Fleeting's Simple Weather plugin. In his plugin the weather forecast is limited to one day. It made me write an inferior but a new code...
The easiest and the quickest way to see it is by downloading the example file.
The plugin makes avaliable 2 functions:
The functions downloads information about the current weather at the requested location. Handling of the data must take place within the success function declared when the GetCurrentWeather() is called.
Parameters:
Returned data:
Example 1:
$.GetCurrentWeather({ location: 'GMXX0007', success: function(weather) { alert(weather.visibility) } });
When the function is called the weather for Berlin (GMXX0007) will be checked and the information about visibility will be displayed.
Downloads information about the 5-day weather forecast (including the current day) at the requested location. Handling of the data must take place within the success function declared when the GetCurrentWeather() is called.
Parameters:
Returned data:
The data received from Yahoo WEather are stored in an array forecast[..]. Data for the current day is to be found in forecast[0], for day 4 in forecast[4]. For each table element the folowing data is available:
Przykład 1:
$.GetWeatherForecast({ location: 'FRXX0076', success: function(forecast) { alert(forecast[0].text) } //End of the success function });
When the function is called the weather for Paris(FRXX0076) will be checked and the current weather descritpnion will be displayed.
Here is the link to the file with examples.