1'use strict'; 2 3document.addEventListener('DOMContentLoaded', function () { 4 if (window.innerWidth > 768) { 5 resizeIframe(); 6 7 window.addEventListener('resize', function () { 8 resizeIframe(); 9 }); 10 11 function resizeIframe() { 12 // const iframe = document.querySelector('#whitepapers-pdf iframe'); 13 const iframe = document.querySelector('.embedpress-document-embed iframe'); 14 15 if (iframe) { 16 iframe.onload = function () { 17 18 iframeBlock(iframe); 19 }; 20 21 if (iframe.contentWindow && iframe.contentWindow.document.readyState === 'complete') { 22 iframeBlock(iframe); 23 } 24 } 25 } 26 27 function iframeBlock(iframe) { 28 const iframeDocument = iframe.contentWindow.document; 29 iframeDocument.querySelector('body').style.backgroundColor = 'rgba(255,255,255, 1)'; 30 let heightIframe; 31 if (iframeDocument?.querySelector('#viewer')) { 32 heightIframe = iframeDocument?.querySelector('#viewer').offsetHeight + 50 + 'px' 33 } 34 iframe.style.minHeight = heightIframe; 35 iframe.height = heightIframe; 36 if (iframeDocument.querySelector('#wppdf-iframe-body .toolbar.pdfemb-toolbar-display-top')) { 37 iframeDocument.querySelector('#wppdf-iframe-body .toolbar.pdfemb-toolbar-display-top').style.display = 'none'; 38 } 39 } 40 } 41 42 // <span class="WebinarDTL resource-date-webinar" data-ts="[acf field='webinar_date']">Date:</span> 43 // <span class="WebinarDTL resource-date-end-webinar" data-ts="[acf field='webinar_date_end']">End Date:</span> 44 45 const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'; 46 const isAmerica = /^America\//.test(tz); 47 48 const MONTHS = { 49 january:0,february:1,march:2,april:3,may:4,june:5, 50 july:6,august:7,september:8,october:9,november:10,december:11 51 }; 52 53 function parseHumanDate(str) { 54 if (!str) return null; 55 const s = String(str).trim(); 56 57 let m = s.match(/^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+([A-Za-z]+)\s+(\d{1,2}),\s+(\d{4})$/i); 58 if (m) { 59 const mi = MONTHS[m[1].toLowerCase()]; 60 if (mi != null) return new Date(Date.UTC(+m[3], mi, +m[2], 12, 0, 0)); 61 } 62 63 m = s.match(/^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+(\d{1,2})\s+([A-Za-z]+),\s+(\d{4})$/i); 64 if (m) { 65 const mi = MONTHS[m[2].toLowerCase()]; 66 if (mi != null) return new Date(Date.UTC(+m[3], mi, +m[1], 12, 0, 0)); 67 } 68 69 m = s.match(/^(\d{4})-(\d{2})-(\d{2})$/); 70 if (m) return new Date(Date.UTC(+m[1], +m[2]-1, +m[3], 12, 0, 0)); 71 72 m = s.match(/^(\d{4})(\d{2})(\d{2})$/); 73 if (m) return new Date(Date.UTC(+m[1], +m[2]-1, +m[3], 12, 0, 0)); 74 75 const f = new Date(s); 76 if (!isNaN(f)) { 77 return new Date(Date.UTC(f.getUTCFullYear(), f.getUTCMonth(), f.getUTCDate(), 12, 0, 0)); 78 } 79 console.warn('[webinar-date] Ðе вдалоÑÑ ÑозпаÑÑиÑи даÑÑ:', s); 80 return null; 81 } 82 83 function formatDate(date) { 84 if (!(date instanceof Date) || isNaN(date)) return ''; 85 86 if (isAmerica) { 87 return new Intl.DateTimeFormat('en-US', { 88 timeZone: tz, weekday: 'short', month: 'long', day: 'numeric', year: 'numeric' 89 }).format(date); 90 } else { 91 const parts = new Intl.DateTimeFormat('en-GB', { 92 timeZone: tz, weekday: 'short', month: 'long', day: 'numeric', year: 'numeric' 93 }).formatToParts(date); 94 const get = t => parts.find(p => p.type === t)?.value || ''; 95 return `${get('weekday')}, ${get('day')} ${get('month')}, ${get('year')}`; 96 } 97 } 98 99 document.querySelectorAll('.WebinarDTL[data-ts]').forEach((el) => { 100 const raw = el.getAttribute('data-ts'); 101 const date = parseHumanDate(raw); 102 if (!date) return; 103 104 const label = (el.firstChild && el.firstChild.nodeType === Node.TEXT_NODE) 105 ? el.firstChild.nodeValue.trim() 106 : ''; 107 const formatted = formatDate(date); 108 109 el.querySelector('.webinar-date-value')?.remove(); 110 111 el.textContent = label ? `${label} ` : ''; 112 const span = document.createElement('span'); 113 span.className = 'webinar-date-value';
114 span.textContent = formatted; 115 el.appendChild(span); 116 }); 117}); 118
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.