javascript for weather data

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 13279
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

javascript for weather data

Post by ChrisGreaves »

I am feeling particularly pleased with myself, but also with Marc Knoll.
I am now in my fourth year of using a bookmark

Code: Select all

https://climate.weather.gc.ca/climate_data/daily_data_e.html?hlyRange=2006-01-23|2021-05-31&dlyRange=2006-07-09|2021-05-31&mlyRange=2006-08-01|2007-07-01&StationID=45047&Prov=NL&urlExtension=_e.html&searchType=stnName&optLimit=yearRange&StartYear=2020&EndYear=2021&selRowPerPage=100&Line=0&searchMethod=contains&txtStationName=bonavista&timeframe=2&Day=1&Year=2019&Month=02#
and then laboriously editing the URL in the URL box to see what is happening this month.
Thanks to Mark I now have a little javascript that (until ten minutes ago) automatically showed me this month's depressing data.
I say "ten minutes ago" because I became brave enough to add a "minus one" factor to the year calculation to see if I could bring up this-month-last-year as a comparison (see third line in the code box below).

Code: Select all

javascript:function url() {
 var date = new Date();
 var y = date.getFullYear() - 1 ; 
 var m = date.getMonth() +1; 
 if(m < 10){m = '0' + m;}
 var d = date.getDate();
 if(d < 10){d = '0' + d;}
 var date = y + "-" + m + "-" + d;

 return 'https://climate.weather.gc.ca/climate_data/daily_data_e.html?hlyRange=2006-01-23%7C2021-05-31&dlyRange=2006-07-09%7C2021-05-31&mlyRange=2006-08-01%7C2007-07-01&StationID=45047&Prov=NL&urlExtension=_e.html&searchType=stnName&optLimit=yearRange&StartYear=2020&EndYear=2021&selRowPerPage=100&Line=0&searchMethod=contains&txtStationName=bonavista&timeframe=2&Day=1&Year=' + y + '&Month=' + m + '#';

} window.open(url(),"_blank");
Now, what else can I program dynamically in my bookmarks ... :scratch:
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
If you think you’re too small to make a difference, try sleeping with a mosquito (Dalai Lama)