1(function(window,document){'use strict';if(!window.ptpadConfig||!window.ptpadDetect){return} 2var config=window.ptpadConfig;var detect=window.ptpadDetect;var i18n=config.i18n||{};var BAR_DISMISS_COOKIE='ptpad_bar_dismissed';var deferredPrompt=null;var overlay;var modal;var tutorialContent;var closeBtn;var dismissBtn;var footer;var topbar;var topbarInstallBtn;var topbarCloseBtn;function init(){overlay=document.getElementById('ptpad-modal-overlay');modal=document.getElementById('ptpad-modal');tutorialContent=document.getElementById('ptpad-tutorial-content');closeBtn=document.getElementById('ptpad-modal-close');dismissBtn=document.getElementById('ptpad-modal-dismiss');footer=overlay?overlay.querySelector('.ptpad-modal-footer'):null;topbar=document.getElementById('ptpad-topbar');topbarInstallBtn=document.getElementById('ptpad-topbar-install');topbarCloseBtn=document.getElementById('ptpad-topbar-close');if(!overlay&&!topbar){return} 3if(detect.isRunningAsApp()){hideInstallTriggers();if(topbar){topbar.hidden=!0} 4if(overlay){overlay.hidden=!0} 5return} 6bindOpenTriggers();bindCloseTriggers();bindTopbarTriggers();bindNativePromptCapture();bindAppInstalledListener();maybeAutoTrigger();maybeOpenViaQueryParam()} 7function bindOpenTriggers(){var triggers=document.querySelectorAll('[data-ptpad-open-modal]');triggers.forEach(function(el){el.addEventListener('click',function(e){e.preventDefault();openModal()})});var menuBarBtns=document.querySelectorAll('.ptpad-menu-bar .ptpad-menu-bar-btn');menuBarBtns.forEach(function(btn){btn.addEventListener('click',function(e){e.preventDefault();openModal()})});if(window.MutationObserver){var observer=new MutationObserver(function(mutations){var found=!1;mutations.forEach(function(mutation){mutation.addedNodes.forEach(function(node){if(node.nodeType!==1){return} 8var isPtpad=node.matches&&(node.matches('.ptpad-menu-bar')||node.matches('[data-ptpad-open-modal]'));var hasPtpad=node.querySelector&&(node.querySelector('.ptpad-menu-bar')||node.querySelector('[data-ptpad-open-modal]'));if(isPtpad||hasPtpad){found=!0}})});if(found){bindOpenTriggers()}});observer.observe(document.body,{childList:!0,subtree:!0});window.setTimeout(function(){observer.disconnect()},10000)}} 9function hideInstallTriggers(){function hide(el){el.style.setProperty('display','none','important');el.setAttribute('aria-hidden','true');el.setAttribute('tabindex','-1')} 10var selector='[data-ptpad-open-modal], .ptpad-menu-bar';document.querySelectorAll(selector).forEach(hide);if(window.MutationObserver){var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){mutation.addedNodes.forEach(function(node){if(node.nodeType!==1){return} 11if(node.matches&&node.matches(selector)){hide(node)} 12if(node.querySelectorAll){node.querySelectorAll(selector).forEach(hide)}})})});observer.observe(document.body,{childList:!0,subtree:!0})}} 13function bindTopbarTriggers(){if(topbarInstallBtn){topbarInstallBtn.addEventListener('click',function(){openModal()})} 14if(topbarCloseBtn){topbarCloseBtn.addEventListener('click',function(){persistBarDismissCookie();closeTopbar()})}} 15function bindCloseTriggers(){if(closeBtn){closeBtn.addEventListener('click',closeModal)} 16if(dismissBtn){dismissBtn.addEventListener('click',closeModal)} 17if(overlay){overlay.addEventListener('click',function(e){if(e.target===overlay){closeModal()}})} 18document.addEventListener('keydown',function(e){if(e.key==='Escape'&&overlay&&!overlay.hidden){closeModal()}})} 19function bindNativePromptCapture(){window.addEventListener('beforeinstallprompt',function(e){e.preventDefault();deferredPrompt=e;if(overlay&&!overlay.hidden){renderTutorial()}})} 20function bindAppInstalledListener(){window.addEventListener('appinstalled',function(){detect.markAppInstalled();logInstall();closeModal();closeTopbar()})} 21function maybeAutoTrigger(){if(!config.autoTrigger){return} 22if(config.showOncePerSession){try{if(window.sessionStorage.getItem('ptpad_modal_shown')){return}}catch(e){}} 23if(config.displayStyle==='bar'&&isBarDismissCookieActive()){return} 24var seconds=parseInt(config.autoTriggerSecs,10)||8;window.setTimeout(function(){if(detect.isRunningAsApp()){return} 25if(config.displayStyle==='bar'&&isBarDismissCookieActive()){return}
26triggerDisplay();if(config.showOncePerSession){try{window.sessionStorage.setItem('ptpad_modal_shown','1')}catch(e){}}},seconds*1000)} 27function triggerDisplay(){if(config.displayStyle==='bar'&&topbar){openTopbar()}else{openModal()}} 28function maybeOpenViaQueryParam(){var params=new URLSearchParams(window.location.search);if(params.get('ptpad_open_modal')==='1'){if(detect.isRunningAsApp()){return} 29openModal()}} 30function persistBarDismissCookie(){var days=parseInt(config.dismissDays,10);if(isNaN(days)||days<=0){return} 31var expires=new Date(Date.now()+days*24*60*60*1000).toUTCString();try{document.cookie=BAR_DISMISS_COOKIE+'=1; expires='+expires+'; path=/; SameSite=Lax'}catch(e){}} 32function isBarDismissCookieActive(){try{var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i].trim();if(c.indexOf(BAR_DISMISS_COOKIE+'=')===0){return!0}}}catch(e){} 33return!1} 34var themeMenuMarked=!1;var barResizeObserver=null;function updateBarOffset(){if(!topbar||'fixed'!==config.barPosition){return} 35var height=topbar.offsetHeight||0;document.documentElement.style.setProperty('--ptpad-bar-offset',height+'px')} 36function markThemeMenuEls(){if(!config.barMenuSelector||themeMenuMarked){return} 37var found;try{found=document.querySelectorAll(config.barMenuSelector)}catch(e){found=[]} 38for(var i=0;i<found.length;i++){found[i].setAttribute('data-ptpad-menu-offset','')} 39themeMenuMarked=!0} 40function openTopbar(){if(!topbar){return} 41var isFixed='fixed'===config.barPosition;topbar.classList.toggle('ptpad-bar-mode-fixed',isFixed);topbar.classList.toggle('ptpad-bar-mode-scroll',!isFixed);if(document.body.firstChild!==topbar){document.body.insertBefore(topbar,document.body.firstChild)} 42if(isFixed){markThemeMenuEls()} 43topbar.hidden=!1;window.requestAnimationFrame(function(){window.requestAnimationFrame(function(){topbar.classList.add('ptpad-visible');if(isFixed){document.documentElement.classList.add('ptpad-bar-fixed-active');updateBarOffset();if('ResizeObserver' in window&&!barResizeObserver){barResizeObserver=new ResizeObserver(updateBarOffset);barResizeObserver.observe(topbar)} 44window.addEventListener('resize',updateBarOffset)}})})} 45function closeTopbar(){if(!topbar){return} 46topbar.classList.remove('ptpad-visible');document.documentElement.classList.remove('ptpad-bar-fixed-active');document.documentElement.style.removeProperty('--ptpad-bar-offset');if(barResizeObserver){barResizeObserver.disconnect();barResizeObserver=null} 47window.removeEventListener('resize',updateBarOffset);window.setTimeout(function(){topbar.hidden=!0},250)} 48function openModal(){if(!overlay){return} 49if(topbar&&!topbar.hidden){closeTopbar()} 50renderLoading();overlay.hidden=!1;document.body.classList.add('ptpad-modal-open');window.requestAnimationFrame(function(){window.requestAnimationFrame(function(){overlay.classList.add('ptpad-visible');overlay.setAttribute('aria-hidden','false')})});window.setTimeout(renderTutorial,350);if(modal){modal.focus()}} 51function closeModal(){if(!overlay){return} 52overlay.classList.remove('ptpad-visible');overlay.setAttribute('aria-hidden','true');document.body.classList.remove('ptpad-modal-open');window.setTimeout(function(){overlay.hidden=!0},200)} 53function renderLoading(){if(!tutorialContent){return} 54tutorialContent.innerHTML='<div class="ptpad-tutorial-loading">'+'<div class="ptpad-spinner"></div>'+'<div class="ptpad-loading-text">'+escapeHtml(i18n.checking)+'</div>'+'</div>';toggleFooter(!1)} 55function renderTutorial(){if(!tutorialContent){return} 56if(deferredPrompt&&detect.supportsNativePrompt()){renderNativeInstallButton();return} 57renderManualSteps()} 58function renderNativeInstallButton(){tutorialContent.innerHTML='<div class="ptpad-native-install-wrap">'+'<button type="button" id="ptpad-native-install" class="ptpad-btn ptpad-btn-primary">'+escapeHtml(i18n.installNow)+'</button>'+'</div>';var nativeBtn=document.getElementById('ptpad-native-install');if(nativeBtn){nativeBtn.addEventListener('click',function(){if(!deferredPrompt){return} 59deferredPrompt.prompt();deferredPrompt.userChoice.finally(function(){deferredPrompt=null})})} 60toggleFooter(!0)} 61function renderManualSteps(){if(!window.ptpadSteps){tutorialContent.innerHTML='<p class="ptpad-step-desc">'+escapeHtml(i18n.stepNoSupportDesc||'')+'</p>';return} 62var platform=detect.getPlatform();var browser=detect.getBrowser();var isMobile=detect.isMobileDevice();var steps=window.ptpadSteps.getSteps(platform,browser,isMobile);var html='<ol class="ptpad-steps">';steps.forEach(function(s,index){html+='<li class="ptpad-step">';
62html+='<span class="ptpad-step-icon">'+(s.icon||(index+1))+'</span>';html+='<span class="ptpad-step-title">'+escapeHtml(s.title||'')+'</span>';html+='<p class="ptpad-step-desc">'+escapeHtml(s.description||'')+'</p>';if(s.needsCopyButton){html+=renderCopyUrlButton()} 63html+='</li>'});html+='</ol>';tutorialContent.innerHTML=html;bindCopyUrlButton();toggleFooter(!0)} 64function renderCopyUrlButton(){var url=config.sourcePage||window.location.href;return('<button type="button" class="ptpad-copy-url-btn" data-ptpad-copy-url="'+escapeHtml(url)+'">'+'<span class="ptpad-copy-url-text">'+escapeHtml(url)+'</span>'+'<span class="ptpad-copy-url-icon">'+'<span class="ptpad-icon-default">'+(window.ptpadSteps?window.ptpadSteps.icons.copy:'')+'</span>'+'<span class="ptpad-icon-success">â</span>'+'</span>'+'</button>')} 65function bindCopyUrlButton(){var btn=tutorialContent.querySelector('[data-ptpad-copy-url]');if(!btn){return} 66btn.addEventListener('click',function(){var url=btn.getAttribute('data-ptpad-copy-url')||'';var markCopied=function(){btn.classList.add('ptpad-copied');window.setTimeout(function(){btn.classList.remove('ptpad-copied')},1500)};if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(url).then(markCopied).catch(function(){legacyCopy(url,markCopied)})}else{legacyCopy(url,markCopied)}})} 67function legacyCopy(text,onSuccess){var helper=document.createElement('textarea');helper.value=text;helper.style.position='fixed';helper.style.opacity='0';document.body.appendChild(helper);helper.focus();helper.select();try{document.execCommand('copy');onSuccess()}catch(err){} 68document.body.removeChild(helper)} 69function logInstall(){var body={platform:detect.getPlatform(),browser:detect.getBrowser(),user_agent:window.navigator.userAgent,source_page:config.sourcePage||window.location.href,nonce:config.nonce,};fetch(config.restUrl,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body),}).catch(function(){})} 70function toggleFooter(visible){if(!footer){return} 71footer.classList.toggle('ptpad-footer-visible',visible)} 72function escapeHtml(str){if(!str){return''} 73var div=document.createElement('div');div.textContent=str;return div.innerHTML} 74document.addEventListener('DOMContentLoaded',init)})(window,document)
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.