29. oktober 2001 - 15:00
#2
Jeg bruger nu dette script, men det fejler...
********************************************
<script LANGUAGE=\"JavaScript\">
<!--Hide from JS-Impaired Browsers
function numDaysIn(mth,yr) {
if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
else if ((mth==1) && leapYear(yr)) return 29;
else if (mth==1) return 28;
else return 31;
}
function leapYear(yr) {
if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
return true;
else
return false;
}
// fixes a Netscape 2 and 3 bug
function getFullYear(d) { // d is a date object
yr = d.getYear();
if (yr < 1000)
yr+=1900;
return yr;
}
function arr() {
for (n=0;n<arr.arguments.length;n++) {
this[n] = arr.arguments[n];
}
}
//weekdays = new arr(\"Sun.\",\"Mon.\",\"Tues.\",\"Wed.\",
// \"Thurs.\",\"Fri.\",\"Sat.\");
// *** comment out the one you don\'t want to use ***
weekdays = new arr(\"Søndag\",\"Mandag\",\"Tirsdag\",\"Onsdag\",
\"Torsdag\",\"Fredag\",\"Lørdag\");
//months = new arr(\"Jan.\",\"Feb.\",\"Mar.\",\"Apr.\",\"May\",
// \"June\",\"July\",\"Aug.\",\"Sep.\",\"Oct.\",\"Nov.\",\"Dec.\");
// *** comment out the one you don\'t want to use ***
months = new arr(\"January\",\"February\",\"March\",\"April\",\"May\",
\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\");
// Change filename to be the name of this file
var filename=\"kalender.html\";
var flg=0;
var today = new Date();
/* You control the size of this calendar
by specifying the font size (from 1
through 7) in the var fs below. */
var fs=2;
/* The events array - E - below uses an
array element for each month from
Jan thru Dec. The string for each
month is indexed with a tilde (~), the
date and a space, followed by the
event description. Substitute the
events you wish here. Use two lines
(with <BR>) for each. */
/*
* Note:
* This has now been expanded to a two dimensional array. The first index is
* the year and the second is the month.
*/
E=new arr( 1999, 2000 );
E[1999]=new arr(\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\");
E[2000]=new arr(\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\");
E[2001]=new arr(\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\");
E[2000][0]=\"~6 Boller<br>i karry~13 Jægergryde~20 Gule ærter<br>m. flæsk<br>og pølse.~27 Fisk i fad<br>Udtrækning på<br>medlemskortet~\";
E[2000][1]=\"~3 Vinsmagning~10 Medisterpølse~17 Hamburgerryg m.<br>aspargessauce~24 Krebinetter m. stuvede<br>ærter og gulerødder.<br>VINDERE:<br>Gitte P.<br>Peter K.~\";
E[2000][2]=\"~2 Kylling i<br>karry~3 ROLLEPILSTUR~4 ROLLEPILSTUR~5 ROLLEPILSTUR~9 <a href=generalforsamling2000.htm>Generalforsamling</a><br>Svensk<br>pølseret~16 Hakkebøf~23 Brunkål~30 Skinke med<br>ærter og<br>gulerødder~\";
E[2000][3]=\"~6 Ribbensteg<br>m. surt~13 Roastbeef~\";
E[2000][8]=\"~14 Kam med<br>krydderier~21 Frikadeller<br>m. kål~28 ---->~29 Grillaften~\";
E[2000][9]=\"~5 Gryderet~12 Stegt<br>flæsk~19 EFTERÅRSFERIE<br>INGEN<br>LOKALHUS~26 Gule<br>ærter~\";
E[2000][10]=\"~2 Hakkebøf~9 Andesteg<br><font color=red>ALT UDSOLGT</font>~16 Medisterpølse~23 Krebinetter~30 Svensk<br>pølseret~\";
E[2000][11]=\"~7 Kødskovs~14 Flæskesteg<br><font color=red>ALT UDSOLGT</font>~24 Glædelig<br>Jul~\";
E[2001][0]=\"~1 Godt<br>nyt år!~4 Forloren<br>hare~11 Suppe~18 Boller<br>i<br>karry~25 Hamburgerryg~\";
E[2001][1]=\"~1 Vinsmagning<br><b><font color=red>OBS: </font></b>Vi har ikke online betilling til denne dag~8 Brunkål~15 Kylling~22 FERIELUKKET<br>pga.<br>ombygning~\";
E[2001][2]=\"~1 Brændende<br>kærlighed~8 Gullash~15 Kalvesteg~22 Kogt<br>flæsk~29 Beuf<br>Stroganoff~\";
E[2001][3]=\"~5 Indbagt mørbrad<br>NB: Sidste aften<br><font color=red>Madbillet 30,-</font>~\";
E[2001][4]=\"\";
E[2001][5]=\"\";
E[2001][6]=\"\";
E[2001][7]=\"\";
E[2001][8]=\"~13 LOKALHUS<br>SYD<br>STARTER<br>Forloren Hare~20 Hamburgerryg~27 Grill Aften<br><font color=red>Billetter kan ikke bestilles online</font>~\";
E[2001][9]=\"~4 Gullasch~11 Boller i Karry~25 Suppe~\";
E[2001][10]=\"~1 Hakkebøf~8 Andesteg<br><font color=red>Billetter kan ikke bestilles online</font>~15 Kogt Flæsk~22 Bøf Stroganoff~29 Kylling~\";
E[2001][11]=\"~6 Frikadeller~13 Flæskesteg<br><font color=red>Billetter kan ikke bestilles online</font>~\";
E[2002][0]=\"\";
/* You can hard code the year by setting
hard_code_year to true and then setting the
hard_yr variable to the year you want */
hard_code_year = false; // change to true if desired
hard_yr = 1999; // specify your hard coded year if desired
/* You can hard code the month by setting
hard_code_date to true and then setting the
hard_mo variable to the month you want */
hard_code_date = false; // change to true if desired
hard_mo = 11; // 0=Jan, 1=Feb, etc.
/*
* Determine the month that is required.
*/
function getMonth()
{
if( hard_code_date )
return( hard_mo );
month=today.getMonth();
endIndex=location.search.length;
if( location.search.length > 1 )
{
index = location.search.indexOf(\",\");
if( index != -1 )
{
endIndex=index;
}
mon = parseInt(location.search.substring(1,endIndex) );
if ( ((\"\"+mon).length<=2) && (mon >= 0) && (mon <= 11)) {
month=mon;
}
}
return( month );
}
/*
* Determine the year that is required.
*/
function getYear()
{
if (hard_code_year) {
return( hard_yr );
}
year=getFullYear(today);
if( location.search.length > 1 )
{
index = location.search.indexOf(\",\");
if( index != -1 )
{
yr = parseInt(location.search.substring(index+1) );
}
if ( ((\"\"+yr).length<=4) && (yr >= 1900) && (yr <= 2010)) {
year=yr;
}
}
return( year );
}
/*
* Output HTML to provide a month selection choice.
*/
function addMonthSelect()
{
document.write( \"<SELECT NAME=\'monthSelect\' SIZE=1>\" );
for( i=0; i<mo; i++ )
{
document.write( \"<OPTION>\"+months[i] );
}
document.write( \"<OPTION SELECTED>\"+months[mo] );
for( i=mo+1; i<12; i++ )
{
document.write( \"<OPTION>\"+months[i] );
}
document.write( \"</SELECT>\" );
}
/*
* Output HTML to provide a year selection choice.
*/
function addYearSelect()
{
document.write( \"<SELECT NAME=\'yearSelect\' SIZE=1>\" );
for( i=2; i>0; i-- )
{
document.write( \"<OPTION>\"+(yr-i) );
}
document.write( \"<OPTION SELECTED>\"+yr );
for( i=1; i<3; i++ )
{
document.write( \"<OPTION>\"+(yr+i) );
}
document.write( \"</SELECT>\" );
}
/*
* Handle changing the date from month and year selects.
*/
function changeDate(monthObj, yearObj)
{
newMonth=monthObj.selectedIndex;
newYear=yearObj.options[yearObj.selectedIndex].text;
location.href=filename+\"?\"+newMonth+\",\"+newYear;
}
/*
* Main calendar generator.
*/
function Calendar()
{
todayYr=getFullYear(today);
mo=getMonth();
yr=getYear();
bgn=new Date(months[mo]+\" 1,\"+yr);
dy=bgn.getDay();
ld=numDaysIn(mo,yr);
// Start table www
document.write(\"<TABLE BORDER=0 CELLSPACING=1 WIDTH=100% BGCOLOR=\'#EEEEEE\'>\");
document.write(\"<TR><TD ALIGN=CENTER COLSPAN=7 BGCOLOR=\'#eeeeee\'>\");
document.write(\"<FONT SIZE=\"+(fs+1)+\"><B>\"+months[mo]+\" \"+yr+\"</B></FONT>\");
document.write(\"</TD></TR><TR>\");
for (var i=0;i<7;i++){
document.write(\"<TD ALIGN=CENTER WIDTH=14% BGCOLOR=\'#DDDDDD\'>\"
+\"<FONT SIZE=3>\"+weekdays[i]+\"</FONT></TD>\");
}
document.write(\"</TR><TR>\");
ctr=0;
for (var i=0;i<7;i++) {
/* If the ctr is less than the day of the
week determined to be the first day
of the month, print a space in
this cell of the table. */
if (i<dy){
document.write(\"<TD ALIGN=CENTER>\"
+\"<FONT SIZE=\"+fs+\"> </FONT>\"
+\"</TD>\");
}
/* Otherwise, write date and the event,
if any, in this cell of the table. */
else {
ctr++;
di=i; // carry var i outside this routine
dupWrt();
}
}
document.write(\"</TR><TR>\");
while (ctr<ld){
for (var i=0;i<7;i++){
ctr++;
/* If the ctr is greater than the last
day of the month, print a space in
this cell of the table. */
if (ctr>ld){
document.write(\"<TD ALIGN=CENTER>\"
+\" </TD>\");
}
/* Otherwise, write date and the event,
if any, in this cell of the table. */
else{
di=i; // carry var i outside this routine
dupWrt();
}
}
document.write(\"</TR><TR>\");
}
// Create prev/next jump links
jump = \"\";
if( ! hard_code_date )
{
document.write(\"<TD colspan=3 align=center>\");
// Prev link
prevMonth=(mo - 1);
prevYr=yr;
if( mo == 0 )
{
prevMonth=11;
prevYr=yr - 1;
}
document.write(\'<a href=\"\'+filename+\'?\'+prevMonth+\',\'+prevYr+\'\"><- \'+months[prevMonth]+\' </a>\');
// Middle
document.write(\" | \");
// Next link
nextMonth=(mo + 1);
nextYr=yr;
if( mo == 11 )
{
nextMonth=0;
nextYr=yr + 1;
}
document.write(\'<a href=\"\'+filename+\'?\'+nextMonth+\',\'+nextYr+\'\"> \'+months[nextMonth]+\' -></a>\');
document.write(\"</TD>\");
// Create quick jump
document.write( \"<TD ALIGN=CENTER COLSPAN=4 BGCOLOR=\'#eeeeee\'>\" );
document.write( \"<FORM Name=\'selectForm\'>\" );
addMonthSelect();
addYearSelect();
document.write( \"<INPUT TYPE=BUTTON VALUE=\'Go\' onClick=\'changeDate(document.selectForm.monthSelect,document.selectForm.yearSelect)\'>\" );
document.write( \"</FORM>\" );
document.write(\"</TD></TR>\");
}
document.write(\"</TABLE>\");
}
function dupWrt() {
document.write(\"<TD ALIGN=CENTER BGCOLOR=\'#DDDDDD\'><FONT SIZE=\"+fs);
colorSet=0;
if ( (mo==today.getMonth()) && (yr==todayYr) && (ctr==today.getDate()) )
{
/* Change color to whatever color you wish
for the current date to be differentiated on
screen. I used green here. */
document.write(\" COLOR=\'yellow\'\");
colorSet=1;
}
else if ( (di==0) )
{
/* Change color to whatever color you wish
for Sundays to be differentiated on
screen. I used red here. */
document.write(\" COLOR=\'GRAY\'\");
colorSet=1;
}
/* For dates without an event, an HTML padder
that will align dates properly with dates
having an event. Here, space break space. */
tmp=\" <BR> \";
/* Then check for event in this month\'s events
array for this date. If present, rewrite the
tmp variable to contain the event. */
if( E[yr] )
{
pos=E[yr][mo].indexOf(\"~\"+ctr+\" \");
if (pos>-1){
tmp=E[yr][mo].substring(pos+3,E[yr][mo].length);
pos=tmp.indexOf(\"~\");
tmp=tmp.substring(0,pos);
if (colorSet!=1){
/* Change color to whatever color you wish
for the events to be differentiated on
screen. I used blue here. */
document.write(\" COLOR=\'#005500\'\");
}
}
}
document.write(\"><B>\"+ctr+\"</B></FONT><BR><FONT SIZE=1>\"+tmp+\"</TD>\");
}
// End Hiding -->
</script>
*****************************************
I HTML\'en bruges
<!--Hide from JS-Impaired Browsers
Calendar();
// End Hiding -->
Er det en let bug??