Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A bookmarklet version' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A bookmarklet version
Authored by: scooby509 on Jan 01, '10 07:50:08AM
Doing this as CGI... possible, but I doubt it would be much simpler (at least in terms of setup) than the OP's code.

But a bookmarklet does sound simple, so here goes:

First, I had to figure out what URL the OP was looking at. Turns out that wunderground (the name has some interesting history) uses 4 letter airport codes, so IAD is KIAD. An example:

http://www.wunderground.com/history/airport/KIAD/2010/1/1/MonthlyHistory.html

We'll put the airport code up front to make it easy to change, and determine the date portion of the URL:


a = 'KIAD'; 
d = new Date();
location.href = 'http://wunderground.com/history/airport/' + a + '/' + 
  (1900 + d.getYear()) + '/' + d.getMonth() + '/' + d.getDate() + '/MonthlyHistory.html';

I ran it through something to crunch it into a bookmarklet online. (It also wrapped it in a function, which is useful.) The end result seems to get cut off:

javascript:(function(){a='KIAD';d=new%20Date();location.href='http://wunderground.com/history/airport/'
+a+'/'+(1900+d.getYear())+'/'+d.getMonth()+'/'+d.getDate()+'/MonthlyHistory.html';})();"

On Firefox, you could use (new Date()).toLocaleFormat("%Y/%m/%d") to get the date formatted in one shot and eliminate the function() wrapper, but that's non-standard and neither Safari nor Chrome understand it. It would look like this:

javascript:location.href='http://wunderground.com/history/airport/KIAD/'
+(new%20Date()).toLocaleFormat("%Y/%m/%d")+'/MonthlyHistory.html';
In both cases, remove the newline before you paste it into your bookmarks.

[ Reply to This | # ]
A bookmarklet version
Authored by: ttt on Jan 01, '10 12:11:16PM

You rock for going to the trouble to do that!



[ Reply to This | # ]