Repository navigation
Expand file tree
/
Copy pathproject.js
More file actions
54 lines (47 loc) · 2.2 KB
/
Copy pathproject.js
File metadata and controls
54 lines (47 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function getQueryString() {
const queryString = window.location.search;
console.log(queryString.substring(1));
return queryString.substring(1);
}
import {projects} from "./Projects.js"
document.addEventListener("DOMContentLoaded", loadProjects)
function loadProjects() {
let github = ""
for (const project of projects) {
for (const key in project) {
if (key === "ID" && project[key] === getQueryString()) {
for (const key in project) {
if (key === "image") {
document.getElementById("image-header").style.background = `url(https://nanomars.github.io/Personal-Website/${project[key]})`;
document.getElementById("image-header").style.backgroundSize = "cover";
document.getElementById("image-header").style.backgroundPosition = "50% 50%";
} else if (key === "inpage-title" ) {
document.getElementById("text-header").innerHTML = project[key];
document.title = project[key];
} else if (key === "github") {
github = project[key];
}
}
let iframeLoaded = false
const contentIframe = document.getElementById("content-iframe");
contentIframe.src = `https://nanomars.github.io/Personal-Website/Projects/${project[key]}`;
contentIframe.addEventListener("load", () => {
if (iframeLoaded) {
return;
}
iframeLoaded = true;
contentIframe.height = (contentIframe.contentWindow.document.body.scrollHeight + 5) + "px";
console.log(contentIframe.contentWindow.location.href);
});
addEventListener("resize", () => {
contentIframe.height = (contentIframe.contentWindow.document.body.scrollHeight + 5) + "px";
});
}
}
}
if (github !== "") {
document.getElementById("github").href = github;
} else {
document.getElementById("github").style.display = "none";
}
}