diff options
Diffstat (limited to 'docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js')
-rw-r--r-- | docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js new file mode 100644 index 0000000..7b31e48 --- /dev/null +++ b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/Pods.js @@ -0,0 +1,56 @@ +/** + * @license + * SPDX-License-Identifier: AGPL-3.0-or-later + * This file is part of Wolfree. + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + */ + +// @ts-check + +export default class Pods { + insert = ({ + container = document.querySelector("main > div:nth-of-type(1)"), + html = String(), + } = {}) => { + try { + /** + * https://www.npmjs.com/package/@types/dompurify + * @type {import('DOMPurify')} + */ + return ( + container instanceof HTMLDivElement + ? container.insertAdjacentHTML( + "afterend", + globalThis.DOMPurify.sanitize(html) + ) + : console.error({ container }), + { container, html } + ); + } catch (error) { + return ( + console.error( + { error }, + "Fail to insert the results of the calculation." + ), + { error } + ); + } + }; + + remove = ({ + pods = document.querySelectorAll("main > div.wolfree-pods"), + } = {}) => { + try { + pods.forEach((element) => { + element.remove(); + }); + return { pods }; + } catch (error) { + console.error( + "Fail to remove the results of the previous calculation.", + error + ); + return { error }; + } + }; +} |