123 }
124
125 let url = "/client/" + input.value + "/cpf-cnpj";
126 $.get(url, function(data){127 if (data === "True") {128 $("#cpfCnpj").addClass("is-invalid");129 $("#cpfCnpj").removeClass("is-valid");130 $("#cpfCnpj").next().text("CPF/CNPJ já cadastrado");131 input.setCustomValidity("CPF/CNPJ já cadastrado");132 } else {133 $("#cpfCnpj").addClass("is-valid");134 $("#cpfCnpj").removeClass("is-invalid");135 $("#cpfCnpj").next().text("");136 input.setCustomValidity("");137 }138 });139}
140
141/**
29 */
30function validateEmail(input) {
31 let url = "/user/" + input.value + "/email";
32 $.get(url, function(data){ 33 if (data === "True") { 34 $("#email").addClass("is-invalid"); 35 $("#email").removeClass("is-valid"); 36 $("#email").next().text("Email já cadastrado"); 37 input.setCustomValidity("Email já existe, por favor informe outro"); 38 } else { 39 $("#email").addClass("is-valid"); 40 $("#email").removeClass("is-invalid"); 41 $("#email").next().text(""); 42 input.setCustomValidity(""); 43 } 44 }); 45}
46
47/**
7 */
8function validateLogin(input) {
9 let url = "/user/" + input.value + "/login";
10 $.get(url, function(data){ 11 if (data === "True") { 12 $("#username").addClass("is-invalid"); 13 $("#username").removeClass("is-valid"); 14 $("#username").next().text("Login já cadastrado"); 15 input.setCustomValidity("Login já existe, por favor escolha outro"); 16 } else { 17 $("#username").addClass("is-valid"); 18 $("#username").removeClass("is-invalid"); 19 $("#username").next().text(""); 20 input.setCustomValidity(""); 21 } 22 }); 23}
24
25/**
7 if (zip_code.length !== 8) {
8 return;
9 } else {
10 $.get(url, function(data){11 $("#state").val(data.state);12 selectCity(data.city);13 $("#neighborhood").val(data.neighborhood);14 $("#street").val(data.street);15 $("#complement").val(data.complement);16 });17 }
18});
1$(document).ready(function() { 2 $('#summernote').summernote({ 3 placeholder: '', 4 height: 200, 5 minHeight: null, 6 maxHeight: null, 7 focus: false, 8 toolbar: [ 9 // [groupName, [list of button]]10 ['style', ['bold', 'italic', 'underline', 'clear']],11 ['font', ['strikethrough', 'superscript', 'subscript']],12 ['para', ['ul', 'ol']],13 ['insert', ['link', 'picture', 'video']],14 ['view', ['codeview', 'undo', 'redo']]15 ]16 });17});
It is recommended to use arrow functions as callbacks.
Arrow functions can be an attractive alternative to function expressions for callbacks or function arguments.
For example, arrow functions are automatically bound to their surrounding scope/context. This provides an alternative to the pre-ES6 standard of explicitly binding function expressions to achieve similar behavior.
Additionally, arrow functions are:
less verbose, and easier to reason about.
bound lexically regardless of where or when they are invoked.
func(function(a) { return a; }); // ERROR
// prefer: func(a => a)
func(function() { return this.a; }.bind(this)); // ERROR
// prefer: func(() => this.a)
// arrow function callback
func(a => a); // OK
// generator as callback
func(function*() { yield; }); // OK
// function expression not used as callback or function argument
var funcVar = function func(a) { return a; }; // OK
// unbound function expression callback
func(function() { return this.a; }); // OK
// recursive named function callback
func(function recursiveFunc(n) { return n && n + recursiveFunc(n - 1); }); // OK