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
// For production use i recommend: https://phuoc.ng/collection/1-loc/shuffle-an-array/ | |
// function | |
function mixArray(array) { | |
let newArray = [], | |
maxRandNbr = array.length; | |
for (let i = 0; i = maxRandNbr; i++) { | |
randNbr = Math.round(Math.random() * (maxRandNbr - 1)); |
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
// source: https://chrisbuttery.com/articles/fade-in-fade-out-with-javascript/ | |
// fadeOut (fade.js) | |
function fadeOut(el) { | |
el.style.opacity = 1; | |
(function fade() { | |
var val = parseFloat(el.style.opacity); | |
if (!((val -= .1) < 0)) { | |
el.style.opacity = val; | |
requestAnimationFrame(fade); |
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
// load JSON | |
function loadJSON(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.onreadystatechange = function () { | |
if (xhr.readyState === 4) { | |
if (xhr.status === 200) { | |
callback(JSON.parse(xhr.responseText)); | |
} else { | |
// callback([{}]); |
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
// 1234 => 1.234 | |
function splitter(t) { | |
if (t = '' + t, | |
t.length > 3) { | |
var e = t.length % 3, | |
n = e > 0 ? t.substring(0, e) : ''; | |
for (i = 0; i < Math.floor(t.length / 3); i++) n += 0 == e && 0 == i ? t.substring(e + 3 * i, e + 3 * i + 3) : '.' + t.substring(e + 3 * i, e + 3 * i + 3); | |
return n; | |
} |
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
[data-before]::before { | |
content: attr(data-before); | |
} | |
[data-after]::after { | |
content: attr(data-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
fetch(YOUR_JSON_FILE_URL).then(function(responsive) { | |
return responsive.json(); | |
}).then(function(obj) { | |
console.log(obj); | |
}); |
NewerOlder