From 8af82e35584a0c4524c89400a4f874114a9d3410 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:42:23 +0200 Subject: [PATCH] Fixes --- .../assets/scripts/tools/jsonFormatter.js | 8 +- Frontend/assets/scripts/tools/xmlFormatter.js | 31 ++++- Frontend/assets/scripts/tools/xpath.js | 109 +++++++++++------- Frontend/assets/scripts/tools/xsd.js | 16 +++ Frontend/assets/scripts/tools/xslt.js | 17 +++ 5 files changed, 135 insertions(+), 46 deletions(-) diff --git a/Frontend/assets/scripts/tools/jsonFormatter.js b/Frontend/assets/scripts/tools/jsonFormatter.js index 425f7f9..8be8832 100644 --- a/Frontend/assets/scripts/tools/jsonFormatter.js +++ b/Frontend/assets/scripts/tools/jsonFormatter.js @@ -146,7 +146,13 @@ const mergeHTMLPlugin = (function () { }()); - +/** + * This function is executed after the page is loaded. + * + * @function + * @name init + * @kind function + */ function init() { // Make sure that only plain text is pasted configurePastingInElement("jsonBlock"); diff --git a/Frontend/assets/scripts/tools/xmlFormatter.js b/Frontend/assets/scripts/tools/xmlFormatter.js index 04a35cc..fef7d28 100644 --- a/Frontend/assets/scripts/tools/xmlFormatter.js +++ b/Frontend/assets/scripts/tools/xmlFormatter.js @@ -1,11 +1,34 @@ +/** + * This function is executed after the page is loaded. + * + * @function + * @name init + * @kind function + */ +function init() { + configurePastingInElement("xmlArea"); +} + +/** + * Function returns processor that will be used to transform XML. + * This solution allows to use one function for sending request from every tool + * + * @function + * @name getProcessor + * @kind function + */ function getProcessor() { return "libxml"; } +/** + * Function returns version of XML processor that will be used to transform XML. + * This solution allows to use one function for sending request from every tool + * + * @function + * @name getVersion + * @kind function + */ function getVersion() { return "1.0" -} - -function init() { - configurePastingInElement("xmlArea"); } \ No newline at end of file diff --git a/Frontend/assets/scripts/tools/xpath.js b/Frontend/assets/scripts/tools/xpath.js index 6e1d918..ab5bff6 100644 --- a/Frontend/assets/scripts/tools/xpath.js +++ b/Frontend/assets/scripts/tools/xpath.js @@ -1,4 +1,13 @@ +/** + * The `processVersionSelector()` function is responsible for updating the display of the web page + * based on the selected processor and version. + * + * @function + * @name processVersionSelector + * @kind function + * @returns {void} + */ function processVersionSelector() { var processor = getProcessor(); var hideableOptions = document.getElementsByClassName("hideable"); @@ -24,6 +33,15 @@ function processVersionSelector() { } +/** + * The `processTooltip()` function is responsible for updating the display of the tooltip based on the selected version of the processor. + * It shows or hides different sections of the tooltip based on the selected version. + * It also handles the click event on the form and updates the tooltip accordingly. + * + * @function + * @name processTooltip + * @kind function + */ function processTooltip() { var filter = "collapse" + getVersion(); var collList; @@ -58,49 +76,15 @@ function processTooltip() { } } -var triggerList = document.getElementsByClassName("collapseTrigger"); -for (i = 0; i < triggerList.length; i++) { - - triggerList[i].addEventListener("click", function () { - var collapsible = this.parentElement; - if (this.tagName == "A") { - var collapsibleData = this.nextElementSibling; - } else { - var collapsibleData = this.parentElement.nextElementSibling; - - } - if (collapsibleData.style.maxHeight > "0px") { - collapsibleData.style.maxHeight = "0px"; - - this.classList.toggle("active", false); - if (!this.classList.contains("collapsibleMini")) { - collapsible.classList.toggle("active", false); - } - - var subLists1 = collapsibleData.getElementsByClassName("content"); - var subLists2 = collapsibleData.getElementsByClassName("active"); - for (j = 0; j < subLists1.length; j++) { - subLists1[j].style.maxHeight = "0px"; - } - for (j = 0; j < subLists2.length; j++) { - subLists2[j].classList.toggle("active", false); - } - } else { - collapsibleData.style.maxHeight = (collapsibleData.scrollHeight) + "px"; - - this.classList.toggle("active", true); - if (!this.classList.contains("collapsibleMini")) { - collapsible.classList.toggle("active", true); - } else { - var parentContent = this.closest(".content"); - parentContent.style.maxHeight = (parentContent.scrollHeight + collapsibleData.scrollHeight) + "px"; - } - } - }); -} - +/** + * This function is executed after the page is loaded. + * + * @function + * @name init + * @kind function + */ function init() { // Make sure that only plain text is pasted @@ -143,5 +127,48 @@ function init() { } processTooltip(); }) + + var triggerList = document.getElementsByClassName("collapseTrigger"); + for (i = 0; i < triggerList.length; i++) { + + triggerList[i].addEventListener("click", function () { + var collapsible = this.parentElement; + if (this.tagName == "A") { + var collapsibleData = this.nextElementSibling; + } else { + var collapsibleData = this.parentElement.nextElementSibling; + + } + + + if (collapsibleData.style.maxHeight > "0px") { + collapsibleData.style.maxHeight = "0px"; + + this.classList.toggle("active", false); + if (!this.classList.contains("collapsibleMini")) { + collapsible.classList.toggle("active", false); + } + + var subLists1 = collapsibleData.getElementsByClassName("content"); + var subLists2 = collapsibleData.getElementsByClassName("active"); + for (j = 0; j < subLists1.length; j++) { + subLists1[j].style.maxHeight = "0px"; + } + for (j = 0; j < subLists2.length; j++) { + subLists2[j].classList.toggle("active", false); + } + } else { + collapsibleData.style.maxHeight = (collapsibleData.scrollHeight) + "px"; + + this.classList.toggle("active", true); + if (!this.classList.contains("collapsibleMini")) { + collapsible.classList.toggle("active", true); + } else { + var parentContent = this.closest(".content"); + parentContent.style.maxHeight = (parentContent.scrollHeight + collapsibleData.scrollHeight) + "px"; + } + } + }); + } } diff --git a/Frontend/assets/scripts/tools/xsd.js b/Frontend/assets/scripts/tools/xsd.js index 161aa7d..62e5612 100644 --- a/Frontend/assets/scripts/tools/xsd.js +++ b/Frontend/assets/scripts/tools/xsd.js @@ -1,3 +1,10 @@ +/** + * This function is executed after the page is loaded. + * + * @function + * @name init + * @kind function + */ function init() { // Make sure that only plain text is pasted configurePastingInElement("xmlArea"); @@ -21,6 +28,15 @@ function init() { }) } +/** + * The `processTooltip()` function is responsible for updating the display of the tooltip based on the selected version of the processor. + * It shows or hides different sections of the tooltip based on the selected version. + * It also handles the click event on the form and updates the tooltip accordingly. + * + * @function + * @name processTooltip + * @kind function + */ function processTooltip() { if (getProcessor() == "xalan") { diff --git a/Frontend/assets/scripts/tools/xslt.js b/Frontend/assets/scripts/tools/xslt.js index bcc5d9d..82a5f32 100644 --- a/Frontend/assets/scripts/tools/xslt.js +++ b/Frontend/assets/scripts/tools/xslt.js @@ -1,3 +1,12 @@ +/** + * The `processTooltip()` function is responsible for updating the display of the tooltip based on the selected version of the processor. + * It shows or hides different sections of the tooltip based on the selected version. + * It also handles the click event on the form and updates the tooltip accordingly. + * + * @function + * @name processTooltip + * @kind function + */ function processTooltip() { if (getProcessor() == "xalan" || getProcessor() == "libxml") { @@ -48,6 +57,14 @@ for (i = 0; i < triggerList.length; i++) { }); } + +/** + * This function is executed after the page is loaded. + * + * @function + * @name init + * @kind function + */ function init() { // Make sure that only plain text is pasted configurePastingInElement("xmlArea");