mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Some improvements for search function
This commit is contained in:
parent
4994e59846
commit
fe8b82f737
@ -64,7 +64,7 @@ div.footer {
|
||||
left:0px;
|
||||
right:0px;
|
||||
padding:10px;
|
||||
opacity:0.8;
|
||||
opacity:1;
|
||||
}
|
||||
|
||||
div.footer div:nth-child(1) {
|
||||
@ -129,6 +129,7 @@ div.searchresults>span {
|
||||
|
||||
div.searchresults table {
|
||||
width:100%;
|
||||
border-spacing:0px 4px;
|
||||
}
|
||||
|
||||
div.searchresults tr {
|
||||
@ -150,9 +151,8 @@ div.searchresults tr td.image {
|
||||
background-position:center;
|
||||
}
|
||||
|
||||
div.searchresults tr td.info {
|
||||
height:50px;
|
||||
width:350px;
|
||||
div.searchresults tr td:nth-child(2) {
|
||||
padding-left:10px;
|
||||
}
|
||||
|
||||
div.searchresults table.searchresults_tracks td span:nth-child(1) {
|
||||
|
@ -52,14 +52,19 @@
|
||||
|
||||
function search(searchfield) {
|
||||
txt = searchfield.value;
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = searchresult
|
||||
xhttp.open("GET","/db/search?query=" + txt, true);
|
||||
xhttp.send();
|
||||
if (txt == "") {
|
||||
reallyclear()
|
||||
}
|
||||
else {
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = searchresult
|
||||
xhttp.open("GET","/db/search?query=" + txt, true);
|
||||
xhttp.send();
|
||||
}
|
||||
}
|
||||
function searchresult() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
|
||||
if (this.readyState == 4 && this.status == 200 && document.getElementById("searchinput").value != "") {
|
||||
// checking if field is empty in case we get an old result coming in that would overwrite our cleared result window
|
||||
result = JSON.parse(this.responseText);
|
||||
artists = result["artists"].slice(0,5)
|
||||
tracks = result["tracks"].slice(0,5)
|
||||
@ -219,11 +224,15 @@
|
||||
<a href="/"><span style="font-weight:bold;">Maloja</span></a>
|
||||
</div>
|
||||
<div>
|
||||
<span><input placeholder="Search for an artist or track..." oninput="search(this)" onblur="clearresults()" /></span>
|
||||
<span><input id="searchinput" placeholder="Search for an artist or track..." oninput="search(this)" onblur="clearresults()" /></span>
|
||||
</div>
|
||||
|
||||
<span id="resultwrap"></span>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<span id="resultwrap"></span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user