69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
document.getElementById("submitSearch").onclick = function () { search() }
|
|
|
|
function search() {
|
|
var searchString = document.getElementById("idSearchBar").value;
|
|
if (searchString == "") {
|
|
alert("Suche ist leer");
|
|
return;
|
|
}
|
|
|
|
var search = new String();
|
|
|
|
if (document.getElementById('checkBoxTopic').checked == true) {
|
|
if (search.length > 0) {
|
|
search = search + " OR ";
|
|
}
|
|
search = search + "TS=('" + searchString + "')"
|
|
}
|
|
|
|
if (document.getElementById('checkBoxAK').checked == true) {
|
|
if (search.length > 0) {
|
|
search = search + " OR ";
|
|
}
|
|
search = search + "AK=('" + searchString + "')"
|
|
}
|
|
|
|
if (document.getElementById('checkBoxKP').checked == true) {
|
|
if (search.length > 0) {
|
|
search = search + " OR ";
|
|
}
|
|
search = search + "KP=('" + searchString + "')"
|
|
}
|
|
|
|
if (document.getElementById('checkBoxRA').checked == true) {
|
|
if (search.length > 0) {
|
|
search = search + " OR ";
|
|
}
|
|
search = search + "SU=('" + searchString + "')"
|
|
}
|
|
|
|
if (document.getElementById('checkBoxWOSCategory').checked == true) {
|
|
if (search.length > 0) {
|
|
search = search + " OR ";
|
|
}
|
|
search = search + "WC=('" + searchString + "')"
|
|
}
|
|
|
|
let xhr = new XMLHttpRequest();
|
|
let url = 'http://localhost:8000/query';
|
|
xhr.open("POST", url, true);
|
|
xhr.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
|
xhr.setRequestHeader("Content-Type", "application/json");
|
|
xhr.onerror = function () {
|
|
alert("Fehler");
|
|
}
|
|
xhr.onreadystatechange = function () {
|
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
|
|
}
|
|
};
|
|
|
|
// Converting JSON data to string
|
|
var data = JSON.stringify({ "Search": search });
|
|
|
|
// Sending data with the request
|
|
xhr.send(data);
|
|
|
|
|
|
|
|
} |