Jump to content
Fórum Script Brasil
  • 0

Ajuda caixa pesquisa Ajax JSON Search


maquinaw

Question

Preciso arrumar este código. Quando a pessoa faz uma busca na caixa de pesquisa, ele só acha o resultado se a palavra estiver correta, ou seja, se eu procura a palavra MAO sem acento ele não vai encontrar o resultado, mas se colocar MÃO com acento, ele da o resultado solicitado. A questão é, quero que ele encontre palavras com ou sem acento, pra facilitar a vida dos usuários. Abaixo segue imagem com o código. Obrigado.
//Ajax JSON Search Result by MKR
function searchxx(e){!function(t){var r=Alldefaultconfig,a={blogURL:"",srcBlank:r.BackupImage,findText:"Resultados",NotfindText:"Sem Resultados!",Showthumb:!0,LoadingText:"Pesquisando...",viewMoreText:r.viewMoreText,scrthumbSize:50,MaxPost:10,summaryLength:r.summaryLength};a=t.extend({},a,e);var s=t("#ajax-search-form"),o=s.find(":text");s.append('<div id="search-result"></div>');var i=t("#search-result");s.on("submit",function(){var e=o.val();return i.show().html('<div class="load">'+a.LoadingText+"</div>"),t.get((""===a.blogURL?window.location.protocol+"//"+window.location.host:a.blogURL)+"/feeds/posts/default?alt=json-in-script&q="+e+"&max-results="+a.MaxPost,function®{var s,o,l,n,c=r.feed.entry,h=[],u=[],m="";if(void 0!==c){m="<h4>"+a.findText+" &quot;"+e+"&quot;</h4>",m+='<a class="close" href="/">&times;</a><ol>';for(var g=0,d=c.length;d>g;g++){for(var f=new RegExp(e,"ig"),l=c[g].title.$t.replace(f,"<mark>"+e+"</mark>"),p=0,v=c[g].link.length;v>p;p++)"alternate"==c[g].link[p].rel&&(n=c[g].link[p].href);if(s="content"in c[g]?c[g].content.$t:"summary"in c[g]?c[g].summary.$t:"","media$thumbnail"in c[g])o=c[g].media$thumbnail.url.replace(/\/s[0-9]+\-c/g,"/s"+a.scrthumbSize+"-c");else if(null!=(h=s.match(/src=(?:\"|\')?([^>]*[^\/].(?:jpg|bmp|gif|png))(?:\"|\')?/gi)))o=h[0].replace("src=","").replace(/"/g,"").replace(/'/g,"");else if(null!=(u=s.match(/(youtu.be\/|youtube.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&\"\'>]+)/gi))){var b=u[0].match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/);b&&11==b[7].length&&(o="http://img.youtube.com/vi/"+b[7]+"/0.jpg")}else o=a.srcBlank;s=s.replace(/<\S[^>]*>/g,""),s.length>a.summaryLength&&(s=s.substring(0,a.summaryLength)+"..."),s=s.replace(f,"<mark>"+e+"</mark>"),m+='<li><a href="'+n+'" >'+(a.Showthumb===!0?'<img style="width:'+a.scrthumbSize+"px;height:"+a.scrthumbSize+'px" width="'+a.scrthumbSize+'" height="'+a.scrthumbSize+'" src="'+o+'"/>':"")+"<strong>"+l+"</strong></a>"+(a.summaryLength>0?"<p>"+s+"</p>":"")+"</li>"}m+="</ol>"+(r.feed.openSearch$totalResults.$t>r.feed.openSearch$itemsPerPage.$t?'<div class="src-morepost"><a href="/search?q='+e+'">'+a.viewMoreText+" &quot;"+e+"&quot;</a></div>":""),i.html(m),t("#searchnya ol").mCustomScrollbar()}else i.html('<a class="close" href="/">&times;</a><strong>'+a.NotfindText+"</strong>")},"jsonp"),!1}),s.on("click",".close",function(){return i.fadeOut(),!1})}(jQuery)}
<form action='/search' id='ajax-search-form'>
<input name='q' onblur='if (this.value == &quot;&quot;) {this.value = &quot;Pesquisar...&quot;;}' onfocus='if (this.value == &quot;Pesquisar...&quot;) {this.value = &quot;&quot;;}' type='text' value='Pesquisar...'/>
<button title='Search' type='submit'>Pesquisar</button>
</form>
Edited by maquinaw
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...