TODO
import './banana.js';
import './banana.js#foo';
These are both run by Chrome 61, but are only fetched from the network once!
// usage: | |
// importScript('./path/to/script.js').then((allExports) => { .... })); | |
function importScript(path) { | |
let entry = window.importScript.__db[path]; | |
if (entry === undefined) { | |
const escape = path.replace(`'`, `\\'`); | |
const script = Object.assign(document.createElement('script'), { | |
type: 'module', | |
textContent: `import * as x from '${escape}'; importScript.__db['${escape}'].resolve(x);`, | |
}); |
function isLandscape() { | |
var object = window.screen.orientation || window.screen.msOrientation || window.screen.mozOrientation || null; | |
if (object) { | |
if (object.type.indexOf('landscape') !== -1) { return true; } | |
if (object.type.indexOf('portrait') !== -1) { return false; } | |
} | |
if ('orientation' in window) { | |
var value = window.orientation; | |
if (value === 0 || value === 180) { | |
return false; |
/** | |
* Updates the passed dialog to retain focus and restore it when the dialog is closed. Won't | |
* upgrade a dialog more than once. Supports IE11+ and is a no-op otherwise. | |
* @param {!HTMLDialogElement} dialog to upgrade | |
*/ | |
var registerFocusRestoreDialog = (function() { | |
if (!window.WeakMap || !window.MutationObserver) { | |
return function() {}; | |
} | |
var registered = new WeakMap(); |
const functionMatch = /^function\s*\w*\(([\w\s,]+)\) {/; | |
/** | |
* @param {!Function} fn | |
* @return {!Array<string>} array of simple arg names (no =, ... etc) | |
*/ | |
function simpleArgNames(fn) { | |
const match = functionRe.exec(fn.toString()); | |
if (!match) { return []; } | |
const args = match[1].split(',').map((x) => x.trim()); |
Array.from(document.styleSheets).forEach((ss) => { | |
const toDelete = []; | |
const toReplace = new Map(); | |
for (let i = 0; i < ss.rules.length; ++i) { | |
const rule = ss.rules[i]; | |
if (!(rule instanceof CSSMediaRule)) { | |
continue; | |
} |
package main | |
import ( | |
"crypto/tls" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/user" |
// This code now lives at https://github.com/samthor/undoer (or 'undoer' on NPM). |
// FIXME: glitch doesn't know about Map/Set for some reason | |
var Map = window['Map']; | |
var Set = window['Set']; | |
/** | |
* @typedef {{i: number, o: *}} | |
*/ | |
var IntervalData; |
#include <stdint.h> | |
#include <string.h> | |
#include <stdlib.h> | |
typedef struct { | |
int chunks, w, h; | |
} info_t; | |
const char expected_header[8] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a}; |