#dfjasdf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function flatten(A){ | |
| return A.reduce((previous, current) =>{ | |
| if(Array.isArray(current)) current = flatten(current) | |
| return previous.concat(current) | |
| }, []) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| import './style.scss' | |
| export default class Form extends Component { | |
| constructor() { | |
| super() | |
| this.state = { | |
| sentData: false | |
| } | |
| this.validateFields = this.validateFields.bind(this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| import './style.scss' | |
| class Form extends Component { | |
| constructor() { | |
| super() | |
| this.state = { | |
| sentData: false | |
| } | |
| this.validateFields = this.validateFields.bind(this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| import Form from './Form.jsx' | |
| import fieldsets from './fieldsets.js' | |
| import FieldsetsValidator from './fieldsets-validator.js' | |
| import './style.scss' | |
| class FormWrapper extends Component { | |
| constructor() { | |
| super() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const validateEmail = ({ email }) => { | |
| const regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
| if (!regex.test(email)) throw 'email format is not correct!' | |
| } | |
| const validatePasswords = ({ password, confirmation }) => { | |
| if (password !== confirmation) throw 'passwords do not match!' | |
| } | |
| const validateUsername = ({ username }) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fieldsets from './fieldsets.js' | |
| class FieldsetsValidator { | |
| verifyIfThereIsInputEmpty(fieldsetsData) { | |
| let inputsData = [] | |
| fieldsetsData.forEach(({ inputs }) => { | |
| for (let name in inputs) { | |
| if (!inputs[name]) throw 'one or more fields are empty' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react' | |
| class Form extends Component { | |
| constructor() { | |
| super() | |
| this.onSubmit = this.onSubmit.bind(this) | |
| } | |
| //public method | |
| getData() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function processarFormulario(evento){ | |
| evento.preventDefault() | |
| /*codigo para validacao*/ | |
| } | |
| var form = document.querySelector('form') | |
| form.addEventListener('submit', processarFormulario) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| geolocationToPixel({ lat, lng }) { | |
| const bounds = this.map.getBounds() | |
| const geolocation = new google.maps.LatLng({ lat, lng }) | |
| , topRight = this.map.getProjection().fromLatLngToPoint(bounds.getNorthEast()) | |
| , bottomLeft = this.map.getProjection().fromLatLngToPoint(bounds.getSouthWest()) | |
| , scale = Math.pow(2, this.map.getZoom()) | |
| , worldPoint = this.map.getProjection().fromLatLngToPoint(geolocation) | |
| return new google.maps.Point((worldPoint.x - bottomLeft.x) * scale, (worldPoint.y - topRight.y) * scale) |