Passthrou messages from the Space API

This commit is contained in:
2023-11-07 15:30:25 +00:00
parent d64026c1c4
commit d5de319fb1
2 changed files with 8 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ company = "Leigh Hackspace CIC"
company_number = "09404083"
copyright_years = "2023"
description = "Leigh Hackspace is a hackspace located in the north-west of England."
space_api_endpoint = "https://api.leighhack.org/space.json"
[params.social]
twitter = 'leigh_hackspace'

View File

@@ -1,12 +1,16 @@
<div class="notification has-text-centered" id="hackspace-open">
Leigh Hackspace is currently <span id="hackspace_status">Closed</span>
Leigh Hackspace is currently <span id="hackspace-status">Closed</span>
</div>
<script>
$.getJSON("https://api.leighhack.org/space.json", function (data) {
$.getJSON("{{ .Site.Params.space_api_endpoint }}", function (data) {
var date = new Date(data.state.lastchange * 1000);
if (data.state.open) {
$('span#hackspace_status').html('<b>Open</b>');
message = '<b>Open<b>'
if ('message' in data.state) {
message = message + ': ' + data.state.message;
}
$('span#hackspace-status').html(message);
$('div#hackspace-open').addClass('is-success');
} else {
$('span#hackspace_status').html('<b>Closed</b>');