[mod]
This commit is contained in:
parent
ffb4304b0f
commit
0461344aad
3 changed files with 252 additions and 92 deletions
|
@ -79,18 +79,18 @@
|
||||||
],
|
],
|
||||||
"events": [
|
"events": [
|
||||||
{
|
{
|
||||||
"name": "38.KW",
|
"name": "Krautnudeln",
|
||||||
"begin": {
|
"begin": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date": {"year": 2024, "month": 9, "day": 20},
|
"date": {"year": 2024, "month": 9, "day": 21},
|
||||||
"time": {"hour": 17, "minute": 0, "second": 0}
|
"time": {"hour": 17, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"timezone_shift": 2,
|
"timezone_shift": 2,
|
||||||
"date": {"year": 2024, "month": 9, "day": 20},
|
"date": {"year": 2024, "month": 9, "day": 21},
|
||||||
"time": {"hour": 19, "minute": 0, "second": 0}
|
"time": {"hour": 19, "minute": 0, "second": 0}
|
||||||
},
|
},
|
||||||
"description": "Krautnudeln"
|
"description": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
332
source/logic.ts
332
source/logic.ts
|
@ -213,17 +213,21 @@ function calendar_view_table(
|
||||||
timezone_shift ?: int;
|
timezone_shift ?: int;
|
||||||
} = {}
|
} = {}
|
||||||
) : Array<
|
) : Array<
|
||||||
Array<
|
{
|
||||||
{
|
week : int;
|
||||||
pit : type_pit;
|
data : Array<
|
||||||
entries : Array<
|
{
|
||||||
{
|
pit : type_pit;
|
||||||
calendar_id : type_calendar_id;
|
entries : Array<
|
||||||
event : type_event;
|
{
|
||||||
}
|
calendar_id : type_calendar_id;
|
||||||
>;
|
event : type_event;
|
||||||
}
|
}
|
||||||
>
|
>;
|
||||||
|
today : boolean;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
options = Object.assign(
|
options = Object.assign(
|
||||||
|
@ -266,17 +270,21 @@ function calendar_view_table(
|
||||||
to_pit
|
to_pit
|
||||||
);
|
);
|
||||||
let result : Array<
|
let result : Array<
|
||||||
Array<
|
{
|
||||||
{
|
week : int;
|
||||||
pit : type_pit;
|
data : Array<
|
||||||
entries : Array<
|
{
|
||||||
{
|
pit : type_pit;
|
||||||
calendar_id : type_calendar_id;
|
entries : Array<
|
||||||
event : type_event;
|
{
|
||||||
}
|
calendar_id : type_calendar_id;
|
||||||
>;
|
event : type_event;
|
||||||
}
|
}
|
||||||
>
|
>;
|
||||||
|
today : boolean;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
}
|
||||||
> = [];
|
> = [];
|
||||||
let row : Array<
|
let row : Array<
|
||||||
{
|
{
|
||||||
|
@ -287,6 +295,7 @@ function calendar_view_table(
|
||||||
event : type_event;
|
event : type_event;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
today : boolean;
|
||||||
}
|
}
|
||||||
> = [];
|
> = [];
|
||||||
let day : int = 0;
|
let day : int = 0;
|
||||||
|
@ -298,10 +307,11 @@ function calendar_view_table(
|
||||||
{
|
{
|
||||||
"pit": pit_current,
|
"pit": pit_current,
|
||||||
"entries": [],
|
"entries": [],
|
||||||
|
"today": false, // TODO
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (day % 7 === 0) {
|
if (day % 7 === 0) {
|
||||||
result.push(row);
|
result.push({"week": (from.week + Math.floor(day / 7)), "data": row});
|
||||||
row = [];
|
row = [];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -325,9 +335,9 @@ function calendar_view_table(
|
||||||
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");
|
// 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
|
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,
|
data,
|
||||||
calendar_id,
|
calendar_id,
|
||||||
from,
|
from,
|
||||||
|
@ -370,75 +396,209 @@ function calendar_view_table_html(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
(
|
new lib_plankton.xml.class_node_complex(
|
||||||
"<style>\n"
|
"div",
|
||||||
+
|
{
|
||||||
"table {border-collapse: collapse;}\n"
|
"class": "calendar",
|
||||||
+
|
},
|
||||||
"td {border: 1px solid black; padding: 8px; margin: 8px; width: 14%;}\n"
|
[
|
||||||
+
|
new lib_plankton.xml.class_node_complex(
|
||||||
"</style>\n"
|
"style",
|
||||||
)
|
{},
|
||||||
+
|
[
|
||||||
"<table>\n"
|
new lib_plankton.xml.class_node_text(
|
||||||
+
|
"html {background-color: #111; color: #FFF; font-family: sans-serif;}\n"
|
||||||
(
|
+
|
||||||
"\t<thead>\n"
|
"table {width: 100%; border-collapse: collapse;}\n"
|
||||||
+
|
+
|
||||||
"\t</thead>\n"
|
".calendar-cell {border: 1px solid #444; padding: 8px; vertical-align: top;}\n"
|
||||||
)
|
+
|
||||||
+
|
".calendar-cell-day {width: 13.5%;}\n"
|
||||||
(
|
+
|
||||||
"\t<tbody>\n"
|
".calendar-cell-week {width: 5.5%;}\n"
|
||||||
+
|
+
|
||||||
(
|
".calendar-cell-regular {width: 13.5%;}\n"
|
||||||
rows
|
+
|
||||||
.map(
|
".calendar-day {font-size: 0.75em;}\n"
|
||||||
(row) => (
|
+
|
||||||
"\t\t<tr>\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"
|
||||||
row
|
)
|
||||||
.map(
|
]
|
||||||
(cell) => (
|
),
|
||||||
"\t\t\t<td>\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<ul>\n"
|
[
|
||||||
+
|
new lib_plankton.xml.class_node_complex(
|
||||||
(
|
"th",
|
||||||
cell.entries
|
{
|
||||||
|
"class": "calendar-cell",
|
||||||
|
},
|
||||||
|
[
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
.concat(
|
||||||
|
["Mo","Di","Mi","Do","Fr","Sa","So"]
|
||||||
.map(
|
.map(
|
||||||
entry => (
|
(day) => new lib_plankton.xml.class_node_complex(
|
||||||
"\t\t\t\t\t<li>\n"
|
"th",
|
||||||
+
|
{
|
||||||
entry.event.name
|
"class": "calendar-cell calendar-cell-day",
|
||||||
+
|
},
|
||||||
"\t\t\t\t\t</li>\n"
|
[
|
||||||
|
new lib_plankton.xml.class_node_text(day)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
new lib_plankton.xml.class_node_complex(
|
||||||
|
"tbody",
|
||||||
|
{
|
||||||
|
},
|
||||||
|
(
|
||||||
|
rows
|
||||||
|
.map(
|
||||||
|
(row) => (
|
||||||
|
new lib_plankton.xml.class_node_complex(
|
||||||
|
"tr",
|
||||||
|
{
|
||||||
|
},
|
||||||
|
(
|
||||||
|
[
|
||||||
|
new lib_plankton.xml.class_node_complex(
|
||||||
|
"th",
|
||||||
|
{
|
||||||
|
"class": "calendar-cell calendar-cell-week",
|
||||||
|
},
|
||||||
|
[
|
||||||
|
new lib_plankton.xml.class_node_text(
|
||||||
|
row.week.toFixed(0).padStart(2, "0")
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
.concat(
|
||||||
|
row.data
|
||||||
|
.map(
|
||||||
|
(cell) => (
|
||||||
|
new lib_plankton.xml.class_node_complex(
|
||||||
|
"td",
|
||||||
|
{
|
||||||
|
"class": (
|
||||||
|
(
|
||||||
|
["calendar-cell", "calendar-cell-regular"]
|
||||||
|
.concat(cell.today ? ["today"] : [])
|
||||||
|
)
|
||||||
|
.join(" ")
|
||||||
|
),
|
||||||
|
"title": lib_plankton.call.convey(
|
||||||
|
cell.pit,
|
||||||
|
[
|
||||||
|
pit_to_datetime,
|
||||||
|
(x : type_datetime) => lib_plankton.string.coin(
|
||||||
|
"{{year}}-{{month}}-{{day}}",
|
||||||
|
{
|
||||||
|
"year": x.date.year.toFixed(0).padStart(4, "0"),
|
||||||
|
"month": x.date.month.toFixed(0).padStart(2, "0"),
|
||||||
|
"day": x.date.day.toFixed(0).padStart(2, "0"),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
[
|
||||||
|
new lib_plankton.xml.class_node_complex(
|
||||||
|
"span",
|
||||||
|
{
|
||||||
|
"class": "calendar-day",
|
||||||
|
},
|
||||||
|
[
|
||||||
|
new lib_plankton.xml.class_node_text(
|
||||||
|
lib_plankton.call.convey(
|
||||||
|
cell.pit,
|
||||||
|
[
|
||||||
|
pit_to_datetime,
|
||||||
|
(x : type_datetime) => lib_plankton.string.coin(
|
||||||
|
"{{day}}",
|
||||||
|
{
|
||||||
|
"year": x.date.year.toFixed(0).padStart(4, "0"),
|
||||||
|
"month": x.date.month.toFixed(0).padStart(2, "0"),
|
||||||
|
"day": x.date.day.toFixed(0).padStart(2, "0"),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
new lib_plankton.xml.class_node_complex(
|
||||||
|
"ul",
|
||||||
|
{
|
||||||
|
"class": "calendar-events",
|
||||||
|
},
|
||||||
|
(
|
||||||
|
cell.entries
|
||||||
|
.map(
|
||||||
|
entry => (
|
||||||
|
new lib_plankton.xml.class_node_complex(
|
||||||
|
"li",
|
||||||
|
{
|
||||||
|
"class": "calendar-event_entry",
|
||||||
|
"style": lib_plankton.string.coin(
|
||||||
|
"background-color: {{color}}",
|
||||||
|
{
|
||||||
|
"color": lib_plankton.call.convey(
|
||||||
|
entry.calendar_id,
|
||||||
|
[
|
||||||
|
(n : int) => ({"n": n, "saturation": 0.25, "value": 0.5}),
|
||||||
|
lib_plankton.color.give_generic,
|
||||||
|
lib_plankton.color.output_hex,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
},
|
||||||
|
[
|
||||||
|
new lib_plankton.xml.class_node_text(entry.event.name),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.join("")
|
|
||||||
)
|
)
|
||||||
+
|
|
||||||
"\t\t\t\t</ul>\n"
|
|
||||||
)
|
)
|
||||||
// JSON.stringify(cell) + "\n"
|
|
||||||
+
|
|
||||||
"\t\t\t</td>\n"
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.join("")
|
|
||||||
)
|
)
|
||||||
+
|
]
|
||||||
"\t\t</tr>\n"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.join("")
|
]
|
||||||
)
|
).compile()
|
||||||
+
|
|
||||||
"\t</tbody>\n"
|
|
||||||
)
|
|
||||||
+
|
|
||||||
"</table>\n"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,11 +113,11 @@ async function main(
|
||||||
4,
|
4,
|
||||||
{
|
{
|
||||||
"year": 2024,
|
"year": 2024,
|
||||||
"week": 37
|
"week": 35
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"year": 2024,
|
"year": 2024,
|
||||||
"week": 40
|
"week": 41
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timezone_shift": parseInt(args["timezone_shift"]),
|
"timezone_shift": parseInt(args["timezone_shift"]),
|
||||||
|
|
Loading…
Add table
Reference in a new issue