1axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; 2 3class CartEvent extends EventEmitter { 4 async onPage() { 5 this.emit('view_cart'); 6 this.emit('loading', false); 7 } 8 9 async getCart() { 10 this.emit('loading', true); 11 const { data } = await axios.get(`index.php?route=extension/module/cart/list`); 12 13 this.emit('loaded_cart', data); 14 this.emit('loading', false); 15 } 16 17 async getCartModal(event = true) { 18 this.emit('loading', true); 19 20 const { data } = await axios.get(`index.php?route=extension/module/cart/modal`); 21 22 if (event) { 23 this.emit('view_cart_modal', data); 24 } else { 25 this.emit('load_cart_modal', data); 26 } 27 28 this.emit('loading', false); 29 } 30 31 async openModal() { 32 await this.getCartModal(); 33 } 34 35 async remove(key) { 36 const { data } = await axios.post(`index.php?route=checkout/cart/remove`, { 37 key, 38 }); 39 40 this.emit('removed', data); 41 } 42 43 async add(product_id = 0, quantity) { 44 await axios.post(`index.php?route=checkout/cart/edit`, { 45 product_id: product_id, 46 quantity: (typeof(quantity) != 'undefined' ? quantity : 1), 47 }); 48 49 this.emit('added', {product_id,quantity}); 50 } 51 52 async update(cart_id, quantity) { 53 54 let payload = {}; 55 payload[cart_id] = quantity; 56 57 this.emit('updating'); 58 59 60 const { data } = await axios.post(`index.php?route=checkout/cart/edit`, { 61 quantity: payload 62 }); 63 64 this.emit('updated', cart_id, quantity, data); 65 } 66} 67 68Cart = new CartEvent(); 69 70 71function voucherRemove(key) { 72 $.ajax({ 73 url: 'index.php?route=checkout/cart/remove', 74 type: 'post', 75 data: 'key=' + key, 76 dataType: 'json', 77 beforeSend: function() { 78 $('#header-cart .loading').show(); 79 }, 80 complete: function() { 81 $('#header-cart .loading').fadeOut(); 82 }, 83 success: function(json) { 84 handlerLoadCart(); 85 }, 86 error: function(xhr, ajaxOptions, thrownError) { 87 console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 88 } 89 }); 90}
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.