setTimeout(function() {
var timerid;
$(".d-search-text").on("input", function(e) {
var value = $(this).val();
var product = $("select.d-input-dropdown-select option:selected").text();
var pattern = /Print/;
var service = /Serv/;
var exists = pattern.test(product);
var hide = service.test(product);
if (hide) {
$( ".d-search-predictive-container" ).hide();
}
if ($(this).data("lastval") != value) {
$(this).data("lastval", value);
clearTimeout(timerid);
timerid = setTimeout(function() {
//your change action goes here
if ( $( "#predict" ).length == 0) {
$(".d-search-predictive-container").append("
");
$("#predict").append("
See all search results");
}
if (exists) {
$("#predictLink").attr("href", "/printing?query=" + value);
}
else {
$("#predictLink").attr("href", "/shop?query=" + value);
}}, 500);
};
})}, 1000);