diff --git a/data/example.kal.json b/data/example.kal.json index 38e2ac8..6f2599d 100644 --- a/data/example.kal.json +++ b/data/example.kal.json @@ -79,18 +79,18 @@ ], "events": [ { - "name": "38.KW", + "name": "Krautnudeln", "begin": { "timezone_shift": 2, - "date": {"year": 2024, "month": 9, "day": 20}, + "date": {"year": 2024, "month": 9, "day": 21}, "time": {"hour": 17, "minute": 0, "second": 0} }, "end": { "timezone_shift": 2, - "date": {"year": 2024, "month": 9, "day": 20}, + "date": {"year": 2024, "month": 9, "day": 21}, "time": {"hour": 19, "minute": 0, "second": 0} }, - "description": "Krautnudeln" + "description": null } ] } diff --git a/source/logic.ts b/source/logic.ts index 10ad15a..2da27e6 100644 --- a/source/logic.ts +++ b/source/logic.ts @@ -213,17 +213,21 @@ function calendar_view_table( timezone_shift ?: int; } = {} ) : Array< - Array< - { - pit : type_pit; - entries : Array< - { - calendar_id : type_calendar_id; - event : type_event; - } - >; - } - > + { + week : int; + data : Array< + { + pit : type_pit; + entries : Array< + { + calendar_id : type_calendar_id; + event : type_event; + } + >; + today : boolean; + } + >; + } > { options = Object.assign( @@ -266,17 +270,21 @@ function calendar_view_table( to_pit ); let result : Array< - Array< - { - pit : type_pit; - entries : Array< - { - calendar_id : type_calendar_id; - event : type_event; - } - >; - } - > + { + week : int; + data : Array< + { + pit : type_pit; + entries : Array< + { + calendar_id : type_calendar_id; + event : type_event; + } + >; + today : boolean; + } + >; + } > = []; let row : Array< { @@ -287,6 +295,7 @@ function calendar_view_table( event : type_event; } >; + today : boolean; } > = []; let day : int = 0; @@ -298,10 +307,11 @@ function calendar_view_table( { "pit": pit_current, "entries": [], + "today": false, // TODO } ); if (day % 7 === 0) { - result.push(row); + result.push({"week": (from.week + Math.floor(day / 7)), "data": row}); row = []; } else { @@ -325,9 +335,9 @@ function calendar_view_table( 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"); +// process.stderr.write(JSON.stringify({entry, distance_days, week, day}, undefined, "\t") + "\n"); - result[week][day].entries.push(entry); + result[week].data[day].entries.push(entry); } ) ); @@ -360,7 +370,23 @@ function calendar_view_table_html( }, options ); - const rows = calendar_view_table( + const rows : Array< + { + week : int; + data : Array< + { + pit : type_pit; + entries : Array< + { + calendar_id : type_calendar_id; + event : type_event; + } + >; + today : boolean; + } + >; + } + > = calendar_view_table( data, calendar_id, from, @@ -370,75 +396,209 @@ function calendar_view_table_html( } ); return ( - ( - "\n" - ) - + - "
\n"
- +
+ new lib_plankton.xml.class_node_complex(
+ "div",
+ {
+ "class": "calendar",
+ },
+ [
+ new lib_plankton.xml.class_node_complex(
+ "style",
+ {},
+ [
+ new lib_plankton.xml.class_node_text(
+ "html {background-color: #111; color: #FFF; font-family: sans-serif;}\n"
+ +
+ "table {width: 100%; border-collapse: collapse;}\n"
+ +
+ ".calendar-cell {border: 1px solid #444; padding: 8px; vertical-align: top;}\n"
+ +
+ ".calendar-cell-day {width: 13.5%;}\n"
+ +
+ ".calendar-cell-week {width: 5.5%;}\n"
+ +
+ ".calendar-cell-regular {width: 13.5%;}\n"
+ +
+ ".calendar-day {font-size: 0.75em;}\n"
+ +
+ ".calendar-events {margin: 0; padding: 0; list-style-type: none;}\n"
+ +
+ ".calendar-event_entry {margin: 4px; padding: 4px; border-radius: 2px; font-size: 0.75em;}\n"
+ )
+ ]
+ ),
+ new lib_plankton.xml.class_node_complex(
+ "table",
+ {
+ },
+ [
+ new lib_plankton.xml.class_node_complex(
+ "thead",
+ {
+ },
+ [
+ new lib_plankton.xml.class_node_complex(
+ "tr",
+ {
+ },
(
- "\t\t\t\t
| \n"
)
)
- .join("")
)
- +
- "\t\t