diff --git a/Frontend/assets/scripts/frame.js b/Frontend/assets/scripts/frame.js index 5b89901..75781ec 100644 --- a/Frontend/assets/scripts/frame.js +++ b/Frontend/assets/scripts/frame.js @@ -25,6 +25,7 @@ function init() { tools.set("xpath", "tools/xpath.html"); tools.set("xsd", "tools/xsd.html"); tools.set("xslt", "tools/xslt.html"); + tools.set("xquery", "tools/xquery.html"); tools.set("xmlform", "tools/xmlFormatter.html"); tools.set("jsonform", "tools/jsonFormatter.html"); tools.set("mock", "tools/mock.html"); diff --git a/Frontend/assets/scripts/tools/xquery.js b/Frontend/assets/scripts/tools/xquery.js new file mode 100644 index 0000000..4e61cb1 --- /dev/null +++ b/Frontend/assets/scripts/tools/xquery.js @@ -0,0 +1,100 @@ +/** + * 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") { + document.getElementById("tooltipFunctionInfo").innerText = "XSLT 1.0 functions"; + document.getElementById("processorTooltipInfo").innerText = "Supports XSLT 1.0"; + hideList(document.getElementsByName("collapse30")); + } else { + document.getElementById("tooltipFunctionInfo").innerText = "XSLT 1.0, 2.0 & 3.0 functions"; + document.getElementById("processorTooltipInfo").innerText = "Supports XSLT up to 3.0"; + showList(document.getElementsByName("collapse30")); + } +} + + +/** + * 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"); + configurePastingInElement("transformArea"); + + //Handle clicks in whole form and set info in tooltip + setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here'); + setDefaultContent(document.getElementById("transformArea"), 'Insert XSLT here'); + + // refreshTooltip(); + processTooltip(); + tool.addEventListener('click', event => { + //Check if script was called from textarea or selector + var targetID = event.target.getAttribute('id'); + if (targetID !== "processors" && targetID !== "xmlArea" && targetID !== "transformArea" && targetID !== "versions") { + return; + } + + processTooltip(); + }) + + tool.addEventListener('change', event => { + //Check if script was called from textarea or selector + var targetID = event.target.getAttribute('id'); + if (targetID !== "processors") { + return; + } + + processTooltip(); + + }) + + var triggerList = document.getElementsByClassName("collapseTrigger"); + for (i = 0; i < triggerList.length; i++) { + + triggerList[i].addEventListener("click", function () { + + var collapsible = this.parentElement; + var collapsibleData = this.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"; + } + } + }); + } + +} \ No newline at end of file diff --git a/Frontend/index.html b/Frontend/index.html index d8aeaa6..1e7b80a 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -36,6 +36,7 @@