|
3 | 3 | <head>
|
4 | 4 | <meta charset="utf-8">
|
5 | 5 | <title>remote-input demo</title>
|
| 6 | + <style> |
| 7 | + marquee, textarea, input { width: 20rem; } |
| 8 | + remote-input, textarea { display: block; } |
| 9 | + </style> |
| 10 | + <script> |
| 11 | + function fakeFetch(url) { |
| 12 | + const urlObj = new URL(url) |
| 13 | + let html = '' |
| 14 | + if (url.pathname === '/results') { |
| 15 | + const doc = document.createElement('div') |
| 16 | + doc.innerHTML = `<li>Hubot</li><li>BB-8</li><li>Wall-E</li><li>Bender</li>` |
| 17 | + const q = url.searchParams.get('q') |
| 18 | + for (const el of doc.querySelectorAll('li')) { |
| 19 | + if (q !== '' && !el.textContent.toLowerCase().match(q.toLowerCase())) el.remove() |
| 20 | + } |
| 21 | + html = doc.innerHTML |
| 22 | + } else if (url.pathname === '/marquee') { |
| 23 | + html = `<marquee>${url.searchParams.get('q') || 'blank'}</marquee>` |
| 24 | + } |
| 25 | + const promiseHTML = new Promise(resolve => resolve(html)) |
| 26 | + return new Promise(resolve => resolve({text: () => promiseHTML})) |
| 27 | + } |
| 28 | + window.fetch = fakeFetch |
| 29 | + </script> |
6 | 30 | </head>
|
7 | 31 | <body>
|
8 |
| - <remote-input aria-owns="results" src="/examples/results.html"> |
9 |
| - <label>Search robots <input type="text"></label> |
| 32 | + <remote-input aria-owns="marquee-preview" src="/marquee"> |
| 33 | + <label>Marquee preview <textarea autofocus>🐈🐈🐈🐈🐈</textarea></label> |
10 | 34 | </remote-input>
|
11 |
| - <ol id="results"></ol> |
| 35 | + <div id="marquee-preview"></div> |
| 36 | + |
| 37 | + <remote-input aria-owns="results" src="/results"> |
| 38 | + <label>Search robots<br><input type="text"></label> |
| 39 | + </remote-input> |
| 40 | + <ul id="results"></ul> |
12 | 41 |
|
13 | 42 | <!-- GitHub Pages development script, uncomment when running example locally and comment out the production one -->
|
14 | 43 | <!-- <script src="../dist/index.umd.js"></script> -->
|
15 | 44 |
|
16 | 45 | <!-- GitHub Pages demo script -->
|
17 |
| - <script src="https://unpkg.com/@github/remote-input-element@latest/dist/index.umd.js"></script></body> |
| 46 | + <script src="https://unpkg.com/@github/remote-input-element@latest/dist/index.umd.js"></script> |
| 47 | +</body> |
18 | 48 | </html>
|
0 commit comments