1 line
1.1 KiB
JavaScript
1 line
1.1 KiB
JavaScript
window.lazyFunctions={more:function(a){const r=a,e=JSON.parse(atob(a.dataset.params)),o=new Headers;o.append("Content-Type","application/json"),o.append("Accept","application/json");const n={page:e.page,route:e.route};"genre"in e.route_parameters&&(n.genre=e.route_parameters.genre),"person_id"in e.route_parameters&&(n.person_id=e.route_parameters.person_id),"search"in e&&(n.search=e.search);const s={method:"POST",headers:o,body:JSON.stringify(n)};fetch(e.route,s).then(t=>t.json()).then(t=>{const i=a.parentNode;i.innerHTML+=t.html,window.lLoad.update(),a.remove(),document.getElementById(a.getAttribute("id")).remove(),t.has_more_pages&&(e.page=t.current_page+1,r.setAttribute("href",r.getAttribute("href").replace(new RegExp(t.current_page+"$"),t.current_page+1)),r.setAttribute("data-params",btoa(JSON.stringify(e))),r.removeAttribute("data-ll-status"),r.classList.remove("entered"),i.appendChild(r),window.lMore.update())}).catch(t=>console.error(t))}};function p(a){var r=a.getAttribute("data-lazy-function"),e=window.lazyFunctions[r];e&&e(a)}window.lMore=new window.LazyLoad({elements_selector:"#next-page",unobserve_entered:!0,callback_enter:p});
|