Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafael Far rrfaria

  • Rafael Far
  • Brazil
View GitHub Profile
View dynamic-event.js
var __ = function () {
this.context = [];
var self = this;
this.selector = function (_elem, _sel) {
return _elem.querySelectorAll(_sel);
}
this.on = function (_event, _element, _function) {
this.context = self.selector(document, _element);
document.addEventListener(_event, function (e) {
var elem = e.target;
@rrfaria
rrfaria / dynamic-event-es6.js
Last active Jun 11, 2019
dynamic event ES6
View dynamic-event-es6.js
class handler {
constructor(element) {
this.el = document.querySelectorAll(element);
this.selector = element;
this.self = this;
}
isClass(elem, clss) {
const names = elem.className.trim().split(" ");
const len = names.length;
@rrfaria
rrfaria / currencyMask.html
Created Mar 22, 2019
Mascara para Moeda - Money mask - Currency mask - Need Refac - based on (https://gist.github.com/antoniopassos/203181)
View currencyMask.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Mask</title>
</head>
@rrfaria
rrfaria / countdownasyncawait.js
Last active Mar 22, 2019
Countdown with async await
View countdownasyncawait.js
const go = {
timer: null,
message:'',
time:0,
countdown: (duration = 10) => {
clearInterval(go.timer);
return new Promise(function(resolve, reject) {
go.timer = setInterval(function() {
go.time--;
console.log(go.message + ':' + go.time);
@rrfaria
rrfaria / App.js
Created May 11, 2018
React redux and Transition Group
View App.js
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import {
BrowserRouter as Router,
Switch,
Route,
Link,
Redirect
} from 'react-router-dom';
import { ConnectedRouter } from 'react-router-redux';