Comparing version 1.2.1 to 1.2.2
@@ -18,27 +18,33 @@ window.onload = () => { | ||
function generalAction(dataId, type) { | ||
const validatedAction = document.querySelector('#validatedAction'+type); | ||
const generatedAction = document.querySelector('#generatedAction'+type); | ||
const validatedAction = document.querySelector('#validatedAction' + type); | ||
const generatedAction = document.querySelector('#generatedAction' + type); | ||
generatedAction.onclick = () => { | ||
console.log(`generatedAction.onclick`) | ||
const generatedInput = document.querySelector('#generated'+type); | ||
generatedInput.value = jsbrasil.fakerBr[dataId](); | ||
if (generatedAction) { | ||
generatedAction.onclick = () => { | ||
console.log(`generatedAction.onclick`) | ||
const generatedInput = document.querySelector('#generated' + type); | ||
generatedInput.value = jsbrasil.fakerBr[dataId](); | ||
} | ||
} | ||
validatedAction.onclick = () => { | ||
console.log(`validatedAction.onclick`) | ||
const validatedInput = document.querySelector('#validated'+type); | ||
const masked = jsbrasil.maskBr[dataId](validatedInput.value); | ||
const validated = jsbrasil.validateBr[dataId](validatedInput.value); | ||
document.querySelector('#validatedResult'+type).classList.remove('hidden'); | ||
if (validatedAction) { | ||
validatedAction.onclick = () => { | ||
console.log(`validatedAction.onclick`) | ||
const validatedInput = document.querySelector('#validated' + type); | ||
const masked = jsbrasil.maskBr[dataId](validatedInput.value); | ||
const validated = jsbrasil.validateBr[dataId](validatedInput.value); | ||
if (validated) { | ||
document.querySelector('#valicon'+type).innerHTML = 'thumb_up'; | ||
document.querySelector('#valtext'+type).innerHTML = 'Parabéns, '+ masked + ' tem a formatação válida!'; | ||
} else { | ||
document.querySelector('#valicon'+type).innerHTML = 'thumb_down'; | ||
document.querySelector('#valtext'+type).innerHTML = 'Esta informação NÃO está correta!'; | ||
document.querySelector('#validatedResult' + type).classList.remove('hidden'); | ||
if (validated) { | ||
document.querySelector('#valicon' + type).innerHTML = 'thumb_up'; | ||
document.querySelector('#valtext' + type).innerHTML = 'Parabéns, ' + masked + ' tem a formatação válida!'; | ||
} else { | ||
document.querySelector('#valicon' + type).innerHTML = 'thumb_down'; | ||
document.querySelector('#valtext' + type).innerHTML = 'Esta informação NÃO está correta!'; | ||
} | ||
} | ||
} | ||
} | ||
@@ -45,0 +51,0 @@ function makeHeader() { |
@@ -185,3 +185,11 @@ "use strict"; | ||
titulo: makeGeneric('titulo'), | ||
processo: makeGeneric('processo') | ||
processo: makeGeneric('processo'), | ||
utils: { | ||
numberToString: function (n) { | ||
if (!n || typeof n === 'string') { | ||
return n; | ||
} | ||
return (n + '').replace('.', ','); | ||
} | ||
} | ||
}; | ||
@@ -188,0 +196,0 @@ /** |
{ | ||
"name": "js-brasil", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Javascript Utils para Brasil (cpf, cnpj...)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -211,3 +211,11 @@ import { isArray, processCaretTraps } from './utils'; | ||
titulo: makeGeneric('titulo'), | ||
processo: makeGeneric('processo') | ||
processo: makeGeneric('processo'), | ||
utils: { | ||
numberToString: (n) => { | ||
if (!n || typeof n === 'string') { | ||
return n; | ||
} | ||
return (n + '').replace('.', ','); | ||
} | ||
} | ||
}; | ||
@@ -214,0 +222,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
845952
76
14229