mirror of
https://github.com/nikdoof/website-hugo.git
synced 2025-12-13 12:12:18 +00:00
Sort the printers
This commit is contained in:
@@ -27,11 +27,12 @@ $(document).ready(function () {
|
||||
if ($('div#printer-status').length) {
|
||||
$.getJSON("https://api.leighhack.org/space.json", function (data) {
|
||||
if (data.sensors.ext_3d_printers.length) {
|
||||
data.sensors.ext_3d_printers.forEach(function (val, indx){
|
||||
|
||||
// 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());
|
||||
console.log(val);
|
||||
console.log(obj);
|
||||
console.log(obj.find('#printer-name'))
|
||||
obj.find('#printer-name').html(val['name']);
|
||||
obj.find('#printer-status').html(titleCase(val['state']));
|
||||
$('div#printer-status').append(obj);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<template id="printer-block">
|
||||
<div class="column is-one-quarter">
|
||||
<div class="box is-large hover-items">
|
||||
<h3 class="is-size-4 has-text-weight-bold" id="printer-name"></h3>
|
||||
<h4 id="printer-status"></h3>
|
||||
<div class="box">
|
||||
<h3 id="printer-name"></h3>
|
||||
<p id="printer-status"></p>
|
||||
<p class="is-hidden" id="printer-finish-block">ETA: <span id="printer-finish"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user