-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
52 lines (45 loc) · 2.02 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>p5.js Example</title>
<script>
let activeScript = 'hw0';
function loadScript(scriptName, active) {
const scripts = document.getElementsByTagName('script');
for (let i = 0; i < scripts.length; i++) {
if (scripts[i].getAttribute('type') === 'text/javascript') {
scripts[i].parentNode.removeChild(scripts[i]);
}
}
let scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';
scriptTag.src = scriptName;
document.body.appendChild(scriptTag);
document.querySelector('.active').classList.remove('active');
document.getElementById(active).classList.add('active');
activeScript = active;
}
</script>
</head>
<body onload="loadScript('hw0.js', 'hw0')">
<section>
<nav>
<ul>
<li><a href="#" onclick="loadScript('hw0.js', 'hw0')" class="active">hw0</a></li>
<li><a href="#" onclick="loadScript('lorenz.js', 'lorenz')">Lorenz</a></li>
<li><a href="#" onclick="loadScript('rosa.js', 'rosa')">Rosa</a></li>
<li><a href="#" onclick="loadScript('spirale.js', 'spirale')">Spirale</a></li>
<li><a href="#" onclick="loadScript('spread.js', 'spread')">Spread</a></li>
<li><a href="#" onclick="loadScript('projet.js', 'projet')">Projet</a></li>
</ul>
</nav>
</section>
</body>
</html>