-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfractal-view.js
62 lines (48 loc) · 1.65 KB
/
fractal-view.js
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
function loadFractals() {
loadFractal("3dgameoflife", "Game of Life", "3DGameOfLife");
loadFractal("carrito", "Carrito", "Carrito");
loadFractal("sierpinski", "Sierpinski", "Sierpinski");
loadFractal("asccimaldelbrot", "Ascii Maldelbrot", "AscciMandelbrot");
loadFractal("barsleyfractal", "Barnsley Fern Fractal", "Barnsley Fern Fractal");
loadFractal("cellularAutomata", "Cellular Automata", "CellularAutomata");
loadFractal("cesaroFractal", "Cesaro Fractal", "Cesaro Fractal");
loadFractal("fractalTree", "Fractal Tree", "Fractal tree");
loadFractal("LangstonAnt", "Langston Ant", "LangstonAnt");
loadFractal("mathrose", "Math Rose", "Math Rose");
}
function loadFractal(id, name, carpet) {
createView(
id,
name,
`./${carpet}/index.html`,
`./${carpet}/index.js`,
);
}
function createView(id, name, htmlFile, jsFile) {
$("body").append(`
<div class="container">
<div class="title">
<h1>${name}</h1>
</div>
<div class="fractal-container">
<iframe class="preview-container" src="${htmlFile}" title="description">
</iframe>
<pre class="code-container">
<code class="language-javascript" id="js-${id}">
</code>
</pre>
</div>
</div>
`);
loadCode(id, jsFile);
}
function loadCode(id, jsFile){
fetch(jsFile)
.then(response => response.text())
.then(code => {
document.getElementById('js-' + id ).textContent = code;
Prism.highlightAll();
})
.catch(error => console.error('Error loading JS file:', error));
}
loadFractals();