generated from projeto-de-algoritmos/RepositorioTemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsquare.js
70 lines (65 loc) · 2.73 KB
/
square.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
const vertexSelect = document.getElementById('vertex-select');
const directDependents = document.getElementById('direct-dependents');
const indirectDependents = document.getElementById('indirect-dependents');
const dependenciesList = document.getElementById('dependencies');
function getColorForSubject(subject) {
const subjectData = data.find(obj => obj.materia === subject);
return subjectData ? subjectData.color : '#000';
}
function populateSelect() {
const vertices = graph.getVertices();
const index = vertices.indexOf('');
if (index !== -1) {
vertices.splice(index, 1);
}
vertices.forEach((vertex) => {
const option = document.createElement('option');
option.value = vertex;
option.textContent = vertex;
vertexSelect.appendChild(option);
});
}
function toggleLogoSize(logo) {
logo.classList.toggle('logo-enlarged');
}
function submitForm() {
const vertex = vertexSelect.value;
const dependents = findRelatedVertices(graph, vertex);
const directDependencies = dependents[0];
const indirectDependencies = dependents[1];
const indirectDependenciesContainer = document.getElementById('indirect-dependents');
indirectDependenciesContainer.innerHTML = '';
indirectDependencies.forEach((subject) => {
const box = document.createElement('div');
box.className = 'box';
box.style.backgroundColor = getColorForSubject(subject); // Adicione esta linha
const text = document.createElement('span');
text.textContent = subject;
box.appendChild(text);
indirectDependenciesContainer.appendChild(box);
});
const directDependenciesContainer = document.getElementById('direct-dependents');
directDependenciesContainer.innerHTML = '';
directDependencies.forEach((subject) => {
const box = document.createElement('div');
box.className = 'box';
box.style.backgroundColor = getColorForSubject(subject); // Adicione esta linha
const text = document.createElement('span');
text.textContent = subject;
box.appendChild(text);
directDependenciesContainer.appendChild(box);
});
const dependenciesContainer = document.getElementById('dependencies');
dependenciesContainer.innerHTML = '';
const dependencies = findDependenciesInGraph(graph, vertex);
dependencies.forEach((dependency) => {
const box = document.createElement('div');
box.className = 'box';
box.style.backgroundColor = getColorForSubject(dependency); // Adicione esta linha
const text = document.createElement('span');
text.textContent = dependency;
box.appendChild(text);
dependenciesContainer.appendChild(box);
});
}
populateSelect();