Main Menu
My Other Sites
Contact Andrew Quinn
jaquinn@ihug.co.nz http://twitter.com/jaquinn| What is on next Wednesday...... |
| Written by Administrator |
| Friday, 05 December 2008 05:40 |
|
Sometimes a simple programming exercise can be a lot of fun and really help someone out. David (ZL1DK.... the guy who manages the Papakura Radio Club website http://www.qsl.net/zl1vk) asked me the other week if there was any way to have the banner in the top corner that advertised the meeting for the upcoming Wednesday evening to update automatically. He had done the banner using animated GIF's and was changing the file manually. Ideally I would have done this as a server side process but the free www.qsl.net hosting doesn't allow such flexibility.... so javascript for the browser provided the solution instead. Not something I write a lot of but quite satisfying to get a good result. For anyone who cares here is the script that solved the problem.... // Work out which happening this week message to display var currentTime = new Date(); // Offset to the closest Wednesday var wed_adj = 3-dow; if (wed_adj < 0) next_meeting.setDate(next_meeting.getDate() + wed_adj + 7); } } next_meeting.setDate(next_meeting.getDate() + 7); } next_meeting.setDate(next_meeting.getDate() + wed_adj); } var weekno = 0; // If the month of the next meeting is not the same as the current month then week 1 if (currentTime.getMonth() != next_meeting.getMonth()) var test_meeting = new Date;
|

