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
// Random Color Generator | |
const getRandomHexColor = () => '#'+ Math.random().toString(16).substr(-6); |
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
var url = new URL('https://sl.se') | |
var params = {lat:35.696233, long:139.570431} // or: | |
var params = [['lat', '35.696233'], ['long', '139.570431']] | |
url.search = new URLSearchParams(params) | |
fetch(url) | |
// NodeJS |
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
export async function uploadFile(url, body, uploadActions) { | |
const formData = new FormData(); | |
formData.append('dataset', body[0]); | |
const { | |
onUploadStart, onUploadProgress, onUploadSuccess, | |
onUploadError, onUploadAbort, onUploadEnd, | |
} = uploadActions; | |
let promise, |
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
const loadStyleSheet = src => { | |
if(document.createStylesheet) { | |
document.createStylesheet(src); | |
} else { | |
const stylesheet = document.createElement('link'); | |
stylesheet.href = src; | |
stylesheet.rel = 'text/css'; | |
document.querySelector('head').appendChild(stylesheet); | |
} | |
} |
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
document.getElementsByClassName('Overview__up-arrow___Y5yuq')[0].addEventListener('click', () => { | |
console.log('Clicked'); | |
yPos = window.scrollY; | |
k = setInterval( () => { | |
if(yPos >= 0){ | |
yPos = yPos - 100; | |
window.scrollTo(0, yPos); | |
} else { | |
clearInterval(k); |
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
window.addEventListener('visibilitychange', () => { | |
switch(document.visibilityState) { | |
case 'prerender': | |
console.log('Tab is pre-rendering'); | |
break; | |
case 'hidden': | |
console.log('Tab is hidden'); | |
break; | |
case 'visible': | |
console.log('Tab is focused'); |