-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
235 lines (204 loc) · 9.94 KB
/
index.html
File metadata and controls
235 lines (204 loc) · 9.94 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dataset Evaluation Explorer</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.feature-checkbox:checked + span {
font-weight: bold;
color: #2563eb;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen p-8">
<div class="max-w-6xl mx-auto">
<h1 class="text-3xl font-bold mb-6 text-gray-800">Dataset Evaluation Explorer</h1>
<p class="mb-8 text-gray-600">Filter repositories by JavaScript features and complexity criteria.</p>
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
<!-- Sidebar: Filters -->
<div class="md:col-span-1 bg-white p-6 rounded-lg shadow">
<h2 class="text-xl font-semibold mb-4">Filters</h2>
<div class="mb-6">
<h3 class="font-medium mb-2">Metrics</h3>
<div class="space-y-2">
<div>
<label class="block text-sm text-gray-600">Min Avg CC</label>
<input type="number" id="minCC" step="0.1" value="0" class="w-full border rounded px-2 py-1">
</div>
<div>
<label class="block text-sm text-gray-600">Min No. Units</label>
<input type="number" id="minUnits" value="0" class="w-full border rounded px-2 py-1">
</div>
</div>
</div>
<div class="mb-6">
<h3 class="font-medium mb-2">Features</h3>
<div id="feature-list" class="space-y-1 max-h-96 overflow-y-auto">
<!-- Features populated dynamically -->
</div>
</div>
<button id="reset-filters" class="w-full bg-gray-200 hover:bg-gray-300 text-gray-800 font-semibold py-2 px-4 rounded transition">
Reset Filters
</button>
</div>
<!-- Main Content: Results -->
<div class="md:col-span-3">
<div class="bg-white p-6 rounded-lg shadow mb-4">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold">
Results (<span id="count">0</span>)
</h2>
<div class="flex items-center space-x-4">
<div class="text-sm text-gray-500">
Showing projects that match <span class="font-bold">ALL</span> selected features.
</div>
<button id="download-btn"
class="bg-gray-200 hover:bg-gray-300 text-gray-800 font-semibold py-2 px-4 rounded transition">
Download Repository Links
</button>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Project</th>
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Avg CC</th>
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Units</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Link</th>
</tr>
</thead>
<tbody id="results-body" class="bg-white divide-y divide-gray-200">
<!-- Results populated dynamically -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
let data = { features: [], projects: [] };
let currentFilteredProjects = [];
const featureListEl = document.getElementById('feature-list');
const resultsBodyEl = document.getElementById('results-body');
const countEl = document.getElementById('count');
const minCCInput = document.getElementById('minCC');
const minUnitsInput = document.getElementById('minUnits');
async function loadData() {
try {
const response = await fetch('web_explorer/web_data.json');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`);
}
data = await response.json();
populateFeatures();
renderResults();
} catch (err) {
console.error('Error loading data:', err);
resultsBodyEl.innerHTML = `
<tr>
<td colspan="4" class="px-4 py-4 text-center text-red-500">
Error loading data: ${err.message}<br>
Make sure <strong>web_data.json</strong> is present in the /web_explorer directory.
</td>
</tr>`;
}
}
function populateFeatures() {
featureListEl.innerHTML = '';
data.features.forEach(feature => {
const label = document.createElement('label');
label.className = 'flex items-center space-x-2 cursor-pointer';
label.innerHTML = `
<input type="checkbox" value="${feature}" class="feature-checkbox rounded text-blue-600 focus:ring-blue-500">
<span class="text-sm text-gray-700">${feature.replace('JS:', '')}</span>
`;
label.querySelector('input').addEventListener('change', renderResults);
featureListEl.appendChild(label);
});
}
function getSelectedFeatures() {
return Array.from(document.querySelectorAll('.feature-checkbox:checked'))
.map(cb => cb.value);
}
function renderResults() {
const selectedFeatures = getSelectedFeatures();
const minCC = parseFloat(minCCInput.value) || 0;
const minUnits = parseInt(minUnitsInput.value) || 0;
currentFilteredProjects = data.projects.filter(project => {
// Feature filter (AND logic)
for (const feature of selectedFeatures) {
if (!project.features[feature]) return false;
}
// Metric filters
if (project.avg_cc < minCC) return false;
if (project.no_units < minUnits) return false;
return true;
});
countEl.textContent = currentFilteredProjects.length;
resultsBodyEl.innerHTML = '';
if (currentFilteredProjects.length === 0) {
resultsBodyEl.innerHTML = `
<tr>
<td colspan="4" class="px-4 py-4 text-center text-gray-500">
No projects match the criteria.
</td>
</tr>`;
return;
}
currentFilteredProjects.forEach(project => {
const row = document.createElement('tr');
row.className = 'hover:bg-gray-50';
row.innerHTML = `
<td class="px-4 py-3 text-sm font-medium text-gray-900">${project.name}</td>
<td class="px-4 py-3 text-sm text-gray-500 text-right">${project.avg_cc.toFixed(2)}</td>
<td class="px-4 py-3 text-sm text-gray-500 text-right">${project.no_units}</td>
<td class="px-4 py-3 text-sm text-blue-600">
${project.repo_link
? `<a href="${project.repo_link}" target="_blank" class="hover:underline">Repo</a>`
: '<span class="text-gray-400">N/A</span>'}
</td>
`;
resultsBodyEl.appendChild(row);
});
}
document.getElementById('download-btn').addEventListener('click', () => {
if (!currentFilteredProjects.length) {
alert("No repositories to download.");
return;
}
const links = currentFilteredProjects
.map(project => project.repo_link)
.filter(link => link);
if (!links.length) {
alert("No repository links available in current results.");
return;
}
const fileContent = links.join('\n');
const blob = new Blob([fileContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'filtered_repositories.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
});
[minCCInput, minUnitsInput].forEach(input => {
input.addEventListener('input', renderResults);
});
document.getElementById('reset-filters').addEventListener('click', () => {
document.querySelectorAll('.feature-checkbox')
.forEach(cb => cb.checked = false);
minCCInput.value = 0;
minUnitsInput.value = 0;
renderResults();
});
loadData();
</script>
</body>
</html>