Format function now allows to choose source and target IDs
This commit is contained in:
@@ -96,18 +96,20 @@ function refreshTooltip() {
|
|||||||
document.getElementById("xsltelementsheader").innerText = XSLTheader;
|
document.getElementById("xsltelementsheader").innerText = XSLTheader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function performRequest(endpoint, checkXML, checkTransform){
|
function performRequest(endpoint, checkXML, checkTransform){
|
||||||
var xmlData = document.getElementById("xmlArea").value.trim();
|
var xmlData = document.getElementById(sourceId).value.trim();
|
||||||
var transformData = document.getElementById("transformArea").value.trim();
|
var transformData = document.getElementById(targetId).value.trim();
|
||||||
|
|
||||||
var empty = false;
|
var empty = false;
|
||||||
if (defaultStrings.includes(xmlData) && checkXML) {
|
if (defaultStrings.includes(xmlData) && checkXML) {
|
||||||
document.getElementById("xmlArea").style.backgroundColor = color_red;
|
document.getElementById(sourceId).style.backgroundColor = color_red;
|
||||||
xmlData = "";
|
xmlData = "";
|
||||||
empty = true;
|
empty = true;
|
||||||
}
|
}
|
||||||
if (defaultStrings.includes(transformData) && checkTransform) {
|
if (defaultStrings.includes(transformData) && checkTransform) {
|
||||||
document.getElementById("transformArea").style.backgroundColor = color_red;
|
document.getElementById(targetId).style.backgroundColor = color_red;
|
||||||
empty = true;
|
empty = true;
|
||||||
}
|
}
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
@@ -128,34 +130,30 @@ function performRequest(endpoint, checkXML, checkTransform){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function performFormatRequest(endpoint, checkXML){
|
function performFormatRequest(endpoint, checkXML, sourceId, targetId){
|
||||||
var xmlData = document.getElementById("xmlArea").value.trim();
|
var xmlData = document.getElementById(sourceId).value.trim();
|
||||||
|
|
||||||
var empty = false;
|
var empty = false;
|
||||||
if (defaultStrings.includes(xmlData) && checkXML) {
|
if (defaultStrings.includes(xmlData) && checkXML) {
|
||||||
document.getElementById("xmlArea").style.backgroundColor = color_red;
|
document.getElementById(sourceId).style.backgroundColor = color_red;
|
||||||
xmlData = "";
|
xmlData = "";
|
||||||
empty = true;
|
empty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
var result = restRequest(endpoint, xmlData, null);
|
restRequest(endpoint, xmlData, "").then(function(result) {
|
||||||
document.getElementById("resultArea").value = result.result;
|
document.getElementById(targetId).value = result.result;
|
||||||
document.getElementById("procinfo").innerText = ' Computed using '.concat(" ", result.processor);
|
|
||||||
if (response.ok) {
|
});
|
||||||
document.getElementById("procinfo").innerText = document.getElementById("procinfo").innerText.concat(" in ", result.time, "ms");
|
|
||||||
procinfo.style.color = "#30aa58";
|
|
||||||
} else {
|
|
||||||
procinfo.style.color = "#aa3030";
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
document.getElementById("resultArea").value = "No data provided!";
|
document.getElementById(targetId).value = "No data provided!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Form REST request, send, receive and display in resultArea
|
//Form REST request, send and return received data
|
||||||
async function restRequest(endpoint, xmlData, transformData) {
|
async function restRequest(endpoint, xmlData, transformData) {
|
||||||
const escapeChar = "specialEscapeChar";
|
const escapeChar = "specialEscapeChar";
|
||||||
var port = ":8081/"
|
var port = ":8081/"
|
||||||
|
|||||||
@@ -29,9 +29,9 @@
|
|||||||
onfocus="clearDefaultContent(this, 'Insert XML here');"></textarea>
|
onfocus="clearDefaultContent(this, 'Insert XML here');"></textarea>
|
||||||
<br><br>
|
<br><br>
|
||||||
<button id="requestButton" class="max-width block-label action-button active"
|
<button id="requestButton" class="max-width block-label action-button active"
|
||||||
onclick="performFormatRequest('prettifypost', true)">Prettify XML</button>
|
onclick="performFormatRequest('prettifypost', true, 'xmlArea', 'resultArea')">Prettify XML</button>
|
||||||
<button id="requestButton" class="max-width block-label action-button active"
|
<button id="requestButton" class="max-width block-label action-button active"
|
||||||
onclick="performFormatRequest('minimizepost', true)">Minimize XML</button>
|
onclick="performFormatRequest('minimizepost', true, 'xmlArea', 'resultArea')">Minimize XML</button>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<label for="resultArea"><b>Result:<span id="procinfo"></span></b></label>
|
<label for="resultArea"><b>Result:<span id="procinfo"></span></b></label>
|
||||||
|
|||||||
Reference in New Issue
Block a user