--- import Layout from "../layouts/Layout.astro"; import Taskbar from "../components/taskbar.astro"; import App from "../components/app.astro"; import Aboutme from "../components/aboutme.astro"; import Redirect from "../components/redirect.astro"; import Contact from "../components/contact.astro"; import Pgp from "../components/pgp.astro"; import Projects from "../components/projects.astro"; import Duolingo from "../components/duolingo.astro"; import GitHubGraph from "../components/githubgraph.astro"; import NowPlaying from "../components/nowplaying.astro"; import Ram from "../components/ram.astro"; // Projects import Summize from "../components/projects/summize.astro"; import Notion from "../components/projects/notion.astro"; // import Imdb from "../components/projects/imdb.astro"; import "../styles/global.css"; import me from "../assets/apps/me.png"; import github from "../assets/apps/github.png"; import pastwork from "../assets/apps/pastWork.png"; import projects from "../assets/apps/projects.png"; import blog from "../assets/apps/blog.png"; import contact from "../assets/apps/contact.png"; import pgp from "../assets/apps/pgp.png"; import Glance from "../components/projects/glance.astro"; import ramIcon from "../assets/apps/blog.png"; function dragElement(elmnt) { var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; if (document.getElementById(elmnt.id + "header")) { document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown; document.getElementById(elmnt.id + "header").ontouchstart = dragMouseDown; } else { elmnt.onmousedown = dragMouseDown; elmnt.ontouchstart = dragMouseDown; } function dragMouseDown(e) { // e.preventDefault(); raiseUpSpec(elmnt.id); if (e.type == "touchstart") { pos3 = e.touches[0].clientX; pos4 = e.touches[0].clientY; } else { pos3 = e.clientX; pos4 = e.clientY; } document.onmouseup = closeDragElement; document.ontouchend = closeDragElement; document.onmousemove = elementDrag; document.ontouchmove = elementDrag; } function elementDrag(e) { // e.preventDefault(); if (e.type == "touchmove") { pos1 = pos3 - e.touches[0].clientX; pos2 = pos4 - e.touches[0].clientY; pos3 = e.touches[0].clientX; pos4 = e.touches[0].clientY; } else { pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; } elmnt.style.top = elmnt.offsetTop - pos2 + "px"; elmnt.style.left = elmnt.offsetLeft - pos1 + "px"; } function closeDragElement() { document.onmouseup = null; document.ontouchend = null; document.onmousemove = null; document.ontouchmove = null; } } /** Raise up window with given ID */ function raiseUpSpec(id: string) { console.log("raising ", id); let els = document.getElementsByClassName("window"); let elArray = Array.from(els as HTMLCollectionOf); // find the highest z-index let highestIndex = 0; for (let element in elArray) { let zindex = parseInt(elArray[element].style.zIndex); if (zindex > highestIndex) { highestIndex = zindex; } } // set the highest z-index plus one document.getElementById(id).style.zIndex = (highestIndex + 1).toString(); } function updateRedirectMessage() { const redirectElement = document.getElementById("Redirect"); const redirectUrl = redirectElement.dataset.redirecturl; // Access the data attribute const messageElement = redirectElement.querySelector("h2"); messageElement.innerHTML = `You are about to be redirected to ${redirectUrl.replace("https://", "")}`; const buttonElement = redirectElement.querySelector("#okButton"); // open redirect url buttonElement.setAttribute( "onclick", `window.location.href = "${redirectUrl}"` ); } let apps: app[] = [ { name: "About Me", logo: me.src, onclick: () => { raiseUpSpec("About Me"); document.getElementById("About Me").style.display = "block"; }, row: 1, }, // { // name: "Blog", // logo: blog.src, // onclick: () => { // raiseUpSpec("Redirect"); // document.getElementById("Redirect").style.display = "block"; // document.getElementById("Redirect").dataset.redirecturl = // "https://blog.simo.ng/"; // updateRedirectMessage(); // }, // row: 1, // }, { name: "Projects", logo: projects.src, onclick: () => { raiseUpSpec("Projects "); document.getElementById("Projects ").style.display = "block"; }, row: 1, }, // { // name: "Past Work", // logo: pastwork.src, // row: 1, // }, { name: "Git", logo: github.src, onclick: () => { // ignore raiseUpSpec("Redirect"); document.getElementById("Redirect").style.display = "block"; document.getElementById("Redirect").dataset.redirecturl = "https://git.simo.ng/simo"; updateRedirectMessage(); }, row: 2, }, { name: "RAM", logo: ramIcon.src, onclick: () => { raiseUpSpec("ram"); document.getElementById("ram").style.display = "block"; }, row: 2, }, { name: "Contact", logo: contact.src, row: 2, onclick: () => { raiseUpSpec("contact"); document.getElementById("contact").style.display = "block"; }, }, { name: "PGP Key", logo: pgp.src, row: 1, onclick: () => { raiseUpSpec("pgp"); document.getElementById("pgp").classList.add("fullscreen"); document.getElementById("pgp").style.display = "block"; }, }, ]; let projectsArr: project[] = [ { title: "Glance", id: "glance", }, { title: "Summize", id: "summize", }, { title: "Notion2Canvas", id: "notion", }, ]; const row1Items = apps.filter((item) => item.row === 1); const row2Items = apps.filter((item) => item.row === 2); let clientFunctions: Function[] | String[] = [ raiseUpSpec, updateRedirectMessage, dragElement, updateRedirectMessage, ]; clientFunctions = clientFunctions.map((item) => String(item)); apps = apps.map((item) => { item.onclick = String(item.onclick); return item; }); ---
{row1Items.map((item) => )}
{row2Items.map((item) => )}