-class StripCalender
-{
- constructor(year)
- {
- this._date = new Date(year);
- }
-
- createMonthHeader()
- {
- let tr = document.createElement("tr");
- tr.classList.add("row");
- tr.classList.add("month");
- let th = null;
- let attr = null;
- const monthnames = [ "Januar", "Februar", "März", "April",
- "Mai", "Juni", "Juli", "August", "September", "Oktober",
- "November", "Dezember" ];
-
- for (let i = 1; i <= 12; i++) {
- this._date.setMonth(i, 0);
- th = document.createElement("th");
- attr = document.createAttribute("colspan");
- attr.value = this._date.getDate();
- th.setAttributeNode(attr);
- th.innerText = monthnames[i - 1];
- tr.appendChild(th);
- }
-
- return tr;
- }
-
- createMonthDaysHeader()
- {
- let tr = document.createElement("tr");
- tr.classList.add("row");
- tr.classList.add("monthday");
-
- for (let i = 1; i <= 12; i++) {
- this._date.setMonth(i, 0);
- this.appendOneMonthDaysHeader(tr, this._date.getDate());
- }
-
- return tr;
- }
-
- appendOneMonthDaysHeader(tr, days)
- {
- let th = null;
-
- for (let i = 1; i <= days; i++) {
- th = document.createElement("th");
- th.innerText = i;
- tr.appendChild(th);
- }
- }
-
- createMonthWeekdayHeader()
- {
- let tr = document.createElement("tr");
- tr.classList.add("row");
- tr.classList.add("weekday");
-
- for (let i = 1; i <= 12; i++) {
- this._date.setMonth(i, 0);
- this.appendOneMonthWeekdayHeader(tr, this._date.getDate());
- }
-
- return tr;
- }
-
- appendOneMonthWeekdayHeader(tr, days)
- {
- let th = null;
- const weekday = [ "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" ]
-
- for (let i = 1; i <= days; i++) {
- this._date.setDate(i);
- th = document.createElement("th");
- th.innerText = weekday[this._date.getDay()];
- tr.appendChild(th);
- }
- }
-}
+import { StripCalender } from './stripcalender.mjs';
function calender()
{
cal.appendChild(table);
}
+
+document.addEventListener("onload", calender());
<title>Kalender</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="cal.css" />
- <script src="cal.js" type="text/javascript"></script>
+ <script src="cal.js" type="module"></script>
</head>
- <body onload="calender()">
+ <body>
<div id=cal>
</div>
</body>
--- /dev/null
+export class StripCalender
+{
+ constructor(year)
+ {
+ this._date = new Date(year);
+ }
+
+ createMonthHeader()
+ {
+ let tr = document.createElement("tr");
+ tr.classList.add("row");
+ tr.classList.add("month");
+ let th = null;
+ let attr = null;
+ const monthnames = [ "Januar", "Februar", "März", "April",
+ "Mai", "Juni", "Juli", "August", "September", "Oktober",
+ "November", "Dezember" ];
+
+ for (let i = 1; i <= 12; i++) {
+ this._date.setMonth(i, 0);
+ th = document.createElement("th");
+ attr = document.createAttribute("colspan");
+ attr.value = this._date.getDate();
+ th.setAttributeNode(attr);
+ th.innerText = monthnames[i - 1];
+ tr.appendChild(th);
+ }
+
+ return tr;
+ }
+
+ createMonthDaysHeader()
+ {
+ let tr = document.createElement("tr");
+ tr.classList.add("row");
+ tr.classList.add("monthday");
+
+ for (let i = 1; i <= 12; i++) {
+ this._date.setMonth(i, 0);
+ this.appendOneMonthDaysHeader(tr, this._date.getDate());
+ }
+
+ return tr;
+ }
+
+ appendOneMonthDaysHeader(tr, days)
+ {
+ let th = null;
+
+ for (let i = 1; i <= days; i++) {
+ th = document.createElement("th");
+ th.innerText = i;
+ tr.appendChild(th);
+ }
+ }
+
+ createMonthWeekdayHeader()
+ {
+ let tr = document.createElement("tr");
+ tr.classList.add("row");
+ tr.classList.add("weekday");
+
+ for (let i = 1; i <= 12; i++) {
+ this._date.setMonth(i, 0);
+ this.appendOneMonthWeekdayHeader(tr, this._date.getDate());
+ }
+
+ return tr;
+ }
+
+ appendOneMonthWeekdayHeader(tr, days)
+ {
+ let th = null;
+ const weekday = [ "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" ]
+
+ for (let i = 1; i <= days; i++) {
+ this._date.setDate(i);
+ th = document.createElement("th");
+ th.innerText = weekday[this._date.getDay()];
+ tr.appendChild(th);
+ }
+ }
+}