xxxxxxxxxx
1. Add tsconfig.json file to project
2. Integrate with a build tool
3. Change all .js files to .ts files
4. Check for any errors
xxxxxxxxxx
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
});
}
xxxxxxxxxx
const Validacao =() => {
const {getFieldProps, handleSubmit, isValid} = useFormik({
initialValues: {
name:'',
contact:{
email:'',
phone:''
}
},
validate: values => {
const err ={}
const message= ' campo obrigatorio'
if(!values.name) err.name = message
if(!values.contact.email) err.email = message
return err
},
onSubmit: (values, bag) => {
console.log(values)
}
})
const [name, metadataName] = getFieldProps('name','text')
const [email, metadataEmail] = getFieldProps('contact.email', 'text')
const [phone, metadataPhone] = getFieldProps('contact.phone', 'text')
xxxxxxxxxx
const swaggerAutogen = require('swagger-autogen')()
const outputFile = './swagger_output.json'
const endpointsFiles = ['./endpoints.js']
swaggerAutogen(outputFile, endpointsFiles)
xxxxxxxxxx
function parseJwt(token) {
var base64Payload = token.split('.')[1];
var payload = Buffer.from(base64Payload, 'base64');
return JSON.parse(payload.toString());
}
xxxxxxxxxx
$('.digit-group').find('input').each(function() {
$(this).attr('maxlength', 1);
$(this).on('keyup', function(e) {
var parent = $($(this).parent());
if(e.keyCode === 8 || e.keyCode === 37) {
var prev = parent.find('input#' + $(this).data('previous'));
if(prev.length) {
$(prev).select();
}
} else if((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 65 && e.keyCode <= 90) || (e.keyCode >= 96 && e.keyCode <= 105) || e.keyCode === 39) {
var next = parent.find('input#' + $(this).data('next'));
if(next.length) {
$(next).select();
} else {
if(parent.data('autosubmit')) {
parent.submit();
}
}
}
});
});
xxxxxxxxxx
var myModal = document.getElementById('myModal')
var myInput = document.getElementById('myInput')
myModal.addEventListener('shown.bs.modal', function () {
myInput.focus()
})
xxxxxxxxxx
public getValue(): string {
return this.inputNode.value;
}
public get inputNode(): HTMLSelectElement {
return this.node.getElementsByTagName("select")[1];
}
}