dev (#81)
Co-authored-by: mikolaj widla <mikolaj.widla@gmail.com> Co-authored-by: Adam Bem <adam.bem@zoho.eu> Reviewed-on: R11/release11-tools-web#81
This commit is contained in:
		| @@ -330,6 +330,10 @@ | ||||
|     height: 300px; | ||||
| } | ||||
|  | ||||
| .textarea-800 { | ||||
|     height: 800px; | ||||
| } | ||||
|  | ||||
| .centered-content { | ||||
|     display: flex; | ||||
|     justify-content: center; | ||||
|   | ||||
| @@ -11,6 +11,11 @@ function clearDefaultContent(element, text) { | ||||
|     } | ||||
| } | ||||
|  | ||||
| function clearDataField(){ | ||||
|     document.getElementById("xmlArea").value = ""; | ||||
|     document.getElementById("transformArea").value = ""; | ||||
| } | ||||
|  | ||||
| function fillDefaultXML(element) { | ||||
|     if(element.classList.contains("active")){ | ||||
|         const serverAddress = window.location.protocol + "//" + window.location.hostname + ":8086"; | ||||
| @@ -91,22 +96,38 @@ function refreshTooltip() { | ||||
|     document.getElementById("xsltelementsheader").innerText = XSLTheader; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| function performRequest(endpoint, checkXML, checkTransform){ | ||||
|     var xmlData = document.getElementById("xmlArea").value.trim(); | ||||
|     var transformData = document.getElementById("transformArea").value.trim(); | ||||
|     var xmlData = document.getElementById(sourceId).value.trim(); | ||||
|     var transformData = document.getElementById(targetId).value.trim(); | ||||
|      | ||||
|     var port = 8081 | ||||
|     if (getProcessor() == "libxml") { | ||||
|         port = 8082 | ||||
|     } | ||||
|  | ||||
|     var empty = false; | ||||
|     if (defaultStrings.includes(xmlData) && checkXML) { | ||||
|             document.getElementById("xmlArea").style.backgroundColor = color_red; | ||||
|             document.getElementById(sourceId).style.backgroundColor = color_red; | ||||
|             xmlData = ""; | ||||
|             empty = true; | ||||
|     } | ||||
|     if (defaultStrings.includes(transformData) && checkTransform) { | ||||
|         document.getElementById("transformArea").style.backgroundColor = color_red; | ||||
|         document.getElementById(targetId).style.backgroundColor = color_red; | ||||
|         empty = true; | ||||
|     } | ||||
|     if (!empty) { | ||||
|         restRequest(endpoint, xmlData, transformData); | ||||
|         restRequest(port, endpoint, xmlData, transformData).then(function(result) { | ||||
|             document.getElementById("resultArea").value = result.result; | ||||
|             document.getElementById("procinfo").innerText = ' Computed using '.concat(" ", result.processor); | ||||
|             if (result.status = "OK") { | ||||
|                 document.getElementById("procinfo").innerText = document.getElementById("procinfo").innerText.concat(" in ", result.time, "ms"); | ||||
|                 procinfo.style.color = "#30aa58"; | ||||
|             } else { | ||||
|                 procinfo.style.color = "#aa3030"; | ||||
|             } | ||||
|         }); | ||||
|     }else{ | ||||
|         document.getElementById("resultArea").value = "No data provided!"; | ||||
|         return false; | ||||
| @@ -114,33 +135,35 @@ function performRequest(endpoint, checkXML, checkTransform){ | ||||
|      | ||||
| } | ||||
|  | ||||
| function performFormatRequest(endpoint, checkXML){ | ||||
|     var xmlData = document.getElementById("xmlArea").value.trim(); | ||||
| function performFormatRequest(endpoint, checkXML, sourceId, targetId){ | ||||
|     const port = 8082; | ||||
|     var xmlData = document.getElementById(sourceId).value.trim(); | ||||
|      | ||||
|     var empty = false; | ||||
|     if (defaultStrings.includes(xmlData) && checkXML) { | ||||
|             document.getElementById("xmlArea").style.backgroundColor = color_red; | ||||
|             document.getElementById(sourceId).style.backgroundColor = color_red; | ||||
|             xmlData = ""; | ||||
|             empty = true; | ||||
|     } | ||||
|  | ||||
|     if (!empty) { | ||||
|         restRequest(endpoint, xmlData, null); | ||||
|         restRequest(port, endpoint, xmlData, "").then(function(result) { | ||||
|             document.getElementById(targetId).value = result.result; | ||||
|              | ||||
|         }); | ||||
|     }else{ | ||||
|         document.getElementById("resultArea").value = "No data provided!"; | ||||
|         document.getElementById(targetId).value = "No data provided!"; | ||||
|         return false; | ||||
|     } | ||||
|      | ||||
| } | ||||
|  | ||||
|  | ||||
| //Form REST request, send, receive and display in resultArea | ||||
| async function restRequest(endpoint, xmlData, transformData) { | ||||
| //Form REST request, send and return received data | ||||
| async function restRequest(port, endpoint, xmlData, transformData) { | ||||
|     const escapeChar = "specialEscapeChar"; | ||||
|     var port = ":8081/" | ||||
|     if (getProcessor() == "libxml") { | ||||
|         port = ":8082/" | ||||
|     } | ||||
|     const addr = window.location.protocol + "//" + window.location.hostname + port + endpoint; | ||||
|      | ||||
|     const addr = window.location.protocol + "//" + window.location.hostname + ":" + port + "/" + endpoint; | ||||
|  | ||||
|     if(defaultStrings.includes(xmlData)){ | ||||
|         xmlData = "<empty/>"; | ||||
| @@ -167,21 +190,11 @@ async function restRequest(endpoint, xmlData, transformData) { | ||||
|     var request = new Request(addr, init); | ||||
|  | ||||
|      | ||||
|  | ||||
|     await fetch(request).then(response => { | ||||
|         console.log(response.status); | ||||
|         response.text().then(function (text) { | ||||
|             console.log(text); | ||||
|             var result = JSON.parse(text); | ||||
|             document.getElementById("resultArea").value = result.result; | ||||
|             document.getElementById("procinfo").innerText = ' Computed using '.concat(" ", result.processor); | ||||
|             if (response.ok) { | ||||
|                 document.getElementById("procinfo").innerText = document.getElementById("procinfo").innerText.concat(" in ", result.time, "ms"); | ||||
|                 procinfo.style.color = "#30aa58"; | ||||
|             } else { | ||||
|                 procinfo.style.color = "#aa3030"; | ||||
|             } | ||||
|     var result = await fetch(request).then(response => { | ||||
|         return response.text().then(function(text) { | ||||
|             return JSON.parse(text); | ||||
|         }); | ||||
|  | ||||
|          | ||||
|     }); | ||||
|     return result; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user