Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics Fundamentals / 01-Practice-03.10.2022 / exercise1.html
blob: 4968f5c010ce12f58f2c167b42de256aef27ce9c (plain) (blame)
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
<html>
	<head></head>
	<body>
		<script src="three.min.js"></script>
		<script>
			const scripts = [
				[ 'Exercise 04', 'ex04.js' ],
				[ 'Exercise 05', 'ex05.js' ],
				[ 'Exercise 06', 'ex06.js' ],
			];
		</script>
		<script>
			const scrCont = document.createElement('nav');
			scrCont.id = 'scrCont';
			document.body.insertBefore(scrCont, document.body.firstChild);
			const scrSel = document.createElement('select');
			scrSel.id = 'scrSel';
			scrCont.appendChild(scrSel);
		
			function renderScr (index) {
				var temp = document.createElement('script');
				temp.src = scripts[index][1];
				temp.id = scripts[index][1];
				document.body.appendChild(temp);
			}
			
			for (var i = 0; i < scripts.length; i++) {
				var temp = document.createElement('option');
				temp.value = i;
				temp.text = scripts[i][0];
				scrSel.appendChild(temp);
			}
			
			var oldIndex = scrSel.value;
			renderScr(scrSel.value);
			
			scrSel.onchange = function() {
				document.body.removeChild(document.getElementById(scripts[oldIndex][1]));
				document.body.removeChild(document.getElementsByTagName('canvas')[0]);
				renderScr(scrSel.value);
				oldIndex = scrSel.value;
			}
		</script>
	</body>
</html>