The configuration on this is a bit complex. Fortunately, much of any given date's data is optional. Here is a typical date entry with all possible data included:
Code:
/*October*/ special_dates[10]=[];
special_dates[10][15]=['Oct. 15th!', 'Did you see the leaves?', 'Do anything interesting last night?', 'Yo!'];
special_dates[10][15].breakHour=[9, 9, 9, 9];
special_dates[10][15].breakMinute=[41, 44, 47, 50];
special_dates[10][15].breakDay=1;
The month declaration is required only if there are any special dates in that month. Any given month should only be declared once. As many special dates for that month as are desired may be added once it has been declared.
The:
Code:
special_dates[month#][date#]=[message strings];
sets the alert messages for that date and is required for any customization of that date.
The:
Code:
special_dates[month#][date#].breakHour=[hours];
is required only if the breakHour times for that date are different than the defaults.
The:
Code:
special_dates[month#][date#].breakMinute=[minutes];
is required only if the breakMinute times for that date are different than the defaults.
The:
Code:
special_dates[month#][date#].breakDay=#;
is required only if the special_dates[month#][date#] must fall on a certain day of the week to be used. 1 = Sunday, 2= Monday . . . 7=Saturday.
One important note: Wherever they are used, the number of entries in breakHour, breakMinute and the number of message string entries should all be the same. For example, if you have 3 messages, and are using the optional hours, you need three hour entries. If no optional hours or minutes are used, the number of special messages should equal the default number of messages, hours and minutes. The script will error check and degrade gracefully if you ignore this but, the result will be that some messages may not get shown as alerts.
Here is the script with a few more example 'special_dates':
Code:
<script type="text/javascript">
/*Timely Alerts script © John Davenport Scheuer
*as first seen in http://www.dynamicdrive.com/forums
*username: jscheuer1
*This notice must remain for legal use */
// Configure optional special dates:
var special_dates=[]; // <<< do not edit or remove this line!
/*January*/ special_dates[1]=[];
special_dates[1][1]=['Happy New Year!', 'Did you see the parade?', 'Do anything you regret last night?', 'Better get to bed early tonight'];
special_dates[1][1].breakHour=[0, 12, 17, 21];
special_dates[1][1].breakMinute=[0, 30, 30, 30];
/*May*/ special_dates[5]=[];
special_dates[5][25]=['Must be getting near Memorial Day', 'Aren\'t the flowers nice?', 'Is the pollen bothering you?'];
/*October*/ special_dates[10]=[];
special_dates[10][15]=['Oct. 15th!', 'Did you see the leaves?', 'Do anything interesting last night?', 'Yo!'];
special_dates[10][15].breakHour=[9, 9, 9, 9];
special_dates[10][15].breakMinute=[41, 44, 47, 50];
special_dates[10][15].breakDay=1;
special_dates[10][31]=['Happy Halloween!', 'Boo!', 'Don\'t eat too much candy!'];
function breakTime(){ // <<< do not edit or remove this line!
/* Set Default Break Hours in 24hr Notation */
var breakHour=[8, 12, 17];
/* Set Default Break Minutes */
var breakMinute=[30, 30, 30] ;
/* Set Default Break Messages */
var breakMessage=["Good Morning!", "Lunch Time!", "Good Evening!"];
///////////////////No Need to Edit//////////////
var theDate=new Date(), mo=theDate.getMonth()*1+1, dt=theDate.getDate()*1, dy=theDate.getDay()*1+1;
if ((special_dates[mo]&&special_dates[mo][dt]&&special_dates[mo][dt].breakDay&&special_dates[mo][dt].breakDay==dy)||(special_dates[mo]&&special_dates[mo][dt]&&!special_dates[mo][dt].breakDay)){
breakMessage=special_dates[mo][dt];
breakHour = special_dates[mo][dt].breakHour? special_dates[mo][dt].breakHour : breakHour;
breakMinute = special_dates[mo][dt].breakMinute? special_dates[mo][dt].breakMinute : breakMinute;
}
for (var i = 0; i < breakHour.length; i++)
if (breakHour[i]&&breakMinute[i]&&breakMessage[i]&&theDate.getHours()*1==breakHour[i]&&theDate.getMinutes()*1==breakMinute[i]){
window.focus();
clearInterval(breakInt)
alert(breakMessage[i])
if (i<breakHour.length-1&&i<breakMinute.length-1&&i<breakMessage.length-1)
setTimeout("breakInt=setInterval('breakTime()',58000)",120000)
}
}
var breakInt=setInterval("breakTime()",58000)
////////////////////////////////////////////////
</script>
Bookmarks