<link rel="stylesheet" href="components/pma.ui.components.all.min.css" />
<script type="text/javascript" src="components/pma.ui.components.all.js"></script>
<div id="search-container"></div>
<div id="search-results"></div>
<script type="text/javascript">
var context = new PMA.UI.Components.Context({
caller: "demo"
});
new PMA.UI.Authentication.AutoLogin(context, [{
serverUrl: ""https://host.pathomation.com/pma.core.2/"",
username: "admin",
password: "admin"
}]);
var search = new PMA.UI.Components.MetadataSearch(context, { element: "#search-container", serverUrl: ""https://host.pathomation.com/pma.core.2/"" });
search.listen(PMA.UI.Components.Events.SearchFinished, function (searchResults) {
context.getSession(search.options.serverUrl, function (sessionId) {
var html = "";
if (searchResults.length === 0) {
html = "<strong>No matches</strong>";
}
else {
html = "<strong>" + searchResults.length + " matches</strong><ul>";
for (let i = 0; i < searchResults.length; i++) {
html += '<li><a href="' + search.options.serverUrl + 'Viewer/index.htm?sessionID=' + sessionId + '&pathOrUid=' + encodeURIComponent(searchResults[i]) + '" target="_blank">' + searchResults[i] + '</a></li>';
}
html += "</ul>";
}
document.getElementById("search-results").innerHTML = html;
});
});
</script>
Code: