From 45f0135056c5d96a9ed7a4b2480bf2c050aec48a Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Thu, 25 Dec 2025 16:43:12 +0100 Subject: [PATCH 1/3] [upd] plankton --- lib/plankton/plankton.d.ts | 11 +++++++---- lib/plankton/plankton.js | 28 ++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 1d19b5b..8414b5a 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -1,11 +1,11 @@ /** * @author fenris */ -type int = number; +declare type int = number; /** * @author fenris */ -type float = number; +declare type float = number; declare class Buffer { constructor(x: string, modifier?: string); toString(modifier?: string): string; @@ -19,7 +19,7 @@ declare namespace lib_plankton.base { /** * @author fenris */ -type type_pseudopointer = { +declare type type_pseudopointer = { value: type_value; }; /** @@ -2002,7 +2002,7 @@ declare namespace lib_plankton.storage.memory { clear(): Promise; write(key: any, value: any): Promise; delete(key: any): Promise; - read(key: any): Promise>; + read(key: any): Promise; search(term: any): Promise<{ key: string; preview: string; @@ -3861,6 +3861,9 @@ declare namespace lib_plankton.pit { function to_ywd(pit: type_pit, { "timezone_shift": option_timezone_shift, }?: { timezone_shift?: int; }): type_ywd; + /** + */ + function number_of_weeks(year: int): int; /** * computes the point in time for switching to central european summer time * diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index 11c3060..eb95740 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -2241,7 +2241,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -9970,12 +9970,6 @@ var lib_plankton; * @author fenris */ class class_relation { - /** - * @author fenris - */ - check(value, reference) { - return this.predicate(value, reference); - } /** * @author fenris */ @@ -9985,6 +9979,12 @@ var lib_plankton; this.name = name; this.predicate = predicate; } + /** + * @author fenris + */ + check(value, reference) { + return this.predicate(value, reference); + } /** * @author fenris */ @@ -11654,6 +11654,17 @@ var lib_plankton; ]); } pit_1.to_ywd = to_ywd; + /** + */ + function number_of_weeks(year) { + return lib_plankton.call.convey(year, [ + x => from_ywd({ "year": (x + 1), "week": 1, "day": 6 }), + x => shift_week(x, -1), + to_ywd, + x => x.week, + ]); + } + pit_1.number_of_weeks = number_of_weeks; /** * computes the point in time for switching to central european summer time * @@ -11740,7 +11751,8 @@ var lib_plankton; "time": ((datetime.time === null) ? null - : datetime_shifted.time) + : + datetime_shifted.time) }; } } From f1a5e37febcec86cf95c2309c8310b31dd515cf1 Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Thu, 25 Dec 2025 16:43:53 +0100 Subject: [PATCH 2/3] =?UTF-8?q?[mod]=20weekview:Korrekter=20Jahres=C3=BCbe?= =?UTF-8?q?rgang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/base.ts | 33 +++++++++ source/main.ts | 2 + source/widgets/special_number_input/logic.ts | 19 ++++++ source/widgets/weekview/logic.ts | 71 ++++++++++++++++---- 4 files changed, 111 insertions(+), 14 deletions(-) diff --git a/source/base.ts b/source/base.ts index dab47b3..e216fbd 100644 --- a/source/base.ts +++ b/source/base.ts @@ -145,4 +145,37 @@ namespace _dali } } + + /** + */ + export var general_cache : lib_plankton.cache.type_subject = lib_plankton.cache.make( + /* + lib_plankton.storage.memory.implementation_chest( + { + } + ) + */ + ); + + + /** + */ + export async function number_of_weeks( + year : int + ) : Promise + { + const value_raw : unknown = await lib_plankton.cache.get( + _dali.general_cache, + lib_plankton.string.coin( + "number_of_weeks_{{year}}", + { + "year": year.toFixed(0), + } + ), + null, + () => Promise.resolve(lib_plankton.pit.number_of_weeks(year)) + ); + return (value_raw as int); + } + } diff --git a/source/main.ts b/source/main.ts index af55d02..3de64e9 100644 --- a/source/main.ts +++ b/source/main.ts @@ -80,6 +80,8 @@ namespace _dali await _dali.backend.initialize( _dali.conf.get()["backend"] ); + // init:general cache + lib_plankton.cache.init(_dali.general_cache); // init:model await _dali.model.initialize( ); diff --git a/source/widgets/special_number_input/logic.ts b/source/widgets/special_number_input/logic.ts index 738fd99..66b19ee 100644 --- a/source/widgets/special_number_input/logic.ts +++ b/source/widgets/special_number_input/logic.ts @@ -52,6 +52,11 @@ namespace _dali.widgets private value : int; + /** + */ + private dom_root : (null | HTMLElement); + + /** */ public constructor( @@ -80,6 +85,19 @@ namespace _dali.widgets this.maximum = maximum; this.value = initial_value; this.action_change = action_change; + this.dom_root = null; + } + + + /** + */ + public set_value( + value : int + ) : void + { + this.value = value; + const dom_input : HTMLInputElement = (this.dom_root.querySelector(".widget-special_number_input-input") as HTMLInputElement); + dom_input.value = value.toFixed(0); } @@ -160,6 +178,7 @@ namespace _dali.widgets } target_element.appendChild(dom_root); + this.dom_root = dom_root; } } diff --git a/source/widgets/weekview/logic.ts b/source/widgets/weekview/logic.ts index d506cc7..f9660cf 100644 --- a/source/widgets/weekview/logic.ts +++ b/source/widgets/weekview/logic.ts @@ -713,7 +713,17 @@ namespace _dali.widgets const dom_th = document.createElement("th"); dom_th.classList.add("weekview-cell"); dom_th.classList.add("weekview-cell-day"); - dom_th.textContent = (this.week + offset).toFixed(0).padStart(2, "0"); + // const week : int = (this.week + offset); + const week : int = lib_plankton.call.convey( + this.week, + [ + x => lib_plankton.pit.from_ywd({"year": this.year, "week": x, "day": 2}), + x => lib_plankton.pit.shift_week(x, offset), + lib_plankton.pit.to_ywd, + x => x.week + ] + ) + dom_th.textContent = week.toFixed(0).padStart(2, "0"); dom_tr.appendChild(dom_th); } ); @@ -878,42 +888,75 @@ namespace _dali.widgets { } ); + let input_year : _dali.widgets.class_widget_special_number_input; + let input_week : _dali.widgets.class_widget_special_number_input; // control:year { - const widget : lib_plankton.zoo_widget.interface_widget = new _dali.widgets.class_widget_special_number_input( + input_year = new _dali.widgets.class_widget_special_number_input( { "label": lib_plankton.translate.get("widget.weekview.controls.year"), "minimum": 1900, "maximum": 2500, "initial_value": this.year, - "action_change": async (value) => { - this.year = value; + "action_change": async (year_raw) => { + // model + const number_of_weeks : int = await _dali.number_of_weeks(year_raw); + if (this.week > number_of_weeks) + { + this.year = year_raw; + this.week = number_of_weeks; + } + else + { + this.year = year_raw; + // this.week = this.week; + } + + // view + input_week.set_value(this.week); await this.update_table(); await this.update_entries(); }, } ); - await widget.load(target_element.querySelector(".weekview-controls")); + await input_year.load(target_element.querySelector(".weekview-controls")); } // control:week { - const widget : lib_plankton.zoo_widget.interface_widget = new _dali.widgets.class_widget_special_number_input( + input_week = new _dali.widgets.class_widget_special_number_input( { "label": lib_plankton.translate.get("widget.weekview.controls.week"), - "minimum": 1, - /** - * @todo correct - */ - "maximum": 53, "initial_value": this.week, - "action_change": async (value) => { - this.week = value; + "action_change": async (week_raw) => { + // model + if (week_raw < 1) + { + this.year = (this.year - 1); + this.week = await _dali.number_of_weeks(this.year); + } + else + { + if (week_raw > await _dali.number_of_weeks(this.year)) + { + this.year = (this.year + 1); + this.week = 1; + } + else + { + // this.year = this.year; + this.week = week_raw; + } + } + + // view + input_year.set_value(this.year); + input_week.set_value(this.week); await this.update_table(); await this.update_entries(); }, } ); - await widget.load(target_element.querySelector(".weekview-controls")); + await input_week.load(target_element.querySelector(".weekview-controls")); } // control:count /* From d2f9404c6d510eab8e81edd3190683cc2b66775e Mon Sep 17 00:00:00 2001 From: Fenris Wolf Date: Thu, 25 Dec 2025 16:53:48 +0100 Subject: [PATCH 3/3] =?UTF-8?q?[mod]=20weekview:Korrekter=20Jahres=C3=BCbe?= =?UTF-8?q?rgang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/widgets/weekview/logic.ts | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/source/widgets/weekview/logic.ts b/source/widgets/weekview/logic.ts index f9660cf..a717941 100644 --- a/source/widgets/weekview/logic.ts +++ b/source/widgets/weekview/logic.ts @@ -591,8 +591,8 @@ namespace _dali.widgets { type type_row_data = Array< { - week : int; - day_pits : Array; + head : int; + pits : Array; } >; @@ -612,14 +612,23 @@ namespace _dali.widgets lib_plankton.translate.get("common.weekday.saturday"), lib_plankton.translate.get("common.weekday.sunday"), ]; - const row_data_original : type_row_data = ( + const row_data_horizontal : type_row_data = ( lib_plankton.list.sequence(this.count) .map( offset => { const week : int = (this.week + offset); + const week_adjusted : int = lib_plankton.call.convey( + this.week, + [ + x => lib_plankton.pit.from_ywd({"year": this.year, "week": x, "day": 2}), + x => lib_plankton.pit.shift_week(x, offset), + lib_plankton.pit.to_ywd, + x => x.week + ] + ); return { - "week": week, - "day_pits": ( + "head": week_adjusted, + "pits": ( lib_plankton.list.sequence(7) .map( day => lib_plankton.pit.from_ywd( @@ -638,13 +647,13 @@ namespace _dali.widgets } ) ); - const row_data_alternative : type_row_data = ( + const row_data_vertical : type_row_data = ( lib_plankton.list.sequence(7) .map( day_of_week => { return { - /*"day_of_week"*/"week": day_of_week, - /*"week_pits"*/"day_pits": ( + "head": day_of_week, + "pits": ( lib_plankton.list.sequence(this.count) .map( offset => { @@ -669,9 +678,9 @@ namespace _dali.widgets const row_data : type_row_data = ( (! this.vertical) ? - row_data_original + row_data_horizontal : - row_data_alternative + row_data_vertical ); // head { @@ -713,7 +722,6 @@ namespace _dali.widgets const dom_th = document.createElement("th"); dom_th.classList.add("weekview-cell"); dom_th.classList.add("weekview-cell-day"); - // const week : int = (this.week + offset); const week : int = lib_plankton.call.convey( this.week, [ @@ -722,7 +730,7 @@ namespace _dali.widgets lib_plankton.pit.to_ywd, x => x.week ] - ) + ); dom_th.textContent = week.toFixed(0).padStart(2, "0"); dom_tr.appendChild(dom_th); } @@ -746,13 +754,13 @@ namespace _dali.widgets "week": ( (! this.vertical) ? - row.week.toFixed(0).padStart(2, "0") + row.head.toFixed(0).padStart(2, "0") : day_names[index] ), "cells": ( await _dali.helpers.promise_row( - row.day_pits + row.pits .map( (day_pit) => async () => { const is_today : boolean = lib_plankton.pit.is_between(