-
Notifications
You must be signed in to change notification settings - Fork 0
/
vulpesPOG.js
90 lines (83 loc) · 2.07 KB
/
vulpesPOG.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
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
const d = document;
const masterComponent = d.getElementById("container");
const dados = [
{
name: "Bolinhas",
image: "Images/bolinhas.png",
link: "JavaScript/bolinhas/index.html",
type: "Plano de fundo",
},
{
name: "Conjuntos júlia",
image: "Images/julia.png",
link: "JavaScript/julia/index.html",
type: "Fractal",
},
{
name: "Du bist eine Fuchs",
image: "Images/foxgame.png",
link: "JavaScript/foxGame/index.html",
type: "Jogo",
},
{
name: "Formiga de Langton",
image: "Images/formigaDeLangton.png",
link: "JavaScript/formigaDeLangton/index.html",
type: "Autômato celular",
},
{
name: "Fractal Mandelbrot",
image: "Images/mandelbrot.png",
link: "JavaScript/Mandelbrot/index.html",
type: "Fractal",
},
{
name: "Labirinto Procedural",
image: "Images/maze.png",
link: "JavaScript/maze/index.html",
type: "Autômato celular",
},
{
name: "Labirinto Procedural Instantâneo",
image: "Images/maze2.png",
link: "JavaScript/maze2/index.html",
type: "Autômato celular",
},
];
let list = [];
let createComponent = ({ name, image, link }) =>
`<a href=${link}>
<div style="background-image:
linear-gradient(to left, black, rgba(0, 0, 0, 0)),
url(${image});"
>
<p>${name}</p>
</div>
</a>`;
function updateList(element) {
let item = element.id;
let index = list.indexOf(item);
if (index == -1) {
list.push(item);
element.style = "background: black";
} else {
list.splice(index, 1);
element.style = "background: white";
}
renderComponent();
}
function filterSites(site, array) {
if (array.length == 0) return true;
for (let condition of array) {
if (site.type === condition) return true;
}
return false;
}
function renderComponent() {
let components = "";
for (let site of dados) {
if (filterSites(site, list)) components += createComponent(site);
}
masterComponent.innerHTML = components;
}
renderComponent();