Refactored performFormatRequest function
This commit is contained in:
@@ -148,13 +148,15 @@ function performRequest(endpoint, checkXML, checkTransform){
|
||||
}
|
||||
|
||||
function performFormatRequest(endpoint, checkXML, sourceId, targetId){
|
||||
const infoElementId = "formatinfo";
|
||||
const sourceElement = document.getElementById(sourceId);
|
||||
const targetElement = document.getElementById(targetId);
|
||||
const infoElement = document.getElementById("formatinfo");
|
||||
const port = 8082;
|
||||
var xmlData = document.getElementById(sourceId).value.trim();
|
||||
var xmlData = sourceElement.value.trim();
|
||||
|
||||
var empty = false;
|
||||
if (defaultStrings.includes(xmlData) && checkXML) {
|
||||
document.getElementById(sourceId).style.backgroundColor = color_red;
|
||||
sourceElement.style.backgroundColor = color_red;
|
||||
xmlData = "";
|
||||
empty = true;
|
||||
}
|
||||
@@ -163,15 +165,15 @@ function performFormatRequest(endpoint, checkXML, sourceId, targetId){
|
||||
restRequest(port, endpoint, xmlData, "").then(function(result) {
|
||||
console.log(result);
|
||||
if (result.status == "OK") {
|
||||
document.getElementById(targetId).value = result.result;
|
||||
document.getElementById(targetId).style.backgroundColor = null;
|
||||
document.getElementById(infoElementId).innerText = ' Computed'.concat(" in ", result.time, "ms.");
|
||||
document.getElementById(infoElementId).style.color = "#30aa58";
|
||||
targetElement.value = result.result;
|
||||
targetElement.style.backgroundColor = null;
|
||||
infoElement.innerText = ' Computed'.concat(" in ", result.time, "ms.");
|
||||
infoElement.style.color = "#30aa58";
|
||||
}
|
||||
else {
|
||||
document.getElementById(targetId).style.backgroundColor = color_red;
|
||||
document.getElementById(infoElementId).innerText = result.result;
|
||||
document.getElementById(infoElementId).style.color = "#aa3030";
|
||||
targetElement.style.backgroundColor = color_red;
|
||||
infoElement.innerText = result.result;
|
||||
infoElement.style.color = "#aa3030";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user