This file contains hidden or 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
| /** | |
| * 画像の回転を取得する | |
| * @returns {number} 回転を表す数字。正しく表示するために数字に応じて以下の処理をする: | |
| * 1: 何もしない | |
| * 2: 左右反転 | |
| * 3: 180度回転 | |
| * 4: 180度回転し、左右反転 | |
| * 5: 時計回りに90度回転し、左右反転 | |
| * 6: 時計回りに90度回転 | |
| * 7: 時計回りに270度回転し、左右反転 |
This file contains hidden or 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 | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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', | |
| ]; |