-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.html
76 lines (68 loc) · 2.63 KB
/
project.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Portfolio | Antti Vuorenmaa</title>
<meta name="description" content="Tekstianimaatio">
<meta name="author" content="Antti Vuorenmaa">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:300,400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/project.css">
<script src="./projects.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<main class="container">
<div class="project-container" id="project-container">
<div class="back-container">
<img src="./assets/arrow.svg" alt="Back" />
<a href="./index.html#projects">Back</a>
</div>
</div>
</main>
<footer>
<p id="footer-text"></p>
</footer>
<script>
// Set footer text to match current year
document.getElementById('footer-text').innerText = `Antti Vuorenmaa ${new Date().getFullYear()}`
function loadContent() {
var searchParams = {}
window.location.search.replace('?', '').split('&').forEach(function(x) {
var splitted = x.split('=')
searchParams[splitted[0]] = splitted[1]
})
if (!searchParams.v) {
// Show error
return handleNotFound()
} else {
var p = projects.find(function(x) {
return x.id === searchParams.v
})
if (!p) return handleNotFound() // Show error
document.title = p.name
var elem = (`
<div class="project-details">
<img src="${p.image}" alt="Project image">
<h2>${p.name}</h2>
<p>${p.fullDescription}</p>
</div>
`)
return document.getElementById('project-container').append(stringToHtml(elem))
}
}
loadContent()
function handleNotFound() {
var elem = '<h2>Project not found</h2>'
return document.getElementById('project-container').append(stringToHtml(elem))
}
function stringToHtml(html) {
var template = document.createElement('template')
html = html.trim()
template.innerHTML = html
return template.content.firstChild
}
</script>
</body>
</html>