Connected frontend and backend in formatter

This commit is contained in:
2023-02-20 14:57:32 +01:00
parent f5c8910277
commit 947e5d621e
4 changed files with 73 additions and 23 deletions

View File

@@ -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/>";