owm.xjs script for 5 day / 3 hour forcast:
Tell me what you think, please
<?xjs
(function () {
try {
load('geoip.js');
var geoip = get_geoip( http_request.header['x-forwarded-for'] || http_request.remote_ip);
require('openweathermap.js', 'OpenWeatherMap');
var owm = new OpenWeatherMap();
var wq = { units: 'metric', mode: 'json' };
var ts = Math.round((new Date()).getTime() / 1000);
if (geoip.latitude && geoip.longitude) {
wq.lat = geoip.latitude;
wq.lon = geoip.longitude;
} else
if (geoip.cityName) {
wq.q = geoip.cityName;
}
var city = geoip.cityName + ', ' + geoip.countryName; // For Display Only
var fc = owm.call_api('forecast', wq);
writeln('<center>OpenWeatherMap 5 Day/3 Hour Forecast for ' + city + '</center><hr><br>');
fc.list.forEach(function (e) {
if(e.dt >= ts-9900) { // Doesn't list weather 15 minutes prior to next 3 hour block
writeln(system.timestr(e.dt) + ': <br>');
writeln('<img src=
http://openweathermap.org/img/wn/'+e.weather[0].icon+'@2x.png height=50 width=50>');
writeln(e.main.temp_max+'°C, ' );
writeln(e.weather[0].main + ', ' + e.weather[0].description);
writeln(e.clouds.all + '% clouds');
writeln();
print("<br><br><br>");
}
});
}
catch (err) {
writeln('ERROR: ' + err + '<br><br>');
}
}) ();
My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/
---
■ Synchronet ■ AlleyCat! BBS -
http://alleycat.synchro.net:81