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