vizwall_screensaver/public/assets/index-DDszHAtm.js

2 lines
4.8 KiB
JavaScript

(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))i(t);new MutationObserver(t=>{for(const s of t)if(s.type==="childList")for(const r of s.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function o(t){const s={};return t.integrity&&(s.integrity=t.integrity),t.referrerPolicy&&(s.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?s.credentials="include":t.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(t){if(t.ep)return;t.ep=!0;const s=o(t);fetch(t.href,s)}})();function M(n,e,o){e.sort((r,l)=>new Date(r.start.dateTime)-new Date(l.start.dateTime));const i=document.createElement("div");i.className="resource-wrapper";const t=document.createElement("div");switch(t.className="title-row",n.split("@")[0]){case"s-er-1431-00":t.innerHTML="ER 1431-00 Open Space";break;case"s-er-1431-03":t.innerHTML="ER 1431-03 Visualization Lab";break;case"s-er-1431-33":t.innerHTML="ER 1431-33 Ideation Room";break;case"s-er-1431-37":t.innerHTML="ER 1431-37 Multipurpose Room";break;case"s-er-1431-39":t.innerHTML="ER 1431-39 Conference Room";break}i.appendChild(t);const s=document.createElement("div");if(s.className="event-row",e.forEach((r,l)=>{if(l<3){const a=document.createElement("div");a.className="flex-cell";const v=r.subject.length>18?r.subject.substring(0,18)+"...":r.subject,C=!r.location.displayName||r.organizer.emailAddress.address===n?"Walk-Up":r.organizer.emailAddress.name,L=h(r.start.dateTime+"Z"),I=h(r.end.dateTime+"Z");if(new Date(r.end.dateTime)>new Date){const p=document.createElement("div");p.textContent=v;const d=document.createElement("div");d.textContent=C,d.className="organizer";const m=document.createElement("div");m.className="time-range",m.innerHTML=`${L} - ${I}`,a.appendChild(p),a.appendChild(d),a.appendChild(m),s.appendChild(a)}}}),s.children.length===0){const r=document.createElement("div");r.className="flex-cell",r.textContent="No upcoming meetings at this time",s.appendChild(r)}i.appendChild(s),o.appendChild(i)}function h(n){const e=new Date(n),o=e.getHours(),i=e.getMinutes().toString().padStart(2,"0");return`<span class="time">${o}</span><span class="separator">:</span><span class="time">${i}</span>`}async function f(){console.log("fetching events");const e=await(await fetch("http://localhost:8080/api/events")).json(),o=document.getElementById("resources-container");o.innerHTML="",Object.keys(e).forEach(t=>{M(t,e[t],o)})}function g(n){let e=h(new Date);n||(e=e.replace(":"," ")),document.getElementById("time").innerHTML=e}function b(n){const e=document.getElementById(n),o=e.textContent.length;o<=83?e.style.fontSize="5em":o<=166?e.style.fontSize="4em":e.style.fontSize="3em"}async function w(){try{const n=await fetch("http://localhost:8080/api/quotes");if(n.ok){const o=(await n.json()).results,i=Math.floor(Math.random()*o.length),t=o[i];document.getElementById("quote").innerHTML=`<i>${t.content}</i>`,b("quote"),document.getElementById("author").innerHTML=`${t.author}`}else console.error("Failed to fetch data")}catch(n){console.error("An error occurred:",n)}}async function y(){const e=await(await fetch("http://localhost:8080/api/weather")).json();if(e.cod===200){const o=e.main.temp,i=e.weather[0].description,s=`https://openweathermap.org/img/wn/${e.weather[0].icon}.png`;document.getElementById("weather-icon-container").innerHTML=`<img id="weather-icon" alt="Weather Icon" src="${s}">`,document.getElementById("temperature").innerHTML=`${o}°`,document.getElementById("description").innerHTML=`${i}`}else document.getElementById("weather").innerText="Weather data unavailable"}async function H(){try{const n=await fetch("http://localhost:8080/api/slideshow");if(!n.ok)throw new Error("Failed to fetch slideshow images");const e=await n.json();E(e)}catch(n){console.error("Error fetching slideshow images:",n)}}function N(n){const e=document.createElement("img");e.src=`http://localhost:8080${n}`,e.className="slideshow-img",e.style.width="100%",e.style.maxHeight="100vh",e.style.objectFit="cover";const o=n.split("/").pop().split(".")[0];return e.alt=o,e.title=o,e}let u=0;function E(n){if(n.length===0){console.log("No images found for the slideshow.");return}const e=document.getElementById("slideshow");e.innerHTML="";const o=N(n[u]);e.appendChild(o),setTimeout(()=>{o.style.opacity="1"},100),setTimeout(()=>{for(;e.children.length>1;)e.removeChild(e.firstChild)},100),u=(u+1)%n.length,setTimeout(()=>E(n),3e4)}const T=document.getElementById("welcome-message");function S(){T.classList.add("visible")}function x(){T.classList.remove("visible")}setInterval(function(){S(),setTimeout(x,3e4)},6e5);w();setInterval(w,60*60*1e3);y();setInterval(y,5*60*1e3);let c=!0;g(c);setInterval(()=>{g(c),c=!c},1e3);H();f();setInterval(f,3*60*1e3);