XML Formatter QoL improvements (#88)
- Rewritten backend methods for prettifing and minimizing XMLs - Added "Clear" and "Insert default XML" buttons in XML Formatter. - Added place to display error messages in case of any Co-authored-by: Adam Bem <adam.bem@zoho.eu> Reviewed-on: R11/release11-tools-web#88
This commit is contained in:
@@ -148,24 +148,32 @@ function performRequest(endpoint, checkXML, checkTransform){
|
||||
}
|
||||
|
||||
function performFormatRequest(endpoint, checkXML, sourceId, targetId){
|
||||
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;
|
||||
}
|
||||
|
||||
if (!empty) {
|
||||
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;
|
||||
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;
|
||||
targetElement.style.backgroundColor = color_red;
|
||||
infoElement.innerText = result.result;
|
||||
infoElement.style.color = "#aa3030";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user