Connected frontend and backend in formatter
This commit is contained in:
		| @@ -91,7 +91,7 @@ function refreshTooltip() { | ||||
|     document.getElementById("xsltelementsheader").innerText = XSLTheader; | ||||
| } | ||||
|  | ||||
| function performRequest(text, checkXML, checkTransform){ | ||||
| function performRequest(endpoint, checkXML, checkTransform){ | ||||
|     var xmlData = document.getElementById("xmlArea").value.trim(); | ||||
|     var transformData = document.getElementById("transformArea").value.trim(); | ||||
|      | ||||
| @@ -106,7 +106,7 @@ function performRequest(text, checkXML, checkTransform){ | ||||
|         empty = true; | ||||
|     } | ||||
|     if (!empty) { | ||||
|         restRequest(text); | ||||
|         restRequest(endpoint, xmlData, transformData); | ||||
|     }else{ | ||||
|         document.getElementById("resultArea").value = "No data provided!"; | ||||
|         return false; | ||||
| @@ -114,17 +114,33 @@ function performRequest(text, checkXML, checkTransform){ | ||||
|      | ||||
| } | ||||
|  | ||||
| function performFormatRequest(endpoint, checkXML){ | ||||
|     var xmlData = document.getElementById("xmlArea").value.trim(); | ||||
|      | ||||
|     var empty = false; | ||||
|     if (defaultStrings.includes(xmlData) && checkXML) { | ||||
|             document.getElementById("xmlArea").style.backgroundColor = color_red; | ||||
|             xmlData = ""; | ||||
|             empty = true; | ||||
|     } | ||||
|     if (!empty) { | ||||
|         restRequest(endpoint, xmlData, null); | ||||
|     }else{ | ||||
|         document.getElementById("resultArea").value = "No data provided!"; | ||||
|         return false; | ||||
|     } | ||||
|      | ||||
| } | ||||
|  | ||||
|  | ||||
| //Form REST request, send, receive and display in resultArea | ||||
| async function restRequest(text) { | ||||
| async function restRequest(endpoint, xmlData, transformData) { | ||||
|     const escapeChar = "specialEscapeChar"; | ||||
|     var port = ":8081/" | ||||
|     if (getProcessor() == "libxml") { | ||||
|         port = ":8082/" | ||||
|     } | ||||
|     const addr = window.location.protocol + "//" + window.location.hostname + port + text; | ||||
|      | ||||
|     var xmlData = document.getElementById("xmlArea").value.trim(); | ||||
|     var transformData = document.getElementById("transformArea").value.trim(); | ||||
|     const addr = window.location.protocol + "//" + window.location.hostname + port + endpoint; | ||||
|  | ||||
|     if(defaultStrings.includes(xmlData)){ | ||||
|         xmlData = "<empty/>"; | ||||
|   | ||||
| @@ -25,9 +25,9 @@ | ||||
|                     onfocus="clearDefaultContent(this, 'Insert XML here');"></textarea> | ||||
|                 <br><br> | ||||
|                 <button id="requestButton" class="max-width block-label action-button active" | ||||
|                     onclick="performRequest('xsdpost', true, true)">Prettify XML</button> | ||||
|                     onclick="performFormatRequest('prettifypost', true)">Prettify XML</button> | ||||
|                 <button id="requestButton" class="max-width block-label action-button active" | ||||
|                     onclick="performRequest('xsdpost', true, true)">Minimize XML</button> | ||||
|                     onclick="performFormatRequest('minimizepost', true)">Minimize XML</button> | ||||
|                 <br><br> | ||||
|  | ||||
|                 <label for="resultArea"><b>Result:<span id="procinfo"></span></b></label> | ||||
| @@ -73,22 +73,17 @@ | ||||
|     </script> | ||||
|     <script> | ||||
|         function getProcessor() { | ||||
|             return document.getElementById("processors").value; | ||||
|             return "libxml"; | ||||
|         } | ||||
|     </script> | ||||
|     <script> | ||||
|         function getVersion() { | ||||
|             if (getProcInfo() == "xalan") { | ||||
|                 return "1.0"; | ||||
|             } else { | ||||
|                 return "3.0"; | ||||
|             } | ||||
|             return "1.0"; | ||||
|         } | ||||
|     </script> | ||||
|     <script> | ||||
|         function getProcInfo() { | ||||
|             var processVariables = document.getElementById("processors").value;// + "&version=" + document.getElementById("versions").value; | ||||
|             return processVariables; | ||||
|             return "libxml"; | ||||
|         } | ||||
|     </script> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user