From c7d34ed05f946542f8221cb2e8ebd8077f80ffed Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Thu, 23 Feb 2023 13:57:57 +0100 Subject: [PATCH] Fixed bug with choosing ports --- Frontend/assets/scripts/tools/scripts.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Frontend/assets/scripts/tools/scripts.js b/Frontend/assets/scripts/tools/scripts.js index d55ea46..d464330 100644 --- a/Frontend/assets/scripts/tools/scripts.js +++ b/Frontend/assets/scripts/tools/scripts.js @@ -102,6 +102,11 @@ function performRequest(endpoint, checkXML, checkTransform){ 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(sourceId).style.backgroundColor = color_red; @@ -113,7 +118,7 @@ function performRequest(endpoint, checkXML, checkTransform){ empty = true; } if (!empty) { - restRequest(endpoint, xmlData, transformData).then(function(result) { + 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") { @@ -131,6 +136,7 @@ function performRequest(endpoint, checkXML, checkTransform){ } function performFormatRequest(endpoint, checkXML, sourceId, targetId){ + const port = 8082; var xmlData = document.getElementById(sourceId).value.trim(); var empty = false; @@ -141,7 +147,7 @@ function performFormatRequest(endpoint, checkXML, sourceId, targetId){ } if (!empty) { - restRequest(endpoint, xmlData, "").then(function(result) { + restRequest(port, endpoint, xmlData, "").then(function(result) { document.getElementById(targetId).value = result.result; }); @@ -154,13 +160,10 @@ function performFormatRequest(endpoint, checkXML, sourceId, targetId){ //Form REST request, send and return received data -async function restRequest(endpoint, xmlData, transformData) { +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 = "";