Skip to content

Commit daede12

Browse files
sqdortesqdorte
authored andcommitted
dynamically loading p5 scripts
1 parent 3b74103 commit daede12

File tree

7 files changed

+71
-88
lines changed

7 files changed

+71
-88
lines changed
File renamed without changes.

sqdorte/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>selgnairt</title>
7-
<style> body {padding: 0; margin: 0;} </style>
8-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.min.js"></script>
9-
<script src="selgnairt.js"></script>
6+
<title id="title">:: sqdorte ::</title>
7+
<link id="style" rel="stylesheet" type="text/css" href="style.css">
8+
<script id="script" src="menu.js"></script>
109
</head>
1110
<body>
11+
<ul id="ul">
12+
</ul>
1213
</body>
1314
</html>

sqdorte/jooj.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

sqdorte/menu.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
window.onload = function() {
2+
3+
arts = ['artegenerativafoda', 'generartistic', 'selgnairt'];
4+
ul = document.getElementById('ul');
5+
6+
arts.forEach(art => {
7+
a = document.createElement('A');
8+
a.setAttribute('onclick', `loadArt('${art}')`)
9+
a.innerHTML = art
10+
11+
li = document.createElement('LI');
12+
li.appendChild(a);
13+
14+
ul.appendChild(li);
15+
})
16+
}
17+
18+
function injectScript(src) {
19+
script = document.createElement('script');
20+
script.type = 'text/javascript';
21+
script.async = true;
22+
script.src = src;
23+
document.head.appendChild(script);
24+
}
25+
26+
function loadArt(name) {
27+
document.title = name;
28+
document.body.removeChild(document.getElementById('ul'));
29+
30+
document.getElementById('style').setAttribute('href', 'p5.css');
31+
32+
injectScript(`${name}.js`);
33+
injectScript('https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.min.js');
34+
35+
document.head.removeChild(document.getElementById('script'));
36+
}

sqdorte/p5.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
html, body {
2+
height: 100%;
3+
}
4+
5+
body {
6+
padding: 0;
7+
margin: 0;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
}

sqdorte/plzkillme.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

sqdorte/style.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ul {
2+
list-style: none;
3+
text-align: center;
4+
}
5+
6+
li {
7+
padding-top: 30px;
8+
}
9+
10+
a {
11+
outline: none;
12+
color: #4c4d4f;
13+
text-decoration: none;
14+
}
15+
16+
a:hover {
17+
font-weight: bold;
18+
color: #8fefb2;
19+
}

0 commit comments

Comments
 (0)