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
import canvasSketch from "canvas-sketch"; | |
import { random } from "canvas-sketch-util"; | |
import _ from "lodash"; | |
document.body.style.backgroundColor = "#A08BED"; | |
const settings = { | |
animate: true, | |
duration: 15, | |
dimensions: [2048, 2048], |
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
const $ = document.querySelector.bind(document); | |
const $$ = document.querySelectorAll.bind(document); | |
Node.prototype.on = window.on = function(name, fn) { | |
this.addEventListener(name, fn); | |
} | |
NodeList.prototype.__proto__ = Array.prototype; | |
NodeList.prototype.on = NodeList.prototype.addEventListener = function(name, fn) { |
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
const localStorageMiddleware = store => next => action => { | |
if (action.type === REGISTER || action.type === LOGIN) { | |
if (!action.error) { | |
window.localStorage.setItem('jwt', action.payload.user.token); | |
agent.setToken(action.payload.user.token); | |
} | |
} else if (action.type === LOGOUT) { | |
window.localStorage.setItem('jwt', ''); | |
agent.setToken(null); | |
} |
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
// Listen for ambient lighting in room | |
window.addEventListener('devicelight', (e) => { | |
console.log(`${e.value} lux`); | |
}); |
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
if (!Array.prototype.includes) { | |
Array.prototype.includes = function(searchElement /*, fromIndex*/) { | |
'use strict'; | |
if (this == null) { | |
throw new TypeError('Array.prototype.includes called on null or undefined'); | |
} | |
var O = Object(this); | |
var len = parseInt(O.length, 10) || 0; | |
if (len === 0) { |
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
const mapTree = (node,mapper) => { | |
return { | |
value: mapper(node.value), | |
nodes: node.nodes | |
? node.nodes.map( x => | |
mapTree(x, mapper) | |
) | |
: null | |
} | |
} |
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
const scrollToItemId = (containerId, srollToId) => { | |
const scrollContainer = document.getElementById(containerId); | |
const item = document.getElementById(scrollToId); | |
//with animation | |
const from = scrollContainer.scrollTop; | |
const by = item.offsetTop - scrollContainer.scrollTop; | |
if (from < item.offsetTop) { | |
if (item.offsetTop > scrollContainer.scrollHeight - scrollContainer.clientHeight) { | |
by = (scrollContainer.scrollHeight - scrollContainer.clientHeight) - scrollContainer.scrollTop; |
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
width: 200px; | |
text-overflow: ellipsis; | |
overflow: hidden; | |
white-space: nowrap; |
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
/** | |
* Retrieve parameter values from URL | |
* @param {name} name of paramater | |
* @param {url} URL to fetch parameter from | optional | |
* @returns URL param value || null | |
*/ | |
const getURLParemeters = ( name, url ) => { | |
if (!url) url = location.href; | |
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); | |
var regexS = "[\\?&]"+name+"=([^&#]*)"; |
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
let fn; | |
(fn = () => { | |
})(); | |
fn(); |
NewerOlder