From e96608222fd671945e2cd13ebae30b646bf96731 Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Mon, 30 Sep 2024 20:19:34 +0200 Subject: [PATCH] [upd] plankton --- lib/plankton/plankton.d.ts | 317 +++++----- lib/plankton/plankton.js | 1111 +++++++++++++++++++----------------- tools/makefile | 1 + 3 files changed, 763 insertions(+), 666 deletions(-) diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 805e1c7..efe6f51 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -2961,6 +2961,94 @@ declare namespace lib_plankton.url { decode(x: string): any; } } +declare namespace lib_plankton.pit { + /** + */ + type type_date = { + year: int; + month: int; + day: int; + }; + /** + */ + type type_ywd = { + year: int; + week: int; + day: int; + }; + /** + */ + type type_time = { + hour: int; + minute: int; + second: int; + }; + /** + */ + type type_datetime = { + timezone_shift: int; + date: type_date; + time: (null | type_time); + }; + /** + */ + type type_pit = int; +} +declare namespace lib_plankton.pit { + /** + */ + function date_object_get_week_of_year(date: Date): int; + /** + */ + function to_unix_timestamp(pit: type_pit): int; + /** + */ + function from_unix_timestamp(unix_timestamp: int): type_pit; + /** + */ + function to_date_object(pit: type_pit): Date; + /** + * @todo timezone + */ + function to_datetime(pit: type_pit, options?: { + timezone_shift?: int; + }): type_datetime; + /** + */ + function from_datetime(datetime: type_datetime): type_pit; + /** + */ + function is_before(pit: type_pit, reference: type_pit): boolean; + /** + */ + function is_between(pit: type_pit, reference_left: type_pit, reference_right: type_pit): boolean; + /** + */ + function shift_day(pit: type_pit, increment: int): type_pit; + /** + */ + function shift_week(pit: type_pit, increment: int): type_pit; + /** + */ + function trunc_week(pit: type_pit): type_pit; + /** + */ + function now(): type_pit; + /** + * @param year year according to specified timezone shift + * @param week week according to specified timezone shift + * @return the begin of the week (monday, 00:00) + */ + function from_ywd(ywd: type_ywd, options?: { + timezone_shift?: int; + }): type_pit; + /** + * @todo timezone + */ + function to_ywd(pit: type_pit, options?: { + timezone_shift?: int; + }): type_ywd; +} declare namespace lib_plankton.www_form { /** */ @@ -3118,94 +3206,6 @@ declare namespace lib_plankton.zoo_page { export function start(): void; export {}; } -declare namespace lib_plankton.pit { - /** - */ - type type_date = { - year: int; - month: int; - day: int; - }; - /** - */ - type type_ywd = { - year: int; - week: int; - day: int; - }; - /** - */ - type type_time = { - hour: int; - minute: int; - second: int; - }; - /** - */ - type type_datetime = { - timezone_shift: int; - date: type_date; - time: (null | type_time); - }; - /** - */ - type type_pit = int; -} -declare namespace lib_plankton.pit { - /** - */ - function date_object_get_week_of_year(date: Date): int; - /** - */ - function to_unix_timestamp(pit: type_pit): int; - /** - */ - function from_unix_timestamp(unix_timestamp: int): type_pit; - /** - */ - function to_date_object(pit: type_pit): Date; - /** - * @todo timezone - */ - function to_datetime(pit: type_pit, options?: { - timezone_shift?: int; - }): type_datetime; - /** - */ - function from_datetime(datetime: type_datetime): type_pit; - /** - */ - function is_before(pit: type_pit, reference: type_pit): boolean; - /** - */ - function is_between(pit: type_pit, reference_left: type_pit, reference_right: type_pit): boolean; - /** - */ - function shift_day(pit: type_pit, increment: int): type_pit; - /** - */ - function shift_week(pit: type_pit, increment: int): type_pit; - /** - */ - function trunc_week(pit: type_pit): type_pit; - /** - */ - function now(): type_pit; - /** - * @param year year according to specified timezone shift - * @param week week according to specified timezone shift - * @return the begin of the week (monday, 00:00) - */ - function from_ywd(ywd: type_ywd, options?: { - timezone_shift?: int; - }): type_pit; - /** - * @todo timezone - */ - function to_ywd(pit: type_pit, options?: { - timezone_shift?: int; - }): type_ywd; -} declare namespace lib_plankton.zoo_input { /** * @author fenris @@ -3566,55 +3566,6 @@ declare namespace lib_plankton.zoo_input { write(value: string): Promise; } } -declare namespace lib_plankton.zoo_input { - /** - */ - type type_translations = { - add?: string; - remove?: string; - }; - /** - * @author fenris - */ - export class class_input_list implements interface_input> { - /** - */ - private element_input_factory; - /** - */ - private elements_container_dom; - /** - */ - private elements; - /** - */ - private translations; - /** - */ - constructor(element_input_factory: (() => interface_input), options?: { - translations?: type_translations; - }); - /** - */ - private clear; - /** - */ - private add; - /** - * [implementation] - */ - setup(parent: HTMLElement): Promise; - /** - * [implementation] - */ - read(): Promise>; - /** - * [implementation] - */ - write(value: Array): Promise; - } - export {}; -} declare namespace lib_plankton.zoo_input { /** * @author fenris @@ -3693,6 +3644,31 @@ declare namespace lib_plankton.zoo_input { write(value: (null | lib_plankton.pit.type_time)): Promise; } } +declare namespace lib_plankton.zoo_input { + /** + */ + class class_input_datetime implements interface_input { + /** + */ + private core; + /** + */ + constructor(options?: { + label_timezone_shift?: string; + label_date?: string; + label_time?: string; + }); + /** + */ + setup(parent: HTMLElement): Promise; + /** + */ + read(): Promise; + /** + */ + write(value: lib_plankton.pit.type_datetime): Promise; + } +} declare namespace lib_plankton.zoo_input { /** * @author fenris @@ -3726,26 +3702,77 @@ declare namespace lib_plankton.zoo_input { declare namespace lib_plankton.zoo_input { /** */ - class class_input_datetime implements interface_input { + type type_translations = { + add?: string; + remove?: string; + }; + /** + * @author fenris + */ + export class class_input_list implements interface_input> { + /** + */ + private element_input_factory; + /** + */ + private elements_container_dom; + /** + */ + private elements; + /** + */ + private translations; + /** + */ + constructor(element_input_factory: (() => interface_input), options?: { + translations?: type_translations; + }); + /** + */ + private clear; + /** + */ + private add; + /** + * [implementation] + */ + setup(parent: HTMLElement): Promise; + /** + * [implementation] + */ + read(): Promise>; + /** + * [implementation] + */ + write(value: Array): Promise; + } + export {}; +} +declare namespace lib_plankton.zoo_input { + /** + */ + class class_input_hashmap implements lib_plankton.zoo_input.interface_input> { + /** + */ + private hash_key; /** */ private core; /** */ - constructor(options?: { - label_timezone_shift?: string; - label_date?: string; - label_time?: string; - }); + constructor(hash_key: ((key: type_key) => string), key_input_factory: (() => lib_plankton.zoo_input.interface_input), value_input_factory: (() => lib_plankton.zoo_input.interface_input)); /** + * [implementation] */ setup(parent: HTMLElement): Promise; /** + * [implementation] */ - read(): Promise; + read(): Promise>; /** + * [implementation] */ - write(value: lib_plankton.pit.type_datetime): Promise; + write(map: lib_plankton.map.type_map): Promise; } } declare namespace lib_plankton.zoo_form { diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index be209ef..8c05bd1 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -8316,6 +8316,353 @@ var lib_plankton; })(url = lib_plankton.url || (lib_plankton.url = {})); })(lib_plankton || (lib_plankton = {})); /* +This file is part of »bacterio-plankton:pit«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:pit« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:pit« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:pit«. If not, see . + */ +/* +This file is part of »bacterio-plankton:pit«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:pit« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:pit« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:pit«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var pit; + (function (pit_1) { + /** + */ + function date_object_get_week_of_year(date) { + let date_ = new Date(date.getTime()); + date_.setHours(0, 0, 0, 0); + // Thursday in current week decides the year. + date_.setDate(date_.getDate() + 3 - (date_.getDay() + 6) % 7); + // January 4 is always in week 1. + let week1 = new Date(date_.getFullYear(), 0, 4); + // Adjust to Thursday in week 1 and count number of weeks from date to week1. + return (1 + + + Math.round((((date_.getTime() - week1.getTime()) / 86400000) + - + 3 + + + (week1.getDay() + 6) % 7) + / + 7)); + } + pit_1.date_object_get_week_of_year = date_object_get_week_of_year; + /** + */ + function to_unix_timestamp(pit) { + return pit; + } + pit_1.to_unix_timestamp = to_unix_timestamp; + /** + */ + function from_unix_timestamp(unix_timestamp) { + return unix_timestamp; + } + pit_1.from_unix_timestamp = from_unix_timestamp; + /** + */ + function to_date_object(pit) { + return (new Date(pit * 1000)); + } + pit_1.to_date_object = to_date_object; + /** + */ + function from_date_object(date_object) { + return Math.round(date_object.getTime() / 1000); + } + /** + * @todo timezone + */ + function to_datetime(pit, options = {}) { + options = Object.assign({ + "timezone_shift": 0, + }, options); + return lib_plankton.call.convey(pit, [ + to_date_object, + (x) => x.getTime(), + (x) => (x + ((options.timezone_shift * (60 * 60)) * 1000)), + (x) => new Date(x), + x => x.toISOString(), + x => ({ + "timezone_shift": options.timezone_shift, + "date": { + "year": parseInt(x.slice(0, 4)), + "month": parseInt(x.slice(5, 7)), + "day": parseInt(x.slice(8, 10)), + }, + "time": { + "hour": parseInt(x.slice(11, 13)), + "minute": parseInt(x.slice(14, 16)), + "second": parseInt(x.slice(17, 19)), + }, + }) + ]); + } + pit_1.to_datetime = to_datetime; + /** + */ + function from_datetime(datetime) { + return lib_plankton.call.convey(datetime, [ + (x) => lib_plankton.string.coin("{{year}}-{{month}}-{{day}}T{{hour}}:{{minute}}:{{second}}.000+{{shift}}", { + "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"), + "hour": ((x.time !== null) ? x.time.hour : 0).toFixed(0).padStart(2, "0"), + "minute": ((x.time !== null) ? x.time.minute : 0).toFixed(0).padStart(2, "0"), + "second": ((x.time !== null) ? x.time.second : 0).toFixed(0).padStart(2, "0"), + "shift": (x.timezone_shift.toFixed(0).padStart(2, "0") + ":00"), + }), + x => (new Date(x)), + from_date_object, + ]); + } + pit_1.from_datetime = from_datetime; + /** + */ + function is_before(pit, reference) { + return (pit < reference); + } + pit_1.is_before = is_before; + /** + */ + function is_after(pit, reference) { + return (pit > reference); + } + /** + */ + function is_between(pit, reference_left, reference_right) { + return (is_after(pit, reference_left) + && + is_before(pit, reference_right)); + } + pit_1.is_between = is_between; + /** + */ + function shift_hour(pit, increment) { + return (pit + (60 * 60 * increment)); + } + /** + */ + function shift_day(pit, increment) { + return (pit + (60 * 60 * 24 * increment)); + } + pit_1.shift_day = shift_day; + /** + */ + function shift_week(pit, increment) { + return (pit + (60 * 60 * 24 * 7 * increment)); + } + pit_1.shift_week = shift_week; + /** + */ + function shift_year(pit, increment) { + return (pit + (60 * 60 * 24 * 365 * increment)); + } + /** + */ + function trunc_minute(pit) { + const datetime_input = to_datetime(pit); + const datetime_output = { + "timezone_shift": 0, + "date": { + "year": datetime_input.date.year, + "month": datetime_input.date.month, + "day": datetime_input.date.day, + }, + "time": { + "hour": ((datetime_input.time === null) + ? + 0 + : + datetime_input.time.hour), + "minute": ((datetime_input.time === null) + ? + 0 + : + datetime_input.time.minute), + "second": 0, + }, + }; + return from_datetime(datetime_output); + } + /** + */ + function trunc_hour(pit) { + const datetime_input = to_datetime(pit); + const datetime_output = { + "timezone_shift": 0, + "date": { + "year": datetime_input.date.year, + "month": datetime_input.date.month, + "day": datetime_input.date.day, + }, + "time": { + "hour": ((datetime_input.time === null) + ? + 0 + : + datetime_input.time.hour), + "minute": 0, + "second": 0, + }, + }; + return from_datetime(datetime_output); + } + /** + */ + function trunc_day(pit) { + const datetime_input = to_datetime(pit); + const datetime_output = { + "timezone_shift": 0, + "date": { + "year": datetime_input.date.year, + "month": datetime_input.date.month, + "day": datetime_input.date.day, + }, + "time": { + "hour": 0, + "minute": 0, + "second": 0, + }, + }; + return from_datetime(datetime_output); + } + /** + */ + function trunc_week(pit) { + const date_object = to_date_object(pit); + return lib_plankton.call.convey(date_object.getDay(), [ + (x) => ((x === 0) ? 7 : x), + (x) => (x - 1), + (x) => shift_day(pit, (-x)), + trunc_day + ]); + } + pit_1.trunc_week = trunc_week; + /** + */ + function trunc_month(pit) { + const datetime_input = to_datetime(pit); + const datetime_output = { + "timezone_shift": 0, + "date": { + "year": datetime_input.date.year, + "month": datetime_input.date.month, + "day": 1, + }, + "time": { + "hour": 0, + "minute": 0, + "second": 0, + }, + }; + return from_datetime(datetime_output); + } + /** + */ + function trunc_year(pit) { + const datetime_input = to_datetime(pit); + const datetime_output = { + "timezone_shift": 0, + "date": { + "year": datetime_input.date.year, + "month": 1, + "day": 1, + }, + "time": { + "hour": 0, + "minute": 0, + "second": 0, + }, + }; + return from_datetime(datetime_output); + } + /** + */ + function now() { + return from_date_object(new Date(Date.now())); + } + pit_1.now = now; + /** + * @param year year according to specified timezone shift + * @param week week according to specified timezone shift + * @return the begin of the week (monday, 00:00) + */ + function from_ywd(ywd, options = {}) { + options = Object.assign({ + "timezone_shift": 0, + }, options); + return lib_plankton.call.convey({ + "timezone_shift": options.timezone_shift, + "date": { + "year": ywd.year, + "month": 1, + "day": 1, + }, + "time": { + "hour": 0, + "minute": 0, + "second": 0 + } + }, [ + from_datetime, + (x) => shift_week(x, (ywd.week - 1)), + trunc_week, + (x) => shift_day(x, (ywd.day - 1)), + ]); + } + pit_1.from_ywd = from_ywd; + /** + * @todo timezone + */ + function to_ywd(pit, options = {}) { + options = Object.assign({ + "timezone_shift": 0, + }, options); + return lib_plankton.call.convey(pit, [ + to_date_object, + x => ({ + "year": x.getFullYear(), + "week": date_object_get_week_of_year(x), + "day": ((day => (day <= 0) ? 7 : day)(x.getDay())), + }) + ]); + } + pit_1.to_ywd = to_ywd; + })(pit = lib_plankton.pit || (lib_plankton.pit = {})); +})(lib_plankton || (lib_plankton = {})); +/* This file is part of »bacterio-plankton:www_form«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -8931,353 +9278,6 @@ var lib_plankton; })(zoo_page = lib_plankton.zoo_page || (lib_plankton.zoo_page = {})); })(lib_plankton || (lib_plankton = {})); /* -This file is part of »bacterio-plankton:pit«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:pit« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:pit« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:pit«. If not, see . - */ -/* -This file is part of »bacterio-plankton:pit«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:pit« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:pit« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:pit«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var pit; - (function (pit_1) { - /** - */ - function date_object_get_week_of_year(date) { - let date_ = new Date(date.getTime()); - date_.setHours(0, 0, 0, 0); - // Thursday in current week decides the year. - date_.setDate(date_.getDate() + 3 - (date_.getDay() + 6) % 7); - // January 4 is always in week 1. - let week1 = new Date(date_.getFullYear(), 0, 4); - // Adjust to Thursday in week 1 and count number of weeks from date to week1. - return (1 - + - Math.round((((date_.getTime() - week1.getTime()) / 86400000) - - - 3 - + - (week1.getDay() + 6) % 7) - / - 7)); - } - pit_1.date_object_get_week_of_year = date_object_get_week_of_year; - /** - */ - function to_unix_timestamp(pit) { - return pit; - } - pit_1.to_unix_timestamp = to_unix_timestamp; - /** - */ - function from_unix_timestamp(unix_timestamp) { - return unix_timestamp; - } - pit_1.from_unix_timestamp = from_unix_timestamp; - /** - */ - function to_date_object(pit) { - return (new Date(pit * 1000)); - } - pit_1.to_date_object = to_date_object; - /** - */ - function from_date_object(date_object) { - return Math.round(date_object.getTime() / 1000); - } - /** - * @todo timezone - */ - function to_datetime(pit, options = {}) { - options = Object.assign({ - "timezone_shift": 0, - }, options); - return lib_plankton.call.convey(pit, [ - to_date_object, - (x) => x.getTime(), - (x) => (x + ((options.timezone_shift * (60 * 60)) * 1000)), - (x) => new Date(x), - x => x.toISOString(), - x => ({ - "timezone_shift": options.timezone_shift, - "date": { - "year": parseInt(x.slice(0, 4)), - "month": parseInt(x.slice(5, 7)), - "day": parseInt(x.slice(8, 10)), - }, - "time": { - "hour": parseInt(x.slice(11, 13)), - "minute": parseInt(x.slice(14, 16)), - "second": parseInt(x.slice(17, 19)), - }, - }) - ]); - } - pit_1.to_datetime = to_datetime; - /** - */ - function from_datetime(datetime) { - return lib_plankton.call.convey(datetime, [ - (x) => lib_plankton.string.coin("{{year}}-{{month}}-{{day}}T{{hour}}:{{minute}}:{{second}}.000+{{shift}}", { - "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"), - "hour": ((x.time !== null) ? x.time.hour : 0).toFixed(0).padStart(2, "0"), - "minute": ((x.time !== null) ? x.time.minute : 0).toFixed(0).padStart(2, "0"), - "second": ((x.time !== null) ? x.time.second : 0).toFixed(0).padStart(2, "0"), - "shift": (x.timezone_shift.toFixed(0).padStart(2, "0") + ":00"), - }), - x => (new Date(x)), - from_date_object, - ]); - } - pit_1.from_datetime = from_datetime; - /** - */ - function is_before(pit, reference) { - return (pit < reference); - } - pit_1.is_before = is_before; - /** - */ - function is_after(pit, reference) { - return (pit > reference); - } - /** - */ - function is_between(pit, reference_left, reference_right) { - return (is_after(pit, reference_left) - && - is_before(pit, reference_right)); - } - pit_1.is_between = is_between; - /** - */ - function shift_hour(pit, increment) { - return (pit + (60 * 60 * increment)); - } - /** - */ - function shift_day(pit, increment) { - return (pit + (60 * 60 * 24 * increment)); - } - pit_1.shift_day = shift_day; - /** - */ - function shift_week(pit, increment) { - return (pit + (60 * 60 * 24 * 7 * increment)); - } - pit_1.shift_week = shift_week; - /** - */ - function shift_year(pit, increment) { - return (pit + (60 * 60 * 24 * 365 * increment)); - } - /** - */ - function trunc_minute(pit) { - const datetime_input = to_datetime(pit); - const datetime_output = { - "timezone_shift": 0, - "date": { - "year": datetime_input.date.year, - "month": datetime_input.date.month, - "day": datetime_input.date.day, - }, - "time": { - "hour": ((datetime_input.time === null) - ? - 0 - : - datetime_input.time.hour), - "minute": ((datetime_input.time === null) - ? - 0 - : - datetime_input.time.minute), - "second": 0, - }, - }; - return from_datetime(datetime_output); - } - /** - */ - function trunc_hour(pit) { - const datetime_input = to_datetime(pit); - const datetime_output = { - "timezone_shift": 0, - "date": { - "year": datetime_input.date.year, - "month": datetime_input.date.month, - "day": datetime_input.date.day, - }, - "time": { - "hour": ((datetime_input.time === null) - ? - 0 - : - datetime_input.time.hour), - "minute": 0, - "second": 0, - }, - }; - return from_datetime(datetime_output); - } - /** - */ - function trunc_day(pit) { - const datetime_input = to_datetime(pit); - const datetime_output = { - "timezone_shift": 0, - "date": { - "year": datetime_input.date.year, - "month": datetime_input.date.month, - "day": datetime_input.date.day, - }, - "time": { - "hour": 0, - "minute": 0, - "second": 0, - }, - }; - return from_datetime(datetime_output); - } - /** - */ - function trunc_week(pit) { - const date_object = to_date_object(pit); - return lib_plankton.call.convey(date_object.getDay(), [ - (x) => ((x === 0) ? 7 : x), - (x) => (x - 1), - (x) => shift_day(pit, (-x)), - trunc_day - ]); - } - pit_1.trunc_week = trunc_week; - /** - */ - function trunc_month(pit) { - const datetime_input = to_datetime(pit); - const datetime_output = { - "timezone_shift": 0, - "date": { - "year": datetime_input.date.year, - "month": datetime_input.date.month, - "day": 1, - }, - "time": { - "hour": 0, - "minute": 0, - "second": 0, - }, - }; - return from_datetime(datetime_output); - } - /** - */ - function trunc_year(pit) { - const datetime_input = to_datetime(pit); - const datetime_output = { - "timezone_shift": 0, - "date": { - "year": datetime_input.date.year, - "month": 1, - "day": 1, - }, - "time": { - "hour": 0, - "minute": 0, - "second": 0, - }, - }; - return from_datetime(datetime_output); - } - /** - */ - function now() { - return from_date_object(new Date(Date.now())); - } - pit_1.now = now; - /** - * @param year year according to specified timezone shift - * @param week week according to specified timezone shift - * @return the begin of the week (monday, 00:00) - */ - function from_ywd(ywd, options = {}) { - options = Object.assign({ - "timezone_shift": 0, - }, options); - return lib_plankton.call.convey({ - "timezone_shift": options.timezone_shift, - "date": { - "year": ywd.year, - "month": 1, - "day": 1, - }, - "time": { - "hour": 0, - "minute": 0, - "second": 0 - } - }, [ - from_datetime, - (x) => shift_week(x, (ywd.week - 1)), - trunc_week, - (x) => shift_day(x, (ywd.day - 1)), - ]); - } - pit_1.from_ywd = from_ywd; - /** - * @todo timezone - */ - function to_ywd(pit, options = {}) { - options = Object.assign({ - "timezone_shift": 0, - }, options); - return lib_plankton.call.convey(pit, [ - to_date_object, - x => ({ - "year": x.getFullYear(), - "week": date_object_get_week_of_year(x), - "day": ((day => (day <= 0) ? 7 : day)(x.getDay())), - }) - ]); - } - pit_1.to_ywd = to_ywd; - })(pit = lib_plankton.pit || (lib_plankton.pit = {})); -})(lib_plankton || (lib_plankton = {})); -/* This file is part of »bacterio-plankton:zoo-input«. Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' @@ -10153,153 +10153,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:zoo-input«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var zoo_input; - (function (zoo_input) { - /** - * @author fenris - */ - class class_input_list { - /** - */ - constructor(element_input_factory, options = {}) { - options = Object.assign({ - "translations": { - "add": "add", - "remove": "remove", - }, - }, options); - this.element_input_factory = element_input_factory; - this.elements = []; - this.elements_container_dom = null; - this.translations = options.translations; - } - /** - */ - clear() { - this.elements_container_dom.innerHTML = ""; - this.elements = []; - return Promise.resolve(undefined); - } - /** - */ - async add() { - // model - let element_dom = document.createElement("div"); - const input = this.element_input_factory(); - this.elements.push({ "dom": element_dom, "input": input }); - // view & control - { - element_dom.classList.add("plankton_input_list_element"); - // remover - { - let remover_dom = document.createElement("button"); - remover_dom.classList.add("plankton_input_list_button"); - remover_dom.classList.add("plankton_input_list_element_remover"); - remover_dom.setAttribute("title", this.translations.remove); - remover_dom.textContent = "x"; - remover_dom.addEventListener("click", (event) => { - event.preventDefault(); - const index = this.elements.findIndex(element => (element.input === input)); - const element = this.elements[index]; - this.elements_container_dom.removeChild(element.dom); - this.elements.splice(index, 1); - }); - element_dom.appendChild(remover_dom); - } - // input - { - let input_dom = document.createElement("div"); - input_dom.classList.add("plankton_input_list_element_input"); - await input.setup(input_dom); - element_dom.appendChild(input_dom); - } - this.elements_container_dom.appendChild(element_dom); - } - return Promise.resolve(input); - } - /** - * [implementation] - */ - setup(parent) { - let container_dom = document.createElement("div"); - container_dom.classList.add("plankton_input_list"); - // elements - { - this.elements_container_dom = document.createElement("div"); - this.elements_container_dom.classList.add("plankton_input_list_elements"); - container_dom.appendChild(this.elements_container_dom); - } - // foot - { - let footer_dom = document.createElement("div"); - footer_dom.classList.add("plankton_input_list_foot"); - // adder - { - let adder_dom = document.createElement("button"); - adder_dom.classList.add("plankton_input_list_button"); - adder_dom.classList.add("plankton_input_list_adder"); - adder_dom.setAttribute("title", this.translations.add); - adder_dom.textContent = "+"; - adder_dom.addEventListener("click", (event) => { - event.preventDefault(); - this.add(); - }); - footer_dom.appendChild(adder_dom); - } - container_dom.appendChild(footer_dom); - } - parent.appendChild(container_dom); - return Promise.resolve(undefined); - } - /** - * [implementation] - */ - read() { - return (Promise.all(this.elements - .map((element, index) => (element.input.read() - .then((element_value) => Promise.resolve({ - "index": index, - "value": element_value, - }))))) - .then((elements) => Promise.resolve(elements - .sort((x, y) => ((x.index <= y.index) ? 0 : 1)) - .map(element => element.value)))); - } - /** - * [implementation] - */ - write(value) { - return (this.clear() - .then(() => Promise.all(value - .map((element_value) => (this.add() - .then(element_input => element_input.write(element_value)))))) - .then(() => Promise.resolve(undefined))); - } - } - zoo_input.class_input_list = class_input_list; - })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:zoo-input«. - -Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:zoo-input« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:zoo-input« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:zoo-input«. If not, see . */ @@ -10507,6 +10360,77 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-input«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_input; + (function (zoo_input) { + /** + */ + class class_input_datetime { + /** + */ + constructor(options = {}) { + options = Object.assign({ + "label_timezone_shift": "", + "label_date": "", + "label_time": "", + }, options); + this.core = new zoo_input.class_input_group([ + { + "name": "timezone_shift", + "input": new zoo_input.class_input_number(), + "label": options.label_timezone_shift, + }, + { + "name": "date", + "input": new zoo_input.class_input_date(), + "label": options.label_date, + }, + { + "name": "time", + "input": new zoo_input.class_input_soft(new zoo_input.class_input_time()), + "label": options.label_time, + }, + ]); + } + /** + */ + async setup(parent) { + return this.core.setup(parent); + } + /** + */ + async read() { + return this.core.read(); + } + /** + */ + async write(value) { + return this.core.write(value); + } + } + zoo_input.class_input_datetime = class_input_datetime; + })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-input«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-input« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-input« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:zoo-input«. If not, see . */ @@ -10622,51 +10546,196 @@ var lib_plankton; var zoo_input; (function (zoo_input) { /** + * @author fenris */ - class class_input_datetime { + class class_input_list { /** */ - constructor(options = {}) { + constructor(element_input_factory, options = {}) { options = Object.assign({ - "label_timezone_shift": "", - "label_date": "", - "label_time": "", + "translations": { + "add": "add", + "remove": "remove", + }, }, options); - this.core = new zoo_input.class_input_group([ - { - "name": "timezone_shift", - "input": new zoo_input.class_input_number(), - "label": options.label_timezone_shift, - }, - { - "name": "date", - "input": new zoo_input.class_input_date(), - "label": options.label_date, - }, - { - "name": "time", - "input": new zoo_input.class_input_soft(new zoo_input.class_input_time()), - "label": options.label_time, - }, - ]); + this.element_input_factory = element_input_factory; + this.elements = []; + this.elements_container_dom = null; + this.translations = options.translations; } /** */ - async setup(parent) { + clear() { + this.elements_container_dom.innerHTML = ""; + this.elements = []; + return Promise.resolve(undefined); + } + /** + */ + async add() { + // model + let element_dom = document.createElement("div"); + const input = this.element_input_factory(); + this.elements.push({ "dom": element_dom, "input": input }); + // view & control + { + element_dom.classList.add("plankton_input_list_element"); + // remover + { + let remover_dom = document.createElement("button"); + remover_dom.classList.add("plankton_input_list_button"); + remover_dom.classList.add("plankton_input_list_element_remover"); + remover_dom.setAttribute("title", this.translations.remove); + remover_dom.textContent = "x"; + remover_dom.addEventListener("click", (event) => { + event.preventDefault(); + const index = this.elements.findIndex(element => (element.input === input)); + const element = this.elements[index]; + this.elements_container_dom.removeChild(element.dom); + this.elements.splice(index, 1); + }); + element_dom.appendChild(remover_dom); + } + // input + { + let input_dom = document.createElement("div"); + input_dom.classList.add("plankton_input_list_element_input"); + await input.setup(input_dom); + element_dom.appendChild(input_dom); + } + this.elements_container_dom.appendChild(element_dom); + } + return Promise.resolve(input); + } + /** + * [implementation] + */ + setup(parent) { + let container_dom = document.createElement("div"); + container_dom.classList.add("plankton_input_list"); + // elements + { + this.elements_container_dom = document.createElement("div"); + this.elements_container_dom.classList.add("plankton_input_list_elements"); + container_dom.appendChild(this.elements_container_dom); + } + // foot + { + let footer_dom = document.createElement("div"); + footer_dom.classList.add("plankton_input_list_foot"); + // adder + { + let adder_dom = document.createElement("button"); + adder_dom.classList.add("plankton_input_list_button"); + adder_dom.classList.add("plankton_input_list_adder"); + adder_dom.setAttribute("title", this.translations.add); + adder_dom.textContent = "+"; + adder_dom.addEventListener("click", (event) => { + event.preventDefault(); + this.add(); + }); + footer_dom.appendChild(adder_dom); + } + container_dom.appendChild(footer_dom); + } + parent.appendChild(container_dom); + return Promise.resolve(undefined); + } + /** + * [implementation] + */ + read() { + return (Promise.all(this.elements + .map((element, index) => (element.input.read() + .then((element_value) => Promise.resolve({ + "index": index, + "value": element_value, + }))))) + .then((elements) => Promise.resolve(elements + .sort((x, y) => ((x.index <= y.index) ? 0 : 1)) + .map(element => element.value)))); + } + /** + * [implementation] + */ + write(value) { + return (this.clear() + .then(() => Promise.all(value + .map((element_value) => (this.add() + .then(element_input => element_input.write(element_value)))))) + .then(() => Promise.resolve(undefined))); + } + } + zoo_input.class_input_list = class_input_list; + })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:zoo-input«. + +Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:zoo-input« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:zoo-input« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:zoo-input«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var zoo_input; + (function (zoo_input) { + /** + */ + class class_input_hashmap { + /** + */ + constructor(hash_key, key_input_factory, value_input_factory) { + this.hash_key = hash_key; + this.core = new lib_plankton.zoo_input.class_input_list(() => new lib_plankton.zoo_input.class_input_group([ + { + "name": "key", + "input": key_input_factory(), + }, + { + "name": "value", + "input": value_input_factory(), + }, + ])); + } + /** + * [implementation] + */ + setup(parent) { return this.core.setup(parent); } /** + * [implementation] */ async read() { - return this.core.read(); + const pairs = await this.core.read(); + const map = lib_plankton.map.hashmap.implementation_map(lib_plankton.map.hashmap.make(this.hash_key, { + "pairs": pairs + })); + return Promise.resolve(map); } /** + * [implementation] */ - async write(value) { - return this.core.write(value); + async write(map) { + const pairs = lib_plankton.map.dump(map); + await this.core.write(pairs); + return Promise.resolve(undefined); } } - zoo_input.class_input_datetime = class_input_datetime; + zoo_input.class_input_hashmap = class_input_hashmap; })(zoo_input = lib_plankton.zoo_input || (lib_plankton.zoo_input = {})); })(lib_plankton || (lib_plankton = {})); /* diff --git a/tools/makefile b/tools/makefile index a32ffd7..6271f76 100644 --- a/tools/makefile +++ b/tools/makefile @@ -56,6 +56,7 @@ ${dir_temp}/logic-unlinked.js: \ ${dir_source}/pages/logout/logic.ts \ ${dir_source}/pages/oidc_finish/logic.ts \ ${dir_source}/pages/calendar_add/logic.ts \ + ${dir_source}/pages/calendar_edit/logic.ts \ ${dir_source}/pages/event_add/logic.ts \ ${dir_source}/pages/event_edit/logic.ts \ ${dir_source}/pages/events/logic.ts \