1function toggleCalculator() { 2 3 let widthProduct = document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_altura'); 4 if (!widthProduct) { 5 return; 6 } 7 8 document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto').style.display = 'block'; 9} 10 11function getDimension() { 12 let dimensions = { 13 'heigth': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_altura').value, 14 'width': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_largura').value, 15 'length': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_comprimento').value, 16 'weight': document.querySelector('#woocommerce-correios-calculo-de-frete-na-pagina-do-produto #calculo_frete_produto_peso').value 17 } 18 return dimensions; 19} 20 21/** 22 * mask to replace non number 23 * @param {string} content - number to format 24 * @returns {string} 25 * @example 26 * const valueToFormat = '12345678' 27 * numberMask(valueToFormat); 28 */ 29function numberMask(content) { 30 return content.replace(/[^0-9-]+/g, ""); 31} 32 33/** 34 * mask to format postal code 35 * @param {string} content - postal code number 36 * @returns {string} 37 * @example 38 * const valueToFormat = '12345678' 39 * postalCodeMask(valueToFormat); 40 */ 41 function postalCodeMask(content, input) { 42 let value = content; 43 let formatedValue = ''; 44 45 if(isNaN(content)) { 46 input.value = numberMask(content); 47 48 return; 49 } 50 51 //regex to add " - " in position 5 of cep: EX:123456-78 52 formatedValue = value.replace(/(\d{5})(\d{1,2})$/, "$1-$2"); 53 input.value = formatedValue; 54} 55 56/** 57 * this function is used to apply the postal code mask in the input to calculate the quotation 58 */ 59function usePostalCodeMask(evt='') { 60 const inputDefault = evt ? evt.target : evt; 61 const inputShortcode = document.querySelector('.iptCepShortcode'); 62 63 64 if(inputDefault) { 65 const content = inputDefault.value; 66 postalCodeMask(content, inputDefault); 67 } 68 69 if(inputShortcode) { 70 const content = inputShortcode.value; 71 postalCodeMask(content, inputShortcode); 72 } 73} 74 75function validateNumber(event) { 76 var key = window.event ? event.keyCode : event.which; 77 if (event.keyCode === 8 || event.keyCode === 46) { 78 return true; 79 } else if (key < 48 || key > 57) { 80 return false; 81 } else { 82 return true; 83 } 84};
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.