/** * The class provides overreaching options for building the website. */ class PageBuilder { #cssClasses; #functions; constructor() { this.#cssClasses = document.createElement("style"); this.#functions = document.createElement("script"); } /** * Registers a function to be added later in a script tag in the head of the document. * @param {string} name * @param {func} fun */ registerFunction(name, fun) { this.#functions.innerText += `const ${name} = ${fun}`; } /** * Adds a script tag into the head of the document. */ generate() { document.querySelector("head") .appendChild(this.#functions) } } const Page = new PageBuilder();