Skip to content

Commit b0cc490

Browse files
authored
Update PAGE-calendar.js
1 parent b14548f commit b0cc490

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

calendar/assets/PAGE-calendar.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ var cal = {
9494
nowDay = cal.sMth==nowMth && cal.sYear==nowYear ? now.getDate() : null ;
9595

9696
// (E2) DRAW CALENDAR ROWS & CELLS
97-
// (E2-1) INIT + HELPER FUNCTIONS
98-
let rowA, rowB, rowC, rowMap = {}, rowNum = 1,
99-
cell, cellNum = 1,
97+
// (E2-1) INIT
98+
let rowA, rowB, rowC, rowMap = {}, rowNum = 1, cell, cellNum = 1,
99+
100+
// (E2-2) HELPER - DRAW A NEW ROW
100101
rower = () => {
101102
rowA = document.createElement("div");
102103
rowB = document.createElement("div");
@@ -109,6 +110,8 @@ var cal = {
109110
rowA.appendChild(rowB);
110111
rowA.appendChild(rowC);
111112
},
113+
114+
// (E2-3) HELPER - DRAW A NEW CELL
112115
celler = day => {
113116
cell = document.createElement("div");
114117
cell.className = "calCell";
@@ -130,9 +133,11 @@ var cal = {
130133
if (day!==undefined && day==nowDay) { cell.classList.add("calToday"); }
131134
rowC.appendChild(cell);
132135
};
136+
137+
// (E2-4) RESET CALENDAR
133138
cal.hCB.innerHTML = ""; rower();
134139

135-
// (E2-2) BLANK CELLS BEFORE START OF MONTH
140+
// (E2-5) BLANK CELLS BEFORE START OF MONTH
136141
if (cal.mon && startDay != 1) {
137142
let blanks = startDay==0 ? 7 : startDay ;
138143
for (let i=1; i<blanks; i++) { celler(); cellNum++; }
@@ -141,15 +146,15 @@ var cal = {
141146
for (let i=0; i<startDay; i++) { celler(); cellNum++; }
142147
}
143148

144-
// (E2-3) DAYS OF THE MONTH
149+
// (E2-6) DAYS OF THE MONTH
145150
for (let i=1; i<=daysInMth; i++) {
146151
rowMap[i] = { r : rowNum, c : cellNum };
147152
celler(i);
148153
if (cellNum%7==0 && i!=daysInMth) { rowNum++; rower(); }
149154
cellNum++;
150155
}
151156

152-
// (E2-4) BLANK CELLS AFTER END OF MONTH
157+
// (E2-7) BLANK CELLS AFTER END OF MONTH
153158
if (cal.mon && endDay != 0) {
154159
let blanks = endDay==6 ? 1 : 7-endDay;
155160
for (let i=0; i<blanks; i++) { celler(); cellNum++; }
@@ -257,4 +262,4 @@ var cal = {
257262
}
258263
}))
259264
};
260-
window.addEventListener("load", cal.init);
265+
window.addEventListener("load", cal.init);

0 commit comments

Comments
 (0)