handige kalender
Auteur: almar - 01 juli 2006 - 18:56 - Gekeurd door: Gerard - Hits: 6851 - Aantal punten: 3.50 (4 stemmen)
een script wat ik heb aangepast want er zaten veel bugs in.
ik hoop dat je er wat aan hebt
Code:
zet dit in je head:
<script language="JavaScript1.2" type="text/javascript">
<!--
ns4 = (navigator.appName.indexOf("Netscape")>=0 && document.layers)? true : false;
ie4 = (document.all && !document.getElementById)? true : false;
ie5 = (document.all && document.getElementById)? true : false;
ns6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
w3c = (document.getElementById)? true : false;
var HTMLCode = "";
var DaysList = new Array("","Ma","Di","Wo","Do","Vr","Za","Zo");
var MonthsList = new Array("Mois_Vide","Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
var MonthLength = new Array("Mois_longueur_vide",31,29,31,30,31,30,31,31,30,31,30,31);
var QueryDate = 0;
var QueryMonth = 0;
var QueryYear = 0;
var QueryDay = 0;
var FirstDay = 0;
var WeekRef = 0;
var WeekOne = 0;
var Today = new Date();
var TodaysYear = Today.getYear();
var TodaysMonth = Today.getMonth() + 1;
var TodaysDate = Today.getDate();
var TodaysDay = Today.getDay() + 1;
if (TodaysYear < 2000) { TodaysYear += 1900; }
function CheckData()
{
QueryDate = document.Cal.Date.selectedIndex + 1;
QueryMonth = document.Cal.Month.selectedIndex + 1;
QueryYear = (document.Cal.Century.selectedIndex + 15) * 100 + document.Cal.Year.selectedIndex;
MonthLength[2] = CheckLeap(QueryYear);
if ((QueryYear * 10000 + QueryMonth * 100 + QueryDate) < 15821220)
{
alert("Je hebt een datum gekozen van voor Dec 20th 1582.\n\nKies een andere selectie.. zo ver terug gaan we niet !.");
document.Cal.reset();
CheckData();
}
else if (MonthLength[QueryMonth] < QueryDate)
{
alert("Il n'y a pas " + QueryDate + " jours en " + MonthsList[QueryMonth] + " " + QueryYear + " mais " + MonthLength[QueryMonth] + ". \nVeuillez choisir une autre date.");
document.Cal.reset();
CheckData();
}
else { DisplaySchedule(); }
}
function CheckLeap(yy)
{
if ((yy % 100 != 0 && yy % 4 == 0) || (yy % 400 == 0)) { return 29; }
else { return 28; }
}
function DefWeekNum(dd)
{
numd = 0;
numw = 0;
for (n=1; n<QueryMonth; n++)
{
numd += MonthLength[n];
}
numd = numd + dd - (9 - DefDateDay(QueryYear,1,1));
numw = Math.floor(numd / 7) + 1;
if (DefDateDay(QueryYear,1,1) == 1) { numw++; }
return numw;
}
function DefDateDay(yy,mm,dd)
{
return Math.floor((Date2Days(yy,mm,dd)-2) % 7) + 1;
}
function Date2Days(yy,mm,dd)
{
if (mm > 2)
{
var bis = Math.floor(yy/4) - Math.floor(yy/100) + Math.floor(yy/400);
var zy = Math.floor(yy * 365 + bis);
var zm = (mm-1) * 31 - Math.floor(mm * 0.4 + 2.3);
return (zy + zm + dd);
}
else
{
var bis = Math.floor((yy-1)/4) - Math.floor((yy-1)/100) + Math.floor((yy-1)/400);
var zy = Math.floor(yy * 365 + bis);
return (zy + (mm-1) * 31 + dd);
}
}
function findid(name,doc){
var i,layer;
for(i=0;i<doc.layers.length;i++){
layer=doc.layers[i];
if(layer.name==name)return layer;
if(layer.document.layers.length>0)if((layer=findid(name,layer.document))!=null)return layer;
}
return null;
}
function DisplaySchedule()
{
HTMLCode = "<table cellspacing=0 cellpadding=3 border=1 bordercolor=#404040>";
QueryDay = DefDateDay(QueryYear,QueryMonth,QueryDate);
WeekRef = DefWeekNum(QueryDate);
WeekOne = DefWeekNum(1);
HTMLCode += "<tr align=center><td colspan=8 class=TITRE><b>" + MonthsList[QueryMonth] + " " + QueryYear + "</b></td></tr><tr align=center>";
for (s=1; s<8; s++)
{
if (QueryDay == s) { HTMLCode += "<td width=28><b><font color=#FF0000>" + DaysList[s] + "</font></b></td>"; }
else { HTMLCode += "<td width=28><b>" + DaysList[s] + "</b></td>"; }
}
HTMLCode += "<td><b><font color=#FF0000>Week</font></b></td></tr>";
a = 0;
for (i=(1-DefDateDay(QueryYear,QueryMonth,1)); i<MonthLength[QueryMonth]; i++)
{
HTMLCode += "<tr align=center>";
for (j=1; j<8; j++)
{
if ((i+j) <= 0) { HTMLCode += "<td> </td>"; }
else if ((i+j) == QueryDate) { HTMLCode += "<td><b><font color=#FF9933>" + (i+j) + "</font></b></td>"; }
else if ((i+j) > MonthLength[QueryMonth]) { HTMLCode += "<td> </td>"; }
else { HTMLCode += "<td>" + (i+j) + "</td>"; }
}
if ((WeekOne+a) == WeekRef) { HTMLCode += "<td><b><font color=#FF0000>" + WeekRef + "</font></b></td>"; }
else { HTMLCode += "<td><font color=#99CCCC>" + (WeekOne+a) + "</font></td>"; }
HTMLCode += "</tr>";
a++;
i = i + 6;
}
// ALLOWS CROSS-BROWSER WRITING IN DOCUMENT. BEGIN BG MODIFY
if(ie4)document.all['Calendrier'].innerHTML = HTMLCode + "</table>";
if(w3c)document.getElementById('Calendrier').innerHTML= HTMLCode + "</table>";
if(ns4){
var tns4=findid('Calendrier',document);
tns4.document.open();
tns4.document.write('<center>'+HTMLCode+'</table></center>');
tns4.document.close();
}
// END BG MODIFY
}
function Back()
{
document.Cal.Month.selectedIndex = document.Cal.Month.selectedIndex - 1;
if (document.Cal.Month.selectedIndex == -1) { document.Cal.Month.selectedIndex = 11; }
}
function Next()
{
document.Cal.Month.selectedIndex = document.Cal.Month.selectedIndex + 1;
if (document.Cal.Month.selectedIndex == -1) { document.Cal.Month.selectedIndex = 0; }
}
window.onload=CheckData;
if(ns4)window.onresize=function(){
setTimeout('history.go(0)',400);
}
//-->
</script>
<script language = "JavaScript1.2" type= "text/javascript" >
<!--
ns4 = ( navigator. appName. indexOf( "Netscape" ) >= 0 && document. layers) ? true : false ;
ie4 = ( document. all && ! document. getElementById) ? true : false ;
ie5 = ( document. all && document. getElementById) ? true : false ;
ns6 = ( document. getElementById && navigator. appName. indexOf( "Netscape" ) >= 0 ) ? true : false ;
w3c = ( document. getElementById) ? true : false ;
var HTMLCode = "" ;
var DaysList
= new Array ( "" , "Ma" , "Di" , "Wo" , "Do" , "Vr" , "Za" , "Zo" ) ; var MonthsList
= new Array ( "Mois_Vide" , "Januari" , "Februari" , "Maart" , "April" , "Mei" , "Juni" , "Juli" , "Augustus" , "September" , "Oktober" , "November" , "December" ) ; var MonthLength
= new Array ( "Mois_longueur_vide" , 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ) ;
var QueryDate = 0 ;
var QueryMonth = 0 ;
var QueryYear = 0 ;
var QueryDay = 0 ;
var FirstDay = 0 ;
var WeekRef = 0 ;
var WeekOne = 0 ;
var TodaysYear = Today. getYear( ) ;
var TodaysMonth = Today. getMonth( ) + 1 ;
var TodaysDay = Today. getDay( ) + 1 ;
if ( TodaysYear < 2000 ) { TodaysYear += 1900 ; }
function CheckData( )
{
QueryDate
= document
. Cal
. Date . selectedIndex
+ 1 ; QueryMonth = document. Cal. Month. selectedIndex + 1 ;
QueryYear = ( document. Cal. Century. selectedIndex + 15 ) * 100 + document. Cal. Year. selectedIndex;
MonthLength[ 2 ] = CheckLeap( QueryYear) ;
if ( ( QueryYear * 10000 + QueryMonth * 100 + QueryDate) < 15821220 )
{
alert( "Je hebt een datum gekozen van voor Dec 20th 1582.\n \n Kies een andere selectie.. zo ver terug gaan we niet !." ) ;
CheckData( ) ;
}
else if ( MonthLength[ QueryMonth] < QueryDate)
{
alert( "Il n'y a pas " + QueryDate + " jours en " + MonthsList[ QueryMonth] + " " + QueryYear + " mais " + MonthLength[ QueryMonth] + ". \n Veuillez choisir une autre date." ) ;
CheckData( ) ;
}
else { DisplaySchedule( ) ; }
}
function CheckLeap( yy)
{
if ( ( yy % 100 != 0 && yy % 4 == 0 ) || ( yy % 400 == 0 ) ) { return 29 ; }
else { return 28 ; }
}
function DefWeekNum( dd)
{
numd = 0 ;
numw = 0 ;
for ( n= 1 ; n< QueryMonth; n++ )
{
numd += MonthLength[ n] ;
}
numd = numd + dd - ( 9 - DefDateDay( QueryYear, 1 , 1 ) ) ;
numw
= Math
. floor ( numd
/ 7 ) + 1 ;
if ( DefDateDay( QueryYear, 1 , 1 ) == 1 ) { numw++; }
return numw;
}
function DefDateDay( yy, mm, dd)
{
return Math
. floor ( ( Date2Days
( yy
, mm
, dd
) - 2 ) % 7 ) + 1 ; }
function Date2Days( yy, mm, dd)
{
if ( mm > 2 )
{
var zy
= Math
. floor ( yy
* 365 + bis
) ; var zm
= ( mm
- 1 ) * 31 - Math
. floor ( mm
* 0.4 + 2.3 ) ; return ( zy + zm + dd) ;
}
else
{
var bis
= Math
. floor ( ( yy
- 1 ) / 4 ) - Math
. floor ( ( yy
- 1 ) / 100 ) + Math
. floor ( ( yy
- 1 ) / 400 ) ; var zy
= Math
. floor ( yy
* 365 + bis
) ; return ( zy + ( mm- 1 ) * 31 + dd) ;
}
}
function findid( name, doc) {
var i, layer;
for ( i= 0 ; i< doc. layers. length; i++ ) {
layer= doc. layers[ i] ;
if ( layer. name== name) return layer;
if ( layer. document. layers. length> 0 ) if ( ( layer= findid( name, layer. document) ) != null ) return layer;
}
return null ;
}
function DisplaySchedule( )
{
HTMLCode = "<table cellspacing=0 cellpadding=3 border=1 bordercolor=#404040>" ;
QueryDay = DefDateDay( QueryYear, QueryMonth, QueryDate) ;
WeekRef = DefWeekNum( QueryDate) ;
WeekOne = DefWeekNum( 1 ) ;
HTMLCode += "<tr align=center><td colspan=8 class=TITRE><b>" + MonthsList[ QueryMonth] + " " + QueryYear + "</b></td></tr><tr align=center>" ;
for ( s= 1 ; s< 8 ; s++ )
{
if ( QueryDay == s) { HTMLCode += "<td width=28><b><font color=#FF0000>" + DaysList[ s] + "</font></b></td>" ; }
else { HTMLCode += "<td width=28><b>" + DaysList[ s] + "</b></td>" ; }
}
HTMLCode += "<td><b><font color=#FF0000>Week</font></b></td></tr>" ;
a = 0 ;
for ( i= ( 1 - DefDateDay( QueryYear, QueryMonth, 1 ) ) ; i< MonthLength[ QueryMonth] ; i++ )
{
HTMLCode += "<tr align=center>" ;
for ( j= 1 ; j< 8 ; j++ )
{
if ( ( i+ j) <= 0 ) { HTMLCode += "<td> </td>" ; }
else if ( ( i+ j) == QueryDate) { HTMLCode += "<td><b><font color=#FF9933>" + ( i+ j) + "</font></b></td>" ; }
else if ( ( i+ j) > MonthLength[ QueryMonth] ) { HTMLCode += "<td> </td>" ; }
else { HTMLCode += "<td>" + ( i+ j) + "</td>" ; }
}
if ( ( WeekOne+ a) == WeekRef) { HTMLCode += "<td><b><font color=#FF0000>" + WeekRef + "</font></b></td>" ; }
else { HTMLCode += "<td><font color=#99CCCC>" + ( WeekOne+ a) + "</font></td>" ; }
HTMLCode += "</tr>" ;
a++;
i = i + 6 ;
}
// ALLOWS CROSS-BROWSER WRITING IN DOCUMENT. BEGIN BG MODIFY
if ( ie4) document. all[ 'Calendrier' ] . innerHTML = HTMLCode + "</table>" ;
if ( w3c) document. getElementById( 'Calendrier' ) . innerHTML= HTMLCode + "</table>" ;
if ( ns4) {
var tns4= findid( 'Calendrier' , document) ;
tns4. document. open( ) ;
tns4. document. write( '<center>' + HTMLCode+ '</table></center>' ) ;
tns4. document. close( ) ;
}
// END BG MODIFY
}
function Back( )
{
document. Cal. Month. selectedIndex = document. Cal. Month. selectedIndex - 1 ;
if ( document. Cal. Month. selectedIndex == - 1 ) { document. Cal. Month. selectedIndex = 11 ; }
}
{
document. Cal. Month. selectedIndex = document. Cal. Month. selectedIndex + 1 ;
if ( document. Cal. Month. selectedIndex == - 1 ) { document. Cal. Month. selectedIndex = 0 ; }
}
window. onload= CheckData;
if ( ns4) window. onresize= function ( ) {
setTimeout( 'history.go(0)' , 400 ) ;
}
//-->
</script>
zet dit in je body
<center>
<form name="Cal">
<font color="#00FF00">
<script language="JavaScript1.2" type="text/javascript">
<!--
DateText = "<select name=\"Date\">"
for (d=1; d<32; d++)
{
DateText += "<option";
if (d == TodaysDate) { DateText += " SELECTED"; }
DateText += ">";
if (d < 10) { DateText += "0"; }
DateText += d + "</option>";
}
DateText += "</select>";
//*************************************************
MonthText = "<select name=\"Month\">"
for (m=1; m<13; m++)
{
MonthText += "<option";
if (m == TodaysMonth) { MonthText += " SELECTED"; }
MonthText += ">";
MonthText += MonthsList[m] + "</option>";
}
MonthText += "</select>";
//*************************************************
CenturyText = "<select name=\"Century\">"
for (c=15; c<25; c++)
{
CenturyText += "<option";
if (c == Math.floor(TodaysYear / 100)) { CenturyText += " SELECTED"; }
CenturyText += ">" + c + "</option>";
}
CenturyText += "</select>";
//*************************************************
YearText = "<select name=\"Year\">";
for (y=0; y<100; y++)
{
YearText += "<option";
if (y == (TodaysYear - Math.floor(TodaysYear / 100) * 100)) { YearText += " SELECTED"; }
YearText += ">";
if (y < 10) { YearText += "0"; }
YearText += y + "</option>";
}
YearText += "</select>";
//*************************************************
document.write(MonthText+' '+DateText+', '+CenturyText+' '+YearText);
//-->
</script> <input type="button" value=" OK " style="font-size: 8 pt" onClick="CheckData()"><br><br>
<input type="button" value="<< Maand" style="font-size: 8 pt" onClick="Back(); CheckData()"><input type="button" value=" Ga terug naar vandaag..." style="font-size: 8 pt" onClick="document.Cal.reset(); setTimeout('CheckData()',100)"><input type="button" value="Maand >>" style="font-size: 8 pt" onClick="Next();CheckData()">
<br><br><br>
<script language="javascript1.2">
if(ns4)document.write('<layer name="Calendrier"></layer><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>')
else document.write('<div id="Calendrier"></div>');
</script>
</font>
</center></form>
< center>
< form name= "Cal" >
< font color= "#00FF00" >
<script language = "JavaScript1.2" type= "text/javascript" >
<!--
DateText = "<select name=\" Date\" >"
for ( d= 1 ; d< 32 ; d++ )
{
DateText += "<option" ;
if ( d == TodaysDate) { DateText += " SELECTED" ; }
DateText += ">" ;
if ( d < 10 ) { DateText += "0" ; }
DateText += d + "</option>" ;
}
DateText += "</select>" ;
//*************************************************
MonthText = "<select name=\" Month\" >"
for ( m= 1 ; m< 13 ; m++ )
{
MonthText += "<option" ;
if ( m == TodaysMonth) { MonthText += " SELECTED" ; }
MonthText += ">" ;
MonthText += MonthsList[ m] + "</option>" ;
}
MonthText += "</select>" ;
//*************************************************
CenturyText = "<select name=\" Century\" >"
for ( c= 15 ; c< 25 ; c++ )
{
CenturyText += "<option" ;
if ( c
== Math
. floor ( TodaysYear
/ 100 ) ) { CenturyText
+= " SELECTED" ; } CenturyText += ">" + c + "</option>" ;
}
CenturyText += "</select>" ;
//*************************************************
YearText = "<select name=\" Year\" >" ;
for ( y= 0 ; y< 100 ; y++ )
{
YearText += "<option" ;
if ( y
== ( TodaysYear
- Math
. floor ( TodaysYear
/ 100 ) * 100 ) ) { YearText
+= " SELECTED" ; } YearText += ">" ;
if ( y < 10 ) { YearText += "0" ; }
YearText += y + "</option>" ;
}
YearText += "</select>" ;
//*************************************************
document. write( MonthText+ ' ' + DateText+ ', ' + CenturyText+ ' ' + YearText) ;
//-->
</script> < input type= "button" value= " OK " style= "font-size: 8 pt" onClick= "CheckData()" >< br>< br>
< input type= "button" value= "<< Maand" style= "font-size: 8 pt" onClick= "Back(); CheckData()" >< input type= "button" value= " Ga terug naar vandaag..." style= "font-size: 8 pt" onClick= "document.Cal.reset(); setTimeout('CheckData()',100)" >< input type= "button" value= "Maand >>" style= "font-size: 8 pt" onClick= "Next();CheckData()" >
< br>< br>< br>
<script language = "javascript1.2" >
if ( ns4) document. write( '<layer name="Calendrier"></layer><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>' )
else document. write( '<div id="Calendrier"></div>' ) ;
</script>
</ font>
</ center></ form>
Download code (.txt)
Stemmen
Niet ingelogd.