|
63 | 63 | } |
64 | 64 |
|
65 | 65 | function init () { |
| 66 | + addStyles(); |
| 67 | + |
66 | 68 | // Don't show the button when the example is already running inside a remix |
67 | 69 | // service preview (CodeSandbox *.csb.app, Krabbel *.krabbel.fun). |
68 | 70 | if (/\.(csb\.app|krabbel\.fun)$/.test(window.location.hostname)) { return; } |
69 | 71 |
|
70 | 72 | var loc = getExampleLocation(); |
71 | 73 | if (!loc) { return; } |
72 | 74 |
|
73 | | - // Point at the directory, adding a file parameter for non-index.html pages |
74 | | - // so the specific example file is opened. The leading slash is URL-encoded |
75 | | - // (CodeSandbox expects %2F). |
76 | | - var fileParam = (loc.file && loc.file !== 'index.html') ? '?file=' + encodeURIComponent('/' + loc.file) : ''; |
77 | | - var treePath = 'tree/gh-pages/examples/' + loc.dir + fileParam; |
78 | | - var codesandboxUrl = 'https://codesandbox.io/p/sandbox/github/aframevr/aframe/' + treePath; |
79 | | - var krabbelUrl = 'https://krabbel.dev/github/aframevr/aframe/' + treePath; |
80 | | - |
81 | | - addStyles(); |
| 75 | + // Point at the directory, adding a parameter for non-index.html pages so the |
| 76 | + // specific example file is opened. CodeSandbox uses a file parameter (with a |
| 77 | + // leading slash, URL-encoded as %2F); Krabbel supports file and preview parameters |
| 78 | + // (leading slash optional, if preview parameter specified and file parameter not |
| 79 | + // specified, it will open the same file in both editor and preview). |
| 80 | + var treePath = 'tree/gh-pages/examples/' + loc.dir; |
| 81 | + var isFile = loc.file && loc.file !== 'index.html'; |
| 82 | + var fileParam = isFile ? '?file=' + encodeURIComponent('/' + loc.file) : ''; |
| 83 | + var previewParam = isFile ? '?preview=' + encodeURIComponent(loc.file) : ''; |
| 84 | + var codesandboxUrl = 'https://codesandbox.io/p/sandbox/github/aframevr/aframe/' + treePath + fileParam; |
| 85 | + var krabbelUrl = 'https://krabbel.dev/github/aframevr/aframe/' + treePath + previewParam; |
82 | 86 |
|
83 | 87 | var menu = document.createElement('div'); |
84 | 88 | menu.classList.add('a-remix-menu'); |
|
0 commit comments