1document.addEventListener('DOMContentLoaded',function(){window.onbeforeunload=null;if(window._wpLoadBeforeUnload){window.removeEventListener('beforeunload',window._wpLoadBeforeUnload);delete window._wpLoadBeforeUnload} 2const urlCheckoutStepOne='/realizar-donacion/';const urlCheckoutStepTwo='/realizar-donacion/?resumen';let chosenCampaign=null;let chosenAmount=null;let chosenFrequency=null;let chosenTaxDeduction=null;const chosenCampaignContainer=document.querySelector('#chosen_campaign');const amountDonationButtons=document.querySelectorAll('#mdm-chk-amount-buttons input[type="radio"][name="amount"]');const frequencyDonationButtons=document.querySelectorAll('#mdm-chk-frequency-buttons input[type="radio"][name="frequency"]');const taxDeductionButtons=document.querySelectorAll('.mdm-radiobuttons-form input[type="radio"][name="tax"]');const isCheckoutForm=document.querySelector('.mdm-ckt-col-steps');const isThankYouPage=document.querySelector('.woocommerce-order')!==null||document.querySelector('.mdm-thankyou-page')!==null;if(isThankYouPage){handleThankYouPage()} 3const campaignCookie=getCookie('mdmes_donation_campaign_data');const userSelectionCookie=getCookie('mdmes_donation_user_selection_data');let campaignCookieData=campaignCookie?JSON.parse(campaignCookie):null;let userSelectionCookieData=userSelectionCookie?JSON.parse(userSelectionCookie):null;function initializeCampaign(){if(!chosenCampaignContainer){console.error('Contenedor de campañas no encontrado');return!1} 4if(chosenCampaignContainer instanceof HTMLSelectElement){chosenCampaign=campaignCookieData?chosenCampaignContainer.querySelector(`option[value="${campaignCookieData.campaignId}"]`):chosenCampaignContainer.querySelector('option:checked')}else{chosenCampaign=document.querySelector('input#chosen_campaign')} 5if(!chosenCampaign){console.error('No se pudo determinar la campaña seleccionada');return!1} 6return!0} 7function initializeSelections(){if(campaignCookieData&&userSelectionCookieData&&campaignCookieData.campaignId===userSelectionCookieData.campaignId){if(userSelectionCookieData.amountId!=='other-amount'){const amountBtn=document.querySelector(`#mdm-chk-amount-buttons input#${userSelectionCookieData.amountId}`);if(amountBtn){amountBtn.checked=!0;chosenAmount=amountBtn;executeChosenAmountActions(chosenAmount,isCheckoutForm)}}else{const otherAmountContainer=document.querySelector('#mdm-chk-amount-buttons #other-amount-container');if(otherAmountContainer){otherAmountContainer.innerHTML=userSelectionCookieData.amountValue;chosenAmount=document.querySelector('#mdm-chk-amount-buttons #other-amount');if(chosenAmount){chosenAmount.value=userSelectionCookieData.amountValue;chosenAmount.checked=!0}}} 8const freqBtn=document.querySelector(`#mdm-chk-frequency-buttons input#${userSelectionCookieData.frequencyId}`);if(freqBtn){freqBtn.checked=!0;chosenFrequency=freqBtn;executeChosenFrequencyActions(chosenFrequency,isCheckoutForm)} 9const taxBtn=document.querySelector(`#mdm-tax-deduction-selector input#${userSelectionCookieData.taxesDeductionId}`);if(taxBtn){taxBtn.checked=!0;chosenTaxDeduction=taxBtn;executeChosenTaxDeductionActions(chosenTaxDeduction,isCheckoutForm)}}else{setDefaultSelection()}} 10function setupCheckoutForm(){if(!isCheckoutForm)return;const taxContainer=document.querySelector('#mdm-tax-deduction');if(taxContainer){['#billing_road_type_field','#billing_address_1_field','#billing_country_field','#billing_state_field','#billing_city_field','#billing_postcode_field'].forEach(selector=>{const field=document.querySelector(selector);if(field)taxContainer.appendChild(field)})} 11const bacsContainer=document.querySelector('#pay-method .mdm-payments-columns .payment_method_bacs');if(bacsContainer){const ibanField=document.querySelector('#billing_iban_field');if(ibanField)bacsContainer.appendChild(ibanField);const extraInfo=document.createElement('p');extraInfo.id='bacs-extra-info';extraInfo.className='mdm-simple-text info hidden';extraInfo.innerHTML='<strong>IMPORTANTE:</strong> Para donaciones recurrentes, el único método de pago disponible es la domiciliación bancaria.';bacsContainer.appendChild(extraInfo)} 12setupCheckoutFormHandlers();if(window.location.href.indexOf('resumen')!==-1&&chosenCampaign&&chosenAmount&&chosenFrequency&&chosenTaxDeduction){goToStepTwo(urlCheckoutStepTwo,chosenCampaign,chosenAmount,chosenFrequency,chosenTaxDeduction)}} 13function setDefaultSelection(ignoreTaxDeduction=!1){const amount1=document.querySelector('#mdm-chk-amount-buttons input#amount-1');if(amount1){amount1.checked=!0;chosenAmount=amount1;executeChosenAmountActions(chosenAmount,isCheckoutForm)} 14const frequency1=document.querySelector('#mdm-chk-frequency-buttons input#frequency-1');
14if(frequency1){frequency1.checked=!0;chosenFrequency=frequency1;executeChosenFrequencyActions(chosenFrequency,isCheckoutForm)} 15if(!ignoreTaxDeduction){const taxNo=document.querySelector('#mdm-tax-deduction-selector input#tax-no');if(taxNo){taxNo.checked=!0;chosenTaxDeduction=taxNo;executeChosenTaxDeductionActions(chosenTaxDeduction,isCheckoutForm)}}} 16function executeChosenAmountActions(chosenAmount,isCheckoutForm){if(!chosenAmount)return;const amountValue=chosenAmount.value;const customAmountText=document.querySelector('.info-amount-text span.js-custom-amount');const customText=document.querySelector('.info-amount-text span.js-custom-text');const donationObjective=document.querySelector(`#mdm-chk-amount-buttons label[for="${chosenAmount.id}"]`)?.getAttribute('data-donation-objetive');if(customAmountText)customAmountText.innerHTML=amountValue;if(customText&&donationObjective)customText.innerHTML=donationObjective;if(chosenAmount.id!=='other-amount'){const customInfoText=document.querySelector('#custom-info-text');if(customInfoText)customInfoText.classList.remove('info-amount-hidden');const otherAmountContainer=document.querySelector('#mdm-chk-amount-buttons #other-amount-container');if(otherAmountContainer)otherAmountContainer.innerHTML='OTRA CANTIDAD'} 17if(isCheckoutForm&&document.querySelector('.mdm-first-block-result #info-amount')){updateUserAmount(amountValue)}} 18function executeChosenFrequencyActions(chosenFrequency,isCheckoutForm){if(!chosenFrequency)return;const donateButton=document.querySelector('#mdm-first-button-donate');if(donateButton){donateButton.innerHTML=`DONAR ${chosenFrequency.value.toUpperCase()}MENTE`} 19if(isCheckoutForm){const payMethodsContainer=document.querySelector('#pay-method #bacs-extra-info');const paymentMethods={bacs:document.querySelector('#payment li.payment_method_bacs'),redsys:document.querySelector('#payment li.payment_method_redsys'),bizum:document.querySelector('#payment li.payment_method_bizumredsys'),paypal:document.querySelector('#payment li.payment_method_ppcp-gateway')};if(chosenFrequency.value!=='puntual'){if(payMethodsContainer)payMethodsContainer.classList.remove('hidden');if(paymentMethods.bacs)paymentMethods.bacs.classList.remove('hidden');if(paymentMethods.redsys)paymentMethods.redsys.classList.add('hidden');if(paymentMethods.bizum)paymentMethods.bizum.classList.add('hidden');if(paymentMethods.paypal)paymentMethods.paypal.classList.add('hidden');const bacsLabel=document.querySelector('#payment label[for="payment_method_bacs"]');if(bacsLabel)bacsLabel.click()}else{if(payMethodsContainer)payMethodsContainer.classList.add('hidden');if(paymentMethods.bacs)paymentMethods.bacs.classList.add('hidden');if(paymentMethods.redsys)paymentMethods.redsys.classList.remove('hidden');if(paymentMethods.bizum)paymentMethods.bizum.classList.remove('hidden');if(paymentMethods.paypal)paymentMethods.paypal.classList.remove('hidden');const redsysLabel=document.querySelector('#payment label[for="payment_method_redsys"]');if(redsysLabel)redsysLabel.click()} 20if(document.querySelector('.mdm-first-block-result #info-frecuency')){document.querySelector('.mdm-first-block-result #info-frecuency').innerHTML=chosenFrequency.value}}} 21function executeChosenTaxDeductionActions(chosenTaxDeduction,isCheckoutForm){if(!chosenTaxDeduction||!isCheckoutForm)return;const taxDeductionSection=document.querySelector('#mdm-tax-deduction');if(taxDeductionSection){taxDeductionSection.classList.toggle('hidden',chosenTaxDeduction.value!=='tax-yes')} 22if(document.querySelector('.mdm-first-block-result #info-tax')){const taxText=chosenTaxDeduction.parentNode.querySelector('div')?.innerHTML||'No';document.querySelector('.mdm-first-block-result #info-tax').innerHTML=taxText}} 23function goToStepOne(urlCheckoutStepOne){window.history.pushState({id:'checkout'},'Step 1',urlCheckoutStepOne);document.querySelector('#form-step-1')?.classList.add('checked');document.querySelector('#form-step-2')?.classList.remove('checked');document.querySelector('#mdm-second-form')?.classList.add('mdm-block-hidden');document.querySelector('#mdm-first-form')?.classList.remove('mdm-block-hidden');document.querySelector('.flexible-content .advanced-content')?.scrollIntoView({behavior:'smooth'})} 24function goToStepTwo(urlCheckoutStepTwo,campaign,amount,frequency,taxDeduction){if(!campaign||!amount||!frequency||!taxDeduction){console.error('Faltan parámetros para ir al paso 2');return} 25window.history.pushState({id:'checkout'},'Step 2',urlCheckoutStepTwo);setDonationSummary(campaign,amount,frequency,taxDeduction);document.querySelector('#form-step-1')?.classList.remove('checked');document.querySelector('#form-step-2')?.classList.add('checked');document.querySelector('#mdm-first-form')?.classList.add('mdm-block-hidden');document.querySelector('#mdm-second-form')?.classList.remove('mdm-block-hidden');document.querySelector('.flexible-content .advanced-content')?.scrollIntoView({behavior:'smooth'})} 26function setDonationSummary(campaign,amount,frequency,taxDeduction){if(!campaign||!amount||!frequency||!taxDeduction)return;const campaignName=campaign.innerHTML||campaign.value;const campaignInfo=document.querySelector('.mdm-text-info');if(campaignInfo)campaignInfo.innerHTML=campaignName;const amountValue=amount.value>0?amount.value:1;updateUserAmount(amountValue);const frequencyInfo=document.querySelector('.mdm-first-block-result #info-frecuency');if(frequencyInfo)frequencyInfo.innerHTML=frequency.value;const taxInfo=document.querySelector('.mdm-first-block-result #info-tax');if(taxInfo){const taxText=taxDeduction.parentNode.querySelector('div')?.innerHTML||'No';taxInfo.innerHTML=taxText}} 27function updateUserAmount(amount){const amountInfo=document.querySelector('.mdm-first-block-result #info-amount');if(amountInfo)amountInfo.innerHTML=amount+'â¬'} 28function setupCheckoutFormHandlers(){const checkoutForm=document.querySelector('form.checkout');if(!checkoutForm)return;const originalSubmit=checkoutForm.submit;checkoutForm.submit=function(e){if(e&&e.type==='submit'){e.preventDefault();processCheckoutForm(checkoutForm)}else{originalSubmit.call(checkoutForm)}};const placeOrderButton=document.querySelector('#place_order');if(placeOrderButton){placeOrderButton.addEventListener('click',function(e){e.preventDefault();processCheckoutForm(checkoutForm)})}} 29async function processCheckoutForm(form){const placeOrderButton=document.querySelector('#place_order');if(!placeOrderButton)return;const originalText=placeOrderButton.value;try{placeOrderButton.disabled=!0;placeOrderButton.value='Procesando...';if(!validateCheckoutForm(form)){return} 30const formData=new FormData(form);const response=await fetch(wc_checkout_params.checkout_url,{method:'POST',body:formData,headers:{'Accept':'application/json'}});const contentType=response.headers.get('content-type');if(!contentType||!contentType.includes('application/json')){const text=await response.text();throw new Error(`Respuesta no JSON: ${text.substring(0, 100)}`)} 31const result=await response.json();if(result.result==='success'){window.location=result.redirect}else{displayCheckoutErrors(result.messages||'Hubo un error al procesar tu donación')}}catch(error){console.error('Error:',error);displayCheckoutErrors('Error de conexión. Por favor intenta nuevamente.')}finally{placeOrderButton.disabled=!1;placeOrderButton.value=originalText}} 32function validateCheckoutForm(form){if(!form)return!1;let isValid=!0;const requiredFields=form.querySelectorAll('.validate-required:not(.hidden) input[required]');requiredFields.forEach(field=>{if(!field.value.trim()){field.closest('.form-row')?.classList.add('woocommerce-invalid');isValid=!1}});if(!isValid){displayCheckoutErrors('Por favor completa todos los campos requeridos')} 33return isValid} 34function displayCheckoutErrors(message){const errorContainer=document.querySelector('.woocommerce-NoticeGroup-checkout');if(errorContainer){errorContainer.remove()} 35const noticeGroup=document.createElement('div');
35noticeGroup.className='woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout';const notice=document.createElement('ul');notice.className='woocommerce-error';notice.innerHTML=`<li>${message}</li>`;noticeGroup.appendChild(notice);const checkoutForm=document.querySelector('form.checkout');if(checkoutForm?.parentNode){checkoutForm.parentNode.insertBefore(noticeGroup,checkoutForm);noticeGroup.scrollIntoView({behavior:'smooth',block:'center'})}} 36if(chosenCampaignContainer){chosenCampaignContainer.addEventListener('change',function(){chosenCampaign=this.querySelector('option:checked');if(!chosenCampaign)return;setCampaignCookie(chosenCampaign);getChosenCampaignData(chosenCampaign,isCheckoutForm).then(()=>{setDefaultSelection(!0)}).catch(console.error)})} 37amountDonationButtons.forEach(btn=>{btn.addEventListener('click',function(){chosenAmount=this;executeChosenAmountActions(chosenAmount,isCheckoutForm)})});const otherAmountContainer=document.querySelector('#mdm-chk-amount-buttons #other-amount-container');if(otherAmountContainer){otherAmountContainer.addEventListener('click',function(){document.querySelector('.info-amount #custom-info-text')?.classList.add('info-amount-hidden');const donateButton=document.querySelector('#mdm-first-button-donate.mdm-donate-button-text');if(donateButton)donateButton.classList.add('disabled');const inputOtherAmount=document.querySelector('#mdm-chk-amount-buttons #other-amount');if(inputOtherAmount)inputOtherAmount.checked=!0;this.innerHTML='';this.setAttribute('contenteditable','true');this.focus();this.addEventListener('keypress',function(e){if(e.key==='Enter'){e.preventDefault();this.setAttribute('contenteditable','false');let userAmount=parseFloat(this.innerHTML.replace(/[^0-9.,]/g,'').replace(/,/g,'.'))||0;userAmount=parseFloat(userAmount.toFixed(2));userAmount=userAmount<1?1:userAmount;if(inputOtherAmount){inputOtherAmount.value=userAmount;chosenAmount=inputOtherAmount} 38this.innerHTML=userAmount+'â¬';if(donateButton)donateButton.classList.remove('disabled')}});this.addEventListener('blur',function(){this.dispatchEvent(new KeyboardEvent('keypress',{key:'Enter'}))})})} 39frequencyDonationButtons.forEach(btn=>{btn.addEventListener('change',function(){chosenFrequency=this;executeChosenFrequencyActions(chosenFrequency,isCheckoutForm)})});taxDeductionButtons.forEach(btn=>{btn.addEventListener('change',function(){chosenTaxDeduction=this;executeChosenTaxDeductionActions(chosenTaxDeduction,isCheckoutForm)})});const firstDonateButton=document.querySelector('#mdm-first-button-donate');if(firstDonateButton){firstDonateButton.addEventListener('click',async function(e){e.preventDefault();if(!chosenCampaign||!chosenAmount||!chosenFrequency||!chosenTaxDeduction){console.error('Faltan selecciones requeridas');return} 40this.disabled=!0;this.innerHTML='Procesando...';const success=await addDonationToCart();if(success){setUserSelectionCookie(chosenCampaign,chosenAmount,chosenFrequency.id,chosenTaxDeduction.id);if(!isCheckoutForm){window.location.href=urlCheckoutStepTwo}else{goToStepTwo(urlCheckoutStepTwo,chosenCampaign,chosenAmount,chosenFrequency,chosenTaxDeduction)}}else{alert('Hubo un error al procesar tu donación. Por favor intenta nuevamente.');this.disabled=!1;this.innerHTML='DONAR PUNTUALMENTE'}})} 41const changeDonationButton=document.querySelector('#mdm-button-change-donate');if(changeDonationButton){changeDonationButton.addEventListener('click',()=>{goToStepOne(urlCheckoutStepOne)})} 42if(!initializeCampaign())return;getChosenCampaignData(chosenCampaign,isCheckoutForm).then(()=>{setCampaignCookie(chosenCampaign);initializeSelections();setupCheckoutForm()}).catch(error=>{console.error('Error inicializando datos:',error)});if(typeof tipo_formulario!=='undefined'){const bloqueSeleccion=document.querySelector('.mdm-frecuencia-seleccion');const inputPuntual=document.getElementById('frequency-1');const inputMensual=document.getElementById('frequency-2');if(tipo_formulario==='unica'){if(inputPuntual){inputPuntual.checked=!0} 43if(bloqueSeleccion){bloqueSeleccion.style.display='none'} 44console.log("accion frecuencia única")}else if(tipo_formulario==='concurrente'){if(inputPuntual){inputPuntual.style.display='none';const labelPuntual=document.querySelector('label[for="frequency-1"]');if(labelPuntual){labelPuntual.style.display='none'}} 45if(inputMensual){inputMensual.checked=!0} 46console.log("accion frecuencia recursiva")} 47console.log("Sin accion frecuencia")}});function handleThankYouPage(){const invoiceDownloadButton=document.querySelector('.mdm-text-download a');
47if(invoiceDownloadButton){invoiceDownloadButton.addEventListener('click',async function(e){e.preventDefault();const orderId=this.dataset.order;try{const response=await fetch('/wp/wp-admin/admin-ajax.php',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:new URLSearchParams({action:'donation_pdf_download',order_id:orderId})});const contentType=response.headers.get('content-type');if(!contentType||!contentType.includes('application/pdf')){const text=await response.text();throw new Error(`Respuesta no PDF: ${text.substring(0, 100)}`)} 48const responseData=await response.arrayBuffer();const blob=new Blob([responseData],{type:'application/pdf'});const downloadUrl=URL.createObjectURL(blob);const link=document.createElement('a');link.href=downloadUrl;link.download="Donacion-Medicos-del-Mundo.pdf";link.click()}catch(error){console.error('Error al descargar PDF:',error);showErrorAlert('Error al generar el PDF. Por favor inténtalo de nuevo o contacta con nosotros.')}})}} 49function showErrorAlert(message){alert(message||'Error al generar el PDF. Por favor inténtalo de nuevo o contacta con nosotros.')} 50function getCookie(name){const cookie=document.cookie.split('; ').find(c=>c.startsWith(name+'='));return cookie?decodeURIComponent(cookie.split('=')[1]):null} 51function setCampaignCookie(campaign){if(!campaign)return;const campaignData={campaignId:campaign.value,campaignCode:campaign.dataset.campaignCode,wcDonationId:campaign.dataset.wcDonationId};document.cookie=`mdmes_donation_campaign_data=${JSON.stringify(campaignData)}; path=/; SameSite=Strict; Secure`} 52function setUserSelectionCookie(campaign,amount,frequency,taxesDeduction){if(!campaign||!amount||!frequency||!taxesDeduction)return;const userSelectionData={campaignId:campaign.value,amountId:amount.id,amountValue:amount.value,frequencyId:frequency,taxesDeductionId:taxesDeduction};document.cookie=`mdmes_donation_user_selection_data=${JSON.stringify(userSelectionData)}; path=/; SameSite=Strict; Secure`} 53function addDonationDataLayer(campaign,amount,frequencyId,taxDeductionId){if(!window.dataLayer)window.dataLayer=[];window.dataLayer.push({'event':'donation_selection','campaign':campaign.innerHTML||campaign.value,'amount':amount.value,'frequency':document.querySelector(`#${frequencyId}`)?.value||'','taxDeduction':taxDeductionId==='tax-yes'?'SÃ':'No'})} 54async function addDonationToCart(){const cleaned=await clearEntireCart();if(!cleaned){console.error('No se pudo vaciar el carrito');return!1} 55const nonce=document.querySelector('#wc_donation_nonce')?.value;const campaign_id=document.querySelector('#mdm-first-button-donate')?.value;const amount=document.querySelector('#mdm-chk-amount-buttons input[name="amount"]:checked')?.value;if(!nonce||!campaign_id||!amount){console.error('Faltan datos para añadir al carrito');return!1} 56try{const response=await fetch('/wp/wp-admin/admin-ajax.php',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:new URLSearchParams({action:'donation_to_order',nonce:nonce,campaign_id:campaign_id,amount:amount})});return!0}catch(error){console.error('Error al añadir donación:',error);return!1}} 57function copyBankAccount(){const sourceElement=document.getElementById('mdm-es-bank-account');if(!sourceElement){console.error('No se pudo copiar el número de cuenta');return} 58navigator.clipboard.writeText(sourceElement.value).catch(console.error)} 59async function getChosenCampaignData(chosenCampaign,isCheckoutForm){if(!chosenCampaign){return Promise.reject('Campaña no definida')} 60const chosenWcDonationId=chosenCampaign.getAttribute('data-wc-donation-id');if(!chosenWcDonationId){return Promise.reject('Falta data-wc-donation-id')} 61try{const response=await fetch(`/wp-json/wc-donation/v1/campaign/${chosenWcDonationId}`);const contentType=response.headers.get('content-type');if(!contentType||!contentType.includes('application/json')){const text=await response.text();throw new Error(`Respuesta no JSON: ${text.substring(0, 100)}`)} 62const data=await response.json();if(!data)throw new Error('Datos de campaña no recibidos');await loadAmountInfo(data);if(!isCheckoutForm)return;const chosenCampaignId=chosenCampaign.value;if(!chosenCampaignId)throw new Error('Falta ID de campaña');const wpResponse=await fetch(`/wp-json/wp/v2/campaign/${chosenCampaignId}`);const wpData=await wpResponse.json();if(!wpData?.acf?.info_checkform)throw new Error('Falta info_checkform en ACF');loadCampaignInfo(wpData.acf.info_checkform);const campaignCode=chosenCampaign.getAttribute('data-campaign-code');const billingCampaignCodeField=document.querySelector('#billing_campaign_code_field input#billing_campaign_code');if(campaignCode&&billingCampaignCodeField){billingCampaignCodeField.value=campaignCode}}catch(error){console.error('Error en getChosenCampaignData:',error);throw error}} 63function loadAmountInfo(data){if(!data?.campaign_meta)return;const campaignId=data.ID;const amounts=data.campaign_meta['pred-amount']?.[0]||[];const messages=data.campaign_meta['pred-label']?.[0]||[];
63amounts.forEach((amount,index)=>{const amountId=`amount-${index + 1}`;const amountInput=document.querySelector(`#mdm-chk-amount-buttons input#${amountId}`);const amountLabel=document.querySelector(`#mdm-chk-amount-buttons label[for="${amountId}"]`);if(amountInput)amountInput.value=amount;if(amountLabel){amountLabel.innerHTML=`${amount}â¬`;amountLabel.setAttribute('data-donation-objetive',messages[index]||'')}});const donateButton=document.querySelector('#mdm-first-button-donate');if(donateButton)donateButton.value=campaignId} 64function loadCampaignInfo(data){if(!data||!Array.isArray(data))return;const titleElement=document.querySelector('#donation-info-block__title');const contentElement=document.querySelector('#donation-info-block__content');if(!titleElement||!contentElement)return;titleElement.innerHTML='¿EN QUà USAMOS NUESTROS FONDOS?';let html='<div class="mdm-info-columns">';const columnsPerRow=2;data.forEach((item,index)=>{if(index%columnsPerRow===0){html+='<div class="row">'} 65html+=` 66 <div class='column'> 67 <div class="mdm-circle">${item.info_percent}%</div> 68 <p class="mdm-text-info">${item.info_text}</p> 69 </div> 70 `;if(index%columnsPerRow===columnsPerRow-1||index===data.length-1){html+='</div>'}});html+='</div>';contentElement.innerHTML=html} 71async function clearEntireCart(){try{const response=await fetch('/wp/wp-admin/admin-ajax.php',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded',},body:new URLSearchParams({action:'clear_entire_cart'})});const result=await response.json();return result.success}catch(error){console.error('Error al vaciar el carrito:',error);return!1}} 72document.addEventListener("DOMContentLoaded",function(){const selector=document.getElementById("chosen_campaign");const resultado=document.getElementById("resumen_resultado");async function cargarResumen(campaignId){if(!campaignId){resultado.textContent="";return} 73try{const response=await fetch("/wp/wp-admin/admin-ajax.php",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",},body:new URLSearchParams({action:"get_campaign_resumen",campaign_id:campaignId,}),});const data=await response.json();if(data.success){resultado.textContent=data.data}else{resultado.textContent="No se encontró resumen."}}catch(error){console.error("Error en la petición:",error)}} 74if(selector){selector.addEventListener("change",function(){cargarResumen(this.value)});if(selector.value){cargarResumen(selector.value)}}});jQuery(function($){function hasResumenParam(){return new URLSearchParams(window.location.search).has("resumen")} 75function toggleColumna(){if(hasResumenParam()){$(".mdm-checkout-col-2 .bloque-inicial").hide();$(".mdm-checkout-col-2 .bloque-resumen").show()}else{$(".mdm-checkout-col-2 .bloque-inicial").show();$(".mdm-checkout-col-2 .bloque-resumen").hide()}} 76toggleColumna();$(document.body).on("updated_checkout",function(){setTimeout(toggleColumna,100)});const targetNode=document.querySelector('.mdm-checkout-col-2');if(targetNode){const observer=new MutationObserver(toggleColumna);observer.observe(targetNode,{childList:!0,subtree:!0})}})
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.