358
| <![CDATA[<script type="text/javascript">
function pesquisar() {
document.getElementById("divPesquisa").style.display = "none";
document.getElementById("divCarregando").style.display = "block";
setTimeout(function () {
consultar();
}, 500);
event.preventDefault();
}
function consultar() {
categoria = document.getElementById('categoria').value;
ano = document.getElementById('ano').value;
texto = document.getElementById('v').value;
jQuery.ajax({
type: "POST",
url: "https://camaraimbe.rs.gov.br/arquivos/pesquisa",
data: {categoria:categoria, ano:ano, v:texto},
success: function (json) {
document.getElementById("divCarregando").style.display = "none";
const obj = JSON.parse(json);
varHtml = '';
urlBase = 'https://camaraimbe.rs.gov.br/arquivos/camara/';
if(obj.length > 0) {
for(var i=0; i < obj.length; i++) {
var data = obj[i].date;
var dataFormatada = data.replace(/(\d*)-(\d*)-(\d*).*/, '$3-$2-$1');
varHtml += '<div class="post-preview-item" style="background-color:white;"><div class="post-preview-item-cover" style="max-height:160px;"><img src="https://camaraimbe.rs.gov.br/images/brand/logo-post.png" alt=""></div>';
varHtml += '<div class="post-title"><a href="'+urlBase+obj[i].seo_title+'">'+obj[i].title+'</a></div>';
varHtml += '<div class="comment-item-text">'+obj[i].content+'</div>';
varHtml += '<div class="post-info"><div class="post-views post-info-views"><a href="#" class="tag">'+obj[i].category_name+'</a></div>';
varHtml += '<div class="post-date post-info-date">'+ dataFormatada +'</div></div></div>';
}
} else {
varHtml = '<div class="single-content wp-content"><h2>Nenhum arquivo encontrado...</h2></div>';
}
$("#divPesquisa").html(varHtml);
document.getElementById("divPesquisa").style.display = "block";
},
error: function(){
alert('Atenção', 'Pesquisa indisponível');
}
});
}
</script>]]>
|