This commit is contained in:
Fenris Wolf 2024-09-09 21:07:04 +02:00
parent 0461344aad
commit b4e6a26d54

View file

@ -256,6 +256,7 @@ function calendar_view_table(
"timezone_shift": (options.timezone_shift as int), "timezone_shift": (options.timezone_shift as int),
} }
); );
const now_pit : type_pit = pit_now();
// prepare // prepare
const entries : Array< const entries : Array<
@ -324,23 +325,38 @@ function calendar_view_table(
} }
// fill // fill
{
// events
( (
entries entries
.forEach( .forEach(
(entry) => { (entry) => {
const distance_seconds : int = (pit_from_datetime(entry.event.begin) - from_pit); const distance_seconds : int = (pit_from_datetime(entry.event.begin) - from_pit);
// process.stderr.write(JSON.stringify({"begin": entry.event.begin, "begin_pit": pit_from_datetime(entry.event.begin), "from": from_pit, "diff": distance_seconds}) + "\n");
const distance_days : int = (distance_seconds / (60 * 60 * 24)); const distance_days : int = (distance_seconds / (60 * 60 * 24));
const week : int = Math.floor(Math.floor(distance_days) / 7); const week : int = Math.floor(Math.floor(distance_days) / 7);
const day : int = (Math.floor(distance_days) % 7); const day : int = (Math.floor(distance_days) % 7);
// process.stderr.write(JSON.stringify({entry, distance_days, week, day}, undefined, "\t") + "\n");
result[week].data[day].entries.push(entry); result[week].data[day].entries.push(entry);
} }
) )
); );
// today
{
const distance_seconds : int = (now_pit - from_pit);
const distance_days : int = (distance_seconds / (60 * 60 * 24));
const week : int = Math.floor(Math.floor(distance_days) / 7);
const day : int = (Math.floor(distance_days) % 7);
if ((week >= 0) && (week < result.length)) {
result[week].data[day].today = true;
}
else {
// do nothing
}
}
}
return result; return result;
} }
@ -419,6 +435,8 @@ function calendar_view_table_html(
+ +
".calendar-cell-regular {width: 13.5%;}\n" ".calendar-cell-regular {width: 13.5%;}\n"
+ +
".calendar-cell-today {background-color: #333;}\n"
+
".calendar-day {font-size: 0.75em;}\n" ".calendar-day {font-size: 0.75em;}\n"
+ +
".calendar-events {margin: 0; padding: 0; list-style-type: none;}\n" ".calendar-events {margin: 0; padding: 0; list-style-type: none;}\n"
@ -506,7 +524,7 @@ function calendar_view_table_html(
"class": ( "class": (
( (
["calendar-cell", "calendar-cell-regular"] ["calendar-cell", "calendar-cell-regular"]
.concat(cell.today ? ["today"] : []) .concat(cell.today ? ["calendar-cell-today"] : [])
) )
.join(" ") .join(" ")
), ),
@ -523,7 +541,7 @@ function calendar_view_table_html(
} }
), ),
] ]
) ),
}, },
[ [
new lib_plankton.xml.class_node_complex( new lib_plankton.xml.class_node_complex(