xxxxxxxxxx
<script type="text/javascript">
$(function () {
$("#chkPassport").click(function () {
if ($(this).is(":checked")) {
$("#dvPassport").show();
} else {
$("#dvPassport").hide();
}
});
});
</script>
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
1. Install Typescript and types
2. Create a tsconfig.json file
3. Set up your scripts to run tsc and then access the outputted .js files
4. Tweak your file structure to hold src and dist folders
5. Check your project still works
ref: https://medium.com/@mhuckstepp/step-by-step-guide-to-convert-an-existing-express-node-js-backend-to-typescript-931e435ea95d
ref: https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html
ref: https://plainenglish.io/blog/how-to-convert-node-js-code-from-javascript-to-typescript-8e7d031a8f49
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
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.display === "block") {
panel.style.display = "none";
} else {
panel.style.display = "block";
}
});
}
xxxxxxxxxx
require
(["esri/config","esri/Map", "esri/views/MapView"],
function (esriConfig,Map , MapView)
{
esriConfig.apiKey = "AAPKb4dd8a4b511d47db90c8eb0dcd2f50dcUqecvStaAu60DxJYTEyki8OncuffK0-bbJeKr_N678ONK4QAkTDPYa8wI5Wkeksr";
const mymap = new Map({
basemap: "arcgis-topographic" // Basemap layer service
});
const view = new MapView({
map: mymap,
center: [-118.805, 34.027], // Longitude, latitude
zoom: 13, // Zoom level
container: "viewDiv" // Div element
});
}
);
xxxxxxxxxx
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
xxxxxxxxxx
case '/local/forgot':
if( req.method==='POST' ) {
const email=req.body.email.toLowerCase();
return server.get_user_by_email( email ).then ( p => {
if ( p ) {
server.push_token( p, common.get_uuid() );
return res.redirect(`/auth/local/email_sent?email=${email}`);
}
else
return res.redirect(`/auth/local/forgot`);
});
}
xxxxxxxxxx
case '/local/forgot':
if( req.method==='POST' ) {
const email=req.body.email.toLowerCase();
return server.get_user_by_email( email ).then ( p => {
if ( p ) {
server.push_token( p, common.get_uuid() );
return res.redirect(`/auth/local/email_sent?email=${email}`);
}
else
return res.redirect(`/auth/local/forgot`);
});
}
xxxxxxxxxx
update_password( password, user_token ) {
this.mongodb.collection( "users" ).updateOne( { [`password_recovery_tokens.${user_token}`]: {$exists: true} }, {$set : { password : crypto.createHash('sha256').update(password).digest('base64') } } )
}
xxxxxxxxxx
update_password( password, user_token ) {
this.mongodb.collection( "users" ).updateOne( { [`password_recovery_tokens.${user_token}`]: {$exists: true} }, {$set : { password : crypto.createHash('sha256').update(password).digest('base64') } } )
}