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
| // quite untested, adapted from BigstickCarpet's gist, attempt to make it simpler to use | |
| function openIndexedDB (fileindex) { | |
| // This works on all devices/browsers, and uses IndexedDBShim as a final fallback | |
| var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; | |
| var openDB = indexedDB.open("MyDatabase", 1); | |
| openDB.onupgradeneeded = function() { | |
| var db = {} |
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 | |
| /// | |
| /// Very simple script to convert a normal JS module to a RequireJS-compatible | |
| /// AMD module; intended for command-line usage, and integration into build | |
| /// systems. | |
| /// | |
| /// Reads from stdin & writes to stdout; output can be piped to uglifyjs to | |
| /// minify/compress the code. | |
| /// | |
| /// Examples: |
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 dedent(text) { | |
| var re_whitespace = /^([ \t]*)(.*)\n/gm; | |
| var l, m, i; | |
| while ((m = re_whitespace.exec(text)) !== null) { | |
| if (!m[2]) continue; | |
| if (l = m[1].length) { | |
| i = (i !== undefined) ? Math.min(i, l) : l; | |
| } else break; |
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
| // Credit to @steobrien from https://gist.github.com/rmehner/b9a41d9f659c9b1c3340#gistcomment-2940034 | |
| // for modern browsers, this works: | |
| const dbs = await window.indexedDB.databases() | |
| dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) }) | |
| // for older browsers, have a look at previous revisions of this gist. |
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
| hslToRgb = function(_h, s, l) { | |
| var h = Math.min(_h, 359)/60; | |
| var c = (1-Math.abs((2*l)-1))*s; | |
| var x = c*(1-Math.abs((h % 2)-1)); | |
| var m = l - (0.5*c); | |
| var r = m, g = m, b = m; | |
| if (h < 1) { |
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
| // selection range | |
| var range = window.getSelection().getRangeAt(0); | |
| // plain text of selected range (if you want it w/o html) | |
| var text = window.getSelection(); | |
| // document fragment with html for selection | |
| var fragment = range.cloneContents(); | |
| // make new element, insert document fragment, then get innerHTML! |
NewerOlder