JavaScripts -> Kalender -> Terminkalender

Dieses Script beinhaltet einen Terminkalender. Sie binden Ihn einfach mit einem Script mit dem Inhalt calendar(); an der gewünschten Stelle ein. Vor dieser Zeile sollten Sie allerdings neue Termine hinzufügen. Pro Termin benötigen Sie eine Zeile mit dem Inhalt ccnew(Tag,Monat,Jahr,Beschreibung,Wiederholung); Tag,Monat,Jahr geben das Datum an, Beschreibung ist der Beschreibungstext und Wiederholung gibt an, wann sich dieser Termin wiederholt. Dazu sollten Sie die Konstanten none, daily, monthly und yearly verwenden.

Kompatibilität getestet:
Beispiel Anzeigen >>

Script-Code

<script type="text/javascript">
<!--
//Scheduler v1.0 (c) 2003 Triple-M / http://www.htmlarsenal.de

// ZUR BENUTZUNG
// Dieses Script beinhaltet einen Terminkalender. Sie binden Ihn einfach mit einem Script mit dem Inhalt
// calendar();
// an der gewünschten Stelle ein. Vor dieser Zeile sollten Sie allerdings neue Termine hinzufügen. Pro
// Termin benötigen Sie eine Zeile mit dem Inhalt
// ccnew(Tag,Monat,Jahr,Beschreibung,Wiederholung);
// Tag,Monat,Jahr geben das Datum an, Beschreibung ist der Beschreibungstext und Wiederholung gibt an,
// wann sich dieser Termin wiederholt. Dazu sollten Sie die Konstanten none, daily, monthly und yearly
// verwenden.

// USAGE
// This script contains a schedule. You can easily display it by utilizing a script with the content
// calendar();
// on the position of the page where the calendar shall be placed. Before this line you should add the
// dates. For each date you need a line with the content
// ccnew(Day,Month,Year,Description,Repetition);
// Day,Month,Year specify the date, Descripton is a describing text and Repetition deternubes, when this
// date will be repeated. You should use one of the constants none, daily, monthly and yearly here.

var ccmn=new Array("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");

//Monatsnamen / Month Names

var ccdcol="#ff0000"; // Farbe für Tage ohne Termin / Color for days with no dates
var ccncol="#000000"; // Farbe für Tage mit Termin / Color for days with dates

//Konstanten für die Angabe der Wiederholung / Constants for repetition information

var none=0; // Keine Terminwiederholung / No date repetition
var daily=1; // Täglich / Daily
//var weekly=2; // In dieser Version noch nicht implementiert / Not yet implemented in this version
var monthly=3; // Monatlich / Monthly
var yearly=4; // Jährlich / Yearly

//Ab hier bitte nichts mehr verändern / Please do not change anything from here on

var cml=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var ccevent=new Array();
var ccm,ccy;

function ccnew(d,m,y,desc,repeat) {
  ccevent[ccevent.length]=new Array(d,m,y,desc,repeat);
}

function ccsearch(d,m,y,s) {
  var i;
  for(i=s;i<ccevent.length;i++) {
    switch(ccevent[i][4]) {
      case 0: if((d==ccevent[i][0])&&(m==ccevent[i][1])&&(y==ccevent[i][2])) return i; break;
      case 1: return i; break;
      case 2: break;
      case 3: if(d==ccevent[i][0]) return i; break;
      case 4: if((d==ccevent[i][0])&&(m==ccevent[i][1])) return i; break;
    }
  }
  return (-1);
}

function ccisfuture(d,m,y,ev) {
  if(ccevent[ev][4]!=0)return 1;
  else if( (ccevent[ev][2]>y) || ((ccevent[ev][1]>m)&&(ccevent[ev][2]==y)) || ((ccevent[ev][0]>=d)&&(ccevent[ev][1]==m)&&(ccevent[ev][2]==y))) return 1;
  else return(0);
}

function ccml(month,year) {
  if(month!=2)return cml[month-1];
  else {
    if((year%4)==0) {
      if((year%100)==0) {
        if((year%400)==0) {
          return 29;
        } else return 28;
      } else return 29;
    } else return 28;
  }
}



function ccmonth(month,year) {
  ccm=month;
  ccy=year;
  for(i=0;i<6;i++) for(j=0;j<7;j++) {
    document.getElementById('cccell'+i+j).firstChild.nodeValue="";
    document.getElementById('cccell'+i+j).style.fontWeight="normal";
    document.getElementById('cccell'+i+j).style.color=ccncol;
  }
  document.getElementById('ccmonth').firstChild.nodeValue=ccmn[ccm-1]+" "+ccy;
  var d=new Date(ccy,ccm-1,1);
  var o=d.getDay();
  if(o==0)o=7;
  var l=ccml(ccm,ccy);
  for(var i=1;i<=l;i++) {
    document.getElementById('cccell'+Math.floor((i+o-2)/7)+((i+o-2)%7)).firstChild.nodeValue=i;
    if(ccsearch(i,ccm,ccy,0)>=0) {
      document.getElementById('cccell'+Math.floor((i+o-2)/7)+((i+o-2)%7)).style.fontWeight="bold";
      document.getElementById('cccell'+Math.floor((i+o-2)/7)+((i+o-2)%7)).style.color=ccdcol;
    }
  }
}

