1class PDFDownloadHandler{constructor(){this.modal=null,this.currentResource=null,this.init()}init(){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.setup()):this.setup()}setup(){this.createModal(),document.addEventListener("click",e=>{const trigger=e.target.closest("[data-pdf-resource]");if(trigger){e.preventDefault();const resourceHandle=trigger.getAttribute("data-pdf-resource");this.handleDownload(resourceHandle)}})}createModal(){document.body.insertAdjacentHTML("beforeend",` 2 <div id="pdf-download-modal" class="pdf-modal" style="display: none;"> 3 <div class="pdf-modal__overlay"></div> 4 <div class="pdf-modal__content"> 5 <button class="pdf-modal__close" aria-label="Close">×</button> 6 <div class="pdf-modal__body"> 7 <h2 class="pdf-modal__title">Download Resource</h2> 8 <p class="pdf-modal__description">Please fill out this form to access the download.</p> 9 10 <form id="pdf-download-form" class="pdf-form"> 11 <div class="pdf-form__field"> 12 <label for="pdf-name">Name *</label> 13 <input type="text" id="pdf-name" name="name" required> 14 </div> 15 16 <div class="pdf-form__field"> 17 <label for="pdf-email">Email *</label> 18 <input type="email" id="pdf-email" name="email" required> 19 </div> 20 21 <div class="pdf-form__field"> 22 <label for="pdf-company">Company</label> 23 <input type="text" id="pdf-company" name="company"> 24 </div> 25 26 <div class="pdf-form__field"> 27 <label for="pdf-phone">Phone</label> 28 <input type="tel" id="pdf-phone" name="phone"> 29 </div> 30 31 <button type="submit" class="pdf-form__submit button button--primary"> 32 Submit & Download 33 </button> 34 35 <div class="pdf-form__message" style="display: none;"></div> 36 </form> 37 </div> 38 </div> 39 </div> 40 `),this.modal=document.getElementById("pdf-download-modal"),this.modal.querySelector(".pdf-modal__close").addEventListener("click",()=>{this.closeModal()}),this.modal.querySelector(".pdf-modal__overlay").addEventListener("click",()=>{this.closeModal()}),this.modal.querySelector("#pdf-download-form").addEventListener("submit",e=>{this.handleFormSubmit(e)})}async handleDownload(resourceHandle){try{const resource=await this.fetchResource(resourceHandle);if(!resource){alert("Resource not found");return}this.currentResource=resource,resource.requireForm?this.openModal():this.triggerDownload(resource.pdfUrl)}catch(error){console.error("Error handling download:",error),alert("An error occurred. Please try again.")}}async fetchResource(handle){return window.pdfResources&&window.pdfResources[handle]?window.pdfResources[handle]:null}openModal(){this.modal.style.display="block",document.body.style.overflow="hidden",this.currentResource&&this.currentResource.title&&(this.modal.querySelector(".pdf-modal__title").textContent=`Download: ${this.currentResource.title}`)}closeModal(){this.modal.style.display="none",document.body.style.overflow="",this.modal.querySelector("#pdf-download-form").reset();const message=this.modal.querySelector(".pdf-form__message");message.style.display="none"}async handleFormSubmit(e){e.preventDefault();const form=e.target,submitBtn=form.querySelector(".pdf-form__submit"),message=form.querySelector(".pdf-form__message");submitBtn.disabled=!0,submitBtn.textContent="Submitting...";const formData={name:form.name.value,email:form.email.value,company:form.company.value,phone:form.phone.value,resource:this.currentResource.title,timestamp:new Date().toISOString()};try{await this.sendToGoogleSheets(formData),message.textContent="Success! Your download will start shortly.",message.style.display="block",message.style.color="green",setTimeout(()=>{this.triggerDownload(this.currentResource.pdfUrl),setTimeout(()=>this.closeModal(),1e3)},1e3)}catch(error){console.error("Form submission error:",error),message.textContent="An error occurred. Please try again.",message.style.display="block",message.style.color="red",submitBtn.disabled=!1,submitBtn.textContent="Submit & Download"}}async sendToGoogleSheets(data){return await fetch("https://script.google.com/macros/s/AKfycbx1_-Kn31MmC5kUc73CBhQ8mur4oKc-_XUYL7cPqz122tto3QAlwCQ3Nw-uVZaCPzcMDw/exec",{method:"POST",mode:"no-cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(data)})}triggerDownload(url){const link=document.createElement("a");link.href=url,link.download="",link.target="_blank",document.body.appendChild(link),link.click(),document.body.removeChild(link)}}new PDFDownloadHandler; 41//# sourceMappingURL=/cdn/shop/t/6/assets/pdf-download-handler.js.map?v=55171971091043454111771856423
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.