Created
December 21, 2019 15:26
-
-
Save odevodyssey/3473f1b356035f8e0cca0d0238a8d076 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let template = ` | |
<html> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script> | |
</head> | |
<body> | |
<div> | |
<div> | |
<input id="filter" style="width:450px;" type="text" placeholder="Example query: //slide"> | |
</div> | |
<div> | |
<button id="resetButton" style="background-color:red;color:white;">Reset</button> | |
<input id="showErrors" type="checkbox" value="1"/> | |
<span class="item-text" style="font-family:courier;">Show Evaluation Errors</span> | |
</div> | |
<div id="errors" style="font-family:courier;color:red;display:none;"></div> | |
<div> | |
<textarea id="content" style="font-family:courier;color:green;font-size:18px;"></textarea> | |
</div> | |
</div> | |
</body> | |
</html> | |
<script> | |
pm.getData( (error, value) => { | |
var parser = new DOMParser(); | |
var xmlDoc = parser.parseFromString(value.xml, "text/xml"); | |
$(function() { | |
$('#filter').keyup(function() { | |
var node = null; | |
var xml = ''; | |
try { | |
let filteredData = xmlDoc.evaluate($(this).val(), xmlDoc, null, XPathResult.ANY_TYPE, null); | |
while(node = filteredData.iterateNext()) { | |
xml = xml + node.outerHTML; | |
console.log(xml) | |
} | |
$("#content, #errors").empty(); | |
$("#content").val(xml); | |
$('#content').on( 'change paste cut', function (){ | |
$(this).height(0).height(this.scrollHeight); | |
$(this).width(0).width(1085); | |
}).change(); | |
} catch (err) { | |
console.info(err); | |
$("#errors").empty(); | |
$("#errors").append("<pre><code>" + err + "</code></pre>"); | |
} | |
}); | |
}); | |
$( "#resetButton" ).click(function() { | |
$("#content, #errors").empty(); | |
$("#filter").val(''); | |
$("#content").val(''); | |
}) | |
}) | |
$(function() { | |
$("#showErrors").on("click",function() { | |
$("#errors").toggle(this.checked); | |
}); | |
}); | |
</script>` | |
var data = { | |
xml: pm.response.text() | |
}; | |
pm.visualizer.set(template, data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment