jQuery(document).ready(function($) { _Src = $('[name="s"]'); if(_Src.length){ InpSaran = document; $("body").click(function(e){ if(typeof SaranPencarian!=="undefined"){ if(e.target!==InpSaran&&SaranPencarian.is(":visible"))SaranPencarian.fadeOut("fast"); } }); _Src.attr('autocomplete','off'); TOCari = setTimeout(()=>{}); _Src.keyup(function(e){ clearTimeout(TOCari); let I = $(this); InpSaran = e.target; let _w = 300; if(I.outerWidth()>300) _w = I.outerWidth(); let Io = I.offset(); let ILeft = Io.left; let css = {left:"unset",right:"unset",width:_w}; if(ILeft+_w>$(window).width()-10)css.right=0; else css.left=0; SaranPencarian = I.next(); if(!SaranPencarian.hasClass("saranPencarian")){ I.after('
'); SaranPencarian = I.next(); } SaranPencarian.css(css); SaranPencarian.html('Loading...'); if(!SaranPencarian.is(":visible"))SaranPencarian.fadeIn("fast"); TOCari = setTimeout(function(){ jQuery.post("", {action:'CariSaran',CariSaran: encodeURI(I.val().trim()) }, function(J) { J = JSON.parse(J); let html = ""; $.each(J,function(i, v){ html+=''+v.Title+''; }); SaranPencarian.html(html==""?"Not Found":html); }); },300); }); } });