From d90a8cad10a813c199402292342477f56cd10489 Mon Sep 17 00:00:00 2001 From: Gustavo Luigi Date: Fri, 2 Sep 2022 12:03:27 +0200 Subject: [PATCH] . --- content/master.blade.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/content/master.blade.php b/content/master.blade.php index 4ea2ebe..a3fee00 100644 --- a/content/master.blade.php +++ b/content/master.blade.php @@ -310,6 +310,25 @@ $('#count-items-in-bag').html(objProductInfo.quantity+``); } } + if(objProducts.length > 0) { + let url = null; + if(window.location.origin == 'http://localhost') url = window.location.origin+'/areya-energy/public/'+btoa(JSON.stringify(objProducts)); + else url = window.location.origin+'/'+btoa(JSON.stringify(objProducts)); + $('.cart-link').attr('href', url); + $('.cart-link').text(url); + const shareData = { + title: "Share cart list", + text: 'share cart list', + url: url, + }; + $(".btn-share").click(async function() { + if(navigator.share) { try { await navigator.share(shareData); } catch(err) { console.warn(err); } } + else { console.warn('Native Web Sharing not supported'); } + }); + }else{ + $('.cart-link').hide(); + $(".btn-share").hide(); + } } function addToBag(productId){ let objProductInfo = objProducts.find(obj => obj.id == productId); @@ -363,25 +382,6 @@ objProducts[index].quantity = quantity; updateProductsInLocalStorage(); }); - if(objProducts.length > 0) { - let url = null; - if(window.location.origin == 'http://localhost') url = window.location.origin+'/areya-energy/public/'+btoa(JSON.stringify(objProducts)); - else url = window.location.origin+'/'+btoa(JSON.stringify(objProducts)); - $('.cart-link').attr('href', url); - $('.cart-link').text(url); - const shareData = { - title: "Share cart list", - text: 'share cart list', - url: url, - }; - $(".btn-share").click(async function() { - if(navigator.share) { try { await navigator.share(shareData); } catch(err) { console.warn(err); } } - else { console.warn('Native Web Sharing not supported'); } - }); - }else{ - $('.cart-link').hide(); - $(".btn-share").hide(); - } }); @yield('scripts')