1!function(){"use strict";var t={response:null,getEndpointURL:function(t){var e,s="undefined"!=typeof wp&&wp.customize&&wp.customize.settings&&wp.customize.settings.url&&wp.customize.settings.url.self;s?(e=document.createElement("a")).href=wp.customize.settings.url.self:e=document.location,"string"==typeof t&&t.match(/^https?:\/\//)&&((e=document.createElement("a")).href=t);var a="relatedposts=1",r=document.querySelector("#jp-relatedposts");if(!r)return!1;r.hasAttribute("data-exclude")&&(a+="&relatedposts_exclude="+r.getAttribute("data-exclude")),s&&(a+="&jetpackrpcustomize=1");var o=e.pathname;return"/"!==o[0]&&(o="/"+o),""===e.search?o+"?"+a:o+e.search+"&"+a},getAnchor:function(t,e){var s=t.title,a=document.createElement("a");return a.setAttribute("class",e),a.setAttribute("href",t.url),a.setAttribute("title",s),a.setAttribute("data-origin",t.url_meta.origin),a.setAttribute("data-position",t.url_meta.position),""!==t.rel&&a.setAttribute("rel",t.rel),a},cleanHtml:function(t){var e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""},generateMinimalDiv:function(t,e){var s=this,a=document.createElement("div");return a.setAttribute("class","jp-relatedposts-items jp-relatedposts-items-minimal jp-relatedposts-"+e.layout),t.forEach(function(t,r){var o="jp-relatedposts-post jp-relatedposts-post"+r;t.classes.length>0&&(o+=" "+t.classes.join(" "));var n=document.createElement("p");n.setAttribute("class",o),n.setAttribute("data-post-id",t.id),n.setAttribute("data-post-format",t.format),a.appendChild(n);var i=document.createElement("span");i.setAttribute("class","jp-relatedposts-post-title"),n.appendChild(i);var p=s.getAnchor(t,"jp-relatedposts-post-a");if(i.appendChild(p),p.textContent=s.cleanHtml(t.title),e.showDate){var l=document.createElement("time");l.setAttribute("class","jp-relatedposts-post-date"),l.setAttribute("datetime",t.date),l.textContent=t.date,n.appendChild(l)}if(e.showContext){var c=document.createElement("span");c.setAttribute("class","jp-relatedposts-post-context"),c.textContent=s.cleanHtml(t.context),n.appendChild(c)}}),a},generateVisualDiv:function(t,e){var s=this,a=document.createElement("div");return a.setAttribute("class","jp-relatedposts-items jp-relatedposts-items-visual jp-relatedposts-"+e.layout),t.forEach(function(t,r){var o="jp-relatedposts-post jp-relatedposts-post"+r;t.classes.length>0&&(o+=" "+t.classes.join(" ")),t.img.src?o+=" jp-relatedposts-post-thumbs":o+=" jp-relatedposts-post-nothumbs";var n=document.createElement("div");if(n.setAttribute("class",o),n.setAttribute("data-post-id",t.id),n.setAttribute("data-post-format",t.format),a.appendChild(n),t.img.src){var i=s.getAnchor(t,"jp-relatedposts-post-a");n.appendChild(i);var p=document.createElement("img");p.setAttribute("class","jp-relatedposts-post-img"),p.setAttribute("loading","lazy"),p.setAttribute("src",t.img.src),p.setAttribute("width",t.img.width),p.setAttribute("height",t.img.height),t.img.srcset&&p.setAttribute("srcset",t.img.srcset),t.img.sizes&&p.setAttribute("sizes",t.img.sizes),p.setAttribute("alt",t.img.alt_text),i.appendChild(p)}else{var l=s.getAnchor(t,"jp-relatedposts-post-a jp-relatedposts-post-aoverlay");n.appendChild(l)}var c=document.createElement(related_posts_js_options.post_heading);c.setAttribute("class","jp-relatedposts-post-title"),n.appendChild(c);var d=s.getAnchor(t,"jp-relatedposts-post-a");d.textContent=s.cleanHtml(t.title),c.appendChild(d);var u=document.createElement("p");if(u.setAttribute("class","jp-relatedposts-post-excerpt"),u.textContent=s.cleanHtml(t.excerpt),n.appendChild(u),e.showDate){var m=document.createElement("time");m.setAttribute("class","jp-relatedposts-post-date"),m.setAttribute("datetime",t.date),m.textContent=t.date,n.appendChild(m)}if(e.showContext){var h=document.createElement("p");h.setAttribute("class","jp-relatedposts-post-context"),h.textContent=s.cleanHtml(t.context),n.appendChild(h)}}),a},setVisualExcerptHeights:function(){var t=document.querySelectorAll("#jp-relatedposts .jp-relatedposts-post-nothumbs .jp-relatedposts-post-excerpt");if(t.length)for(var e=getComputedStyle(t[0]),s=parseInt(e.fontSize,10),a=parseInt(e.lineHeight,10),r=0;r<t.length;r++)t[r].style.maxHeight=5*a/s+"em"}
1,getTrackedUrl:function(t){var e="relatedposts_hit=1";e+="&relatedposts_origin="+t.getAttribute("data-origin"),e+="&relatedposts_position="+t.getAttribute("data-position");var s=t.pathname;return"/"!==s[0]&&(s="/"+s),""===t.search?s+"?"+e:s+t.search+"&"+e},cleanupTrackedUrl:function(){if("function"==typeof history.replaceState){var t=document.location.search.replace(/\brelatedposts_[a-z]+=[0-9]*&?\b/gi,"");"?"===t&&(t=""),document.location.search!==t&&history.replaceState({},document.title,document.location.pathname+t)}}};function e(){t.setVisualExcerptHeights();var e=document.querySelectorAll("#jp-relatedposts a.jp-relatedposts-post-a");Array.prototype.forEach.call(e,function(e){document.addEventListener("click",function(){e.href=t.getTrackedUrl(e)})})}function s(){t.cleanupTrackedUrl();var s=t.getEndpointURL();if(s)if(document.querySelectorAll("#jp-relatedposts .jp-relatedposts-post").length)e();else{var a=document.querySelector("#jp-relatedposts"),r=new XMLHttpRequest;r.open("GET",s,!0),r.setRequestHeader("x-requested-with","XMLHttpRequest"),r.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE&&200===this.status)try{var s=JSON.parse(r.responseText);if(0===s.items.length||0===a.length)return;t.response=s;var o,n={};"undefined"!=typeof wp&&wp.customize?(o=wp.customize.instance("jetpack_relatedp
1osts[show_thumbnails]").get(),n.showDate=wp.customize.instance("jetpack_relatedposts[show_date]").get(),n.showContext=wp.customize.instance("jetpack_relatedposts[show_context]").get(),n.layout=wp.customize.instance("jetpack_relatedposts[layout]").get()):(o=s.show_thumbnails,n.showDate=s.show_date,n.showContext=s.show_context,n.layout=s.layout);var i=o?t.generateVisualDiv(s.items,n):t.generateMinimalDiv(s.items,n);if(a.appendChild(i),n.showDate){var p=a.querySelectorAll(".jp-relatedposts-post-date");Array.prototype.forEach.call(p,function(t){t.style.display="block"})}a.style.display="block",e()}catch{}},r.send()}}function a(){"undefined"!=typeof wp&&wp.customize?(wp.customize.selectiveRefresh&&wp.customize.selectiveRefresh.bind("partial-content-rendered",function(t){"jetpack_relatedposts"===t.partial.id&&s()}),wp.customize.bind("preview-ready",s)):s()}"loading"!==document.readyState?a():document.addEventListener("DOMContentLoaded",a)}();; 2// listen for rlt authentication events and pass them to children of this document. 3( function() { 4 var currentToken; 5 var parentOrigin; 6 var iframeOrigins; 7 var registeredIframes = []; 8 var initializationListeners = []; 9 var hasBeenInitialized = false; 10 var RLT_KEY = 'jetpack:wpcomRLT'; 11 12 // should we inject RLT into this iframe? 13 function rltShouldAuthorizeIframe( frameOrigin ) { 14 if ( ! Array.isArray( iframeOrigins ) ) { 15 return false; 16 } 17 return iframeOrigins.includes( frameOrigin ); 18 } 19 20 function rltInvalidateWindowToken( token, target, origin ) { 21 if ( target && typeof target.postMessage === 'function' ) { 22 try { 23 target.postMessage( JSON.stringify( { 24 type: 'rltMessage', 25 data: { 26 event: 'invalidate', 27 token: token, 28 sourceOrigin: window.location.origin, 29 }, 30 } ), origin ); 31 } catch ( err ) { 32 return; 33 } 34 } 35 } 36 37 /** 38 * PUBLIC METHODS 39 */ 40 window.rltInvalidateToken = function( token, sourceOrigin ) { 41 // invalidate in current context 42 if ( token === currentToken ) { 43 currentToken = null; 44 } 45 46 // remove from localstorage, but only if in a top level window, not iframe 47 try { 48 if ( window.location === window.parent.location && window.localStorage ) { 49 if ( window.localStorage.getItem(RLT_KEY) === token ) { 50 window.localStorage.removeItem(RLT_KEY); 51 } 52 } 53 } catch( e ) { 54 console.info("localstorage access for invalidate denied - probably blocked third-party access", window.location.href); 55 } 56 57 // invalidate in registered iframes 58 for ( const [ frameOrigin, frameWindow ] of registeredIframes ) { 59 if ( frameOrigin !== sourceOrigin ) { 60 rltInvalidateWindowToken( token, frameWindow, frameOrigin ); 61 } 62 } 63 64 // invalidate in parent 65 if ( parentOrigin && parentOrigin !== sourceOrigin && window.parent ) { 66 rltInvalidateWindowToken( token, window.parent, parentOrigin ); 67 } 68 } 69 70 window.rltInjectToken = function( token, target, origin ) { 71 if ( target && typeof target.postMessage === 'function' ) { 72 try { 73 target.postMessage( JSON.stringify( { 74 type: 'loginMessage', 75 data: { 76 event: 'login', 77 success: true, 78 type: 'rlt', 79 token: token, 80 sourceOrigin: window.location.origin, 81 }, 82 } ), origin ); 83 } catch ( err ) { 84 return; 85 } 86 } 87 }; 88 89 window.rltIsAuthenticated = function() { 90 return !! currentToken; 91 }; 92 93 window.rltGetToken = function() { 94 return currentToken; 95 }; 96 97 window.rltAddInitializationListener = function( listener ) { 98 // if RLT is already initialized, call the listener immediately 99 if ( hasBeenInitialized ) { 100 listener( currentToken ); 101 } else { 102 initializationListeners.push( listener ); 103 } 104 }; 105 106 // store the token in localStorage 107 window.rltStoreToken = function( token ) { 108 currentToken = token; 109 try { 110 if ( window.location === window.parent.location && window.localStorage ) { 111 window.localStorage.setItem( RLT_KEY, token ); 112 } 113 } catch( e ) { 114 console.info("localstorage access denied - probably blocked third-party access", window.location.href); 115 } 116 } 117 118 window.rltInitialize = function( config ) { 119 if ( ! config || typeof window.postMessage !== 'function' ) { 120 return; 121 } 122 123 currentToken = config.token; 124 iframeOrigins = config.iframeOrigins; 125 parentOrigin = config.parentOrigin; // needed? 126 127 // load token from localStorage if possible, but only in top level window 128 try { 129 if ( ! currentToken && window.location === window.parent.location && window.localStorage ) { 130 currentToken = window.localStorage.getItem(RLT_KEY); 131 } 132 } catch( e ) { 133 console.info("localstorage access denied - probably blocked third-party access", window.location.href); 134 } 135 136 // listen for RLT events from approved origins 137 window.addEventListener( 'message', function( e ) { 138 var message = e && e.data; 139 if ( typeof message === 'string' ) { 140 try { 141 message = JSON.parse( message ); 142 } catch ( err ) { 143 return; 144 } 145 } 146 147 var type = message && message.type; 148 var data = message && message.data; 149 150 if ( type === 'loginMessage' ) { 151 if ( data && data.type === 'rlt' && data.token !== currentToken ) { 152 // put into localStorage if running in top-level window (not iframe) 153 rltStoreToken( data.token ); 154 155 // send to registered iframes 156 for ( const [ frameOrigin, frameWindow ] of registeredIframes ) { 157 rltInjectToken( currentToken, frameWindow, frameOrigin ); 158 } 159 160 // send to the parent, unless the event was sent _by_ the parent 161 if ( parentOrigin && parentOrigin !== data.sourceOrigin && window.parent ) { 162 rltInjectToken( currentToken, window.parent, parentOrigin ); 163 } 164 } 165 } 166 167 if ( type === 'rltMessage' ) {
168 if ( data && data.event === 'invalidate' && data.token === currentToken ) { 169 rltInvalidateToken( data.token ); 170 } 171 172 if ( data && data.event === 'register' ) { 173 if ( rltShouldAuthorizeIframe( e.origin ) ) { 174 registeredIframes.push( [ e.origin, e.source ] ); 175 if ( currentToken ) { 176 rltInjectToken( currentToken, e.source, e.origin ); 177 } 178 } 179 } 180 } 181 } ); 182 183 initializationListeners.forEach( function( listener ) { 184 listener( currentToken ); 185 } ); 186 187 initializationListeners = []; 188 189 // inform the parent that we are ready to receive the RLT token 190 window.parent.postMessage( { 191 type: 'rltMessage', 192 data: { 193 event: 'register' 194 }, 195 }, '*' ); 196 197 hasBeenInitialized = true; 198 }; 199} )(); 200;
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.