diff --git a/static/img/banner/0.jpg b/static/img/banner/0.jpg new file mode 100644 index 0000000..072bf27 Binary files /dev/null and b/static/img/banner/0.jpg differ diff --git a/static/img/banner/10.jpg b/static/img/banner/10.jpg new file mode 100644 index 0000000..703fdac Binary files /dev/null and b/static/img/banner/10.jpg differ diff --git a/static/img/banner/100.jpg b/static/img/banner/100.jpg new file mode 100644 index 0000000..02f5e88 Binary files /dev/null and b/static/img/banner/100.jpg differ diff --git a/static/img/banner/15.jpg b/static/img/banner/15.jpg new file mode 100644 index 0000000..890ea2d Binary files /dev/null and b/static/img/banner/15.jpg differ diff --git a/static/img/banner/20.jpg b/static/img/banner/20.jpg new file mode 100644 index 0000000..a7cca81 Binary files /dev/null and b/static/img/banner/20.jpg differ diff --git a/static/img/banner/25.jpg b/static/img/banner/25.jpg new file mode 100644 index 0000000..442d608 Binary files /dev/null and b/static/img/banner/25.jpg differ diff --git a/static/img/banner/30.jpg b/static/img/banner/30.jpg new file mode 100644 index 0000000..3b94813 Binary files /dev/null and b/static/img/banner/30.jpg differ diff --git a/static/img/banner/35.jpg b/static/img/banner/35.jpg new file mode 100644 index 0000000..cbabcd8 Binary files /dev/null and b/static/img/banner/35.jpg differ diff --git a/static/img/banner/40.jpg b/static/img/banner/40.jpg new file mode 100644 index 0000000..3b3d615 Binary files /dev/null and b/static/img/banner/40.jpg differ diff --git a/static/img/banner/45.jpg b/static/img/banner/45.jpg new file mode 100644 index 0000000..6b6c99f Binary files /dev/null and b/static/img/banner/45.jpg differ diff --git a/static/img/banner/5.jpg b/static/img/banner/5.jpg new file mode 100644 index 0000000..85ce247 Binary files /dev/null and b/static/img/banner/5.jpg differ diff --git a/static/img/banner/50.jpg b/static/img/banner/50.jpg new file mode 100644 index 0000000..a7c687c Binary files /dev/null and b/static/img/banner/50.jpg differ diff --git a/static/img/banner/55.jpg b/static/img/banner/55.jpg new file mode 100644 index 0000000..7595664 Binary files /dev/null and b/static/img/banner/55.jpg differ diff --git a/static/img/banner/60.jpg b/static/img/banner/60.jpg new file mode 100644 index 0000000..1462638 Binary files /dev/null and b/static/img/banner/60.jpg differ diff --git a/static/img/banner/65.jpg b/static/img/banner/65.jpg new file mode 100644 index 0000000..9614757 Binary files /dev/null and b/static/img/banner/65.jpg differ diff --git a/static/img/banner/70.jpg b/static/img/banner/70.jpg new file mode 100644 index 0000000..5ad7a8d Binary files /dev/null and b/static/img/banner/70.jpg differ diff --git a/static/img/banner/75.jpg b/static/img/banner/75.jpg new file mode 100644 index 0000000..8ba82f8 Binary files /dev/null and b/static/img/banner/75.jpg differ diff --git a/static/img/banner/80.jpg b/static/img/banner/80.jpg new file mode 100644 index 0000000..a6e2755 Binary files /dev/null and b/static/img/banner/80.jpg differ diff --git a/static/img/banner/85.jpg b/static/img/banner/85.jpg new file mode 100644 index 0000000..122c69a Binary files /dev/null and b/static/img/banner/85.jpg differ diff --git a/static/img/banner/90.jpg b/static/img/banner/90.jpg new file mode 100644 index 0000000..e6ad30c Binary files /dev/null and b/static/img/banner/90.jpg differ diff --git a/static/img/banner/95.jpg b/static/img/banner/95.jpg new file mode 100644 index 0000000..62e28c2 Binary files /dev/null and b/static/img/banner/95.jpg differ diff --git a/static/img/banner/attention.jpg b/static/img/banner/attention.jpg new file mode 100644 index 0000000..ffc1d86 Binary files /dev/null and b/static/img/banner/attention.jpg differ diff --git a/static/img/banner/idle.jpg b/static/img/banner/idle.jpg new file mode 100644 index 0000000..30cbafe Binary files /dev/null and b/static/img/banner/idle.jpg differ diff --git a/static/img/banner/off.jpg b/static/img/banner/off.jpg new file mode 100644 index 0000000..993986f Binary files /dev/null and b/static/img/banner/off.jpg differ diff --git a/themes/hugo-theme-flat/layouts/partials/html-end.html b/themes/hugo-theme-flat/layouts/partials/html-end.html index bd93e64..335cbb8 100644 --- a/themes/hugo-theme-flat/layouts/partials/html-end.html +++ b/themes/hugo-theme-flat/layouts/partials/html-end.html @@ -5,5 +5,4 @@ - - + diff --git a/themes/hugo-theme-flat/static/css/style.css b/themes/hugo-theme-flat/static/css/style.css index 2d170ad..05faf3a 100644 --- a/themes/hugo-theme-flat/static/css/style.css +++ b/themes/hugo-theme-flat/static/css/style.css @@ -268,18 +268,13 @@ a.external:after { /* .header-wrapper, .footer { width: 100vw; } */ .header { /*background-image: url("/img/banner.png");*/ - background-image: url("/img/banner_unknown.jpg"); + background-image: url("/img/banner/off.jpg"); background-size: cover; background-repeat: no-repeat; background-position-x: center ; background-position-y: top ; } -.door_open .header{ - background-image: url("/img/banner_open.jpg"); -} -.door_closed .header{ - background-image: url("/img/banner_closed.jpg"); -} + .header-wrapper, .footer { width: 90vw; diff --git a/themes/hugo-theme-flat/static/js/banner.js b/themes/hugo-theme-flat/static/js/banner.js new file mode 100644 index 0000000..09941bf --- /dev/null +++ b/themes/hugo-theme-flat/static/js/banner.js @@ -0,0 +1,99 @@ +let online,percentage,status; + +const update = function () { + let todo=3; + fetch("https://spaceapi.c3re.de/prusaxl_online.json") + .then(function (response) { + return response.json(); + }) + .then(function (data) { + online=data + todo--; + if(todo===0){ + run(); + } + }); + fetch("https://spaceapi.c3re.de/prusaxl_status.json") + .then(function (response) { + return response.text(); + }) + .then(function (data) { + status=data + todo--; + if(todo===0){ + run(); + } + }); + fetch("https://spaceapi.c3re.de/prusaxl_percentage.json") + .then(function (response) { + return response.text(); + }) + .then(function (data) { + + percentage=parseInt(data) + todo--; + if(todo===0){ + run(); + } + }); + } + + update(); +setInterval(update, 1000); + + +function run(){ + if(!online){ + setImage("OFF"); + }else{ + setImage(status,percentage); + } +} + +//[ IDLE, BUSY, PRINTING, PAUSED, FINISHED, STOPPED, ERROR, ATTENTION, READY ] + +function setImage(status,percentage){ + let el=document.getElementsByClassName("header")[0]; + let imagepath=getBannerPath(status,percentage); + if(imagepath) { + el.style.backgroundImage = "url('" + imagepath + "')"; + } +} + +function getBannerPath(status,percentage){ + if(status === "IDLE") { + return "/img/banner/idle.jpg"; + } else if(status === "BUSY") { + return null; + } else if(status === "PRINTING") { + + percentage = parseInt(percentage); + percentage = Math.min(100, percentage); + percentage = Math.max(0, percentage); + percentage = Math.floor(percentage/5)*5; + return "/img/banner/"+percentage+".jpg"; + + } else if(status === "PAUSED") { + return null; + } else if(status === "FINISHED") { + return "/img/banner/100.jpg"; + } + else if(status === "STOPPED") { + return "/img/banner/attention.jpg"; + } + else if(status === "ERROR") { + return "/img/banner/attention.jpg"; + } + else if(status === "ATTENTION") { + return "/img/banner/attention.jpg"; + } + else if(status === "READY") { + return "/img/banner/idle.jpg"; + } + else { + return "/img/banner/off.jpg"; + } + + + +} \ No newline at end of file diff --git a/themes/hugo-theme-flat/static/js/calendar.js b/themes/hugo-theme-flat/static/js/calendar.js deleted file mode 100644 index 74eac7e..0000000 --- a/themes/hugo-theme-flat/static/js/calendar.js +++ /dev/null @@ -1,87 +0,0 @@ -const calRefresh=function () { - let url = - "https://ical2json.c3re.de/api/?url=https%3A%2F%2Fcloud.c3re.de%2Fremote.php%2Fdav%2Fpublic-calendars%2FRLKKkdjNYgXH8yEz%3Fexport&start=today&end=next+month&maxitems=10"; - let xmlHttp = new XMLHttpRequest(); - let zeropad = function (i) { - let o = ""; - if (i <= 9) o += "0"; - o += i; - return o; - }; - xmlHttp.onreadystatechange = function () { - if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { - let cal = JSON.parse(xmlHttp.responseText); - let $ = jQuery; - let box = $("#calendar"); - - box.removeClass("loading"); - try{ - for( el of document.querySelectorAll("#calendar li")){ - el.remove() - } - }catch(e){} - for (let item of cal) { - let li = $("
  • "); - //li.text(item.summary) - let startDate = new Date(item.start * 1000); - - //check if the date is within today, not tomorrow, not yesterday - let today = new Date(); - let todayString = today.getFullYear() + "-" + zeropad(today.getMonth() + 1) + "-" + zeropad(today.getDate()); - let startDateString = startDate.getFullYear() + "-" + zeropad(startDate.getMonth() + 1) + "-" + zeropad(startDate.getDate()); - let todayClass="" - if (todayString === startDateString) todayClass=" today"; - - - let date = $(""); - date.text( - zeropad(startDate.getDate()) + - "." + - zeropad(1 + startDate.getMonth()) + - "." + - startDate.getFullYear() + - " - " + - zeropad(startDate.getHours()) + - ":" + - zeropad(startDate.getMinutes()) - ); - date.appendTo(li); - let summary = $(""); - summary.text(item.summary); - if (item.url) { - let a = $(""); - a.attr("href", item.url); - a.attr("title", item.description); - a.append(summary); - a.appendTo(li); - } else { - summary.appendTo(li); - } - if (item.location) { - let loc = $("📍"); - - loc.attr("data-loc", item.location); - loc.attr("title", "Click to copy: " + item.location); - loc.appendTo(date); - } - - li.attr("title", item.description); - li.appendTo(box); - } - try{ - document.querySelector("#calendar .loading").remove(); - }catch(e){} - - $(".location", box).click(function () { - navigator.clipboard.writeText($(this).attr("data-loc")); - }); - } - }; - xmlHttp.open("GET", url, true); // true for asynchronous - xmlHttp.send(); -} - -document.addEventListener("DOMContentLoaded", function(){ - calRefresh(); - setInterval(calRefresh, 1000*60*15); -}); diff --git a/themes/hugo-theme-flat/static/js/door-status.js b/themes/hugo-theme-flat/static/js/door-status.js deleted file mode 100644 index 87bed38..0000000 --- a/themes/hugo-theme-flat/static/js/door-status.js +++ /dev/null @@ -1,49 +0,0 @@ -document.addEventListener("DOMContentLoaded", function () { - const update = function () { - fetch("https://spaceapi.c3re.de/") - .then(function (response) { - return response.json(); - }) - .then(function (data) { - let body=document.getElementsByTagName("body")[0]; - let fav=document.querySelector("head link[rel='icon']"); - if (data.state.open) { - body.classList.remove("door_closed"); - body.classList.add("door_open"); - fav.setAttribute("href", "img/favopen.png") - } else { - body.classList.remove("door_open"); - body.classList.add("door_closed"); - fav.setAttribute("href", "img/favclosed.png") - - } - document - .getElementById("ds-img") - .setAttribute( - "src", - data.state.open ? data.state.icon.open : data.state.icon.closed - ); - document.getElementById("ds-status").innerHTML = data.state.open - ? "Geöffnet" - : "Geschlossen"; - - document.getElementById("ds-temp").innerHTML = - "" + - data.sensors.temperature[0].value + - data.sensors.temperature[0].unit; - const lastchange = new Date(data.state.lastchange * 1000); - document.getElementById("ds-date").innerHTML = - lastchange.getDate().toString().padStart(2, "0") + - "." + - (lastchange.getMonth() + 1).toString().padStart(2, "0") + - "." + - lastchange.getFullYear() + - " " + - lastchange.getHours().toString().padStart(2, "0") + - ":" + - lastchange.getMinutes().toString().padStart(2, "0"); - }); - }; - update(); - setInterval(update, 10000); -}); diff --git a/themes/hugo-theme-flat/static/js/href_handling.js b/themes/hugo-theme-flat/static/js/href_handling.js deleted file mode 100644 index be8bc00..0000000 --- a/themes/hugo-theme-flat/static/js/href_handling.js +++ /dev/null @@ -1,19 +0,0 @@ -document.addEventListener("DOMContentLoaded", function () { - document.querySelectorAll("a").forEach(function (element) { - const myhost = window.location.hostname; - const linkhost = new URL(element.href).hostname; - if (myhost === linkhost) { - let prefetchUrl = new URL(element.href).toString(); - // lest make a prefetch tag for this url - let link = document.createElement("link"); - link.setAttribute("rel", "prefetch"); - link.setAttribute("href", prefetchUrl); - link.setAttribute("as", "document"); - document.head.appendChild(link); - element.classList.add("internal"); - } else { - element.setAttribute("target", "_blank"); - element.classList.add("external"); - } - }); -});