poc form SDK (extends to form)

This commit is contained in:
Benjamin Dalsass
2023-08-24 14:29:31 +02:00
parent 245c1d0be5
commit 20ae64706a
3325 changed files with 1500 additions and 547966 deletions

69
js/DI/toolkit.js Normal file
View File

@@ -0,0 +1,69 @@
/**
* Toolkit.
*
* @returns {{init: init, parseTextToHtml: (function(*): Document), createElementFromHtml: (function(*): DocumentFragment)}}
* @constructor
*/
const Toolkit = function(){
function init(){
installStringFormatFunction();
}
/**
* installStringFormatFunction.
*
* String formatter utility.
*/
function installStringFormatFunction(){
if (!String.format) {
String.format = function(format) {
const args = Array.prototype.slice.call(arguments, 1);
return format.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined' ? args[number] : match;
});
};
}
}
/**
* parseTextToHtml.
*
* @param sText
* @returns {Document}
*/
function parseTextToHtml(sText){
const oParser = new DOMParser();
return oParser.parseFromString(sText, 'text/html');
}
/**
*
* @param html
* @returns {DocumentFragment}
*/
function createElementFromHtml(html) {
const t = document.createElement('template');
t.innerHTML = html;
return t.content;
}
return {
init,
parseTextToHtml,
createElementFromHtml
}
};