Skip to content

Commit f776cb8

Browse files
authored
Merge pull request #23 from Looky1173/content-browser-loading-indicator
Added loading and error messages to the content browser
2 parents c58639b + 8804c41 commit f776cb8

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

assets/content-explorer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
const listContainer = document.getElementById('list-container');
55
const COMPENSATION_TEXTS = { free: 'Download (free)', donation: 'Download (donation-ware)', commercial: 'Buy (commercial)' };
66

7-
const _routes = await fetch('https://static.openrails.org/content/routes.json');
7+
const _routes = await fetch('https://static.openrails.org/content/routes.json').catch((e) => {
8+
listContainer.innerHTML = `
9+
<div style="text-align: center; color: red;">
10+
<strong>Sorry, there was an error while loading content.</strong>
11+
<p>${e}</p>
12+
</div>`;
13+
});
814
const routes = (await _routes.json()).map((item, index) => ({ index, ...item }));
915

1016
let selectedCard = 'routes';

download/explore-content/index.html

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,12 @@
77

88
<div class="content-explorer-container">
99
<div class="row">
10+
<p>This catalogue lists free and pay routes from all over the world. Use the search and filter options to find ones that suit your interests.</p>
1011
<p>
11-
This catalogue lists free and pay routes from all over the world.
12-
Use the search and filter options to find ones that suit your interests.
13-
</p>
14-
<p>
15-
Note that these routes are currently limited to those that a self-contained and require no other files.
16-
This makes them easy to install<!-- and Open Rails includes an Install Content button to download and install a route for you. -->.
12+
Note that these routes are currently limited to those that a self-contained and require no other files. This makes them easy to install<!-- and Open Rails includes an Install Content button to download and install a route for you. -->.
1713
We plan to extend this catalogue to include other routes, Train Cars and Trains.
1814
</p>
19-
<p>
20-
If you wish to add an entry to the catalogue, then send a message using <a href="/contact/form.html">our contact form</a>.
21-
</p>
15+
<p>If you wish to add an entry to the catalogue, then send a message using <a href="/contact/form.html">our contact form</a>.</p>
2216
</div>
2317
<div class="selection-container">
2418
<div class="selection selected" data-card="routes" style="--image: url(https://d3i6fh83elv35t.cloudfront.net/static/2022/06/GettyImages-915441550-1024x683.jpg)">
@@ -28,7 +22,9 @@
2822
<div
2923
class="selection"
3024
data-card="train-cars"
31-
style="--image: url(https://www.nps.gov/subjects/steamtownlocomotivesexhibit/images/Boston-Maine-Railroad-locomotive-number-3713-cms.jpg)" disabled="true">
25+
style="--image: url(https://www.nps.gov/subjects/steamtownlocomotivesexhibit/images/Boston-Maine-Railroad-locomotive-number-3713-cms.jpg)"
26+
disabled="true"
27+
>
3228
<div class="gradient"></div>
3329
<div class="selection-inside">Train cars</div>
3430
</div>
@@ -45,7 +41,9 @@
4541
<button class="filter-btn" data-type="free" data-secondary>Free</button>
4642
</div>
4743
</div>
48-
<div id="list-container"></div>
44+
<div id="list-container">
45+
<em style="text-align: center">Please wait, loading content...</em>
46+
</div>
4947
</div>
5048

5149
<script src="{{ '/assets/content-explorer.js' | relative_url }}" type="module"></script>

0 commit comments

Comments
 (0)