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"> | |
<title>Form</title> | |
</head> | |
<body> | |
<p> | |
URL: <input id="url" type="text" readonly style="width:60em"> |
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 { XMLParser, XMLBuilder } = require('fast-xml-parser'); | |
const presentationAttrs = [ | |
'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-rendering', | |
'cursor', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', | |
'opacity', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', | |
'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', | |
'stroke-opacity', 'stroke-width', 'transform', 'vector-effect', 'visibility', | |
]; |
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 pageVisible = true; | |
function updatePageVisibility(e) { | |
if (e.type === "visibilitychange") { | |
pageVisible = !document.hidden; | |
} else { | |
const typeVisibilityMap = { blur: false, focus: true, pagehide: false, pageshow: true }; | |
pageVisible = typeVisibilityMap[e.type]; | |
} | |
} |
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
export function waitForGlobalVariable(objPath, interval, timeout, callback) { | |
function find(objPath) { | |
var found = window; | |
objPath = objPath.split("."); | |
while (objPath.length > 0) { | |
var objPart = objPath.shift(); | |
if (objPart in found) { | |
found = found[objPart]; | |
} else { | |
return 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
/** | |
* @param {number} delay | |
* @param {Function} callback | |
* @returns {Function} | |
*/ | |
function debounce(delay, callback) { | |
var timer = 0; | |
return function () { | |
var self = this; | |
var args = arguments; |
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" /> | |
<title>Load polyfills conditionally from CDN</title> | |
<script> | |
function loadFromCdn(src, integrity) { | |
var s = document.createElement("script"); | |
s.src = src; | |
s.integrity = integrity; |
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 getFirstTextNode(root) { | |
return traverse(root, (node) => node.nodeType === Node.TEXT_NODE && node.textContent.trim() !== ""); | |
} | |
/** | |
* ツリー上で最後に登場するテキストノードを深さ優先で探索し取得する | |
*/ |
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
#!/usr/bin/env node | |
/** | |
* @fileoverview rem を 10/16 倍する | |
* @example cat styles.css | ./adjust-rem > styles.css | |
*/ | |
const { readFileSync } - require("fs"); | |
const postcss = require("postcss"); |
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
/** | |
* @fileOverview | |
* localStorage, sessionStorage のごく薄いラッパー。 | |
* Cookie 無効環境でストレージにアクセスしたときに発生する例外を捕捉しスクリプトが止まらないようにする。 | |
*/ | |
type storageType = 'localStorage' | 'sessionStorage' | |
class WebStorage { | |
constructor(private storageType: storageType) {} |
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 rollFocus(backFlag) { | |
let focusIndex | |
const currentIndex = this.tabbableElements.indexOf(document.activeElement) | |
if (currentIndex < 0) { | |
focusIndex = 0 | |
} else { | |
const tabbableLength = this.tabbableElements.length | |
const direction = backFlag ? -1 : 1 | |
focusIndex = (currentIndex + direction + tabbableLength) % tabbableLength | |
} |
NewerOlder