diff --git a/source/logic.ts b/source/logic.ts index 2da27e6..efcfc15 100644 --- a/source/logic.ts +++ b/source/logic.ts @@ -256,6 +256,7 @@ function calendar_view_table( "timezone_shift": (options.timezone_shift as int), } ); + const now_pit : type_pit = pit_now(); // prepare const entries : Array< @@ -324,23 +325,38 @@ function calendar_view_table( } // fill - ( - entries - .forEach( - (entry) => { - 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 week : int = Math.floor(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); + { + // events + ( + entries + .forEach( + (entry) => { + const distance_seconds : int = (pit_from_datetime(entry.event.begin) - 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); + + 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; } @@ -419,6 +435,8 @@ function calendar_view_table_html( + ".calendar-cell-regular {width: 13.5%;}\n" + + ".calendar-cell-today {background-color: #333;}\n" + + ".calendar-day {font-size: 0.75em;}\n" + ".calendar-events {margin: 0; padding: 0; list-style-type: none;}\n" @@ -506,7 +524,7 @@ function calendar_view_table_html( "class": ( ( ["calendar-cell", "calendar-cell-regular"] - .concat(cell.today ? ["today"] : []) + .concat(cell.today ? ["calendar-cell-today"] : []) ) .join(" ") ), @@ -523,7 +541,7 @@ function calendar_view_table_html( } ), ] - ) + ), }, [ new lib_plankton.xml.class_node_complex(