<!DOCTYPE html>
<html>
<head>
<title>File Filters</title>
</head>
<body style="background-color: black; color: aliceblue;" >
<h1 style="color: darkmagenta;">Search Queries</h1>
<button id="powerpointButton">Search PowerPoint</button>
<button id="wordButton">Search Word</button>
<button id="excelButton">Search Excel</button>
<h2>Search Results:</h2>
<div id="results" style="color:aliceblue !important"></div>
<script>
async function testFilter(searchURL) {
const xhr1 = new XMLHttpRequest();
xhr1.open("GET", searchURL);
xhr1.setRequestHeader("accept", "application/json;odata=verbose");
xhr1.onreadystatechange = async function () {
if (xhr1.readyState === 4) {
if (xhr1.status === 200) {
const response = JSON.parse(xhr1.responseText);
console.log(`XHR1 Success!!`, response);
// Extract URLs of document files from the response
const results = response.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
const resultsDiv = document.getElementById("results");
resultsDiv.innerHTML = "";
for (const result of results) {
const extension = result.Cells.results.find(cell => cell.Key === 'FileExtension').Value;
if (extension && extension.toLowerCase() !== 'aspx') {
const title = result.Cells.results.find(cell => cell.Key === 'Title').Value;
const url = result.Cells.results.find(cell => cell.Key === 'Path').Value.replace("https://", "http://");
resultsDiv.innerHTML += `<p><a href='${url}'>${title}</a></p>`;
}
}
} else {
console.error('XHR1 Error:', xhr1.statusText);
}
}
};
xhr1.send();
}
document.getElementById("powerpointButton").addEventListener("click", function() {
testFilter(searchURL);
});
});
</script>
</body>
</html>