-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
100 lines (90 loc) · 3.46 KB
/
index.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Homepage Erik Rohr</title>
<link rel="stylesheet" href="resources/dark-theme.css">
<style>
ul {
list-style: none outside none;
}
li {
margin-bottom: 5px;
}
td, th {
width: 50%;
text-align: center;
}
</style>
</head>
<body>
<div class="centered">
<div class="header">
<h1> Semesterprojekt Homepage </h1>
<h2>"Solution-Navigator"</h2>
</div>
<div class="header">
<h2> Allgemeines </h2>
</div>
<div class="content">
<table class="centered-wide-table">
<tr>
<th> Name </th>
<th> Matrikel-Nummer </th>
</tr>
<tr>
<td> <span id="name"> ... </span> </td>
<td> <span id="matnr"> ... </span> </td>
</tr>
</table>
<span id="err" style="color:red"></span>
</div>
<div class="header">
<h2> Übungen </h2>
</div>
<div class="content">
<ul>
<li> <a class="hover_element" href="Exercises/1/1.html" target="_self">Übung 1 | HTTP, URI & HTML</a> </li>
<li> <a class="hover_element" href="Exercises/2/1.html" target="_self">Übung 2 | CSS</a> </li>
<li> <a class="hover_element" href="Exercises/3/0.html" target="_self">Übung 3 | RWD</a> </li>
<li> <a class="hover_element" href="Exercises/4/1.html" target="_self">Übung 4 | JS</a> </li>
<li> <a class="hover_element" href="Exercises/5/1.html" target="_self">Übung 5 | DOM</a> </li>
<li> <a class="hover_element" href="Exercises/6/1.html" target="_self">Übung 6 | ES6</a> </li>
<li> <a class="hover_element" href="Exercises/7/1.html" target="_self">Übung 7 | Functional Programming</a> </li>
<li> <a class="hover_element" href="Exercises/7/1.html" target="_self">Übung 8 | Asynchronous JavaScript</a> </li>
</ul>
</div>
</div>
<script>
// Initialize DOM Elements
const name = document.getElementById("name");
const matrikelnummer = document.getElementById("matnr");
const err = document.getElementById("err");
// Path to the JSON
const path = "../resources/personal_info.json"
fetch(path)
.then(response => {
/*
Because 404 Errors are not network errors, fetch() will not throw errors to catch.
We have to generate an error ourselves.
*/
if (response.ok) {
return response.json()
}
throw new URIError(`FILE ${path} NOT FOUND`)
})
// Catch the URIError and set DOM Elements accordingly
.catch((error) => {
name.textContent = 'X';
matrikelnummer.textContent = 'X';
err.textContent = error;
console.error(error);
})
// If everything worked fine, set DOM Elements accordingly
.then(value => {
name.textContent = `${value["vorname"]} ${value["nachname"]}`;
matrikelnummer.textContent = `${value["matrikelnummer"]}`;
})
</script>
</body>
</html>