1/* global mvrpiData, navigator */ 2/** 3 * Mevabi â Related Posts Inline | Front-end JS v1.1.0 4 * Intercepts clicks on related-post links and records them via AJAX. 5 */ 6( function () { 7 'use strict'; 8 9 if ( typeof mvrpiData === 'undefined' || ! mvrpiData.ajaxUrl ) { 10 return; 11 } 12 13 document.addEventListener( 'click', function ( e ) { 14 var mvrpiLink = e.target.closest( '.mvrpi-block a[data-mvrpi-id]' ); 15 if ( ! mvrpiLink ) { 16 return; 17 } 18 19 var mvrpiId = mvrpiLink.getAttribute( 'data-mvrpi-id' ); 20 if ( ! mvrpiId ) { 21 return; 22 } 23 24 var mvrpiBody = new URLSearchParams( { 25 action: 'mvrpi_track_click', 26 related_id: mvrpiId, 27 _nonce: mvrpiData.nonce, 28 } ); 29 30 // Use keepalive so the request completes even if the page navigates away. 31 if ( typeof window.fetch === 'function' ) { 32 window.fetch( mvrpiData.ajaxUrl, { 33 method: 'POST', 34 body: mvrpiBody, 35 keepalive: true, 36 } ).catch( function () { /* silent */ } ); 37 } else { 38 // Fallback for very old browsers. 39 var mvrpiXhr = new XMLHttpRequest(); 40 mvrpiXhr.open( 'POST', mvrpiData.ajaxUrl, true ); 41 mvrpiXhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); 42 mvrpiXhr.send( mvrpiBody.toString() ); 43 } 44 } ); 45}() );
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.