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
/** | |
* Focuses an element even if it isn't focusable. | |
* @param {HTMLElement} target - element to focus | |
*/ | |
function focusTarget(target) { | |
if (document.activeElement === target) { | |
return; | |
} | |
if (target.tabIndex < 0 && !target.getAttribute('tabIndex')) { |
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 errorHelpMaybe = (func) => { | |
try { | |
func(); | |
} catch (err) { | |
const { name, message } = err; | |
const url = `https://stackoverflow.com/search?q=${encodeURIComponent(`${name} ${message}`)}`; | |
console.log(name, message, url); | |
window.open(url, `StackOverflow${Math.random()}`); | |
throw 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
/** | |
* This marquee stuff is deliberately low-tech. Use at your own risk. Licensed under whatever license you need. | |
* Also available as a part of https://github.com/erikvorhes/Useless-JS | |
* | |
* Usage: `marquee();` | |
*/ | |
function marquee(behavior, direction) { | |
var behaviors = ['scroll', 'slide', 'alternate']; | |
var directions = ['left', 'right', 'up', 'down']; |
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
<!-- NOTE: This doesn't work reliably. DO NOT USE. Thx. --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Responsive Images</title> | |
<!-- A variation on http://www.monoliitti.com/images/ --> | |
<!-- Note: the `big` version of the image will be broken, as it doesn’t exist. --> | |
</head> | |
<body> |
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
(function fanTest () { | |
'use strict'; | |
var i = 1; | |
while (i) { | |
i = i + 1; | |
// Let's be nice and not throw errors in browsers that don't have consoles ... | |
if (!!console) { | |
i < 10000 && console.log('These fans work great!'); | |
i >= 10000 && console.log('Listen to the music those fans make!'); | |
} |