|
@@ -106,17 +106,24 @@ let apps: app[] = [
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+const row1Items = apps.filter((item) => item.row === 1);
|
|
|
|
|
+const row2Items = apps.filter((item) => item.row === 2);
|
|
|
|
|
+
|
|
|
|
|
+let clientFunctions: Function[] | String[] = [
|
|
|
|
|
+ raiseUpSpec,
|
|
|
|
|
+ updateRedirectMessage,
|
|
|
|
|
+]
|
|
|
|
|
+
|
|
|
|
|
+clientFunctions = clientFunctions.map((item) => String(item))
|
|
|
|
|
+
|
|
|
apps = apps.map((item, index) => {
|
|
apps = apps.map((item, index) => {
|
|
|
item.onclick = String(item.onclick);
|
|
item.onclick = String(item.onclick);
|
|
|
|
|
|
|
|
- // replace all functions inside with a string that expresses the function
|
|
|
|
|
- item.onclick = item.onclick.toString();
|
|
|
|
|
-
|
|
|
|
|
return item;
|
|
return item;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const row1Items = apps.filter((item) => item.row === 1);
|
|
|
|
|
-const row2Items = apps.filter((item) => item.row === 2);
|
|
|
|
|
---
|
|
---
|
|
|
|
|
|
|
|
<Layout title="Simo">
|
|
<Layout title="Simo">
|
|
@@ -136,54 +143,14 @@ const row2Items = apps.filter((item) => item.row === 2);
|
|
|
|
|
|
|
|
<Taskbar />
|
|
<Taskbar />
|
|
|
|
|
|
|
|
-<script define:vars={{ apps }}>
|
|
|
|
|
- function raiseUpSpec(id) {
|
|
|
|
|
- let els = document.getElementsByClassName("window");
|
|
|
|
|
-
|
|
|
|
|
- let elArray = Array.from(els);
|
|
|
|
|
-
|
|
|
|
|
- // find the highest z-index
|
|
|
|
|
- let highestIndex = 0;
|
|
|
|
|
|
|
+<script define:vars={{ apps, clientFunctions }}>
|
|
|
|
|
|
|
|
- for (let element in elArray) {
|
|
|
|
|
- // @ts-ignore
|
|
|
|
|
- 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 <a class="redirUrl" style=" cursor: pointer;
|
|
|
|
|
- color: blue;
|
|
|
|
|
- text-decoration: underline; " href="${redirectUrl}"">${redirectUrl}</a>`;
|
|
|
|
|
-
|
|
|
|
|
- const buttonElement = redirectElement.querySelector("#okButton");
|
|
|
|
|
- // open redirect url
|
|
|
|
|
- buttonElement.setAttribute(
|
|
|
|
|
- "onclick",
|
|
|
|
|
- `window.location.href = "${redirectUrl}"`
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ for(func in clientFunctions){
|
|
|
|
|
+ eval(clientFunctions[func])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // const abt = document.getElementById("AboutMe");
|
|
|
|
|
-
|
|
|
|
|
- // abt.addEventListener("click", () => {
|
|
|
|
|
- // console.log("test");
|
|
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
for (x in apps) {
|
|
for (x in apps) {
|
|
|
let app = apps[x];
|
|
let app = apps[x];
|
|
|
- console.info(app);
|
|
|
|
|
|
|
|
|
|
let itemName = app.name.replace(" ", "")
|
|
let itemName = app.name.replace(" ", "")
|
|
|
|
|
|
|
@@ -193,12 +160,9 @@ const row2Items = apps.filter((item) => item.row === 2);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log(`Adding onclick for ${app}, ${app.onclick}`);
|
|
|
|
|
-
|
|
|
|
|
document.getElementById(itemName).addEventListener("click", () => {
|
|
document.getElementById(itemName).addEventListener("click", () => {
|
|
|
const appFunc = eval(app.onclick);
|
|
const appFunc = eval(app.onclick);
|
|
|
appFunc();
|
|
appFunc();
|
|
|
- // console.log(ap)
|
|
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|