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
/** | |
* getAllUrlParams( @url ); | |
* url: https://www.sitepoint.com/get-url-parameters-with-javascript/ | |
*/ | |
function getAllUrlParams(url) { | |
var queryString = url ? url.split('?')[1] : window.location.search.slice(1); | |
var obj = {}; | |
if (queryString) { |
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(){ | |
function randomErrors(){ | |
var errorMessages = ['Unexpected Error!','Something happended, please try again']; | |
var randomMessage = errorMessages[Math.floor(Math.random() * errorMessages.length)]; | |
var currentURL = (window.location != window.parent.location) ? document.referrer : document.location; | |
if (confirm( randomMessage )) { | |
window.location.reload(true); | |
} else { | |
window.location.reload(true); | |
} |
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
// react then checkbox change state | |
$('input[type="checkbox"]').on('change', function(e) { | |
if( this.checked ) { | |
console.log('checked'); | |
} else { | |
console.log('not checked'); | |
} | |
}); | |
// check |
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
// Arrow SCSS Mixin | |
// | |
// Easy creation of CSS-only directional arrows | |
// | |
// .arrow { | |
// @include arrow(100px, #f60, up); | |
// } | |
@mixin arrow($size: 10px, $color: inherit, $direction: down) { |
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
// Shortcut to get elements | |
var $ = function(element) { | |
if (element.charAt(0) === "#") { // If passed an ID... | |
return document.querySelector(element); // ... returns single element | |
} | |
return document.querySelectorAll(element); // Otherwise, returns a nodelist | |
}; |
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
/*! | |
* numberToCurrency(@number) | |
* transforms a number to currency used in Chile, adds '$'' | |
* @number: int | |
* http://stackoverflow.com/a/17563787/2148418 | |
* USE: numberToCurrency(876142) // returns $876.142 | |
*/ | |
function numberToCurrency(number){ | |
return "$" + (number + "").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."); | |
} |
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
/** | |
* multipleEventsListeners.js | |
* Add the capability to attach multiple events to an element, just like jQuery does | |
* https://gist.github.com/juanbrujo/a1f77db1e6f7cb17b42b | |
*/ | |
function multipleEventsListeners(elem, events, func) { | |
var event = events.split(' '); | |
for (var i = 0; i < event.length; i++) { | |
elem.addEventListener(event[i], func, false); |
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
// Given this array: | |
var arr = [ | |
{ | |
"pais": "Chile", | |
"herramienta": "GTalk, Mailchimp", | |
"fecha": "ayer" | |
}, | |
{ | |
"pais": "Argentina", | |
"herramienta": "JIRA, Mailchimp", |
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
/** | |
* output from sass-maps-index-iterator.scss | |
*/ | |
li:nth-of-type(1):before { | |
content: "english - hello"; | |
} | |
li:nth-of-type(2):before { | |
content: "spanish - hola"; | |
} |
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
// moduleName = name of your npm module | |
var moduleName = (function moduleName() { | |
"use strict"; | |
// YOUR PRETTY JS CODE THAT WILL CHANGE THE WORLD | |
// return whatever; | |
})( this ); |