-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmapping.html
328 lines (315 loc) · 17 KB
/
mapping.html
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="no-NB">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mapping Table</title>
<link rel="stylesheet" href="style.css">
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1, h2 {
text-align: center;
color: var(--primary-color);
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: var(--primary-background-color);
color: var(--primary-color);
}
tr:nth-child(even) {
background-color: var(--primary-color-10);
}
tr:hover {
background-color: var(--primary-color-20);
}
.note {
font-size: 0.9em;
color: #555;
}
.error {
color: var(--error-color);
}
.warning {
color: var(--warning-color);
}
.dropdown-info {
display: none;
position: absolute;
background-color: var(--primary-background-color);
border: 1px solid var(--primary-color);
padding: 10px;
z-index: 1000;
max-width: 300px;
font-size: 0.9em;
left: 50%;
transform: translateX(-50%);
}
tr.locked .dropdown-info {
display: block;
}
</style>
</head>
<body>
<h1>Mapping Table</h1>
<h2>Correctly Referenced Elements</h2>
<table>
<thead>
<tr>
<th>Element ID/Class</th>
<th>CSS File</th>
<th>JavaScript File</th>
<th>HTML File</th>
</tr>
</thead>
<tbody>
<!-- Correctly referenced elements will be populated here by JavaScript -->
</tbody>
</table>
<h2>Incorrectly Referenced Elements</h2>
<table id="error-table">
<thead>
<tr>
<th>Element ID/Class</th>
<th>Error/Warning</th>
</tr>
</thead>
<tbody>
<!-- Errors will be populated here by JavaScript -->
</tbody>
</table>
<h2>Unused Functions</h2>
<table id="unused-functions-table">
<thead>
<tr>
<th>Function Name</th>
<th>File</th>
<th>Line Number</th>
</tr>
</thead>
<tbody>
<!-- Unused functions will be populated here by JavaScript -->
</tbody>
</table>
<h2>Hidden Elements</h2>
<table id="hidden-elements-table">
<thead>
<tr>
<th>Element ID/Class</th>
<th>Hidden By</th>
<th>File</th>
<th>Line Number</th>
</tr>
</thead>
<tbody>
<!-- Hidden elements will be populated here by JavaScript -->
</tbody>
</table>
<div class="note">
<p><strong>Note:</strong> This table maps the elements in the HTML file to their corresponding CSS and JavaScript files. This helps in understanding the connections and dependencies between the files, making it easier to maintain and update the codebase.</p>
</div>
<h2>Tips and Tricks for Debugging</h2>
<div class="note">
<p><strong>Start with:</strong></p>
<ul>
<li>Check the console for any JavaScript errors.</li>
<li>Ensure all referenced IDs and classes are unique.</li>
<li>Verify that all CSS and JavaScript files are correctly linked.</li>
<li>Use browser developer tools to inspect elements and debug issues.</li>
</ul>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const elements = [
{ id: '#toggle-sidebar', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Toggles the sidebar visibility.' },
{ id: '#menu-placeholder', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Placeholder for the menu content.' },
{ id: '#student-form', css: 'style.css', js: '', html: 'index.html', description: 'Form for entering student names.' },
{ id: '#student-names', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Textarea for entering student names.' },
{ id: '#fetch-students', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to fetch students from a file.' },
{ id: '#fill-example-students', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to fill example students.' },
{ id: '#settings-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to toggle settings section.' },
{ id: '#file-input', css: '', js: 'script.js', html: 'index.html', description: 'File input for uploading student names.' },
{ id: '#reset-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to reset the seating chart.' },
{ id: '#settings-section', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Section for settings.' },
{ id: '#add-group-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to add a new group.' },
{ id: '#add-student-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to add a new student.' },
{ id: '#add-row-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to add a new row.' },
{ id: '#remove-row-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to remove a row.' },
{ id: '#num-rows', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Input for number of rows.' },
{ id: '#num-cols', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Input for number of columns.' },
{ id: '#apply-settings', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to apply settings.' },
{ id: '#generate-seating', css: '', js: '', html: 'index.html', description: 'Section for generating seating chart.' },
{ id: '#generate-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to generate seating chart.' },
{ id: '#groups-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to toggle help section.' },
{ id: '#toggle-advanced-requirements', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to toggle advanced requirements section.' },
{ id: '#sit-two-by-two', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Checkbox for sitting two by two.' },
{ id: '#groups-section', css: 'style.css', js: '', html: 'index.html', description: 'Section for help.' },
{ id: '#seating-style', css: 'style.css', js: '', html: 'index.html', description: 'Input for seating style.' },
{ id: '#advanced-requirements', css: 'style.css', js: '', html: 'index.html', description: 'Section for advanced requirements.' },
{ id: '#front-row-students', css: 'style.css', js: '', html: 'index.html', description: 'Textarea for students who should sit in the front row.' },
{ id: '#back-row-students', css: 'style.css', js: '', html: 'index.html', description: 'Textarea for students who should sit in the back row.' },
{ id: '#together-students', css: 'style.css', js: '', html: 'index.html', description: 'Textarea for students who should sit together.' },
{ id: '#apart-students', css: 'style.css', js: '', html: 'index.html', description: 'Textarea for students who should not sit together.' },
{ id: '#export-section', css: '', js: '', html: 'index.html', description: 'Section for exporting the seating chart.' },
{ id: '#export-pdf', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to export the seating chart as PDF.' },
{ id: '#editable-title', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Editable title for the seating chart.' },
{ id: '#editable-room-number', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Editable room number for the seating chart.' },
{ id: '#seating-chart', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Container for the seating chart.' },
{ id: '#kateter-cell', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Cell for the teacher\'s desk.' },
{ id: '#kateter-text', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Input for the teacher\'s desk label.' },
{ id: '#toggle-fixed-settings', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to toggle fixed settings.' },
{ id: '#fixed-settings', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Container for fixed settings.' },
{ id: '#toggle-generate-seating-heading', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to toggle generate seating heading.' },
{ id: '#toggle-visibility-button', css: 'style.css', js: 'script.js', html: 'index.html', description: 'Button to toggle visibility of grid lines.' }
];
const correctTableBody = document.querySelector('table tbody');
const errorTableBody = document.querySelector('#error-table tbody');
const unusedFunctionsTableBody = document.querySelector('#unused-functions-table tbody');
const hiddenElementsTableBody = document.querySelector('#hidden-elements-table tbody');
const ids = new Set();
const errors = [];
const unusedFunctions = [];
const hiddenElements = [];
elements.forEach(element => {
if (ids.has(element.id)) {
errors.push({ id: element.id, message: 'Duplicate ID', type: 'warning' });
} else {
ids.add(element.id);
}
if (!element.css && !element.js) {
errors.push({ id: element.id, message: 'Missing CSS and JavaScript references', type: 'error' });
} else {
const row = document.createElement('tr');
row.innerHTML = `
<td>${element.id}</td>
<td>${element.css}</td>
<td>${element.js}</td>
<td>${element.html}</td>
<div class="dropdown-info">
<p>${element.description}</p>
<p><a href="${element.css}" target="_blank">CSS: ${element.css}</a></p>
<p><a href="${element.js}" target="_blank">JS: ${element.js}</a></p>
<p><a href="${element.html}" target="_blank">HTML: ${element.html}</a></p>
</div>
`;
row.addEventListener('click', () => {
row.classList.toggle('locked');
});
correctTableBody.appendChild(row);
}
});
errors.forEach(error => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${error.id}</td>
<td class="${error.type}">${error.message}</td>
`;
errorTableBody.appendChild(row);
});
// Check for unused functions
const scriptContent = document.querySelector('script[src="script.js"]').textContent;
const functionNames = scriptContent.match(/function\s+(\w+)/g).map(fn => fn.replace('function ', ''));
functionNames.forEach(fn => {
if (!scriptContent.includes(`${fn}(`)) {
unusedFunctions.push({ name: fn, file: 'script.js', line: scriptContent.split('\n').findIndex(line => line.includes(`function ${fn}`)) + 1 });
}
});
unusedFunctions.forEach(fn => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${fn.name}</td>
<td>${fn.file}</td>
<td>${fn.line}</td>
<div class="dropdown-info">
<p>Function ${fn.name} is defined but not used.</p>
<p><a href="${fn.file}" target="_blank">File: ${fn.file}</a></p>
<p>Line: ${fn.line}</p>
</div>
`;
row.addEventListener('click', () => {
row.classList.toggle('locked');
});
unusedFunctionsTableBody.appendChild(row);
});
// Check for hidden elements
const cssContent = document.querySelector('link[href="style.css"]').sheet.cssRules;
Array.from(cssContent).forEach((rule, index) => {
if (rule.selectorText && rule.style.display === 'none') {
hiddenElements.push({ id: rule.selectorText, hiddenBy: 'CSS', file: 'style.css', line: index + 1 });
}
});
const scriptLines = scriptContent.split('\n');
scriptLines.forEach((line, index) => {
if (line.includes('.classList.add(\'hidden\')') || line.includes('.classList.toggle(\'hidden\')')) {
const elementId = line.match(/document\.getElementById\('([^']+)'\)/);
if (elementId) {
hiddenElements.push({ id: `#${elementId[1]}`, hiddenBy: 'JavaScript', file: 'script.js', line: index + 1 });
}
}
});
const htmlContent = document.documentElement.outerHTML.split('\n');
htmlContent.forEach((line, index) => {
if (line.includes('class="hidden"')) {
const elementId = line.match(/id="([^"]+)"/);
if (elementId) {
hiddenElements.push({ id: `#${elementId[1]}`, hiddenBy: 'HTML', file: 'index.html', line: index + 1 });
}
}
});
hiddenElements.forEach(element => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${element.id}</td>
<td>${element.hiddenBy}</td>
<td><a href="${element.file}" target="_blank">${element.file}</a></td>
<td>${element.line}</td>
`;
hiddenElementsTableBody.appendChild(row);
});
const unusedElements = [
{ id: '#export-pdf', file: 'index.html', line: 1, description: 'Button to export the seating chart as PDF.' },
{ id: '#toggle-advanced-requirements', file: 'index.html', line: 1, description: 'Button to toggle advanced requirements section.' },
{ id: '#add-row-button', file: 'index.html', line: 1, description: 'Button to add a new row.' },
{ id: '#remove-row-button', file: 'index.html', line: 1, description: 'Button to remove a row.' },
{ id: '#toggle-visibility-button', file: 'index.html', line: 1, description: 'Button to toggle visibility of grid lines.' }
];
unusedElements.forEach(element => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${element.id}</td>
<td>${element.file}</td>
<td>${element.line}</td>
<div class="dropdown-info">
<p>${element.description}</p>
<p><a href="${element.file}" target="_blank">File: ${element.file}</a></p>
<p>Line: ${element.line}</p>
</div>
`;
row.addEventListener('click', () => {
row.classList.toggle('locked');
});
unusedFunctionsTableBody.appendChild(row);
});
window.onerror = function(message, source, lineno, colno, error) {
const row = document.createElement('tr');
row.innerHTML = `
<td>JavaScript Error</td>
<td class="error">${message} at ${source}:${lineno}:${colno}</td>
`;
errorTableBody.appendChild(row);
};
});
</script>
</body>
</html>