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 n of document.querySelectorAll('link[rel="modulepreload"]'))r(n);new MutationObserver(n=>{for(const s of n)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(n){const s={};return n.integrity&&(s.integrity=n.integrity),n.referrerPolicy&&(s.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?s.credentials="include":n.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(n){if(n.ep)return;n.ep=!0;const s=o(n);fetch(n.href,s)}})();function D(t,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 n=document.createElement("div");switch(n.className="title-row",t.split("@")[0]){case"s-er-1431-00":n.innerHTML="ER 1431-00 Open Space";break;case"s-er-1431-03":n.innerHTML="ER 1431-03 Visualization Lab";break;case"s-er-1431-33":n.innerHTML="ER 1431-33 Ideation Room";break;case"s-er-1431-37":n.innerHTML="ER 1431-37 Multipurpose Room";break;case"s-er-1431-39":n.innerHTML="ER 1431-39 Conference Room";break}r.appendChild(n);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 L=i.subject.length>18?i.subject.substring(0,18)+"...":i.subject,M=!i.location.displayName||i.organizer.emailAddress.address===t?"Walk-Up":i.organizer.emailAddress.name,H=p(i.start.dateTime+"Z"),S=p(i.end.dateTime+"Z");if(new Date(i.end.dateTime)>new Date){const g=document.createElement("div");g.textContent=L;const m=document.createElement("div");m.textContent=M,m.className="organizer";const u=document.createElement("div");u.className="time-range",u.innerHTML=`${H} - ${S}`,c.appendChild(g),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(t){const e=new Date(t),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("/api/events")).json(),o=document.getElementById("resources-container");o.innerHTML="",Object.keys(e).forEach(n=>{D(n,e[n],o)})}function T(t){let e=p(new Date);t||(e=e.replace(":"," ")),document.getElementById("time").innerHTML=e}function v(t){const e=document.getElementById(t),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 t=await fetch("/api/quotes");if(t.ok){const e=await t.json();if(e&&e.quote&&e.author)document.getElementById("quote").innerHTML=`<i>${e.quote}</i>`,v("quote"),document.getElementById("author").innerHTML=`${e.author}`;else throw new Error("Invalid quote data received")}else console.error("Server responded with status:",t.status),w()}catch(t){console.error("An error occurred:",t),w()}}function w(){document.getElementById("quote").innerHTML="<i>Wishing you an utmost wonderful day!</i>",v("quote"),document.getElementById("author").innerHTML="Next-Generation Cities Institute"}async function b(){const e=await(await fetch("/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 N(){try{const t=await fetch("/api/slideshow");if(!t.ok)throw new Error("Failed to fetch slideshow images");const e=await t.json
|