|
16 | 16 | <div class="panel panel-editor"> |
17 | 17 | <div id="editor"></div> |
18 | 18 | <p> |
19 | | - <label for="example-select">Load an Example:</label> |
| 19 | + <label for="example-select">Load an existing definition:</label> |
20 | 20 | <select name="examples" id="example-select"> |
21 | | - <option value="">--Please choose an example--</option> |
| 21 | + <option value="">pick a board</option> |
22 | 22 | </select> |
23 | 23 | </p> |
24 | | - <script> |
25 | | - document.addEventListener('DOMContentLoaded', () => { |
26 | | - const selectElement = document.getElementById('example-select'); |
27 | 24 |
|
28 | | - fetch('index.json') |
29 | | - .then(response => { |
30 | | - if (!response.ok) { |
31 | | - throw new Error(`HTTP error! status: ${response.status}`); |
32 | | - } |
33 | | - return response.json(); |
34 | | - }) |
35 | | - .then(data => { |
36 | | - // Sort examples alphabetically by title |
37 | | - const sortedExamples = Object.entries(data).sort(([, titleA], [, titleB]) => |
38 | | - titleA.localeCompare(titleB) |
39 | | - ); |
40 | | - |
41 | | - sortedExamples.forEach(([path, title]) => { |
42 | | - const option = document.createElement('option'); |
43 | | - option.value = path; |
44 | | - option.textContent = title; |
45 | | - selectElement.appendChild(option); |
46 | | - }); |
47 | | - }) |
48 | | - .catch(error => { |
49 | | - console.error('Error loading or parsing index.json:', error); |
50 | | - // Optionally disable the select or show an error message |
51 | | - selectElement.disabled = true; |
52 | | - const errorOption = document.createElement('option'); |
53 | | - errorOption.textContent = 'Error loading examples'; |
54 | | - selectElement.appendChild(errorOption); |
55 | | - }); |
56 | | - |
57 | | - selectElement.addEventListener('change', (event) => { |
58 | | - const selectedPath = event.target.value; |
59 | | - if (selectedPath) { |
60 | | - window.location.search = `?load=${encodeURIComponent(selectedPath)}`; |
61 | | - } |
62 | | - }); |
63 | | - }); |
64 | | - </script> |
65 | 25 |
|
66 | 26 | <p> |
67 | 27 | <b>Learn more</b> about the tool and available config options in the |
|
82 | 42 | <p> |
83 | 43 | <small>A tool made by <a href="https://www.splitbrain.org">splitbrain</a></small> |
84 | 44 | </p> |
| 45 | + |
| 46 | + |
| 47 | +<script> |
| 48 | + // load existing definitions |
| 49 | + document.addEventListener('DOMContentLoaded', () => { |
| 50 | + const selectElement = document.getElementById('example-select'); |
| 51 | + |
| 52 | + fetch('index.json') |
| 53 | + .then(response => { |
| 54 | + if (!response.ok) { |
| 55 | + throw new Error(`HTTP error! status: ${response.status}`); |
| 56 | + } |
| 57 | + return response.json(); |
| 58 | + }) |
| 59 | + .then(data => { |
| 60 | + // Sort examples alphabetically by title |
| 61 | + const sortedExamples = Object.entries(data).sort(([, titleA], [, titleB]) => |
| 62 | + titleA.localeCompare(titleB) |
| 63 | + ); |
| 64 | + |
| 65 | + sortedExamples.forEach(([path, title]) => { |
| 66 | + const option = document.createElement('option'); |
| 67 | + option.value = path; |
| 68 | + option.textContent = title; |
| 69 | + selectElement.appendChild(option); |
| 70 | + }); |
| 71 | + }) |
| 72 | + .catch(error => { |
| 73 | + console.error('Error loading or parsing index.json:', error); |
| 74 | + // Optionally disable the select or show an error message |
| 75 | + selectElement.disabled = true; |
| 76 | + const errorOption = document.createElement('option'); |
| 77 | + errorOption.textContent = 'Error loading examples'; |
| 78 | + selectElement.appendChild(errorOption); |
| 79 | + }); |
| 80 | + |
| 81 | + selectElement.addEventListener('change', (event) => { |
| 82 | + const selectedPath = event.target.value; |
| 83 | + if (selectedPath) { |
| 84 | + window.location.search = `?load=${encodeURIComponent(selectedPath)}`; |
| 85 | + } |
| 86 | + }); |
| 87 | + }); |
| 88 | +</script> |
85 | 89 | </body> |
86 | 90 | </html> |
0 commit comments