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
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
// http://creativecommons.org/publicdomain/zero/1.0/ | |
(function (win, doc) { | |
'use strict'; | |
// Cut the mustard | |
if (!doc.querySelectorAll || !doc.querySelectorAll('input[list]') || !win.HTMLDataListElement || !win.addEventListener){ | |
return; | |
} | |
// Loop through each input element with a list attribute |
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
<?php | |
function getEmbedCode($url="") { | |
$return = ''; | |
$providers = array( | |
'flickr.com' => 'https://www.flickr.com/services/oembed/', | |
'huffduffer.com' => 'https://huffduffer.com/oembed', | |
'instagram.com' => 'https://api.instagram.com/publicapi/oembed', |
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 (win, doc) { | |
win.addEventListener('load', function() { | |
var latlons = []; | |
doc.querySelectorAll('.h-geo').forEach( function(geo) { | |
var lat = geo.querySelector('data.p-latitude').getAttribute('value'); | |
var lon = geo.querySelector('data.p-longitude').getAttribute('value'); | |
if (lat && lon) { | |
latlons.push([lat, lon]); | |
} | |
}); |
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
// Generate a timestamp (in seconds) on the server. This won't change if the page is served from a cache. | |
var serverTimestamp = <?php echo time(); ?>; | |
// Create a new Date object from the local date and time on the client. | |
var localDate = new Date(); | |
// Convert the local date and time to Universal Time (same as the server). | |
var localUTCString = localDate.toUTCString(); | |
// Create a new Date object from the UTC date and time on the client. | |
var UTCDate = new Date(localUTCString); | |
// Generate a timestamp (in seconds) from the UTC date and time on the client. | |
var clientTimestamp = UTCDate.getTime() / 1000; |
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 (win, doc) { | |
win.addEventListener('beforeinstallprompt', function (e) { | |
e.preventDefault(); | |
var deferredPrompt = e; | |
var insertionPoint = doc.querySelector('main .contents'); | |
insertionPoint.insertAdjacentHTML('afterbegin',` | |
<div class="feedback" role="dialog" aria-labelledby="homescreen"> | |
<h2 id="homescreen">Install The Session</h2> | |
<p>Would you like to add The Session to your home screen?</p> | |
<button class="back">No, thanks</button> |
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
// Limit the number of items in a specified cache. | |
function trimCache(cacheName, maxItems) { | |
caches.open(cacheName) | |
.then( cache => { | |
cache.keys() | |
.then(keys => { | |
if (keys.length > maxItems) { | |
cache.delete(keys[0]) | |
.then( () => { | |
trimCache(cacheName, maxItems) |
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
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
// http://creativecommons.org/publicdomain/zero/1.0/ | |
// HTML files: try the network first, then the cache. | |
// Other files: try the cache first, then the network. | |
// Both: cache a fresh version if possible. | |
// (beware: the cache will grow and grow; there's no cleanup) | |
const cacheName = 'files'; |
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
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
// http://creativecommons.org/publicdomain/zero/1.0/ | |
// Pass in an array of numbers ranging from 0 to 20. | |
function playSparkline(notes) { | |
if (!window.AudioContext && !window.webkitAudioContext) { | |
return; | |
} | |
var playing = 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title></title> | |
</head> | |
<body> | |
</body> |