Sindbad~EG File Manager
const lpArchiveAddQueryArgs=(e,t)=>{const r=new URL(e);return Object.keys(t).forEach(e=>{r.searchParams.append(e,t[e])}),r},lpArchiveCourse=()=>{const e=document.querySelectorAll(".lp-archive-course-skeleton");if(e.length&&"IntersectionObserver"in window){const t=new IntersectionObserver((e,r)=>{e.forEach(e=>{if(e.isIntersecting){const r=e.target;if(!lpArchiveSkeleton)return;lpArchiveRequestCourse(lpArchiveSkeleton),t.unobserve(r)}})});[...e].map(e=>t.observe(e))}};let skeleton,skeletonClone,isLoading=!1,firstLoad=1;const lpArchiveRequestCourse=e=>{const t=lpGlobalSettings.lp_rest_url,r=lpGlobalSettings.user_id||"";if(!t)return;const s=document.querySelector(".lp-archive-courses"),o=s&&s.querySelector("div.lp-archive-courses .lp-content-area"),n=o&&o.querySelector("ul.learn-press-courses");if(!n)return;if(isLoading)return;isLoading=!0,skeletonClone?n.innerHTML=skeletonClone:(skeleton=document.querySelector(".lp-archive-course-skeleton"),skeletonClone=skeleton.outerHTML);const c=lpArchiveAddQueryArgs(t+"lp/v1/courses/archive-course",{...e,userID:r});wp.apiFetch({path:"lp/v1/courses/archive-course"+c.search,method:"GET"}).then(e=>{void 0!==e.data.content&&n&&(n.innerHTML=e.data.content||"");const t=e.data.pagination;if(lpArchiveSearchCourse(),void 0!==t){const e=(new DOMParser).parseFromString(t,"text/html").querySelector(".learn-press-pagination"),r=document.querySelector(".learn-press-pagination");r&&r.remove(),e&&(n.after(e),lpArchivePaginationCourse())}}).catch(e=>{n.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/courses/archive-course"}</div>`}).finally(()=>{isLoading=!1,skeleton&&skeleton.remove(),jQuery("form.search-courses button").removeClass("loading"),firstLoad?firstLoad=0:s.scrollIntoView()})},lpArchiveSearchCourse=()=>{document.querySelectorAll("form.search-courses").forEach(e=>{const t=e.querySelector('input[name="s"]'),r=e.getAttribute("action"),s=e.querySelector('[name="post_type"]').value||"",o=e.querySelector('[name="taxonomy"]').value||"",n=e.querySelector('[name="term_id"]').value||"",c=e.querySelector('[type="submit"]');t.addEventListener("keyup",e=>{e.preventDefault();const t=e.target.value;if(!t||t&&t.length>2){c.classList.add("loading"),lpArchiveRequestCourse({...lpArchiveSkeleton,s:t});const e=lpArchiveAddQueryArgs(r,{post_type:s,taxonomy:o,term_id:n,s:t});window.history.pushState("","",e)}}),e.addEventListener("submit",t=>{t.preventDefault();const r=e.querySelector('input[name="s"]');r&&r.dispatchEvent(new Event("keyup"))})})},lpArchivePaginationCourse=()=>{const e=document.querySelectorAll(".lp-archive-courses .learn-press-pagination .page-numbers");e.length>0&&e.forEach(t=>t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();const s=r.currentTarget.getAttribute("href");if(s){const o=new URL(s),n={};o.searchParams.forEach((e,t)=>{n[t]=e});const c=[...e].filter(e=>e.classList.contains("current")),a=r.currentTarget.textContent||t.classList.contains("next")&&parseInt(c[0].textContent)+1||t.classList.contains("prev")&&parseInt(c[0].textContent)-1;lpArchiveRequestCourse({...n,paged:a}),window.history.pushState("","",s)}}))},lpArchiveGridListCourse=()=>{const e=LP.Cookies.get("courses-layout"),t=document.querySelectorAll('.lp-courses-bar .switch-layout [name="lp-switch-layout-btn"]');t.length>0&&[...t].map(t=>t.value===e&&(t.checked=!0))},lpArchiveGridListCourseHandle=()=>{const e=document.querySelectorAll('.lp-archive-courses input[name="lp-switch-layout-btn"]');e.length>0&&e.forEach(e=>e.addEventListener("change",e=>{e.preventDefault();const t=e.target.value;if(t){const e=document.querySelector(".lp-archive-courses .learn-press-courses[data-layout]");e&&(e.dataset.layout=t),LP.Cookies.set("courses-layout",t)}}))};function LPArchiveCourseInit(){lpArchiveCourse(),lpArchiveGridListCourseHandle(),lpArchiveGridListCourse()}LPArchiveCourseInit();
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists