1jQuery( document ).ready( async function ($){ 2 3 let cartTotalDomElems = $('.crwCartTotal'); 4 if( cartTotalDomElems.length ) displayCartTotal(); 5 6 7 /** 8 * set the cart sticker to the total contents 9 * logs error if could not set the cort total 10 */ 11 async function displayCartTotal(){ 12 try{ 13 //simple update the cart total on the dom element with class .crwCartTotal 14 function updateCartTotalOnDom(n){ 15 cartTotalDomElems.text(`${n}`) 16 } 17 18 //update with the cookied cart total 19 let CT = $.cookie('cartTotal') ?? 0 //current total 20 updateCartTotalOnDom(CT) 21 22 let cart = JSON.parse( await i_lib_class.salesDoc_getCurrentCartPkg() ) 23 let NCT = cart.Data.Cart.ItemCount// new cart total 24 25 //if val has changed => update cookie and display 26 if(NCT != CT ){ 27 let path = "/;SameSite=Lax" 28 updateCartTotalOnDom(NCT) 29 //only setting the cookie anew if not set to prevent overlived cookie 30 if( typeof $.cookie(`cartTotal`) !== "undefined" ) { 31 $.cookie (`cartTotal` , NCT , { path: path } ) 32 } 33 else{ 34 $.cookie (`cartTotal`, NCT , { expires: 240 / 1440, path: path }); 35 } 36 } 37 } 38 catch( e ){ 39 console.log( "Error: failed to update the DOM cart total. " , e ) 40 } 41 } 42 43})
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.