2 lines
5.2 KiB
JavaScript
2 lines
5.2 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"]'))r(t);new MutationObserver(t=>{for(const s of t)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).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 r(t){if(t.ep)return;t.ep=!0;const s=o(t);fetch(t.href,s)}})();function N(n,e,o){e.sort((i,d)=>new Date(i.start.dateTime)-new Date(d.start.dateTime));const r=document.createElement("div");r.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}r.appendChild(t);const s=document.createElement("div");if(s.className="event-row",e.forEach((i,d)=>{if(d<3){const c=document.createElement("div");c.className="flex-cell";const I=i.subject.length>18?i.subject.substring(0,18)+"...":i.subject,L=!i.location.displayName||i.organizer.emailAddress.address===n?"Walk-Up":i.organizer.emailAddress.name,M=p(i.start.dateTime+"Z"),H=p(i.end.dateTime+"Z");if(new Date(i.end.dateTime)>new Date){const f=document.createElement("div");f.textContent=I;const m=document.createElement("div");m.textContent=L,m.className="organizer";const u=document.createElement("div");u.className="time-range",u.innerHTML=`${M} - ${H}`,c.appendChild(f),c.appendChild(m),c.appendChild(u),s.appendChild(c)}}}),s.children.length===0){const i=document.createElement("div");i.className="flex-cell",i.textContent="No upcoming meetings at this time",s.appendChild(i)}r.appendChild(s),o.appendChild(r)}function p(n){const e=new Date(n),o=e.getHours(),r=e.getMinutes().toString().padStart(2,"0");return`<span class="time">${o}</span><span class="separator">:</span><span class="time">${r}</span>`}async function E(){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=>{N(t,e[t],o)})}function T(n){let e=p(new Date);n||(e=e.replace(":"," ")),document.getElementById("time").innerHTML=e}function w(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 C(){try{const n=await fetch("http://localhost:8080/api/quotes");if(n.ok){const o=(await n.json()).results,r=Math.floor(Math.random()*o.length),t=o[r];document.getElementById("quote").innerHTML=`<i>${t.content}</i>`,w("quote"),document.getElementById("author").innerHTML=`${t.author}`}else document.getElementById("quote").innerHTML="<i>Wishing you an utmost wonderful day!</i>",w("quote"),document.getElementById("author").innerHTML="Next-Generation Cities Institute"}catch(n){console.error("An error occurred:",n)}}async function b(){const e=await(await fetch("http://localhost:8080/api/weather")).json();if(e.cod===200){const o=e.main.temp,r=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=`${r}`}else document.getElementById("weather").innerText="Weather data unavailable"}async function S(){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();v(e)}catch(n){console.error("Error fetching slideshow images:",n)}}function k(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 h=0;function v(n){if(n.length===0){console.log("No images found for the slideshow.");return}const e=document.getElementById("slideshow");e.innerHTML="";const o=k(n[h]);e.appendChild(o),setTimeout(()=>{o.style.opacity="1"},100),setTimeout(()=>{for(;e.children.length>1;)e.removeChild(e.firstChild)},100),h=(h+1)%n.length,setTimeout(()=>v(n),3e4)}const g=document.getElementById("welcome-message"),x=document.querySelector("#welcome-message img"),y=["#00ADEF","#912338","#e5a712","#db0272","#8cc63e","#573996"],B=["black","white","black","white","black","white"];let a=0;function D(){g.classList.add("visible"),g.style.backgroundColor=y[a],x.src=B[a]==="white"?"ngci-logo-white-wide.svg":"ngci-logo-black.png",a=(a+1)%y.length}function $(){g.classList.remove("visible")}setInterval(function(){D(),setTimeout($,3e4)},6e5);C();setInterval(C,60*60*1e3);b();setInterval(b,5*60*1e3);let l=!0;T(l);setInterval(()=>{T(l),l=!l},1e3);S();E();setInterval(E,3*60*1e3);
|