This demo page overrides your browser's built-in geolocation support, if possible.
8 | 9 |Equirectangular projection by Strebe. Licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
14 | 15 |Checking position...
16 | 17 | 18 | 19 | 20 | 52 | -------------------------------------------------------------------------------- /demos/geo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inexorabletash/polyfill/716a3f36ca10fad032083014faf1a47c638e2502/demos/geo.jpg -------------------------------------------------------------------------------- /demos/keyboard.html: -------------------------------------------------------------------------------- 1 | 2 |222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /demos/keyboard_test.js: -------------------------------------------------------------------------------- 1 | 2 | function contains(s, ss) { return s.indexOf(ss) != -1; } 3 | if (contains(navigator.platform, 'Win')) 4 | document.body.classList.add('meta-win'); 5 | if (contains(navigator.platform, 'Mac')) 6 | document.body.classList.add('meta-mac'); 7 | if (contains(navigator.userAgent, 'CrOS')) 8 | document.body.classList.add('meta-cros'); 9 | 10 | function select(event) { 11 | var id = event.code; 12 | return [].map.call(document.querySelectorAll('.' + id), function(x) { return x; }); 13 | 14 | // Can't override |location| on KeyboardEvent in some browsers, so it 15 | // may be wrong, e.g. NumLock in moz-mac 16 | } 17 | 18 | var target = document.getElementById('target'); 19 | 20 | document.documentElement.addEventListener('click', function(e) { 21 | target.focus(); 22 | }); 23 | 24 | // Block Apps (context menu) key in IE 25 | document.documentElement.addEventListener('contextmenu', function (e) { 26 | return false; 27 | }); 28 | 29 | var lastKey = -1; 30 | 31 | // Workaround for Opera which doesn't allow cancelling Tab, IE/Apps 32 | target.addEventListener('blur', function (e) { 33 | if (lastKey === 0x09 || lastKey === 0x5D) 34 | target.focus(); 35 | lastKey = -1; 36 | }); 37 | 38 | function hex(x, w) { 39 | if (x === undefined) return x; 40 | x = Number(x); 41 | w = Number(w) || 2; 42 | return '0x' + ('0'.repeat(w) + x.toString(16)).slice(-w); 43 | } 44 | 45 | function show(selector, e) { 46 | var elem = document.querySelector(selector), 47 | data = [ 48 | { 49 | category: 'UI Events', 50 | link: 'https://w3c.github.io/uievents/', 51 | attributes: { 52 | code: e.code, 53 | key: e.key, 54 | location: e.location 55 | } 56 | }, 57 | 58 | { 59 | category: 'UI Events (extension)', 60 | link: 'https://dvcs.w3.org/hg/d4e/raw-file/tip/source_respec.htm', 61 | attributes: { 62 | 'queryKeyCap()': KeyboardEvent.queryKeyCap(e.code) 63 | } 64 | }, 65 | 66 | { 67 | category: 'Legacy user agents', 68 | attributes: { 69 | charCode: hex(e.charCode), 70 | keyCode: hex(e.keyCode), 71 | which: hex(e.which), 72 | char: e.char // IE only 73 | } 74 | }, 75 | 76 | { 77 | category: 'Abandoned proposals', 78 | attributes: { 79 | keyChar: e.keyChar, 80 | keyIdentifier: e.keyIdentifier, 81 | keyLocation: e.keyLocation, 82 | keyName: e.keyName 83 | } 84 | }, 85 | 86 | { 87 | category: 'Modifiers', 88 | attributes: { 89 | altKey: e.altKey, 90 | ctrlKey: e.ctrlKey, 91 | metaKey: e.metaKey, 92 | shiftKey: e.shiftKey, 93 | repeat: e.repeat 94 | } 95 | } 96 | ]; 97 | 98 | while (elem.hasChildNodes()) 99 | elem.removeChild(elem.firstChild); 100 | 101 | var s = data.map(function(cat) { 102 | return cat.category + ':\n' + 103 | Object.keys(cat.attributes).filter(function(k) { 104 | return typeof cat.attributes[k] !== 'undefined'; 105 | }).map(function(k) { 106 | return ' ' + k + ': ' + cat.attributes[k] + '\n'; 107 | }).join(''); 108 | }).join('\n'); 109 | elem.appendChild(document.createTextNode(s)); 110 | } 111 | 112 | target.addEventListener('keydown', function(e) { 113 | identifyKey(e); // for IE8- 114 | lastKey = e.keyCode; 115 | 116 | show('#eventdata', e); 117 | 118 | select(e).forEach( 119 | function (elem) { 120 | elem.style.backgroundColor = 'red'; 121 | }); 122 | 123 | e.preventDefault(); 124 | e.stopPropagation(); 125 | }); 126 | 127 | target.addEventListener('keyup', function (e) { 128 | identifyKey(e); // for IE8- 129 | if (lastKey == e.keyCode) { lastKey = -1; } 130 | 131 | show('#eventdata', e); 132 | 133 | select(e).forEach( 134 | function (elem) { 135 | elem.style.backgroundColor = '#ffaaaa'; 136 | setTimeout(function() { 137 | elem.style.backgroundColor = '#aaaaaa'; 138 | }, 200); 139 | }); 140 | 141 | e.preventDefault(); 142 | e.stopPropagation(); 143 | }); 144 | 145 | target.addEventListener('keypress', function (e) { 146 | e.preventDefault(); 147 | e.stopPropagation(); 148 | }); 149 | 150 | target.addEventListener('contextmenu', function (e) { 151 | e.preventDefault(); 152 | e.stopPropagation(); 153 | }); 154 | 155 | target.focus(); 156 | -------------------------------------------------------------------------------- /demos/polyfill.css: -------------------------------------------------------------------------------- 1 | body { margin-left: 80px; margin-right: 80px; } 2 | h1 { border-bottom: solid 2px black; margin-bottom: 0; } 3 | h2 { text-decoration: underline; margin-bottom: 0; } 4 | p { margin-top: 0.5em; margin-bottom: 0.5em; } 5 | code { background-color: #eeeeee; } 6 | -------------------------------------------------------------------------------- /demos/raf.html: -------------------------------------------------------------------------------- 1 | 2 |
This demo uses your browser's native requestAnimationFrame
support, if present.
8 |
9 |
key | code | name | message | native? 46 | |
---|
10 | Native implementations of the following functions exist, so the
11 | test results do not reflect the polyfill:
12 |
13 |
14 |
17 | The following lack native implementations, so the polyfills are tested:
18 |
19 |
20 |