PageSourceSearch

https://metro.co.uk/var/www/wp-content/themes/metro/dist/trending-…-strip-personalisation.js?ver=1790260574552

js metro.co.uk collected 2026-10-01 07:25:47 UTC 10,689 bytes, 1 lines download raw bytes

1!function(){"use strict";var t={394:function(t,e,n){n.d(e,{PK:function(){return r}});var r=function(t){var e=(new Date).getTime(),n=new Date(t),r=n.getTime(),o=Math.ceil((e-r)/1e3),i="";if(o<604800){if(o<60)i=o+" sec";else if(o<3600)i=Math.ceil(o/60)+" min";else if(o<86400)i=Math.ceil(o/60/60)+" hr";else{var a=Math.ceil(o/60/60/24);i=a+(a>1?" days":" day")}i+=" ago"}else i=n.toLocaleString("default",{month:"long",day:"numeric",year:"numeric"});return i}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.d=function(t,e){if(Array.isArray(e))for(var r=0;r<e.length;){var o=e[r++],i=e[r++];n.o(t,o)?0===i&&r++:0===i?Object.defineProperty(t,o,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,o,{enumerable:!0,get:i})}else for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var r=function(){var t="test";try{return localStorage.setItem(t,t),localStorage.removeItem(t),!0}catch(t){return!1}}(),o=function(t){if(r)return localStorage.getItem(t)},i="metro.behaviour",a=function(t,e){var n=JSON.parse(o(i));n||(n={}),n[t]=e,function(t,e){r&&localStorage.setItem(t,e)}(i,JSON.stringify(n))},s=function(t){var e=null,n=JSON.parse(o(i));return null!=n&&n[t]&&(e=n[t]),e};a("lastVisit",Date.now());var l=function(t){var e=t.getBoundingClientRect();return e.top>=-t.offsetHeight&&e.left>=-t.offsetWidth&&e.right<=(window.innerWidth||document.documentElement.clientWidth)+t.offsetWidth&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)+t.offsetHeight},c=n(394),u="trendingPostStripPersonalisation",d="recentlyRead",p="trendingPostStripPersonalisedCache",f={category:"subCategoryId",post_tag:"postTagIds",metro_internal_tag:"internalTagIds",post_style:"postStyleId"},g=function(t,e){var n=!1;return"post_tag"===e&&metro.trendingPostStripPersonalisation.blacklisted_tag_ids.includes(t)&&(n=!0),n},v=function(){if(metro.trendingPostStripPersonalisation.active){var t=document.querySelector('.trending-post-strip[data-personalise="1"]');t&&(l(t)||requestAnimationFrame(function(){setTimeout(function(){var t=m();t&&(null==t?void 0:t.length)?_(t):y().then(_)},0)}))}},m=function(){var t;if(!0===metro.trendingPostStripPersonalisation.disable_local_caching)return!1;var e=[],n=s(p);return(null===(t=null==n?void 0:n.posts)||void 0===t?void 0:t.length)>0&&metro.trendingPostStripPersonalisation.local_cache_duration<n.timestamp&&(e=n.posts),e},_=function(t){var e=document.querySelector(".trending-post-strip");if(e){var n=s(d),r=Object.keys(n).map(function(t){return Number.parseInt(t)}),o=t.filter(function(t){return!r.includes(t.id)});if(0!==o.length&&!l(e)){var i=e.querySelector("h2.trending-post-strip-more");if(i){i.innerHTML="";var a=document.createElement("span");a.classList.add("trending-for-you"),a.textContent=metro.trendingPostStripPersonalisation.label_replacement,i.appendChild(a)}e.querySelectorAll(".trending-post-strip .trending-now__list-item").forEach(function(t,n){var r,i,a,s=o.shift();if(s&&!e.querySelector(".trending-post-strip-item[data-post-id='".concat(s.id,"']"))){var l=t.querySelector(".trending-now__list-item .article-card__title a");l||(l=t.querySelector(".trending-now__list-item a")),(null==s?void 0:s.link)&&l&&l&&(l.setAttribute("data-ico","trending-post-strip-personalised_item_".concat(n+1)),l.setAttribute("data-vars-track","trending-post-strip-personalised_click_".concat(n+1)),l.setAttribute("href",s.link)),l&&((null==s?void 0:s.short_title)?l.innerHTML=s.short_title:(null===(r=null==s?void 0:s.title)||void 0===r?void 0:r.rendered)&&(l.innerHTML=s.title.rendered));var u=t.querySelector(".metro-signpost");u&&u.remove();var d=t.querySelector(".article-card__title");if((null==s?void 0:s.signpost)&&l&&d){var p=document.createElement("span");p.classList.add("metro-signpost","metro-signpost-".concat(s.signpost)),d.insertBefore(p,l)}if(null===(a=null===(i=null==s?void 0:s.featured_media_sizes)||void 0===i?void 0:i.landscape_16_9)||void 0===a?void 0:a.source_url){var f=t.querySelector(".article-card__image img");f&&f.setAttribute("src",s.featured_media_sizes.landscape_16_9.source_url)}var g=t.querySelector(".channel-glyph");if((null==s?void 0:s.categories_infos)&&(null==s?void 0:s.categories_infos.length)&&g){var v=t.querySelector(".channel-glyph__label"),m=t.querySelector("svg title"),_="",y="",h="";null==s||s.categories_infos.forEach(function(t){if(!_&&!y&&!h)return _=t.url?t.url:"",y=t.name?t.name:"",void(h=t.slug);0!==t.parent&&(_=t.url?t.url:"",y=t.name?t.name:"")}),h&&(t.removeAttribute("class"),t.classList.add("trending-now__list-item","accent--".concat(h))),g&&g.setAttribute("href",_),v&&(v.textContent=y),m&&(m.textContent=y)}var b=t.querySelector(".article-card__date");b&&(null==s?void 0:s.date_gmt)&&(b.textContent=(0,c.PK)(null==s?void 0:s.date_gmt));var S=t.querySelector(".article-card__author");if(S&&(null==s?void 0:s.authors)&&(null==s?void 0:s.authors.length)){var P=[];
1s.authors.forEach(function(t){var e=document.createElement("a");e.setAttribute("href",t.author_URL?t.author_URL:"");var n=document.createElement("strong");n.textContent=t.name?t.name:"",e.appendChild(n),P.push(e.outerHTML)}),S.innerHTML="By ".concat(P.join(" &amp; "))}}});var u=e.getAttribute("data-vars-type")||"trending-post-strip";e.setAttribute("data-vars-type","".concat(u,"-personalised"))}}},y=function(){return t=void 0,e=void 0,r=function(){var t,e,n,r,o,i,l,c,d,f,v,m,_;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,function(y){switch(y.label){case 0:return t=[],(null==(e=s(u))?void 0:e[metro.trendingPostStripPersonalisation.taxonomy_to_query])?(n=Object.entries(e[metro.trendingPostStripPersonalisation.taxonomy_to_query]).filter(function(t){var e;return(null===(e=t[1])||void 0===e?void 0:e.views)>metro.trendingPostStripPersonalisation.minimum_view_threshold}),0===n.length?[2,t]:(n.sort(function(t,e){return e[1].views-t[1].views}),r=n.map(function(t){return Number.parseInt(t[0])}),"post_tag"===metro.trendingPostStripPersonalisation.taxonomy_to_query&&(r=r.filter(function(t){return!g(t,"post_tag")})),r=r.slice(0,metro.trendingPostStripPersonalisation.number_of_terms_to_query),o=new Date,i="".concat(o.getFullYear(),"-").concat("".concat(o.getMonth()+1).padStart(2,"0"),"-").concat("".concat(o.getDate()).padStart(2,"0"),"T23:59:59"),l=new Date(o.getTime()-2592e6),c="".concat(l.getFullYear(),"-").concat("".concat(l.getMonth()+1).padStart(2,"0"),"-").concat("".concat(l.getDate()).padStart(2,"0"),"T00:00:00"),d="".concat("/wp-json/wp/v2/posts/","?per_page=").concat(metro.trendingPostStripPersonalisation.number_of_posts_to_query,"\n\t\t\t&page=1\n\t\t\t&before=").concat(i,"\n\t\t\t&after=").concat(c,"\n\t\t\t&_fields=id,title,link,featured_media_sizes,signpost,short_title,categories_infos,date_gmt,authors\n\t\t\t&metro-trending-post-strip-personalisation=1"),"category"===(f=metro.trendingPostStripPersonalisation.taxonomy_to_query)?f="categories":"post_tag"===f&&(f="tags"),d+="&".concat(f,"=").concat(r.join(",")),"tags"===f&&(v=0,(metro.trendingPostStripPersonalisation.bound_post_tag_by_subcategory||metro.trendingPostStripPersonalisation.bound_post_tag_by_parent_category)&&((null===(m=null===metro||void 0===metro?void 0:metro.pageData)||void 0===m?void 0:m.topCategoryId)&&(v=metro.pageData.topCategoryId),metro.trendingPostStripPersonalisation.bound_post_tag_by_subcategory&&(null===(_=null===metro||void 0===metro?void 0:metro.pageData)||void 0===_?void 0:_.subCategoryId)&&(v=metro.pageData.subCategoryId)),v&&(d+="&categories=".concat(v,"\n\t\t\t\t\t&tax_relation=AND"))),[4,fetch(d)])):[2,t];case 1:return[4,y.sent().json()];case 2:return t=y.sent(),t=Array.isArray(t)?t:[],a(p,{posts:t,timestamp:Date.now()}),[2,t]}})},new((n=void 0)||(n=Promise))(function(o,i){function a(t){try{l(r.next(t))}catch(t){i(t)}}function s(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())});var t,e,n,r};!function(){var t=Object.keys(f),e=s(u);if(!(null==e?void 0:e.category)){var n=!1;null!==e&&"object"==typeof e&&(n=JSON.parse(JSON.stringify(e))),e={},t.forEach(function(t){e[t]={}}),n&&(e.category=n)}t.forEach(function(t){var n,r=null===(n=null===metro||void 0===metro?void 0:metro.pageData)||void 0===n?void 0:n[f[t]];if(r){Array.isArray(r)||(r=[r]),r.forEach(function(n){var r;g(n,t)||((null===(r=null==e?void 0:e[t])||void 0===r?void 0:r[n])||(e[t][n]={views:0,lastRead:null}),e[t][n].views++,e[t][n].lastRead=Date.now())});var o=Object.entries(e[t]).sort(function(t,e){return e[1].lastRead-t[1].lastRead}).filter(function(t){return t[1].lastRead>metro.trendingPostStripPersonalisation.term_staleness_threshold});e[t]=Object.fromEntries(o)}}),a(u,e)}(),function(){var t,e=s(d);null!==e&&"object"==typeof e||(e={});var n=null===(t=null===metro||void 0===metro?void 0:metro.pageData)||void 0===t?void 0:t.postId;if(n){e[n]=Date.now();var r=Object.entries(e),o=Date.now()-864e5,i=r.filter(function(t){return t[1]>o}),l=Object.fromEntries(i);a(d,l)}}(),metro.trendingPostStripPersonalisation.disable_lazy_loading?window.addEventListener("DOMContentLoaded",v):window.addEventListener("DOMContentLoaded",function(){var t=document.querySelector(".trending-post-strip");
1if(t){var e=new IntersectionObserver(function(n){n.forEach(function(n){n.isIntersecting&&(v(),e.unobserve(t))})},{rootMargin:metro.trendingPostStripPersonalisation.lazy_loading_distance,threshold:0});e.observe(t)}})}();

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.