From 05e0c7d20701640e16db361fb66fc2bc0b85276e Mon Sep 17 00:00:00 2001 From: jan Date: Wed, 30 Dec 2015 15:19:43 +0100 Subject: =?UTF-8?q?kleine=20verbesserungen=20bei=20der=20clientseitigen=20?= =?UTF-8?q?suche.=20hoffentlich=20f=C3=BChlt=20es=20sich=20jetzt=20etwas?= =?UTF-8?q?=20runder=20an.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/assets/js/search.js b/assets/js/search.js index 0f544ab..ebf46cb 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -1,30 +1,29 @@ var strokeTimeout = null; function instantSearch() { - value = document.getElementById("search").value; - if (strokeTimeout) { clearTimeout(strokeTimeout); } strokeTimeout = setTimeout(doSearch, 150, value); } -function doSearch(value) { - if (value == "") { +function doSearch() { + value = document.getElementById("search").value; + + if (value === "") { strokeTimeout = null; return; } var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { - if (xhr.status === 404 || xhr.status === 400 || typeof xhr.response === 'undefined') { - console.log(xhr.status); + if (xhr.status === 404 || xhr.status === 400 || typeof xhr.response === 'undefined' || xhr.response === '404 not found') { document.getElementById("search-results").innerHTML = ''; + return } document.getElementById("search-results").innerHTML = xhr.response; } } - console.log(value); xhr.open('GET', '/search/gril_instant/' + value, true); xhr.send(null); strokeTimeout = null; -- cgit v0.10.1