PDA

View Full Version : Highlighting Current Week


bazjones
02-15-2005, 03:06 PM
Hi
Fairly new to javascript so dont know alot about it.

I have written a small script whcih is used as a call out rota to show which person is on call in whcih week, it also shows who has been on call for the passed 4 weeks.

I want to highlight the current week so that everyone can tell which week it is and who is on call in this week??

Any ideas??

<script language = "Javascript">
var dayname = new Array ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
var monthname = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

// ***** Alter following lines to configure rota *****
var colour= new Array("Yellow","Red","Pink","Lime","White","White","White","White","White","White");
var person = new Array("John Kelly","Paul Fox","Robert Tate","Paul West","", "","","","","");
var now = new Date();
var dayinmillis = 1000*60*60*24;
var weekinmillis = dayinmillis*7;
var startwed = 28 + (now.getDay() - 3);
var startrotadate = now.getTime();// Start date for the rota (noon to avoid problems with UTC/BST)
var numberofweeks = 52; // Number of weeks for the rota to run
// ***** End of configuration data *****

//Find out the number of people in the rota, cater for up to ten

for (var numbofpeople = 0; numbofpeople < 10; numbofpeople++){
if (person[numbofpeople]=="")
break;}

var calendardate = new Date(); // Create a new date object
var startmillis = now.getTime() - (startwed*dayinmillis);
var startrotaweeknum = 0;
var personidx = 0;

document.open
document.write ("<H4 ALIGN = 'CENTER'>", " ","</H4>")
document.write ("<DIV ALIGN=CENTER>")
document.write ("<TABLE BORDER=10 BORDERCOLOR = 'navy'>")

var rowhtm = "<TR>";
rowhtm = rowhtm + "<TD BGCOLOR = '#A0A0A0' ALIGN = 'CENTER'>" + "Date" + "</TD>"
rowhtm = rowhtm + "<TD BGCOLOR = '#A0A0A0' ALIGN = 'CENTER'>" + "Engineer" + "</TD>"
rowhtm = rowhtm + "</TR>"
document.write (rowhtm)
for (var count = 0; count < numberofweeks; count++){
calendardate.setTime(startmillis + count*1000*60*60*24*7); // Increment date by one week

startrotaweeknum = Math.floor(calendardate / weekinmillis);
personidx = startrotaweeknum % numbofpeople;

rowhtm = "<TR>"
rowhtm = rowhtm + "<TD BGCOLOR = 'silver'>" + " " + dayname[calendardate.getDay()] + " " + calendardate.getDate() + " "
+ monthname[calendardate.getMonth()] + " " + calendardate.getFullYear() + " " + "</TD>"
rowhtm = rowhtm + "<TD BGCOLOR = " + colour[personidx] + ">" + " " + person[personidx] + " " + "</TD>"
document.write (rowhtm)
}

document.write ("</TABLE>");
document.close;
</script>

Willy Duitt
02-15-2005, 04:26 PM
Try replacing this:

rowhtm = rowhtm + "<TD BGCOLOR = 'silver'>" + " " + dayname[calendardate.getDay()] + " " + calendardate.getDate() + " "
+ monthname[calendardate.getMonth()] + " " + calendardate.getFullYear() + " " + "</TD>"
rowhtm = rowhtm + "<TD BGCOLOR = " + colour[personidx] + ">" + " " + person[personidx] + " " + "</TD>"
document.write (rowhtm)
}


With this:

script removed by author...
Try looking here:
http://www.webdeveloper.com/forum/showthread.php?s=&threadid=56676


.....Willy