https://codehandbook.org/how-to-remove-duplicates-from-javascript-array/
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
var css = document.createElement('style'); | |
css.type = 'text/css'; | |
var styles = 'a:focus {background: blue}'; | |
if (css.styleSheet) css.styleSheet.cssText = styles; | |
else css.appendChild(document.createTextNode(styles)); | |
document.getElementsByTagName("head")[0].appendChild(css); |
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
// needs https://github.com/liddiard/preview-gif | |
const GifAnimationHandler = function({timeoutInSec = 5000} = {}) { | |
const self = this; | |
const allImgs = document.querySelectorAll("img"); | |
self.deactivateAnimatedGifs = (gifNodeList) => { | |
gifNodeList.forEach(gif => { | |
PreviewGIF(gif.dataset.src, (err, imageData) => { | |
if (err) console.error(err); |
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
/** | |
* based on | |
* @url https://github.com/rstacruz/details-polyfill | |
* @todo https://www.sitepoint.com/fixing-the-details-element/ | |
* @todo https://www.smashingmagazine.com/2014/11/complete-polyfill-html5-details-element/ | |
*/ | |
const detailsPolyfillEs6 = ({ | |
CSS_CLASS = 'no-details', | |
CSS_STRING = false, |
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
// based on https://github.com/arasatasaygin/is.js/blob/master/is.js | |
// this is a cut off minimal version | |
const userAgent = (navigator && navigator.userAgent.toLowerCase()) || ''; | |
const vendor = (navigator && navigator.vendor || '').toLowerCase(); | |
// build a 'comparator' object for various comparison checks | |
const comparator = { | |
'<': (a, b) => a < b, | |
'<=': (a, b) => a <= b, |
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 l = localStorage | |
const crappyStore = { | |
get: (key) => JSON.parse(l.getItem(key)), | |
set: (key, data) => l.setItem(key, JSON.stringify(data)), | |
rm: (key) => l.removeItem(key), | |
getKeysFor: (prefix) => { | |
const ret = [] | |
for (let key in l) { | |
ret.push(key) |
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 store = { | |
storageIndex: undefined, | |
debug: false, | |
state: Object.freeze({ | |
}), | |
setState(keyword, value) { | |
if (this.debug) console.log(`STATE: ${keyword}:`, value); // eslint-disable-line no-console | |
const newObject = Object.assign({}, this.state, { [keyword]: value }); | |
this.state = Object.freeze(newObject); | |
if (this.storageIndex) localStorage.setItem(this.storageIndex, JSON.stringify(newObject)); |
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
/* GENERAL DEVICE CONSTANTS | |
##################################################################################################################### */ | |
/* | |
* iOS | |
*/ | |
// iOS metrics | |
$ios-status-bar-height: em-calc(20); | |
$ios-nav-bar-height: em-calc(44); |
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
'use strict'; | |
(function(){ | |
window.NIJS = window.NIJS || {}; | |
NIJS.detection = NIJS.detection || {}; | |
var html = document.getElementsByTagName('html')[0], | |
removeClass = function(str, className){ | |
var classArr = str.split(' '), |
NewerOlder