From dc8e8b3fc57665570e5220a993ff3c037b867fbd Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 10:48:01 +0200 Subject: [PATCH 01/13] Separated in XPath --- Frontend/assets/scripts/tools/xpath.js | 148 ++++++++++++++++++++++++ Frontend/tools/xpath.html | 151 +------------------------ 2 files changed, 149 insertions(+), 150 deletions(-) create mode 100644 Frontend/assets/scripts/tools/xpath.js diff --git a/Frontend/assets/scripts/tools/xpath.js b/Frontend/assets/scripts/tools/xpath.js new file mode 100644 index 0000000..e3f6e02 --- /dev/null +++ b/Frontend/assets/scripts/tools/xpath.js @@ -0,0 +1,148 @@ + +function processVersionSelector() { + var processor = getProcessor(); + var hideableOptions = document.getElementsByClassName("hideable"); + for (let i = 0; i < hideableOptions.length; i++) { + hideableOptions[i].style = "display: none;"; + } + if (processor == "xalan" || processor == "libxml") { + var xalanOptions = document.getElementsByClassName("xalan"); + for (let i = 0; i < xalanOptions.length; i++) { + xalanOptions[i].style = ""; + } + document.getElementById("versions").selectedIndex = 0; + } + else { + var saxonOptions = document.getElementsByClassName("saxon"); + for (let i = 0; i < saxonOptions.length; i++) { + saxonOptions[i].style = ""; + } + document.getElementById("versions").selectedIndex = 3; + + } + processTooltip(); + +} + +function processTooltip() { + var filter = "collapse" + getVersion(); + var collList; + + + if (filter == "collapse3.0") { + document.getElementById("tooltipFunctionInfo").innerText = "XPath 3.0 functions"; + hideList(document.getElementsByName("collapse10")); + hideList(document.getElementsByName("collapse20")); + showList(document.getElementsByName("collapse30")); + hideList(document.getElementsByName("collapse31")); + + } else if (filter == "collapse3.1") { + document.getElementById("tooltipFunctionInfo").innerText = "XPath 3.1 functions"; + hideList(document.getElementsByName("collapse10")); + hideList(document.getElementsByName("collapse20")); + hideList(document.getElementsByName("collapse30")); + showList(document.getElementsByName("collapse31")); + } else if (filter == "collapse2.0") { + document.getElementById("tooltipFunctionInfo").innerText = "XPath 2.0 functions"; + hideList(document.getElementsByName("collapse10")); + showList(document.getElementsByName("collapse20")); + hideList(document.getElementsByName("collapse30")); + hideList(document.getElementsByName("collapse31")); + } else { + document.getElementById("tooltipFunctionInfo").innerText = "XPath 1.0 functions"; + showList(document.getElementsByName("collapse10")); + hideList(document.getElementsByName("collapse20")); + hideList(document.getElementsByName("collapse30")); + hideList(document.getElementsByName("collapse31")); + + } +} + +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"; + } + } + }); +} + +function init() { + //importScript("../assets/scripts/tools/scripts.js"); + + // 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 XPath expression here'); + + processVersionSelector(); + processTooltip(); + tool.addEventListener('change', event => { + //Check if script was called from textarea or selector + var targetID = event.target.getAttribute('id'); + if (targetID == "processors") { + processVersionSelector(); + processTooltip(); + } + else if (targetID == "versions") { + processTooltip(); + } + + + }) + tool.addEventListener('click', event => { + //Check if script was called from textarea or selector + var targetID = event.target.getAttribute('id'); + if (targetID !== "xmlArea" && targetID !== "transformArea") { + return; + } + processTooltip(); + + }) + tool.addEventListener('change', event => { + //Check if script was called from textarea or selector + var targetID = event.target.getAttribute('id'); + if (targetID !== "xmlArea" && targetID !== "transformArea") { + return; + } + processTooltip(); + }) +} + diff --git a/Frontend/tools/xpath.html b/Frontend/tools/xpath.html index b7726d4..6a6fc3c 100644 --- a/Frontend/tools/xpath.html +++ b/Frontend/tools/xpath.html @@ -5,6 +5,7 @@ + @@ -17115,156 +17116,6 @@ - - \ No newline at end of file -- 2.51.0 From 2f90f706805c27bd517e63e1a2da11d7fb707640 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 10:49:05 +0200 Subject: [PATCH 02/13] Separated in XSD --- Frontend/assets/scripts/tools/xsd.js | 35 ++++++++++++++++++++++++ Frontend/tools/xsd.html | 40 +--------------------------- 2 files changed, 36 insertions(+), 39 deletions(-) create mode 100644 Frontend/assets/scripts/tools/xsd.js diff --git a/Frontend/assets/scripts/tools/xsd.js b/Frontend/assets/scripts/tools/xsd.js new file mode 100644 index 0000000..161aa7d --- /dev/null +++ b/Frontend/assets/scripts/tools/xsd.js @@ -0,0 +1,35 @@ +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 XSD 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(); + + }) +} + +function processTooltip() { + + if (getProcessor() == "xalan") { + 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")); + } +} \ No newline at end of file diff --git a/Frontend/tools/xsd.html b/Frontend/tools/xsd.html index 100756b..52e559a 100644 --- a/Frontend/tools/xsd.html +++ b/Frontend/tools/xsd.html @@ -6,6 +6,7 @@ + @@ -79,45 +80,6 @@ - - \ No newline at end of file -- 2.51.0 From 92678e57bc9c7c3525f1ff2103917e82f2e8cf6c Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 10:57:57 +0200 Subject: [PATCH 03/13] Separated in XSLT --- Frontend/assets/scripts/tools/xslt.js | 83 +++++++++++++++++++++++++++ Frontend/tools/xslt.html | 1 + 2 files changed, 84 insertions(+) create mode 100644 Frontend/assets/scripts/tools/xslt.js diff --git a/Frontend/assets/scripts/tools/xslt.js b/Frontend/assets/scripts/tools/xslt.js new file mode 100644 index 0000000..bcc5d9d --- /dev/null +++ b/Frontend/assets/scripts/tools/xslt.js @@ -0,0 +1,83 @@ +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")); + } +} + +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"; + } + } + }); +} + +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(); + + }) + +} \ No newline at end of file diff --git a/Frontend/tools/xslt.html b/Frontend/tools/xslt.html index 7fd299b..1a43ef5 100644 --- a/Frontend/tools/xslt.html +++ b/Frontend/tools/xslt.html @@ -6,6 +6,7 @@ + -- 2.51.0 From 4ebe38ad38828efbf731d5895b8ee440005129a6 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 10:58:53 +0200 Subject: [PATCH 04/13] Separated in XML Formatter --- Frontend/assets/scripts/tools/xmlFormatter.js | 11 +++++++++++ Frontend/tools/xmlFormatter.html | 15 +-------------- 2 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 Frontend/assets/scripts/tools/xmlFormatter.js diff --git a/Frontend/assets/scripts/tools/xmlFormatter.js b/Frontend/assets/scripts/tools/xmlFormatter.js new file mode 100644 index 0000000..04a35cc --- /dev/null +++ b/Frontend/assets/scripts/tools/xmlFormatter.js @@ -0,0 +1,11 @@ +function getProcessor() { + return "libxml"; +} + +function getVersion() { + return "1.0" +} + +function init() { + configurePastingInElement("xmlArea"); +} \ No newline at end of file diff --git a/Frontend/tools/xmlFormatter.html b/Frontend/tools/xmlFormatter.html index c9419ea..c0f4253 100644 --- a/Frontend/tools/xmlFormatter.html +++ b/Frontend/tools/xmlFormatter.html @@ -7,6 +7,7 @@ + @@ -62,20 +63,6 @@ - - -- 2.51.0 From b9d87f11bc6d007e105a6ffcc38ad49b751f3a6c Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:04:02 +0200 Subject: [PATCH 05/13] Separated in JSON Formatter --- .../assets/scripts/tools/jsonFormatter.js | 168 +++++++++++++++++ Frontend/tools/jsonFormatter.html | 173 +----------------- 2 files changed, 170 insertions(+), 171 deletions(-) create mode 100644 Frontend/assets/scripts/tools/jsonFormatter.js diff --git a/Frontend/assets/scripts/tools/jsonFormatter.js b/Frontend/assets/scripts/tools/jsonFormatter.js new file mode 100644 index 0000000..7ea7801 --- /dev/null +++ b/Frontend/assets/scripts/tools/jsonFormatter.js @@ -0,0 +1,168 @@ +const mergeHTMLPlugin = (function () { + 'use strict'; + + var originalStream; + + /** + * @param {string} value + * @returns {string} + */ + function escapeHTML(value) { + return value + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + /* plugin itself */ + + /** @type {HLJSPlugin} */ + const mergeHTMLPlugin = { + // preserve the original HTML token stream + "before:highlightElement": ({ el }) => { + originalStream = nodeStream(el); + }, + // merge it afterwards with the highlighted token stream + "after:highlightElement": ({ el, result, text }) => { + if (!originalStream.length) { + return; + } + + const resultNode = document.createElement('div'); + resultNode.innerHTML = result.value; + result.value = mergeStreams(originalStream, nodeStream(resultNode), text); + el.innerHTML = result.value; + } + }; + + /** + * @param {Node} node + */ + function tag(node) { + return node.nodeName.toLowerCase(); + } + + /** + * @param {Node} node + */ + function nodeStream(node) { + /** @type Event[] */ + const result = []; + (function _nodeStream(node, offset) { + for (let child = node.firstChild; child; child = child.nextSibling) { + if (child.nodeType === 3) { + offset += child.nodeValue.length; + } else if (child.nodeType === 1) { + result.push({ + event: 'start', + offset: offset, + node: child + }); + offset = _nodeStream(child, offset); + + if (!tag(child).match(/br|hr|img|input/)) { + result.push({ + event: 'stop', + offset: offset, + node: child + }); + } + } + } + return offset; + })(node, 0); + return result; + } + + /** + * @param {any} original - the original stream + * @param {any} highlighted - stream of the highlighted source + * @param {string} value - the original source itself + */ + function mergeStreams(original, highlighted, value) { + let processed = 0; + let result = ''; + const nodeStack = []; + + function selectStream() { + if (!original.length || !highlighted.length) { + return original.length ? original : highlighted; + } + if (original[0].offset !== highlighted[0].offset) { + return (original[0].offset < highlighted[0].offset) ? original : highlighted; + } + + return highlighted[0].event === 'start' ? original : highlighted; + } + + /** + * @param {Node} node + */ + function open(node) { + /** @param {Attr} attr */ + function attributeString(attr) { + return ' ' + attr.nodeName + '="' + escapeHTML(attr.value) + '"'; + } + + // @ts-ignore + result += '<' + tag(node) + [].map.call(node.attributes, attributeString).join('') + + '>'; + } + + /** + * @param {Node} node + */ + function close(node) { + result += ''; + } + + /** + * @param {Event} event + */ + function render(event) { + (event.event === 'start' ? open : close)(event.node); + } + + while (original.length || highlighted.length) { + let stream = selectStream(); + result += escapeHTML(value.substring(processed, stream[0].offset)); + processed = stream[0].offset; + if (stream === original) { + /* + On any opening or closing tag of the original markup we first close + the entire highlighted node stack, then render the original tag along + with all the following original tags at the same offset and then + reopen all the tags on the highlighted stack. + */ + nodeStack.reverse().forEach(close); + do { + render(stream.splice(0, 1)[0]); + stream = selectStream(); + } while (stream === original && stream.length && stream[0].offset === processed); + nodeStack.reverse().forEach(open); + } else { + if (stream[0].event === 'start') { + nodeStack.push(stream[0].node); + } else { + nodeStack.pop(); + } + render(stream.splice(0, 1)[0]); + } + } + return result + escapeHTML(value.substr(processed)); + } + + return mergeHTMLPlugin; + +}()); + + + +function init() { + // Make sure that only plain text is pasted + configurePastingInElement("jsonBlock"); + + hljs.addPlugin(mergeHTMLPlugin); +} \ No newline at end of file diff --git a/Frontend/tools/jsonFormatter.html b/Frontend/tools/jsonFormatter.html index 300ff95..a71aea2 100644 --- a/Frontend/tools/jsonFormatter.html +++ b/Frontend/tools/jsonFormatter.html @@ -8,7 +8,8 @@ - + + @@ -61,175 +62,5 @@ - - -- 2.51.0 From 29255c6c895392ce5da4036eb4cfdcd50b4c6d5b Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:05:50 +0200 Subject: [PATCH 06/13] Removed unused script tag in jsonFormatter.html --- Frontend/tools/jsonFormatter.html | 1 - 1 file changed, 1 deletion(-) diff --git a/Frontend/tools/jsonFormatter.html b/Frontend/tools/jsonFormatter.html index a71aea2..0321df0 100644 --- a/Frontend/tools/jsonFormatter.html +++ b/Frontend/tools/jsonFormatter.html @@ -9,7 +9,6 @@ - -- 2.51.0 From 93ddee7c2bdb8a6f791283fa948cf47b6c73c2a7 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:07:48 +0200 Subject: [PATCH 07/13] Fixed some htmls still using cloudflare hljs --- Frontend/tools/jsonFormatter.html | 2 +- Frontend/tools/xmlFormatter.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Frontend/tools/jsonFormatter.html b/Frontend/tools/jsonFormatter.html index 0321df0..348715b 100644 --- a/Frontend/tools/jsonFormatter.html +++ b/Frontend/tools/jsonFormatter.html @@ -7,7 +7,7 @@ - + diff --git a/Frontend/tools/xmlFormatter.html b/Frontend/tools/xmlFormatter.html index c0f4253..a200e44 100644 --- a/Frontend/tools/xmlFormatter.html +++ b/Frontend/tools/xmlFormatter.html @@ -5,7 +5,7 @@ - + -- 2.51.0 From 52c1620552a60cc8e76c4257f8780f4fd3b94eb5 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:10:34 +0200 Subject: [PATCH 08/13] Removed unused code --- Frontend/assets/scripts/frame.js | 15 --------------- Frontend/assets/scripts/tools/jsonFormatter.js | 13 ------------- Frontend/assets/scripts/tools/xpath.js | 1 - 3 files changed, 29 deletions(-) diff --git a/Frontend/assets/scripts/frame.js b/Frontend/assets/scripts/frame.js index c1c72f7..00f61c6 100644 --- a/Frontend/assets/scripts/frame.js +++ b/Frontend/assets/scripts/frame.js @@ -1,20 +1,5 @@ const tools = new Map(); -/** - * This functions imports other js file. I hate this solution, but other didn't work. - * - * @function - * @name importScript - * @kind function - * @param {any} url - * @returns {void} - */ -function importScript(url) { - var script = document.createElement("script"); - script.src = url; - document.head.appendChild(script); -} - /** * Get address of Mock Services * diff --git a/Frontend/assets/scripts/tools/jsonFormatter.js b/Frontend/assets/scripts/tools/jsonFormatter.js index 7ea7801..425f7f9 100644 --- a/Frontend/assets/scripts/tools/jsonFormatter.js +++ b/Frontend/assets/scripts/tools/jsonFormatter.js @@ -3,19 +3,6 @@ const mergeHTMLPlugin = (function () { var originalStream; - /** - * @param {string} value - * @returns {string} - */ - function escapeHTML(value) { - return value - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - } - /* plugin itself */ /** @type {HLJSPlugin} */ diff --git a/Frontend/assets/scripts/tools/xpath.js b/Frontend/assets/scripts/tools/xpath.js index e3f6e02..6e1d918 100644 --- a/Frontend/assets/scripts/tools/xpath.js +++ b/Frontend/assets/scripts/tools/xpath.js @@ -102,7 +102,6 @@ for (i = 0; i < triggerList.length; i++) { } function init() { - //importScript("../assets/scripts/tools/scripts.js"); // Make sure that only plain text is pasted configurePastingInElement("xmlArea"); -- 2.51.0 From 8af82e35584a0c4524c89400a4f874114a9d3410 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:42:23 +0200 Subject: [PATCH 09/13] 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"); -- 2.51.0 From 18d9e654d2722f1b8a67bab195de1cbb4c012dfc Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:53:23 +0200 Subject: [PATCH 10/13] Merged json.js to jsonFormatter.js --- Frontend/assets/scripts/tools/json.js | 72 --------------- .../assets/scripts/tools/jsonFormatter.js | 91 ++++++++++++++++++- Frontend/tools/jsonFormatter.html | 1 - 3 files changed, 90 insertions(+), 74 deletions(-) delete mode 100644 Frontend/assets/scripts/tools/json.js diff --git a/Frontend/assets/scripts/tools/json.js b/Frontend/assets/scripts/tools/json.js deleted file mode 100644 index 1f5f09c..0000000 --- a/Frontend/assets/scripts/tools/json.js +++ /dev/null @@ -1,72 +0,0 @@ -function formatAndValidateJson(errorElement) { - const input = document.querySelector('#jsonBlock'); - const processInfo = document.getElementById(errorElement); - - const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/formatting" - - fetch(address, { - method: 'POST', - body: input.textContent - }) - .then(async (response) => { - const promise = response.json(); - if (!response.ok) { - throw Error(await promise); - } - - return promise; - }) - .then((data) => { - input.innerText = data.data; - processInfo.innerText = ""; - hljs.highlightElement(input); - - processInfo.innerHTML = "Computed in " + data.time + "ms"; - }) - .catch((error) => { - processInfo.innerHTML = "" + error.data + ""; - console.error('Error:', error); - }); -} - -function minimizeJson(errorElement) { - const input = document.querySelector('#jsonBlock'); - const processInfo = document.getElementById(errorElement); - - const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/minimize" - - fetch(address, { - method: 'POST', - body: input.textContent - }) - .then(async (response) => { - const promise = response.json(); - if (!response.ok) { - throw Error(await promise); - } - - return promise; - }) - .then((data) => { - input.innerText = data.data; - processInfo.innerText = ""; - hljs.highlightElement(input); - - processInfo.innerHTML = "Computed in " + data.time + "ms"; - }) - .catch((error) => { - processInfo.innerHTML = "" + error.data + ""; - console.error('Error:', error); - }); -} - -function clearJsonData() { - const input = document.querySelector('#jsonBlock'); - input.textContent = ""; -} - -function insertDefaultJson() { - const input = document.querySelector('#jsonBlock'); - input.textContent = "{\"enter\": \"your\", \"json\": \"here\"}"; - hljs.highlightElement(input); -} \ No newline at end of file diff --git a/Frontend/assets/scripts/tools/jsonFormatter.js b/Frontend/assets/scripts/tools/jsonFormatter.js index 8be8832..54b7da5 100644 --- a/Frontend/assets/scripts/tools/jsonFormatter.js +++ b/Frontend/assets/scripts/tools/jsonFormatter.js @@ -1,8 +1,24 @@ + + const mergeHTMLPlugin = (function () { 'use strict'; var originalStream; + /** + * @param {string} value + * @returns {string} + */ + function escapeHTML(value) { + return value + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + /* plugin itself */ /** @type {HLJSPlugin} */ @@ -158,4 +174,77 @@ function init() { configurePastingInElement("jsonBlock"); hljs.addPlugin(mergeHTMLPlugin); -} \ No newline at end of file +} + +function formatAndValidateJson(errorElement) { + const input = document.querySelector('#jsonBlock'); + const processInfo = document.getElementById(errorElement); + + const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/formatting" + + fetch(address, { + method: 'POST', + body: input.textContent + }) + .then(async (response) => { + const promise = response.json(); + if (!response.ok) { + throw Error(await promise); + } + + return promise; + }) + .then((data) => { + input.innerText = data.data; + processInfo.innerText = ""; + hljs.highlightElement(input); + + processInfo.innerHTML = "Computed in " + data.time + "ms"; + }) + .catch((error) => { + processInfo.innerHTML = "" + error.data + ""; + console.error('Error:', error); + }); + } + + function minimizeJson(errorElement) { + const input = document.querySelector('#jsonBlock'); + const processInfo = document.getElementById(errorElement); + + const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/minimize" + + fetch(address, { + method: 'POST', + body: input.textContent + }) + .then(async (response) => { + const promise = response.json(); + if (!response.ok) { + throw Error(await promise); + } + + return promise; + }) + .then((data) => { + input.innerText = data.data; + processInfo.innerText = ""; + hljs.highlightElement(input); + + processInfo.innerHTML = "Computed in " + data.time + "ms"; + }) + .catch((error) => { + processInfo.innerHTML = "" + error.data + ""; + console.error('Error:', error); + }); + } + + function clearJsonData() { + const input = document.querySelector('#jsonBlock'); + input.textContent = ""; + } + + function insertDefaultJson() { + const input = document.querySelector('#jsonBlock'); + input.textContent = "{\"enter\": \"your\", \"json\": \"here\"}"; + hljs.highlightElement(input); + } \ No newline at end of file diff --git a/Frontend/tools/jsonFormatter.html b/Frontend/tools/jsonFormatter.html index 348715b..8081f02 100644 --- a/Frontend/tools/jsonFormatter.html +++ b/Frontend/tools/jsonFormatter.html @@ -10,7 +10,6 @@ - -- 2.51.0 From cad01a4285ccaa4a0e34928d621d9db55c86f966 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 11:58:05 +0200 Subject: [PATCH 11/13] Reformated jsonFormatter.js --- .../assets/scripts/tools/jsonFormatter.js | 156 +++++++++--------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/Frontend/assets/scripts/tools/jsonFormatter.js b/Frontend/assets/scripts/tools/jsonFormatter.js index 54b7da5..64f7609 100644 --- a/Frontend/assets/scripts/tools/jsonFormatter.js +++ b/Frontend/assets/scripts/tools/jsonFormatter.js @@ -11,13 +11,13 @@ const mergeHTMLPlugin = (function () { */ function escapeHTML(value) { return value - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); } - + /* plugin itself */ @@ -161,6 +161,78 @@ const mergeHTMLPlugin = (function () { }()); +function formatAndValidateJson(errorElement) { + const input = document.querySelector('#jsonBlock'); + const processInfo = document.getElementById(errorElement); + + const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/formatting" + + fetch(address, { + method: 'POST', + body: input.textContent + }) + .then(async (response) => { + const promise = response.json(); + if (!response.ok) { + throw Error(await promise); + } + + return promise; + }) + .then((data) => { + input.innerText = data.data; + processInfo.innerText = ""; + hljs.highlightElement(input); + + processInfo.innerHTML = "Computed in " + data.time + "ms"; + }) + .catch((error) => { + processInfo.innerHTML = "" + error.data + ""; + console.error('Error:', error); + }); +} + +function minimizeJson(errorElement) { + const input = document.querySelector('#jsonBlock'); + const processInfo = document.getElementById(errorElement); + + const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/minimize" + + fetch(address, { + method: 'POST', + body: input.textContent + }) + .then(async (response) => { + const promise = response.json(); + if (!response.ok) { + throw Error(await promise); + } + + return promise; + }) + .then((data) => { + input.innerText = data.data; + processInfo.innerText = ""; + hljs.highlightElement(input); + + processInfo.innerHTML = "Computed in " + data.time + "ms"; + }) + .catch((error) => { + processInfo.innerHTML = "" + error.data + ""; + console.error('Error:', error); + }); +} + +function clearJsonData() { + const input = document.querySelector('#jsonBlock'); + input.textContent = ""; +} + +function insertDefaultJson() { + const input = document.querySelector('#jsonBlock'); + input.textContent = "{\"enter\": \"your\", \"json\": \"here\"}"; + hljs.highlightElement(input); +} /** * This function is executed after the page is loaded. @@ -176,75 +248,3 @@ function init() { hljs.addPlugin(mergeHTMLPlugin); } -function formatAndValidateJson(errorElement) { - const input = document.querySelector('#jsonBlock'); - const processInfo = document.getElementById(errorElement); - - const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/formatting" - - fetch(address, { - method: 'POST', - body: input.textContent - }) - .then(async (response) => { - const promise = response.json(); - if (!response.ok) { - throw Error(await promise); - } - - return promise; - }) - .then((data) => { - input.innerText = data.data; - processInfo.innerText = ""; - hljs.highlightElement(input); - - processInfo.innerHTML = "Computed in " + data.time + "ms"; - }) - .catch((error) => { - processInfo.innerHTML = "" + error.data + ""; - console.error('Error:', error); - }); - } - - function minimizeJson(errorElement) { - const input = document.querySelector('#jsonBlock'); - const processInfo = document.getElementById(errorElement); - - const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/minimize" - - fetch(address, { - method: 'POST', - body: input.textContent - }) - .then(async (response) => { - const promise = response.json(); - if (!response.ok) { - throw Error(await promise); - } - - return promise; - }) - .then((data) => { - input.innerText = data.data; - processInfo.innerText = ""; - hljs.highlightElement(input); - - processInfo.innerHTML = "Computed in " + data.time + "ms"; - }) - .catch((error) => { - processInfo.innerHTML = "" + error.data + ""; - console.error('Error:', error); - }); - } - - function clearJsonData() { - const input = document.querySelector('#jsonBlock'); - input.textContent = ""; - } - - function insertDefaultJson() { - const input = document.querySelector('#jsonBlock'); - input.textContent = "{\"enter\": \"your\", \"json\": \"here\"}"; - hljs.highlightElement(input); - } \ No newline at end of file -- 2.51.0 From 00dc6834acfefad4f17f96f149fb07ef2a6e9d6b Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 13:42:26 +0200 Subject: [PATCH 12/13] Removed duplicated code from xpath.html --- Frontend/tools/xslt.html | 87 ---------------------------------------- 1 file changed, 87 deletions(-) diff --git a/Frontend/tools/xslt.html b/Frontend/tools/xslt.html index 1a43ef5..e5dd2f0 100644 --- a/Frontend/tools/xslt.html +++ b/Frontend/tools/xslt.html @@ -1148,93 +1148,6 @@ - - \ No newline at end of file -- 2.51.0 From 708e1a3a8499d70768cdc52a3d55abfd2dd8098d Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 15 May 2023 13:43:41 +0200 Subject: [PATCH 13/13] Fixed not working tooltips in xslt --- Frontend/assets/scripts/tools/xslt.js | 78 +++++++++++++-------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/Frontend/assets/scripts/tools/xslt.js b/Frontend/assets/scripts/tools/xslt.js index 82a5f32..4e61cb1 100644 --- a/Frontend/assets/scripts/tools/xslt.js +++ b/Frontend/assets/scripts/tools/xslt.js @@ -20,43 +20,6 @@ function 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"; - } - } - }); -} - /** * This function is executed after the page is loaded. @@ -94,7 +57,44 @@ function init() { } 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 -- 2.51.0