69
| <![CDATA[<script type="module">
import {Paginator} from './public/js/paginator.js';
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
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('galleries/?page=' + page + '&perpage=18').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 boxGall = document.querySelector('.list-gall');
let news = '';
response.data.forEach(obj => {
let {id, titulo, arquivo} = obj;
titulo = utf8_decode(titulo);
news += `<article class="box-news">
<a href="${env.URL + 'galeria/' + id + '/' + slugify(titulo)}">
<img src="${env.URL_TMP}salaImprensa/mini-${arquivo}" alt="${titulo}">
<span class="title">${titulo}</span>
</a>
</article>`;
});
boxGall.innerHTML = news;
});
}
goToPage(1);
</script>]]>
|