From cebe52b56cc67fbfa4547ffef3718cbb7438d809 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 27 Oct 2021 15:40:57 +0530 Subject: [PATCH] Added: the minified version of the script(#e5d9vw) --- scripts/script-tag.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/script-tag.min.js b/scripts/script-tag.min.js index 02b7aab..2a565bb 100644 --- a/scripts/script-tag.min.js +++ b/scripts/script-tag.min.js @@ -1 +1 @@ -!function(){let e;this.preOrderCustomConfig={enableCartRedirection:!0};let t="https://dev-hc.hotwax.io";async function a(){if(location.pathname.includes("products")){const a=e("form[action='/cart/add']").serializeArray().find(e=>"id"===e.name).value,n=e("form[action^='/cart/add']:first [type=submit]:visible:first"),r=function(a){return new Promise(function(n,r){e.ajax({type:"POST",url:`${t}/api/searchProducts`,data:JSON.stringify({filters:[`sku: ${a}`]}),dataType:"json",crossDomain:!0,headers:{"Content-Type":"application/json"},success:function(e){n(e)},error:function(e){r(e)}})})}(meta.product.variants.find(e=>e.id==a).sku);r.preOrder&&(n.html("Pre Order"),n.after(`Ships from ${r.timestamp}`),n.on("click",function(t){let a=e("form[action='/cart/add']");t.preventDefault(),t.stopImmediatePropagation();let n=e('');a.append(n),e.ajax({type:"POST",url:"/cart/add.js",data:a.serialize(),dataType:"JSON",success:function(){preOrderCustomConfig.enableCartRedirection&&location.replace("/cart")}}),n.remove()}.bind(null)))}}"undefined"==typeof jQuery||parseFloat(jQuery.fn.jquery)<1.7?function(e,t){let a=document.createElement("script");a.type="text/javascript",a.readyState?a.onreadystatechange=function(){"loaded"!=a.readyState&&"complete"!=a.readyState||(a.onreadystatechange=null,t())}:a.onload=function(){t()},a.src=e,document.getElementsByTagName("head")[0].appendChild(a)}("//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js",function(){(e=jQuery.noConflict(!0))(document).ready(function(){a()})}):(e=jQuery)(document).ready(function(){a()});let n=location.href;new MutationObserver(()=>{location.href!==n&&(n=location.href,a())}).observe(document,{subtree:!0,childList:!0})}(); \ No newline at end of file +!function(){let e;this.preOrderCustomConfig={enableCartRedirection:!0};let t="https://dev-hc.hotwax.io",o=function(e,t){let o=document.createElement("script");o.type="text/javascript",o.readyState?o.onreadystatechange=function(){"loaded"!=o.readyState&&"complete"!=o.readyState||(o.onreadystatechange=null,t())}:o.onload=function(){t()},o.src=e,document.getElementsByTagName("head")[0].appendChild(o)};async function n(){if(location.pathname.includes("products")){const n=e("form[action='/cart/add']").serializeArray().find(e=>"id"===e.name).value,a=meta.product.variants.map(e=>e.id),r=e("form[action^='/cart/add']:first [type=submit]:visible:first"),i=await(o=a,new Promise(function(n,a){e.ajax({type:"POST",url:`${t}/api/checkPreorderItemAvailability`,data:JSON.stringify({filters:{sku:o,sku_op:"in"}}),dataType:"json",crossDomain:!0,headers:{"Content-Type":"application/json"},success:function(e){n(e)},error:function(e){a(e)}})})).catch(e=>console.error(e));let c=e("#hc_preordershipsfrom"),d=e("#hc_preordershipsfrom span");if(i&&i.count>0){const t=i.docs.find(e=>e.productId===n);if(t){const o=moment.utc(t.estimatedDeliveryDate),n=moment(o).local().format("MMM Do YYYY");r.html("Pre Order"),c.length>0&&d.html(`${n}`),c.show(),r.on("click",function(t){let o=e("form[action='/cart/add']");t.preventDefault(),t.stopImmediatePropagation();let n=e('');o.append(n),e.ajax({type:"POST",url:"/cart/add.js",data:o.serialize(),dataType:"JSON",success:function(){preOrderCustomConfig.enableCartRedirection&&location.replace("/cart")}}),n.remove()}.bind(null))}}}var o}"undefined"==typeof jQuery||parseFloat(jQuery.fn.jquery)<1.7?o("//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js",function(){(e=jQuery.noConflict(!0))(document).ready(function(){n()})}):(e=jQuery)(document).ready(function(){n()}),"undefined"==typeof moment&&o("https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js",function(){console.log("moment js loaded")});let a=location.href;new MutationObserver(()=>{location.href!==a&&(a=location.href,n())}).observe(document,{subtree:!0,childList:!0})}(); \ No newline at end of file