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