mirror of
https://github.com/nikdoof/website-hugo.git
synced 2025-12-13 20:22:32 +00:00
Move site specific layouts and JS to the site folders
This commit is contained in:
38
assets/js/site.js
Normal file
38
assets/js/site.js
Normal file
@@ -0,0 +1,38 @@
|
||||
function titleCase(word) {
|
||||
return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
if ($('span#hackspace-status').length) {
|
||||
$.getJSON("https://api.leighhack.org/space.json", function (data) {
|
||||
if (data.state.open) {
|
||||
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>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 'printers' shortcode
|
||||
if ($('div#printer-status').length) {
|
||||
$.getJSON("https://api.leighhack.org/space.json", function (data) {
|
||||
if (data.sensors.ext_3d_printers.length) {
|
||||
|
||||
// sort the printers
|
||||
const printers = Array.from(data.sensors.ext_3d_printers).sort((a, b) => a['name'].localeCompare(b['name']));
|
||||
|
||||
printers.forEach(function (val, indx) {
|
||||
var obj = $($("template#printer-block").html());
|
||||
obj.find('#printer-name').html(val['name']);
|
||||
obj.find('#printer-status').html(titleCase(val['state']));
|
||||
$('div#printer-status').append(obj);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user