97
| <![CDATA[<script type="module">
import {Paginator} from './public/js/paginator.js';
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
let busca;
if(urlParams.has('busca')){
busca = urlParams.get('busca');
//busca = busca.replace(/[^a-zA-Z0-9 ]/g, '');
busca = busca
.toString()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
.trim()
.replace(/[^a-z0-9 \/-]/g, '')
.replace(/\s+/g, ' ');
busca = '&busca=' + busca;
}
const utf8_decode = (strData) => {
const tmpArr = []
let i = 0
let c1 = 0
let seqlen = 0
strData += ''
while (i < strData.length) {
c1 = strData.charCodeAt(i) & 0xFF
seqlen = 0
if (c1 <= 0xBF) {
c1 = (c1 & 0x7F)
seqlen = 1
} else if (c1 <= 0xDF) {
c1 = (c1 & 0x1F)
seqlen = 2
} else if (c1 <= 0xEF) {
c1 = (c1 & 0x0F)
seqlen = 3
} else {
c1 = (c1 & 0x07)
seqlen = 4
}
for (let ai = 1; ai < seqlen; ++ai) {
c1 = ((c1 << 0x06) | (strData.charCodeAt(ai + i) & 0x3F))
}
if (seqlen === 4) {
c1 -= 0x10000
tmpArr.push(String.fromCharCode(0xD800 | ((c1 >> 10) & 0x3FF)))
tmpArr.push(String.fromCharCode(0xDC00 | (c1 & 0x3FF)))
} else {
tmpArr.push(String.fromCharCode(c1))
}
i += seqlen
}
return tmpArr.join('')
}
const goToPage = (page) =>{
fetchData('licitacoes/?page=' + page + '&perpage=18' + busca).then(response => {
let {current, next, prev, pages} = response.pagination;
let el = document.querySelector('.pagination');
const pagin = new Paginator(el, next, prev, pages, 11, goToPage);
pagin.mount(current);
const boxLicitacoes = document.querySelector('.list-licitacoes');
let licitacoes = '';
response.data.forEach(obj => {
let {id, titulo, data_edital, numero, descricao, files} = obj;
/* licitacoes += `<article class="box-licitacoes">
<span class="title">${utf8_decode(titulo)}</span>
<span class="numero">${utf8_decode(numero)}</span>
<span class="desc">${utf8_decode(descricao)}</span>`;
if(files){
files.forEach(file => {
let{arquivo, tit_arquivo} = file;
licitacoes += `<a href="${env.URL_TMP + 'licitacao/' + arquivo}" class="file" download>${utf8_decode(tit_arquivo)}</a>`;
});
} */
licitacoes += `<article class="box-licitacoes">
<span class="title">${titulo}</span>
<span class="numero">${numero}</span>
<span class="desc">${descricao}</span>`;
if(files){
files.forEach(file => {
let{arquivo, tit_arquivo} = file;
licitacoes += `<a href="${env.URL_TMP + 'licitacao/' + arquivo}" class="file" download>${tit_arquivo}</a>`;
});
}
licitacoes += `</article>`;
});
boxLicitacoes.innerHTML = licitacoes;
});
}
goToPage(1);
</script>]]>
|