Como prevenir evento drag drop no input?
<input type="text" (drop)="onDrop($event)"></div>
export class DropComponent {
onDrop(event) {
event.preventDefault();
}
}
prevent drag in input Angular 5
Como prevenir evento drag drop no input?
<input type="text" (drop)="onDrop($event)"></div>
export class DropComponent {
onDrop(event) {
event.preventDefault();
}
}
prevent drag in input Angular 5
Há em nossas aplicações mobile sempre a necessidade de enviar notificações push aos usuários dos nossos app.
O Google vem mudando recentemente o GCM para FCM (Firebase Cloud Messassing).
Neste post mostro como realizar o envio através do PostMan.


{
"to": "seu token ou instance id ou device token gerado ao registrar o app do usuário",
"notification" : {
"body" : "Um novo post sobre notificação firebase ionic!",
"title" : "CTASoftware Blog",
"content_available" : "true",
"priority" : "high"
},
"data" : {
"body" : "Um novo post sobre notificação firebase ionic!",
"title" : "CTASoftware Blog",
"content_available" : true,
"priority" : "high"
}
}
Para saber mais sobre todos os parâmetros utilize a documentação do firebase https://firebase.google.com/docs/cloud-messaging/http-server-ref
Abraços.
O PHP por default não aceita Authorization enviado no header.
Para utilizar se faz necessário alterar o .htaccess do apache.
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* – [e=HTTP_AUTHORIZATION:%1]
Gera GUID em JavaScript.
[js]
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + ‘-‘ + s4() + ‘-‘ + s4() + ‘-‘ +
s4() + ‘-‘ + s4() + s4() + s4();
}
[/js]
O css e html abaixo alteram o padrão do input file para uma imagem.
css
[css]
.image-upload > input
{
display: none;
}
[/css]
HTML
[html]
[/html]
Resultado
![]()
Simples assim…
Formata CPF em JavaScript.
Obs: Não faz validação, apenas formata.
[js]
function formatarCPFExibicaoApenas(v) {
if (v != undefined) {
if (v.length <= 14) { //CPF
//Coloca um ponto entre o terceiro e o quarto dígitos
v = v.replace(/(\d{3})(\d)/, "$1.$2")
//Coloca um ponto entre o terceiro e o quarto dígitos
//de novo (para o segundo bloco de números)
v = v.replace(/(\d{3})(\d)/, "$1.$2")
//Coloca um hífen entre o terceiro e o quarto dígitos
v = v.replace(/(\d{3})(\d{1,2})$/, "$1-$2")
return v;
}
}
}
[/js]
Script para geração de senha em JavaScript
[js]
// Gera um número aleatório
function returnRand() {
var randomization = Math.random().toString();
var lengthNumbers = randomization.length;
var sort = randomization.substring(lengthNumbers, lengthNumbers – 1);
return sort;
}
// Gera uma senha simples
function generatePasswordEasy() {
var retorno = ‘password’;
var letters = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’];
retorno = letters[returnRand()].toUpperCase() + letters[returnRand()] + letters[returnRand()] +
returnRand() + returnRand() + returnRand();
return retorno;
}
// Gera uma senha complexa
function generatePassword(len) {
var pwd = [],
cc = String.fromCharCode,
R = Math.random,
rnd, i;
pwd.push(cc(48 + (0 | R() * 10))); // push a number
pwd.push(cc(65 + (0 | R() * 26))); // push an upper case letter
for (i = 2; i < len; i++) {
rnd = 0 | R() * 62; // generate upper OR lower OR number
pwd.push(cc(48 + rnd + (rnd > 9 ? 7 : 0) + (rnd > 35 ? 6 : 0)));
}
// shuffle letters in password
return pwd.sort(function() { return R() – .5; }).join(”);
}
[/js]
Faz a verificação se um e-mail é válido em JavaScript
[js]
function emailIsValid(email) {
var regexEmail = new RegExp(“[a-zA-Z0-9][a-zA-Z0-9._-]+@([a-zA-Z0-9._-]+.)[a-zA-Z-0-9]{2,3}”);
if (!regexEmail.test(email)) { return false; }
return true;
}
[/js]
Método para formatar telefone com 8 ou 9 dígitos em JavaScript.
[js]
function formataNumeroTelefone(ddd, numero) {
var length = numero.length;
var telefoneFormatado;
if (length === 8) {
telefoneFormatado = ‘(‘ + ddd + ‘) ‘ + numero.substring(0, 4) + ‘-‘ + numero.substring(4, 8);
} else if (length === 9) {
telefoneFormatado = ‘(‘ + ddd + ‘) ‘ + numero.substring(0, 5) + ‘-‘ + numero.substring(5, 9);
}
return telefoneFormatado;
}
[/js]
Até a próxima
Lendo JSON rapidamente em C#
[js]
dynamic array = JsonConvert.DeserializeObject(json);
foreach(var item in array)
{
Console.WriteLine(“{0} – {1}”, item.Nome, item.Telefone);
}
[/js]
Você precisa fazer login para comentar.