Refactor of History module #184
@@ -77,10 +77,41 @@ function showHeadersHistory(element){
|
|||||||
showPopup();
|
showPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatXML(xml) {
|
||||||
|
const address = window.location.protocol + "//" + window.location.hostname + ":" + 8082 + "/prettify";
|
||||||
|
var data = {
|
||||||
|
data: xml,
|
||||||
|
process: "",
|
||||||
|
processor: "libxml",
|
||||||
|
version: "1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("formattedXML");
|
||||||
|
fetch(address, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
})
|
||||||
|
.then(async (response) => {
|
||||||
|
const promise = response.json();
|
||||||
|
if (!response.ok) {
|
||||||
|
throw Error(await promise);
|
||||||
|
}
|
||||||
|
return promise;
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
document.getElementById('code-highlight-content').innerText = data.result;
|
||||||
|
highlightSyntax('code-highlight-content');
|
||||||
|
//console.log(data.result);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function showRequestBody(element){
|
function showRequestBody(element){
|
||||||
requestBody = "";
|
requestBody = "";
|
||||||
historyRequestBody = historyJson[element.id].requestBody;
|
historyRequestBody = historyJson[element.id].requestBody;
|
||||||
console.log(historyRequestBody);
|
|
||||||
switch(historyJson[element.id].headers["content-type"]){
|
switch(historyJson[element.id].headers["content-type"]){
|
||||||
case "application/json":{
|
case "application/json":{
|
||||||
const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/formatting"
|
const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/formatting"
|
||||||
@@ -97,6 +128,7 @@ function showRequestBody(element){
|
|||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
requestBody = '<code class="language=json">'+data.data+'</code>';
|
requestBody = '<code class="language=json">'+data.data+'</code>';
|
||||||
|
|
||||||
document.getElementById('history-request-body-content').innerHTML = requestBody;
|
document.getElementById('history-request-body-content').innerHTML = requestBody;
|
||||||
hljs.highlightElement(document.getElementById('history-request-body-content'));
|
hljs.highlightElement(document.getElementById('history-request-body-content'));
|
||||||
})
|
})
|
||||||
@@ -106,13 +138,14 @@ function showRequestBody(element){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "application/xml":{
|
case "application/xml":{
|
||||||
document.getElementById('code-highlight-content').innerText = historyRequestBody;
|
//document.getElementById('code-highlight-content').innerText = historyRequestBody;
|
||||||
highlightSyntax('code-highlight-content');
|
formatXML(historyRequestBody);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:{
|
default:{
|
||||||
requestBody = '<code>'+historyRequestBody+'</code>'
|
requestBody = '<code>'+historyRequestBody+'</code>';
|
||||||
document.getElementById('history-request-body-content').innerText = requestBody;
|
document.getElementById('history-request-body-content').innerText = requestBody;
|
||||||
hljs.highlightElement(document.getElementById('history-request-body-content'));
|
hljs.highlightElement(document.getElementById('history-request-body-content'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user