2026-04-22 07:47:23 +02:00
|
|
|
namespace formgen
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2026-09-30 08:38:52 +02:00
|
|
|
let _input : (null | formgen.ioc.interface_ioc<unknown>) = null;
|
2026-04-22 07:47:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
async function render(
|
2026-09-30 08:38:52 +02:00
|
|
|
kind : string,
|
|
|
|
|
content : string,
|
2026-04-22 07:47:23 +02:00
|
|
|
element_target : Element
|
|
|
|
|
) : Promise<void>
|
|
|
|
|
{
|
|
|
|
|
element_target.innerHTML = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
2026-09-30 08:38:52 +02:00
|
|
|
let input : formgen.ioc.interface_ioc<unknown>;
|
|
|
|
|
|
|
|
|
|
const variant : string = "description";
|
|
|
|
|
|
|
|
|
|
switch (kind)
|
|
|
|
|
{
|
|
|
|
|
case "manual":
|
2026-04-22 22:24:32 +02:00
|
|
|
{
|
2026-09-30 08:38:52 +02:00
|
|
|
const ioc_input = new formgen.ioc.class_ioc_group(
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
"name": "left",
|
|
|
|
|
"ioc": new formgen.ioc.class_ioc_number(
|
|
|
|
|
{
|
|
|
|
|
"label": "Eingabe | links",
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
"marked": true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "right",
|
|
|
|
|
"ioc": new formgen.ioc.class_ioc_number(
|
|
|
|
|
{
|
|
|
|
|
"label": "Eingabe | rechts",
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
"marked": true,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
const ioc_output = new formgen.ioc.class_ioc_number(
|
|
|
|
|
{
|
|
|
|
|
"label": "Ausgabe",
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
input = new formgen.ioc.class_ioc_group(
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
"name": "input",
|
|
|
|
|
"ioc": ioc_input,
|
|
|
|
|
"marked": true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "output",
|
|
|
|
|
"ioc": ioc_output,
|
|
|
|
|
"marked": false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
{
|
|
|
|
|
// "label": "Eingabe",
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
break;
|
2026-04-22 22:24:32 +02:00
|
|
|
}
|
2026-09-30 08:38:52 +02:00
|
|
|
case "raw_description":
|
|
|
|
|
{
|
|
|
|
|
const description : formgen.ioc.type_description = (formgen.helpers.json.decode(content) as formgen.ioc.type_description);
|
|
|
|
|
input = formgen.ioc.from_raw(
|
|
|
|
|
description
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "json_schema":
|
|
|
|
|
{
|
|
|
|
|
const json_schema : formgen.helpers.json_schema.type_root = (formgen.helpers.json.decode(content) as formgen.helpers.json_schema.type_root);
|
|
|
|
|
input = formgen.ioc.from_json_schema(
|
|
|
|
|
json_schema,
|
|
|
|
|
{
|
|
|
|
|
// "map_unhandled_refs_to_empty": true,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 07:47:23 +02:00
|
|
|
await input.setup(element_target);
|
2026-09-30 08:38:52 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ioc_input.listen(
|
|
|
|
|
value => {
|
|
|
|
|
if ((value.left === null) || (value.right === null))
|
|
|
|
|
{
|
|
|
|
|
ioc_output.write(null);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ioc_output.write(value.left * value.right);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
*/
|
2026-04-22 07:47:23 +02:00
|
|
|
_input = input;
|
|
|
|
|
}
|
|
|
|
|
catch (error)
|
|
|
|
|
{
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2026-09-30 08:38:52 +02:00
|
|
|
async function main(
|
|
|
|
|
) : Promise<void>
|
2026-04-22 07:47:23 +02:00
|
|
|
{
|
2026-09-30 08:38:52 +02:00
|
|
|
// init:conf
|
|
|
|
|
{
|
|
|
|
|
await formgen.conf.initialize("conf.json");
|
|
|
|
|
}
|
|
|
|
|
// init:zerez
|
|
|
|
|
{
|
|
|
|
|
await formgen.helpers.zerez.initialize(
|
|
|
|
|
formgen.conf.get().zerez,
|
2026-04-22 07:47:23 +02:00
|
|
|
{
|
2026-09-30 08:38:52 +02:00
|
|
|
"fake": formgen.conf.get().zerez.fake,
|
2026-04-22 07:47:23 +02:00
|
|
|
}
|
2026-09-30 08:38:52 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
// exec
|
|
|
|
|
{
|
|
|
|
|
document.querySelector("#render").addEventListener(
|
|
|
|
|
"click",
|
|
|
|
|
() => {
|
|
|
|
|
document.querySelector("#value").textContent = "";
|
|
|
|
|
render(
|
|
|
|
|
(document.querySelector("#description_kind") as HTMLInputElement).value,
|
|
|
|
|
(document.querySelector("#description_content") as HTMLInputElement).value,
|
|
|
|
|
document.querySelector("#form")
|
|
|
|
|
);
|
2026-04-22 07:47:23 +02:00
|
|
|
}
|
2026-09-30 08:38:52 +02:00
|
|
|
);
|
|
|
|
|
document.querySelector("#read").addEventListener(
|
|
|
|
|
"click",
|
|
|
|
|
async () => {
|
|
|
|
|
if (_input === null)
|
|
|
|
|
{
|
|
|
|
|
console.warn("no input present");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const value = await _input.read();
|
|
|
|
|
document.querySelector("#value").textContent = JSON.stringify(value, undefined, " ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-04-22 07:47:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export function entry(
|
|
|
|
|
) : void
|
|
|
|
|
{
|
|
|
|
|
document.addEventListener(
|
|
|
|
|
"DOMContentLoaded",
|
|
|
|
|
() => {
|
2026-09-30 08:38:52 +02:00
|
|
|
(
|
|
|
|
|
main()
|
|
|
|
|
.then(() => {})
|
|
|
|
|
.catch(console.error)
|
|
|
|
|
);
|
2026-04-22 07:47:23 +02:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|