From 72d8b4e6bee0ffac79e96dd649a9da2adb86b507 Mon Sep 17 00:00:00 2001 From: name Date: Wed, 27 Sep 2023 11:34:23 +0000 Subject: 2023-09-26 --- .../ajax/libs/wolfree/23.7.8/js/PodsParser.js | 201 --------------------- 1 file changed, 201 deletions(-) delete mode 100644 docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js (limited to 'docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js') diff --git a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js b/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js deleted file mode 100644 index bfb0ab0..0000000 --- a/docusaurus/static/ajax/libs/wolfree/23.7.8/js/PodsParser.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @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 PodsParser { - parse = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - } = {}) => { - try { - return { html: this.buildHTML({ input, i2d, extraPodstates, response }) }; - } catch (error) { - return console.error({ error }), { error }; - } - }; - - buildHTML = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - } = {}) => { - return ` -
-
-
-
- ${this.parseQueryResult({ response })} - ${this.buildTechnicalInfo({ - input, - i2d, - extraPodstates, - response, - })} -
-
-
-
- `; - }; - - parseQueryResult = ({ response = { queryresult: { pods: Array() } } }) => { - const { queryresult } = response; - const { pods } = queryresult; - if (pods) { - return pods.map(this.parsePod).join(""); - } - return ""; - }; - - parsePod = ( - pod = { - title: String(), - states: Array(), - subpods: Array(), - } - ) => { - return ` -
- ${this.buildPodHeader(pod)} -
- ${pod.subpods.map(this.buildSubpod).join("")} -
- `; - }; - - buildPodHeader = (pod = { title: String(), states: Array() }) => { - return ` -
-

${this.escapeHTML(pod.title)}

- ${pod.states ? pod.states.map(this.buildSelectElement).join("") : ""} -
- `; - }; - - buildSubpod = ( - subpod = { img: { src: String(), alt: String() }, plaintext: String() } - ) => { - return ` -
- ${this.escapeHTML(subpod.img.alt)} -
-
-
${this.buildSubpodDetails(subpod)}
-
- `; - }; - - buildSubpodDetails = (subpod = { plaintext: String() }) => { - return ` -
- -
${this.escapeHTML(subpod.plaintext)}
-
-
- `; - }; - - buildSelectElement = (state = { value: String(), states: Array() }) => { - if (state.states) { - return ` - - `; - } - return ""; - }; - - buildOption = (state = { name: String() }) => { - return ` - - `; - }; - - buildTechnicalInfo = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - }) => { - return ` -
-

Technical information

-
-
${this.buildTechnicalInfoDetails({ - input, - i2d, - extraPodstates, - response, - })}
-
-
- `; - }; - - buildTechnicalInfoDetails = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - }) => { - return ` -
-
- If you have programming knowledge, feel free to explore the technical information provided below: -
- ${this.buildTextarea({ input, i2d, extraPodstates, response })} -
- `; - }; - - buildTextarea = ({ - input = String(), - i2d = Boolean(), - extraPodstates = Array(), - response = { queryresult: { pods: Array() } }, - }) => { - return ` - - `; - }; - - escapeHTML = (unsafe = String()) => { - return unsafe - .replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); - }; -} - -// Can I escape HTML special chars in JavaScript? - Stack Overflow -// https://stackoverflow.com/questions/6234773/can-i-escape-html-special-chars-in-javascript - -// test case: -// https://www.wolframalpha.com/input?i=solve+%7By%27%28x%29+%3D+-2+y%2C+y%280%29%3D1%7D+from+0+to+10+using+r+k+f+algorithm -- cgit v1.2.3