|
8 | 8 | let wallets$ |
9 | 9 |
|
10 | 10 | const themes = ['system', 'default', 'light', 'dark', 'custom'] |
11 | | - let selectedTheme = 'custom' |
| 11 | + let selectedTheme = 'system' |
12 | 12 |
|
13 | 13 | let webURL = '' |
14 | 14 | let iframeUsed = false |
|
30 | 30 |
|
31 | 31 | const addURLToIFrame = () => { |
32 | 32 | if (!webURL || !isValidUrl(webURL)) { |
33 | | - alert('Invaled URL entered') |
| 33 | + alert('Invalid URL entered') |
34 | 34 | return |
35 | 35 | } |
36 | | - iframeUsed = true |
37 | | - document.querySelector('#iframe_underlay').setAttribute('src', webURL) |
38 | | - hideDirections = true |
39 | | - onboard.connectWallet() |
| 36 | +
|
| 37 | + fetch(webURL) |
| 38 | + .then(() => { |
| 39 | + iframeUsed = true |
| 40 | + document.querySelector('#iframe_underlay').setAttribute('src', webURL) |
| 41 | + hideDirections = true |
| 42 | + !onboard && getOnboard() |
| 43 | + onboard.connectWallet() |
| 44 | + }) |
| 45 | + .catch(() => { |
| 46 | + alert( |
| 47 | + 'The website entered cannot be displayed within an iframe. Please try a different URL. See the browser console for more information.' |
| 48 | + ) |
| 49 | + }) |
40 | 50 | } |
41 | 51 |
|
42 | 52 | const resetPage = () => { |
|
47 | 57 | uploaded_image = undefined |
48 | 58 | webURL = '' |
49 | 59 | resetTheme() |
| 60 | + closeOnboard() |
| 61 | + } |
| 62 | +
|
| 63 | + const closeOnboard = () => { |
50 | 64 | const onboardCloseBtnVisible = document |
51 | 65 | ?.querySelector('body > onboard-v2') |
52 | 66 | ?.shadowRoot?.querySelector('.close-button') |
|
266 | 280 | placeholder="Enter your Website URL" |
267 | 281 | bind:value={webURL} |
268 | 282 | /> |
269 | | - <button on:click={addURLToIFrame}>Preview On Your Website</button> |
| 283 | + <button type="submit">Preview On Your Website</button> |
270 | 284 | <button |
271 | | - on:click={resetPage} |
| 285 | + on:click={() => resetPage()} |
272 | 286 | type="button" |
273 | 287 | disabled={iframeUsed || !!uploaded_image ? false : true}>Reset</button |
274 | 288 | > |
|
0 commit comments