PageSourceSearch

https://home.cern/wp-content/themes/cern/build/news/view.js?ver=6eccf858c1a20322d8b5

js home.cern collected 2026-09-24 08:27:19 UTC 5,842 bytes, 1 lines download raw bytes

1import{getContext as e,getElement as t,store as r}from"@wordpress/interactivity";const a=/^(0[1-9]|[12]\d|3[01])-(0[1-9]|1[0-2])-\d{4}$/,n={updated:{orderby:"modified",order:"desc"},created:{orderby:"date",order:"desc"},alphabetical:{orderby:"title",order:"asc"},"alphabetical-reverse":{orderby:"title",order:"desc"}},s={_fields:"id,title,tags,date,featured_media,link,content,excerpt,author",per_page:-1,status:"publish"},o=e;r("cern/news",{state:{get posts(){return o().posts||[]},get hasPosts(){return(o().posts||[]).length>0},get columns(){return o().attributes.columns},get sortingOrder(){return o().attributes.sortingOrder},get currentPage(){var e;return null!==(e=o().currentPage)&&void 0!==e?e:1},get maxPages(){var e;return null!==(e=o().maxPages)&&void 0!==e?e:1},get selectedFilterValue(){var e,t;const r=o(),a=r.filterIndex;return"number"!=typeof a?-1:null!==(e=null!==(t=r.selectedFilters?.[a]?.id)&&void 0!==t?t:r.attributes.filters?.[a]?.defaultId)&&void 0!==e?e:-1},get isCurrentCategorySelected(){var e,t;const r=o();return(null!==(e=r.selectedCategory)&&void 0!==e?e:0)===(null!==(t=r.categoryId)&&void 0!==t?t:0)},get borderRadiusStyle(){return o().style?.borderRadius},get slideIndexStyle(){var e;return`--slide-index: ${null!==(e=o().slideIndex)&&void 0!==e?e:0}`},get isSlideAtStart(){var e;return 0===(null!==(e=o().slideIndex)&&void 0!==e?e:0)},get isSlideAtEnd(){var e,t;const r=o(),a=Math.max((null!==(e=r.posts?.length)&&void 0!==e?e:0)-r.visibleCards,0);return(null!==(t=r.slideIndex)&&void 0!==t?t:0)>=a},get slideCounter(){var e,t;const r=o(),a=Math.max((null!==(e=r.posts?.length)&&void 0!==e?e:0)-r.visibleCards,0);return`${(null!==(t=r.slideIndex)&&void 0!==t?t:0)+1}/${a+1}`},get shouldShowPagination(){var e;const t=o();return Boolean(t.attributes.pagination)&&(null!==(e=t.maxPages)&&void 0!==e?e:1)>1},get isFirstPage(){var e;return(null!==(e=o().currentPage)&&void 0!==e?e:1)<=1},get isLastPage(){var e,t;const r=o();return(null!==(e=r.currentPage)&&void 0!==e?e:1)>=(null!==(t=r.maxPages)&&void 0!==t?t:1)},get pageNumbers(){var e,t;const r=o(),a=null!==(e=r.maxPages)&&void 0!==e?e:1,n=null!==(t=r.currentPage)&&void 0!==t?t:1;return a<=0?[]:((e,t)=>{const r=Math.floor(3.5);if(e<=7)return Array.from({length:e},(e,t)=>t+1);const a=Math.max(1,Math.min(t-r,e-7+1)),n=Math.min(e,a+7-1);return Array.from({length:n-a+1},(e,t)=>a+t)})(a,n).map(e=>({ariaLabel:`Page ${e}`,isCurrent:e===n,page:e}))}},actions:{selectCategory:e=>{const t=o(),r=e.currentTarget.getAttribute("data-category-id")||"",a=parseInt(r,10);t.selectedCategory=Number.isNaN(a)?null:a,t.currentPage=1},selectFilter:e=>{const t=o(),r=e.currentTarget,a=parseInt(r.value,10),n=parseInt(r.getAttribute("data-filter-index")||"",10),s="category"===t.attributes.filters?.[n]?.taxonomy?"category":"post_tag";t.selectedFilters[n]=-1===a?void 0:{taxonomy:t.selectedFilters[n]?.taxonomy||s,id:Number.isNaN(a)?-1:a},t.currentPage=1},selectSortingOrder:e=>{const t=o(),r=e.currentTarget.value;r&&(t.sortingOrder=r,t.currentPage=1)},slidePrev:()=>{var e;const t=o();t.slideIndex=Math.max((null!==(e=t.slideIndex)&&void 0!==e?e:0)-1,0)},slideNext:()=>{var e,t;const r=o(),{posts:a,visibleCards:n}=r,s=Math.max((null!==(e=a?.length)&&void 0!==e?e:0)-n,0);r.slideIndex=Math.min((null!==(t=r.slideIndex)&&void 0!==t?t:0)+1,s)},pagePrev:()=>{var e;const t=o();t.currentPage=Math.max((null!==(e=t.currentPage)&&void 0!==e?e:1)-1,1)},pageNext:()=>{var e,t;const r=o(),a=null!==(e=r.maxPages)&&void 0!==e?e:1;r.currentPage=Math.min((null!==(t=r.currentPage)&&void 0!==t?t:1)+1,a)},selectPage:e=>{const t=o(),r=e.currentTarget,a=parseInt(r.getAttribute("data-page-number")||"",10);Number.isNaN(a)||(t.currentPage=a)}},callbacks:{*initSlider(){const e=o(),r=t().ref;if(!r)return;const a=()=>{const t=parseInt(getComputedStyle(r).getPropertyValue("--n"),10);t>0&&(e.visibleCards=t)};a(),new ResizeObserver(a).observe(r)},*fetchPosts(){const e=o(),t=((e,t,r,o,l,i)=>{const g={...s};if(l&&(g.exclude=[l]),e?.category?.length&&e?.category?.length>0&&!e.groupCategory&&(g.categories=e.category.join(",")),t&&"button"===e.displayStyle&&(g.categories=t.toString()),e.sortingOrder&&Ob
1ject.assign(g,n[e.sortingOrder]),e?.tags?.length&&!e.groupTag&&(g.tags=e.tags.join(",")),r&&Object?.values(r)?.some(e=>!!e)&&"select"===e.displayStyle){const e=Object.values(r).filter(e=>!!e&&-1!==e.id).map(e=>({taxonomy:"category"===e?.taxonomy?"category":"post_tag",term:e?.id}));g.category_and=e.filter(e=>"category"===e.taxonomy).map(e=>e.term).join(","),g.tag_and=e.filter(e=>"post_tag"===e.taxonomy).map(e=>e.term).join(",")}return e.groupCategory&&e.category.length>0&&(g.category_and?g.category_and=g.category_and+","+e.category.join(","):g.category_and=e.category.join(",")),e.groupTag&&e.tags.length>0&&(g.tag_and?g.tag_and=g.tag_and+","+e.tags.join(","):g.tag_and=e.tags.join(",")),e?.fromDateFilter&&a.test(e.fromDateFilter)&&(g.after=new Date(e.fromDateFilter).toISOString().slice(0,10)+"T23:59:59Z"),e?.toDateFilter&&a.test(e.toDateFilter)&&(g.before=new Date(e.toDateFilter).toISOString().slice(0,10)+"T23:59:59Z"),e.maxPosts&&(g.per_page=e.numberOfPosts),o&&(g.lang=o),i&&e.pagination&&(g.page=i),g})(e.attributes,e.selectedCategory,e.selectedFilters,e.language,e.currentPostId,e.currentPage),r=encodeURIComponent(JSON.stringify(t));Promise.all([fetch(`/wp-json/cern/v1/news-render?query=${r}`,{credentials:"omit"})]).then(([e])=>e.json()).then(t=>{var r,a,n;const s=Math.max(null!==(r=t?.max_num_pages)&&void 0!==r?r:0,0);e.maxPages=s,s>0&&(null!==(a=e.currentPage)&&void 0!==a?a:1)>s?e.currentPage=s:e.posts=(null!==(n=t?.posts)&&void 0!==n?n:[]).map(t=>{const r=t.tags||[],a=t.image||e.fallbackImage||"";return{...t,legacyBackgroundImage:a?`radial-gradient(circle, rgba(31, 31, 31, 0.5) 70%, rgba(31, 31, 31, 0.75) 100%), url(${a})`:"none",tags:r.slice(0,2)}})})}}});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.