Skip to content

Commit 165bd05

Browse files
committed
Move SpaceAPI definition to separate file
1 parent e17386f commit 165bd05

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ <h1> {{page.title}} </h1>
5151
</div>
5252

5353
</div>
54+
<script src="{{ "/assets/js/script.js" | relative_url }}"></script>
5455
</body>
5556
</html>

assets/js/script.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
fetch("https://spaceapi.osaa.dk/status/json")
3+
.then(response => response.json())
4+
.then(data => {
5+
if (data.state && data.state.open === true) {
6+
document.getElementById("statusBox").style.display = "block";
7+
}
8+
})
9+
.catch(error => console.error("Error fetching space status:", error));
10+
});

index.html

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@
5151
<div id="statusBox" style="display: none; background-color: green; color: white; padding: 10px; margin-bottom: 10px;">
5252
Lige nu er spacet åbent.
5353
</div>
54-
<script>
55-
document.addEventListener("DOMContentLoaded", function () {
56-
fetch("https://spaceapi.osaa.dk/status/json")
57-
.then(response => response.json())
58-
.then(data => {
59-
if (data.state && data.state.open === true) {
60-
document.getElementById("statusBox").style.display = "block";
61-
}
62-
})
63-
.catch(error => console.error("Error fetching space status:", error));
64-
});
65-
</script>
6654
</div>
6755
</div>
6856
</div>

0 commit comments

Comments
 (0)