PageSourceSearch

https://audified.com/wp-content/cache/min/1/wp-content/plugins/aud…/js/upgrades-buttons.js?ver=1790273935

js audified.com collected 2026-09-24 20:09:19 UTC 6,447 bytes, 33 lines download raw bytes

1jQuery(document).ready(function($){$(document).on('click','#upgradeToPro',function(e){e.preventDefault();handleUpgradeCheck('pro')});$(document).on('click','#upgradeToUltra',function(e){e.preventDefault();handleUpgradeCheck('ultra')});$(document).on('click','#upgradeToGKPro',function(e){e.preventDefault();handleUpgradeCheck('gk_pro')});function handleUpgradeCheck(upgradeType,isRetry){showLoadingPopup('Checking your eligibility for upgrade...');$.ajax({url:customUpgradeButtonsParams.ajax_url,type:'POST',data:{action:'custom_audified_check_upgrade',upgrade_type:upgradeType,nonce:(typeof customUpgradeButtonsParams!=='undefined'&&customUpgradeButtonsParams.nonce)?customUpgradeButtonsParams.nonce:''},success:function(response){var parsed=normalizeResponse(response);if(parsed.success){showUpgradeOptions(parsed.message,parsed.upgrade_options||[]);return}
2if(parsed.code==='invalid_nonce'&&!isRetry&&canRefreshNonce()){window.audifiedNonce.refresh('audified_upgrades_nonce').then(function(nonce){customUpgradeButtonsParams.nonce=nonce;handleUpgradeCheck(upgradeType,!0)},function(){showErrorPopup(parsed.message||'An error occurred while checking upgrade options.',parsed.logged,parsed.checkout)});return}
3showErrorPopup(parsed.message||'An error occurred while checking upgrade options.',parsed.logged,parsed.checkout)},error:function(){showErrorPopup('An error occurred while checking upgrade options.')}})}
4function canRefreshNonce(){return typeof window.audifiedNonce!=='undefined'&&typeof window.audifiedNonce.refresh==='function'&&typeof customUpgradeButtonsParams!=='undefined'}
5function normalizeResponse(response){if(typeof response==='string'){try{return JSON.parse(response)}catch(e){return{success:!1,message:'An error occurred while processing the response.'}}}
6if(response&&typeof response==='object'){return response}
7return{success:!1,message:'An error occurred while processing the response.'}}
8function showLoadingPopup(message){closePopup();$('<div class="custom-upgrade-popup"><div class="popup-content"><div class="custom-loading"></div><p>'+message+'</p></div></div>').appendTo('body')}
9function showUpgradeOptions(message,options){var popupContent=$('.custom-upgrade-popup .popup-content');popupContent.empty().append('<p><b>'+message+'</b></p>');options.forEach(function(option){$('<button class="upgrade-option" data-product-id="'+option.product_id+'">'+option.label+' - $'+option.price+'</button>').appendTo(popupContent)});$('<span class="close-popup">&times;</span>').appendTo('.custom-upgrade-popup').on('click',closePopup).show();popupContent.find('.upgrade-option').on('click',function(){var productId=$(this).data('product-id');var productName=$(this).text();showLoadingPopup('Adding '+productName+' to cart...');addToCart(productId,1,productName)})}
10function showErrorPopup(message,logged,checkout){var popupContent=$('.custom-upgrade-popup .popup-content');popupContent.empty().append('<p style="color: #ff3a33;">'+message+'</p>');$('<span class="close-popup">&times;</span>').appendTo('.custom-upgrade-popup').on('click',closePopup).show();enablePopupOverlayClose();if(!logged){popupContent.append('<a href="'+getLoginUrl()+'" class="button">Login</a>')}
11if(checkout){popupContent.append('<a href="'+getCheckoutUrl()+'" class="button">Go to checkout</a>')}}
12function addToCart(productID,quantity,productName){addToCartViaLegacyAjax(productID,quantity,function(){onAddToCartSuccess(productID,productName)},function(){addToCartViaWooAjax(productID,quantity,function(){onAddToCartSuccess(productID,productName)},function(){showErrorPopup('An error occurred while adding the product to the cart. Please try again.')})})}
13function onAddToCartSuccess(productID,productName){$(document.body).trigger('wc_fragment_refresh');showSuccessPopup(productName);pushDataLayer(productID)}
14function addToCartViaLegacyAjax(productID,quantity,onSuccess,onFail){$.ajax({url:custom_add_to_cart_params.ajax_url,data:{action:'woocommerce_add_to_cart',product_id:productID,quantity:quantity},type:'POST',success:function(response){var parsed=normalizeResponse(response);if(!isLegacyAddToCartSuccess(parsed)){onFail();return}
15onSuccess()},error:function(){onFail()}})}
16function addToCartViaWooAjax(productID,quantity,onSuccess,onFail){$.ajax({url:getWooAjaxAddToCartUrl(),data:{product_id:productID,quantity:quantity},type:'POST',success:function(response){if(response&&response.error){onFail();return}
17onSuccess()},error:function(){onFail()}})}
18function getWooAjaxAddToCartUrl(){if(window.wc_add_to_cart_params&&window.wc_add_to_cart_params.wc_ajax_url){return window.wc_add_to_cart_params.wc_ajax_url.replace('%%endpoint%%','add_to_cart')}
19return window.location.origin+'/?wc-ajax=add_to_cart'}
20function showSuccessPopup(productName){var popupContent=$('.custom-upgrade-popup .popup-content');popupContent.empty().append('<p><b>'+productName+'</b> was added to your cart.</p>');popupContent.append('<a href="'+getCheckoutUrl()+'" class="button">Go to checkout</a>');$('<span class="close-popup">&times;</span>').appendTo('.custom-upgrade-popup').on('click',closePopup).show();enablePopupOverlayClose()}
21function getLoginUrl(){if(typeof customUpgradeButtonsParams!=='undefined'&&customUpgradeButtonsParams.login_url){return customUpgradeButtonsParams.login_url}
22return'/account/'}
23function getCheckoutUrl(){if(typeof customUpgradeButtonsParams!=='undefined'&&customUpgradeButtonsParams.checkout_url){return customUpgradeButtonsParams.checkout_url}
24return'/checkout/'}
25function isLegacyAddToCartSuccess(parsed){if(!parsed||typeof parsed!=='object'){return!1}
26if(parsed.error){return!1}
27if(parsed.fragments||parsed.cart_hash||parsed.success===!0||parsed.product_url){return!0}
28return!1}
29function pushDataLayer(productID){if(typeof customAddToCartData==='undefined'||!customAddToCartData[productID]){return}
30var productData=customAddToCartData[productID];var categories=Array.isArray(productData.categories)?productData.categories.join(', '):'';window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:'add_to_cart',items:[{id:String(productID),name:productData.name,price:productData.price,category:categories}]})}
31function closePopup(){$('.custom-upgrade-popup').remove();disablePopupOverlayClose()}
32function enablePopupOverlayClose(){$('.custom-upgrade-popup').on('click',function(e){if($(e.target).is('.custom-upgrade-popup')){closePopup()}})}
33function disablePopupOverlayClose(){$('.custom-upgrade-popup').off('click')}})

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.