Jojoxx.net logotyp

 

 

Användare ikonAnvändare
Besökare just nu: 35
Snabblänkar ikonSnabblänkar
JavaScript-arkivet
Perl
FAQ

Sök på Jojoxx.net


Månadskalender 2

Exempel

Kod


<style type="text/css">
.mcCell { width:80px; height:50px; border: solid black 1px; border-right: solid rgb(200,200,200) 1px; border-bottom: solid rgb(200,200,200) 1px; vertical-align:top; font-family:Verdana; font-size: 10px; }
.mcWeekCell { vertical-align:top; font-family:Verdana; font-size: 10px; font-weight: bold; }
.mcSundayCell { color: red; }
.mcHeadingCell { vertical-align:top; font-family:Verdana; font-size: 10px; font-weight: bold; }
.mcTodayCell { background-color: rgb(230,255,230); }
</style>
<script type="text/javascript">
var dateevents=new Object();
// --- Lägg till egna händelser nedan ---
dateevents["31/12-1999"]="Millenieskifte";
dateevents["24/12"]="Julafton";
dateevents["1"]="Ny månad";

// --- Icke användarredigerbar kod nedan ---
Date.prototype.getWeek=function(){
	var nywd=(new Date(this.getFullYear(),0,1).getDay()==0)?7:new Date(this.getFullYear(),0,1).getDay();
	var w=Math.ceil((this.getTime()+nywd*86400000-new Date(this.getFullYear(),0,1).getTime())/(604800000))
	if(nywd>4){w--;}
	if(w==0){ return new Date(this.getFullYear()-1,11,31).getWeek()}
	if(w==53 && new Date(this.getFullYear()+1,0,1).getDay()<=4){w=1}
	return w
}
var mc=new Object();
mc.wd=function(i){ return((i==0)?7:i); }
mc.date=new Date();
mc.i=new Date(mc.date.getFullYear(),mc.date.getMonth(),1);
mc.html='<table><tr><td></td><td class="mcHeadingCell">Mån</td><td class="mcHeadingCell">Tis</td><td class="mcHeadingCell">Ons</td><td class="mcHeadingCell">Tor</td><td class="mcHeadingCell">Fre</td><td class="mcHeadingCell">Lör</td><td class="mcHeadingCell">Sön</td></tr>';
if(mc.i.getDay()!=1){ mc.html+='<tr><td class="mcWeekCell">'+mc.i.getWeek()+'</td><td colspan="'+(mc.wd(mc.i.getDay())-1)+'"></td>'; }
for(mc.i=mc.i;mc.i.getMonth()==mc.date.getMonth();mc.i.setDate(mc.i.getDate()+1)){
	var datestr=mc.i.getDate()+"/"+(mc.i.getMonth()+1);
	var dayevent=(dateevents[datestr+"-"+mc.i.getFullYear()])?"<br>"+dateevents[datestr+"-"+mc.i.getFullYear()]:"";
	dayevent+=(dateevents[datestr])?"<br>"+dateevents[datestr]:"";
	dayevent+=(dateevents[mc.i.getDate()])?"<br>"+dateevents[mc.i.getDate()]:"";
	if(mc.i.getDay()==1){ mc.html+='<tr><td class="mcWeekCell">'+mc.i.getWeek()+'</td>'; }
	var cellClass="mcCell";
	if(mc.i.getDay()==0){ cellClass+=" mcSundayCell"; }
	if(mc.i.getDate()==mc.date.getDate()){ cellClass+=" mcTodayCell"; }
	mc.html+='<td class="'+cellClass+'">'+mc.wd(mc.i.getDate())+dayevent+'</td>'
	if(mc.i.getDay()==0){ mc.html+='</tr>'; }
}
mc.html+='</tr></table>'
document.write('<div id="monthcalender">'+mc.html+'</div>')
</script>

,