function ccnext() {
  ccm++;
  if(ccm>12) {
    ccy++;
    ccm=1;
  }
  ccmonth(ccm,ccy);
}

function cclast() {
  ccm--;
  if(ccm<1) {
    ccy--;
    ccm=12;
  }
  ccmonth(ccm,ccy);
}

function ccnextdate(d,m,y) {
  var fe=0;
  var rd,rm,ry,l,res=-1;
  var rs="";
  for(var i=0;i<ccevent.length;i++) if(ccisfuture(d,m,y,i)) fe=1;
  if(fe) {
   rd=d;
   rm=m;
   for(ry=y;;ry++) {
    for(;rm<13;rm++) {
      l=ccml(rm,ry);
      for(;rd<=l;rd++) {
        if(ccsearch(rd,rm,ry,0)>=0) {
          res=ccsearch(rd,rm,ry,0);
          while(res>=0) {
            if(rs.length)rs+=", ";
            rs+=ccevent[res][3];
            res=ccsearch(rd,rm,ry,(res+1));
          }
          document.getElementById("ccnd").firstChild.nodeValue=rd+"."+rm+"."+ry+": "+rs;
          return;
        }
      }
      rd=1;
    }
    rm=1;

   }
  } else {
   document.getElementById("ccnd").firstChild.nodeValue="--keine--";
  }
}

function ccthisdate(d,m,y) {
  var res=-1;
  var rs="";
  document.getElementById("ccddl").firstChild.nodeValue="Termine am "+d+"."+m+"."+y;
  if(ccsearch(d,m,y,0)>=0) {
    res=ccsearch(d,m,y,0);
      while(res>=0) {
      if(rs.length)rs+=", ";
      rs+=ccevent[res][3];
      res=ccsearch(d,m,y,(res+1));
    }
    document.getElementById("ccdd").firstChild.nodeValue=rs;
    return;
  } else {
    document.getElementById("ccdd").firstChild.nodeValue="--keine--";
  }
}


function ccclick(row,column) {
  var d=new Date(ccy,ccm-1,1);
  var o=d.getDay();
  if(o==0)o=7;
  ccthisdate(row*7+column+2-o,ccm,ccy);
}

function calendar(form,element) {
  document.write('<table class="calendar"><colgroup span="7" width="14%"><tr><th class="calendar" colspan="7" id="cchead"><a href="javascript:cclast()" class="calendar">[&lt;&lt;]</a> <span id="ccmonth">MONAT</span> <a href="javascript:ccnext()" class="calendar">[&gt;&gt;]</a></th></tr>');
  document.write('<tr><th class="calendar">M</th><th class="calendar">D</th><th class="calendar">M</th><th class="calendar">D</th><th class="calendar">F</th><th class="calendar">S</th><th class="calendar">S</th></tr>');
  for(i=0;i<6;i++) {
    document.write("<tr>");
    for(j=0;j<7;j++)document.write('<td class="calendar" id="cccell'+i+j+'" onClick="ccclick('+i+','+j+')">x</td>');
    document.write("</tr>");
  }
  document.write('<tr><td class="calendarout" colspan="7"><b id="ccddl">Termine am XX.XX.XXXX:</b><br><span id="ccdd">&nbsp;</span></td></tr>');
  document.write('<tr><td class="calendarout" colspan="7"><b>N&auml;chster Termin:</b><br><span id="ccnd">&nbsp;</span></td></tr>');
  document.write("</table>");
  var d=new Date();
  ccmonth(d.getMonth()+1,d.getFullYear());
  ccthisdate(d.getDate(),d.getMonth()+1,d.getFullYear());
  ccnextdate(d.getDate(),d.getMonth()+1,d.getFullYear());


}
//-->
</script>
<style type="text/css">
<!--
  /* Diese Formatierungsangaben können angepasst werden / This style sheet may be adapted */
  table.calendar {
    width:100%;
    border:2px solid #000000;
    background-color:#ffffff;
    empty-cells:hide;
    table-layout:fixed;
    border-collapse:separate;
    border-spacing:2px;
    font-family:Verdana;
  }

  th.calendar {
    margin:2px;
    background-color:#c0c0c0;
    border:1px solid #000000;
    color:#000000;
    font-weight:bold;
    text-align:center;
    font-size:12px;
  }

  td.calendar {
    margin:2px;
    background-color:#ffffff;
    color:#000000;
    border:1px solid #000000;
    font-weight:normal;
    font-size:10px;
    text-align:center;
    cursor:pointer;
  }

  td.calendarout {
    margin:2px;
    background-color:#ffffff;
    color:#000000;
    border:1px solid #000000;
    font-weight:normal;
    font-size:10px;
    text-align:center;
  }


  a.calendar {
    color:#800000;
    text-decoration:none;
  }


-->
</style>