-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Expand file tree
/
Copy pathheatmap_index.js
More file actions
104 lines (88 loc) · 3.57 KB
/
heatmap_index.js
File metadata and controls
104 lines (88 loc) · 3.57 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Tachyon Profiler - Heatmap Index JavaScript
// Index page specific functionality
// ============================================================================
// Heatmap Bar Coloring
// ============================================================================
function applyHeatmapBarColors() {
const bars = document.querySelectorAll('.heatmap-bar[data-intensity]');
bars.forEach(bar => {
const intensity = parseFloat(bar.getAttribute('data-intensity')) || 0;
const color = intensityToColor(intensity);
bar.style.backgroundColor = color;
});
}
// ============================================================================
// Theme Support
// ============================================================================
function toggleTheme() {
toggleAndSaveTheme();
applyHeatmapBarColors();
}
// ============================================================================
// Type Section Toggle (stdlib, project, etc)
// ============================================================================
function toggleTypeSection(header) {
const section = header.parentElement;
const content = section.querySelector('.type-content');
const icon = header.querySelector('.type-icon');
if (content.style.display === 'none') {
content.style.display = 'block';
icon.textContent = '\u25BC';
} else {
content.style.display = 'none';
icon.textContent = '\u25B6';
}
}
// ============================================================================
// Folder Toggle
// ============================================================================
function toggleFolder(header) {
const folder = header.parentElement;
const content = folder.querySelector('.folder-content');
const icon = header.querySelector('.folder-icon');
if (content.style.display === 'none') {
content.style.display = 'block';
icon.textContent = '\u25BC';
folder.classList.remove('collapsed');
} else {
content.style.display = 'none';
icon.textContent = '\u25B6';
folder.classList.add('collapsed');
}
}
// ============================================================================
// Expand/Collapse All
// ============================================================================
function expandAll() {
// Expand all type sections
document.querySelectorAll('.type-section').forEach(section => {
const content = section.querySelector('.type-content');
const icon = section.querySelector('.type-icon');
content.style.display = 'block';
icon.textContent = '\u25BC';
});
// Expand all folders
document.querySelectorAll('.folder-node').forEach(folder => {
const content = folder.querySelector('.folder-content');
const icon = folder.querySelector('.folder-icon');
content.style.display = 'block';
icon.textContent = '\u25BC';
folder.classList.remove('collapsed');
});
}
function collapseAll() {
document.querySelectorAll('.folder-node').forEach(folder => {
const content = folder.querySelector('.folder-content');
const icon = folder.querySelector('.folder-icon');
content.style.display = 'none';
icon.textContent = '\u25B6';
folder.classList.add('collapsed');
});
}
// ============================================================================
// Initialization
// ============================================================================
document.addEventListener('DOMContentLoaded', function() {
restoreUIState();
applyHeatmapBarColors();
});