javascript
This file contains 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
let data = moment($(this).val()).add(10, 'days').toDate(); | |
$('#data-final').val(moment(data).format("YYYY-MM-DD")); |
This file contains 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 carregarListaDeAnexosDocumento() { | |
let $selectAnexos = $('.lista-anexos'); | |
let listaDeAnexos = DocumentoVisualizacaoForm.retornaListaAnexosDocumento(); | |
listaDeAnexos.forEach(function (anexo) { | |
console.log(anexo) | |
optText = anexo.nomeOriginal; | |
optValue = anexo.id; | |
$selectAnexos.append($('<option>').val(optValue).text(optText)); | |
}); | |
}; |
This file contains 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 query = `select id, nome from USUARIO`; | |
const params = JSON.stringify({ | |
connectionName: 'CONEXAO', | |
query: query | |
}); | |
Ecm.ajax(BASE_URL + '/api/v2/integracao/select', params) | |
.done(onAjaxSuccess) | |
.fail(onAjaxError); | |
function onAjaxSuccess(provas) { | |
debugger; | |
} | |
function onAjaxError(error) { | |
debugger; | |
console.log('error: ', error); | |
} |
This file contains 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 getAccountAjax(id, callback) { | |
$.ajax({ | |
type: 'GET', | |
async: false, | |
contentType: 'application/json', | |
url: 'controller/get_objeto/' + id + '/' + metodo, | |
success: (function (objeto) { | |
callback(objeto, false); | |
}), | |
error: (function (erro) { | |
callback(erro, true); | |
}) | |
}); | |
} | |
getAccountAjax('1', function (result, error) { | |
if (result.status == true && error === false) { | |
//aqui retorna o true ou dados que vem da api | |
} | |
if (!result.status && error === false) { | |
//erro interno na api | |
} | |
if (error === true) { | |
//erro do evento ajax | |
console.log(result) | |
} | |
}); |
This file contains 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 ajax(options) { | |
return new Promise(function (resolve, reject) { | |
$.ajax(options).done(resolve).fail(reject); | |
}); | |
} | |
ajax({ | |
url: someURL, | |
type: 'post', | |
contentType: 'application/json; charset=utf-8', | |
data: JSON.stringify({ | |
something: something, | |
anotherthing: anotherthing | |
}) | |
}).then( | |
function fulfillHandler(data) { | |
// ... | |
}, | |
function rejectHandler(jqXHR, textStatus, errorThrown) { | |
// ... | |
} | |
).catch(function errorHandler(error) { | |
// ... | |
}); |
This file contains 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 _ajax(method, url) { | |
return new Promise(function (resolve, reject) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open(method, url); | |
xhr.onload = resolve; | |
xhr.onerror = reject; | |
xhr.send(); | |
}); | |
} | |
ajax('GET', 'http://sopt.moon') | |
.then(function (dados) { | |
console.log(dados); | |
}).catch(function (err) { | |
console.error('Oh não!!', err.statusText); | |
}); |
This file contains 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 visualizarAnexos(itemSelecionado) { | |
if ($(itemSelecionado.currentTarget).val() === '') { | |
$('#frameVisualizacao1').attr('src', ""); | |
return false; | |
}; | |
let idAnexoSelecionado = `#anexo-${$(itemSelecionado.currentTarget).val()}`; | |
$(idAnexoSelecionado).trigger('click'); | |
}; | |
function carregarListaDeAnexosDocumento() { | |
debugger; | |
let $selectAnexos = $('.lista-anexos'); | |
let listaDeAnexos = DocumentoVisualizacaoForm.retornaListaAnexosDocumento(); | |
listaDeAnexos.forEach(function (anexo) { | |
console.log(anexo) | |
optText = anexo.nomeOriginal; | |
optValue = anexo.id; | |
$selectAnexos.append($('<option>').val(optValue).text(optText)); | |
}); | |
}; | |
DocumentoVisualizacaoForm.camposCarregados(function () { | |
carregarListaDeAnexosDocumento(); | |
$('.lista-anexos').on('change', visualizarAnexos); | |
// $('#anexo1 .arquivo span[data-tipo-anexo-id="6" ]:first').closest('.arquivo').trigger('click'); | |
// $("#anexo1 .arquivo:first").trigger("click"); | |
}); |
This file contains 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
// convert first letter para cada primeira letra | |
function convertStringToCamelCase(str) { | |
debugger; | |
if (typeof (str) == "string") { | |
str.indexOf('_') > 0 ? str = str.split("-") : str = str.split("_"); | |
for (let i = 0; i < str.length; i++) { | |
if (i == 0) { | |
if (str[i].charAt(0) == str[i].charAt(0).toUpperCase()) { | |
str[i] = str[i]; | |
} | |
} else { | |
str[i] = str[i][0].toUpperCase() + str[i].substr(1); | |
} | |
}; | |
}; | |
str = str.join(''); | |
return str; | |
}; | |
convertStringToCamelCase("the-stealth-warrior"); |
This file contains 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 imageURL = 'https://img.jpg'; | |
const inputImage = new Image(); | |
inputImage.onerror = function(){ | |
// se der erro no carregamento da imagem, faça algo aqui | |
} | |
// a proporção desejada de nossa imagem de saída (largura/altura) | |
const outputImageAspectRatio = 1; | |
//queremos esperar por nossa imagem para carregar | |
inputImage.onload = () => { | |
let cropLength = 200; // quantidade de pixels que vai ser cortado em cima e embaixo | |
// armazena a largura e altura de nossa imagem | |
const inputWidth = inputImage.naturalWidth; | |
const inputHeight = inputImage.naturalHeight; | |
// calcular a posição para desenhar a imagem em | |
const outputX = 0; | |
const outputY = Number('-' + parseInt(cropLength / 2)); | |
// criar uma tela que apresentará a imagem de saída | |
const outputImage = document.createElement('canvas'); | |
// defini-lo para o mesmo tamanho que a imagem | |
outputImage.width = inputWidth; | |
outputImage.height = inputHeight - cropLength; | |
// desenhar nossa imagem na posição 0, 0 na tela | |
const ctx = outputImage.getContext('2d'); | |
ctx.drawImage(inputImage, outputX, outputY); | |
// mostrar tanto a imagem e o canvas na tela | |
document.body.appendChild(inputImage); | |
document.body.appendChild(outputImage); | |
} | |
inputImage.src = imageURL; |
This file contains 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
var menu = (() => { | |
let execultaAjax = (rota, parametros = "", metodo = "") => { | |
let objAjax = { | |
url: rota, | |
method: metodo, | |
success: done, | |
error: done | |
}; | |
parametros != "" ? objAjax.data = parametros : parametros; | |
$.ajax(objAjax); | |
function done(resposta, status, JQxhr) { | |
console.log(resposta); | |
}; | |
} | |
$(document).ready(() => { | |
//debugger; | |
execultaAjax("https://177.11.50.184/api-prova/api/Disciplina", "", "GET"); | |
//Ecm.registraEvento("", "", () => { | |
//}); | |
}) | |
})(); |
This file contains 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
let populaTabela = (disciplinas) => { | |
relatorio = $("#relatorio").DataTable({ | |
destroy: true, | |
data: disciplinas, | |
columns: [ | |
{ | |
data: "id", | |
name: "id", | |
title: "ID", | |
defaultContent: "-" | |
}, | |
{ | |
data: "ativo", | |
name: "ativo", | |
title: "Ativo", | |
defaultContent: "-" | |
}, | |
{ | |
data: "descricao", | |
name: "descricao", | |
title: "Descrição", | |
defaultContent: "-" | |
}, | |
{ | |
// Adiciona coluna alterar com botao | |
title: "Alterar", | |
data: null, | |
render: function (data, type, row) { | |
return '<button onclick="alterarUsuario(this);" class="botao-acao-alterar bg-white border-0"><img src="../images/bootstrap-icons/pencil.svg" class="bi bi-pencil" alt="Alterar"/></button>'; | |
} | |
}, | |
{ | |
// Adiciona coluna Excluir com botao | |
title: "Excluir", | |
data: null, | |
render: function (data, type, row) { | |
return '<button onclick="excluirUsuario(this);" class="botao-acao-excluir bg-white border-0"><img src="../images/bootstrap-icons/trash.svg" class="bi bi-trash" alt="Excluir"/></button>'; | |
} | |
} | |
], | |
paging: true, | |
info: true, | |
language: { | |
decimal: ",", | |
emptyTable: "Dados não encontrados.", | |
info: "Exibindo página _PAGE_ de _PAGES_", | |
infoEmpty: "", | |
infoFiltered: " - filtrado de _MAX_ resultados", | |
thousands: ".", | |
lengthMenu: "_MENU_ resultados", | |
search: "Procurar:", | |
zeroRecords: "Nenhum resultado encontrado", | |
paginate: { | |
first: "Primeira página", | |
last: "Última página", | |
previous: "Página anterior", | |
next: "Próxima página" | |
} | |
}, | |
buttons: [ | |
{ | |
extend: "csvHtml5", | |
text: "Exportar para CSV", | |
filename: "relatorio", | |
className: "btn red", | |
fieldSeparator: ";" | |
} | |
], | |
dom: "Bfrtip" | |
}); | |
} |
This file contains 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
// get-obj-path.js v1 | |
function getObjPath(obj, infos, path = 'this') { // infos = string | {param: string, value: string} | |
// let this_ = arguments.callee; | |
infos = typeof(infos) !== 'string' ? infos : { | |
param: infos, | |
value: infos | |
}; | |
if (typeof(obj) === 'object' && obj !== null) { | |
Object.keys(obj).forEach(function(key) { | |
let value = obj[key]; | |
let prefix = '.'; | |
let suffix = ''; | |
if (Array.isArray(obj)) { | |
prefix = '['; | |
suffix = ']'; | |
}; | |
if (key === infos.param || value === infos.value) { | |
console.log(path + prefix + key + suffix); | |
}; | |
if (typeof(value) === 'object') { // recursive | |
getObjPath(value, infos, path + prefix + key + suffix); | |
}; | |
}); | |
}; | |
}; |
This file contains 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
let diaDaSemana = new Date(2022,07,20); | |
diaDaSemana.toLocaleString('pt-br', {weekday: 'long'}) |
This file contains 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 getUrlSite() { | |
let nomeUrl = location.hostname; | |
let temPorta = location.port != '' ? location.port : '' | |
let temCaminhoServidor = window.location.pathname.split('/')[1] != '' ? window.location.pathname.split('/')[1] : ''; | |
let protolo = location.protocol; | |
let urlSite = ''; | |
// se tiver a porta coloca na url | |
if (location.port != '') { | |
urlSite = nomeUrl + ':' + temPorta; | |
if (window.location.pathname.split('/')[1] != '' && window.location.pathname.split('/')[1] === 'certacon-dev') { | |
urlSite = '/' + temCaminhoServidor; | |
} | |
urlSite = protolo + '//' + urlSite; | |
}else{ | |
urlSite = nomeUrl; | |
if (window.location.pathname.split('/')[1] != '' && window.location.pathname.split('/')[1] === 'certacon-dev') { | |
urlSite = urlSite + '/' + temCaminhoServidor; | |
} | |
urlSite = protolo + '//' + urlSite; | |
} | |
return urlSite; | |
} |
This file contains 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
$tabelaUsuarios.DataTable({ | |
data: usuarios, | |
destroy: true, | |
columns: [ | |
{ | |
title: "ID", | |
data: "id", | |
width: "", | |
}, | |
{ | |
title: "Nome", | |
data: "nome", | |
width: "", | |
}, | |
{ | |
title: "E-mail", | |
data: "email", | |
width: "" | |
}, | |
{ | |
title: "Permissão", | |
data: "permissao", | |
width: "" | |
}, | |
{ | |
// Adiciona coluna alterar com botao | |
title: "Alterar", | |
data: null, | |
render: function (data, type, row) { | |
return '<button onclick="alterarUsuario(this);" class="botao-acao-alterar bg-white border-0"><img src="../images/bootstrap-icons/pencil.svg" class="bi bi-pencil" alt="Alterar"/></button>'; | |
} | |
}, | |
{ | |
// Adiciona coluna Excluir com botao | |
title: "Excluir", | |
data: null, | |
render: function (data, type, row) { | |
return '<button onclick="excluirUsuario(this);" class="botao-acao-excluir bg-white border-0"><img src="../images/bootstrap-icons/trash.svg" class="bi bi-trash" alt="Excluir"/></button>'; | |
} | |
}, | |
], | |
"language": { | |
"aria": { | |
"sortAscending": ": ordenar crescente", | |
"sortDescending": ": ordenar decrescente" | |
}, | |
"emptyTable": "Nenhum resgistro", | |
"info": "Exibindo _START_ a _END_ de _TOTAL_ registros", | |
"infoEmpty": "Nenhum registro", | |
"infoFiltered": "(filtrado de _MAX_ registros)", | |
"lengthMenu": "Mostrar _MENU_", | |
"search": "Filtrar:", | |
"zeroRecords": "Nenhum resgistro", | |
"paginate": { | |
"previous": "Anterior", | |
"next": "Próximo", | |
"last": "Ultimo", | |
"first": "primeiro" | |
} | |
}, | |
buttons: [ | |
{ | |
extend: "csvHtml5", | |
text: "Exportar para CSV", | |
filename: "relatorio", | |
className: "btn red", | |
fieldSeparator: ";" | |
} | |
], | |
dom: "Bfrtip" | |
}); |
This file contains 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
// Declaração da gtag no index | |
// <!-- Global site tag (gtag.js) - Google Analytics --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=G-HCEH8P6CDM"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'T-JFHY9POMLK'); | |
</script> | |
// chamar o metodo gtag no script | |
gtag('event', 'page_view', { | |
'app_name': 'catalogo', // Nome da aplicação | |
'screen_name': 'Pesquisa: ' + search // rota ou info da pesquisa | |
}); |
This file contains 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
let functions = (function () { | |
function init() { | |
alert('chamou'); | |
} | |
return { | |
init | |
} | |
})(); | |
document.addEventListener("DOMContentLoaded", functions.init); |
This file contains 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
var cpf = document.querySelector("#cpf"); | |
cpf.addEventListener("blur", function(){ | |
if(cpf.value) cpf.value = cpf.value.match(/.{1,3}/g).join(".").replace(/\.(?=[^.]*$)/,"-"); | |
}); |
This file contains 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
bootbox.dialog({ | |
title: 'Adiconar Disciplina', | |
message: blocoHtml, | |
onEscape: true, | |
backdrop: true, | |
buttons: { | |
fee: { | |
label: 'Adicionar Disciplina', | |
className: 'btn-primary', | |
callback: function (e) { | |
//debugger; | |
let nomeDisciplina = $('#disciplina').val(); | |
let disciplinaEstaAtiva = $('#check-ativo').is(':checked'); | |
let objDisciplina = { | |
"id": 0, | |
"descricao": nomeDisciplina, | |
"ativo": disciplinaEstaAtiva | |
}; | |
DocumentoVisualizacaoForm.executarScriptExternoSemDocumento(idsScriptExternos.CadastrarDisciplinas, [{ | |
"CHAVE": "InformacoesDisciplina", "VALOR": JSON.stringify(objDisciplina) | |
}], | |
function (status, mensagem, objeto) { | |
//debugger; | |
if (mensagem == "Disciplina Cadastrada!") { | |
//Ecm.desbloquearElemento("#menu-dinamico"); | |
Ecm.alertSucesso('Disciplinas Cadastrada!'); | |
buscarDisciplinas(); | |
} else { | |
Ecm.alertWarning('Disciplinas não Cadastrada, tente novamente'); | |
} | |
}); | |
} | |
}, | |
fi: { | |
label: 'Cancelar', | |
className: 'btn-danger', | |
callback: function (e) { | |
} | |
} | |
} | |
}) |
This file contains 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
// phraseParser v.1 | |
function phraseParser(phrase, removeSpaces) { | |
debugger; | |
if (phrase != "" || phrase != " " || phrase != null) { | |
if(removeSpaces){ | |
phrase = phrase.replace(/[\s]/g, ""); | |
} | |
let totalCharacters = phrase.length; | |
let phraseWithBreakLines = phrase.replace(/(\n)/gm, ""); | |
let totalWords = phraseWithBreakLines.match(/[\w]+/g).length; | |
let totalLines = phrase.match(/(\n)/g) == null ? 1 : phrase.match(/(\n)/g).length; | |
return { | |
characters: totalCharacters, | |
words: totalWords, | |
lines: totalLines | |
} | |
} else { | |
alert("Informe uma frase"); | |
} | |
} | |
console.log( | |
phraseParser("Once upon a time", true) | |
); |
This file contains 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 carregarclientes() { | |
$.getJSON("data.html", function(dados) { | |
$(dados).each(function(index) { | |
$('#table').append('<tbody><tr><td>' + $(this).nome + '</td>' + | |
'<td>' + $(this).idade + '</td>' + | |
'<td>' + $(this).cpf + '</td>' + | |
'<td>' + $(this).rg + '</td>' + | |
'<td>' + $(this).data_nasc + | |
'</td></tr></tbody>'); | |
}); | |
}); | |
} | |
carregarclientes(); |
This file contains 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
// Retorno do catch | |
const myPromisse3 = new Promise(function(resolve, reject){ | |
debugger; | |
// nome simula que veio de uma requisição externa | |
const nome = "João"; | |
if (nome === "Wilson"){ | |
resolve('Usuário Matheus encontrado'); | |
} | |
else{ | |
reject('Usuário não encontrado'); | |
} | |
}); | |
myPromisse3.then(function(data){ | |
console.console(data); | |
}).then(function(data){ | |
console.log(data); | |
return data.toLowerCase(); | |
}).catch(function(erro){ | |
console.log('Aconteceu um erro' + erro); | |
}); |
This file contains 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
// replace-text-with.js v1.1.2 | |
function replaceTextWith(text, ObjOrBefore, after) { | |
let before = ObjOrBefore; | |
// convert string to array | |
before = typeof before === 'string' ? [before] : before; | |
after = typeof after === 'string' ? [after] : after; | |
// convert obj to array | |
if (!Array.isArray(before)) { | |
after = Object.values(before); | |
before = Object.keys(before); | |
before.forEach(function(beforeString, index) { | |
before[index] = '@@' + beforeString + '@@'; | |
}); | |
}; | |
before.forEach(function(beforeString, index) { | |
let afterString = after[index]; | |
text = text.split(beforeString).join(afterString); | |
}); | |
return text; | |
}; | |
String.prototype.replaceTextWith = function(before, after) { | |
let text = this.toString(); | |
return replaceTextWith(text, before, after); | |
}; |
This file contains 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
// get campos por processo e atividade v1 | |
var settings = { | |
"url": BASE_URL + "/api/ecm/processos/27/atividades/2/pendencias", | |
"method": "GET", | |
"timeout": 0, | |
"headers": { | |
"Authorization": Ecm.token, | |
"Content-Type": "application/json" | |
}, | |
}; | |
$.ajax(settings).done(function (data) { | |
debugger; | |
var qra = []; | |
data.Pendencias.forEach((linha, index) => { | |
qra.push(linha.QRA); | |
}); | |
console.log(data.documentos); | |
$("#CAMPO_2,#CAMPO_21,#motorista,#auxiliar,#agente").autocomplete({ | |
source: qra, | |
select: function (event, ui) { | |
//debugger; PreencherGuardaGrid(ui.item.value) | |
} | |
}); | |
$(".ui-autocomplete ").css("z-index", "9999999"); | |
}); |
This file contains 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 rotacao(V, Q) { | |
let index = 0; | |
if (V.length > 0){ | |
while(index < Q){ | |
V.unshift(V.pop()); | |
index++; | |
} | |
return V; | |
} else { | |
return V; | |
} | |
} | |
console.log(rotacao(["A", "B", "C", "D", "E"], 2)) |
This file contains 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
//api select integracao com promisse | |
const query = `select id, nome from USUARIO`; | |
const params = JSON.stringify({ | |
connectionName: 'CONEXAO', | |
query: query | |
}); | |
Ecm.ajax(BASE_URL + '/api/v2/integracao/select', params) | |
.done(onAjaxSuccess) | |
.fail(onAjaxError); | |
function onAjaxSuccess(provas) { | |
debugger; | |
} | |
function onAjaxError(error) { | |
debugger; | |
console.log('error: ', error); | |
} |
This file contains 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
let regex = /^\d+(?:\.\d{0,2})$/; | |
if (regex.test($(td).text())) { | |
$(td).css("background-color", "#ff6a6a") | |
} |
This file contains 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
// via-cep.js v1 | |
function viaCEP(cep) { | |
return { | |
then: function(cb) { | |
$.ajax({ | |
type: 'GET', | |
url: 'https://viacep.com.br/ws/' + cep + '/json/' | |
}).done(function(response, textStatus, jqXHR) { | |
cb(response, textStatus, jqXHR); | |
}); | |
} | |
}; | |
}; | |
let cep = '30350100'; | |
viaCEP(cep).then(function(response) { | |
console.log(response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment