-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
506 lines (455 loc) · 22.3 KB
/
index.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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CS:S to CS:GO FGD Comparison</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<style>
body { padding: 20px; }
.entity-name, .property-name, .input-name, .output-name, .spawnflag-name { cursor: pointer; }
.highlight-diff { background-color: #fff3cd; }
.complexity-high { color: #85272f; }
.complexity-medium { color: #ad8c28; }
.complexity-low { color: #237236; }
</style>
</head>
<body>
<div class="container">
<h1 class="mb-4">CS:S to CS:GO FGD Comparison</h1>
<div id="metadata" class="mb-4">
<h3>Metadata</h3>
<!-- Metadata will be populated here -->
</div>
<div class="mb-4">
<h3>Summary</h3>
<ul>
<li>New Entities: <span id="new-entities-count">0</span></li>
<li>Removed Entities: <span id="removed-entities-count">0</span></li>
<li>Modified Entities: <span id="modified-entities-count">0</span></li>
<li>Backward Porting Issues: <span id="backward-porting-issues-count">0</span></li>
</ul>
</div>
<div class="mb-4">
<h3>Entities</h3>
<div class="accordion" id="entitiesAccordion">
<!-- New Entities -->
<div class="accordion-item">
<h2 class="accordion-header" id="headingNew">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseNew" aria-expanded="false">
New Entities (<span id="new-entities-number">0</span>)
</button>
</h2>
<div id="collapseNew" class="accordion-collapse collapse" aria-labelledby="headingNew" data-bs-parent="#entitiesAccordion">
<div class="accordion-body">
<ul id="new-entities-list">
<!-- New entities will be populated here -->
</ul>
</div>
</div>
</div>
<!-- Removed Entities -->
<div class="accordion-item">
<h2 class="accordion-header" id="headingRemoved">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseRemoved" aria-expanded="false">
Removed Entities (<span id="removed-entities-number">0</span>)
</button>
</h2>
<div id="collapseRemoved" class="accordion-collapse collapse" aria-labelledby="headingRemoved" data-bs-parent="#entitiesAccordion">
<div class="accordion-body">
<ul id="removed-entities-list">
<!-- Removed entities will be populated here -->
</ul>
</div>
</div>
</div>
<!-- Modified Entities -->
<div class="accordion-item">
<h2 class="accordion-header" id="headingModified">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseModified" aria-expanded="false">
Modified Entities (<span id="modified-entities-number">0</span>)
</button>
</h2>
<div id="collapseModified" class="accordion-collapse collapse" aria-labelledby="headingModified" data-bs-parent="#entitiesAccordion">
<div class="accordion-body">
<div class="list-group" id="modified-entities-list">
<!-- Modified entities will be populated here -->
</div>
</div>
</div>
</div>
<!-- Backward Porting Issues -->
<div class="accordion-item">
<h2 class="accordion-header" id="headingBackwardPorting">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseBackwardPorting" aria-expanded="false">
Backward Porting Issues (<span id="backward-porting-issues-number">0</span>)
</button>
</h2>
<div id="collapseBackwardPorting" class="accordion-collapse collapse" aria-labelledby="headingBackwardPorting" data-bs-parent="#entitiesAccordion">
<div class="accordion-body">
<div class="list-group" id="backward-porting-issues-list">
<!-- Backward porting issues will be populated here -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Detailed Changes Modal -->
<div class="modal fade" id="detailsModal" tabindex="-1" aria-labelledby="detailsModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="detailsModalLabel">Entity Details</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="entity-details">
<!-- Content dynamically added -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script>
async function fetchData() {
try {
const response = await fetch('cs_fgd_differences.json');
if (!response.ok) {
throw new Error('Network response was not ok');
}
return await response.json();
} catch (error) {
console.error('Error fetching JSON data:', error);
alert('Failed to load JSON data. Please ensure "cs_fgd_differences.json" is in the correct directory.');
}
}
async function init() {
const data = await fetchData();
if (!data) return;
populateMetadata(data.metadata);
populateSummary(data);
populateEntitiesLists(data);
populateBackwardPortingIssues(data.backward_porting_issues);
}
function populateMetadata(metadata) {
const metadataDiv = document.getElementById('metadata');
metadataDiv.innerHTML = `
<p><strong>Comparison Date:</strong> ${metadata.comparison_date}</p>
<p><strong>CS:S Version:</strong> ${metadata.css_version}</p>
<p><strong>CS:GO Version:</strong> ${metadata.csgo_version}</p>
`;
}
function populateSummary(data) {
document.getElementById('new-entities-count').textContent = data.new_entities.length;
document.getElementById('removed-entities-count').textContent = data.removed_entities.length;
document.getElementById('modified-entities-count').textContent = Object.keys(data.modified_entities).length;
document.getElementById('backward-porting-issues-count').textContent = data.backward_porting_issues.length;
}
function populateEntitiesLists(data) {
populateEntityList('new-entities-list', data.new_entities);
populateEntityList('removed-entities-list', data.removed_entities);
populateModifiedEntitiesList(data.modified_entities);
}
function populateEntityList(elementId, entities) {
const list = document.getElementById(elementId);
list.innerHTML = '';
entities.forEach(entity => {
const li = document.createElement('li');
li.textContent = entity;
list.appendChild(li);
});
document.getElementById(`${elementId.split('-')[0]}-entities-number`).textContent = entities.length;
}
function populateModifiedEntitiesList(modifiedEntities) {
const list = document.getElementById('modified-entities-list');
list.innerHTML = '';
for (const [entityName, changes] of Object.entries(modifiedEntities)) {
const listItem = document.createElement('button');
listItem.className = `list-group-item list-group-item-action d-flex justify-content-between align-items-center complexity-${changes.backward_porting_complexity.toLowerCase()}`;
listItem.innerHTML = `
${entityName}
<span class="badge bg-primary rounded-pill">${getChangeCount(changes.changes_summary)}</span>
`;
listItem.addEventListener('click', () => showEntityDetails(entityName, changes));
list.appendChild(listItem);
}
document.getElementById('modified-entities-number').textContent = Object.keys(modifiedEntities).length;
}
function populateBackwardPortingIssues(issues) {
const list = document.getElementById('backward-porting-issues-list');
list.innerHTML = '';
issues.forEach(issue => {
const listItem = document.createElement('div');
listItem.className = `list-group-item list-group-item-action severity-${issue.severity.toLowerCase()}`;
listItem.innerHTML = `
<h6 class="mb-1">${issue.entity}</h6>
<p class="mb-1">${issue.issue}</p>
${issue.property ? `<small>Property: ${issue.property}</small>` : ''}
<span class="badge bg-secondary">${issue.severity}</span>
`;
list.appendChild(listItem);
});
document.getElementById('backward-porting-issues-number').textContent = issues.length;
}
function getChangeCount(changesSummary) {
return Object.values(changesSummary).reduce((total, changes) =>
total + changes.new + changes.removed + changes.modified, 0);
}
function showEntityDetails(entityName, changes) {
const modal = new bootstrap.Modal(document.getElementById('detailsModal'));
const modalTitle = document.getElementById('detailsModalLabel');
const modalBody = document.getElementById('entity-details');
modalTitle.textContent = `Entity: ${entityName} (Porting Complexity: ${changes.backward_porting_complexity})`;
modalBody.innerHTML = '';
// Changes summary
const summarySection = createChangesSummarySection(changes.changes_summary);
modalBody.appendChild(summarySection);
// Class type changes
if (changes.class_type) {
const classTypeSection = createClassTypeSection(changes.class_type);
modalBody.appendChild(classTypeSection);
}
// Description changes
if (changes.description) {
const descriptionSection = createDescriptionSection(changes.description);
modalBody.appendChild(descriptionSection);
}
// Definitions
if (changes.definitions) {
const definitionsSection = createDefinitionsSection(changes.definitions);
modalBody.appendChild(definitionsSection);
}
// Other sections
const sections = ['properties', 'inputs', 'outputs', 'spawnflags'];
sections.forEach(sectionName => {
if (changes[sectionName]) {
const section = createSection(sectionName, changes[sectionName]);
modalBody.appendChild(section);
}
});
modal.show();
}
function createChangesSummarySection(summary) {
const section = document.createElement('div');
section.className = 'mb-3';
section.innerHTML = `
<h5>Changes Summary</h5>
<ul>
${Object.entries(summary).map(([category, counts]) => `
<li>${capitalizeFirstLetter(category)}:
New: ${counts.new},
Removed: ${counts.removed},
Modified: ${counts.modified}
</li>
`).join('')}
</ul>
`;
return section;
}
function createClassTypeSection(classType) {
const section = document.createElement('div');
section.className = 'mb-3';
section.innerHTML = `
<h5>Class Type Changes</h5>
<p>CS:S: ${classType.css}</p>
<p>CS:GO: ${classType.csgo}</p>
`;
return section;
}
function createDescriptionSection(description) {
const section = document.createElement('div');
section.className = 'mb-3';
section.innerHTML = `
<h5>Description Changes</h5>
<p>CS:S: ${description.css}</p>
<p>CS:GO: ${description.csgo}</p>
`;
return section;
}
function createDefinitionsSection(definitions) {
const section = document.createElement('div');
section.className = 'mb-3';
section.innerHTML = `
<h5>Definitions</h5>
<h6>CS:S:</h6>
<ul>
${definitions.css.map(def => `<li>${def.name}(${def.args.join(', ')})</li>`).join('')}
</ul>
<h6>CS:GO:</h6>
<ul>
${definitions.csgo.map(def => `<li>${def.name}(${def.args.join(', ')})</li>`).join('')}
</ul>
`;
return section;
}
function createSection(sectionName, sectionData) {
const section = document.createElement('div');
section.className = 'mb-3';
const header = document.createElement('h5');
header.textContent = capitalizeFirstLetter(sectionName);
section.appendChild(header);
['new', 'removed', 'modified'].forEach(changeType => {
if (sectionData[changeType]) {
const subSection = createSubSection(sectionName, changeType, sectionData[changeType]);
if (subSection) section.appendChild(subSection);
}
});
return section;
}
function createSubSection(sectionName, changeType, changeData) {
if (!changeData || (Array.isArray(changeData) && changeData.length === 0) ||
(typeof changeData === 'object' && Object.keys(changeData).length === 0)) {
return null;
}
const subSection = document.createElement('div');
const subHeader = document.createElement('h6');
subHeader.textContent = capitalizeFirstLetter(changeType);
subSection.appendChild(subHeader);
if (Array.isArray(changeData)) {
const ul = document.createElement('ul');
changeData.forEach(item => {
const li = document.createElement('li');
li.innerHTML = formatValue(item);
ul.appendChild(li);
});
subSection.appendChild(ul);
} else if (typeof changeData === 'object') {
if (sectionName === 'spawnflags') {
const spawnflagsTable = createSpawnflagsTable({[changeType]: changeData});
subSection.appendChild(spawnflagsTable);
} else {
const table = createDifferencesTable(changeData);
subSection.appendChild(table);
}
}
return subSection;
}
function createDifferencesTable(diffs) {
const table = document.createElement('table');
table.className = 'table table-bordered table-sm';
table.innerHTML = `
<thead>
<tr>
<th>Attribute</th>
<th>CS:S</th>
<th>CS:GO</th>
</tr>
</thead>
<tbody>
${Object.entries(diffs).map(([attr, values]) => {
const cssValue = values.css !== undefined ? values.css : 'See JSON';
const csgoValue = values.csgo !== undefined ? values.csgo : 'See JSON';
return `
<tr class="${cssValue !== csgoValue ? 'highlight-diff' : ''}">
<td>${attr}</td>
<td>${formatValue(cssValue)}</td>
<td>${formatValue(csgoValue)}</td>
</tr>
`;
}).join('')}
</tbody>
`;
return table;
}
function createSpawnflagsTable(spawnflags) {
const table = document.createElement('table');
table.className = 'table table-bordered table-sm';
let tableContent = `
<thead>
<tr>
<th>Value</th>
<th>Display Name (CS:S)</th>
<th>Display Name (CS:GO)</th>
<th>Default Value (CS:S)</th>
<th>Default Value (CS:GO)</th>
<th>Change Type</th>
</tr>
</thead>
<tbody>
`;
const processSpawnflag = (value, data, type) => {
const cssDisplayName = data.display_name?.css || '';
const csgoDisplayName = data.display_name?.csgo || '';
const cssDefaultValue = data.default_value?.css ?? '';
const csgoDefaultValue = data.default_value?.csgo ?? '';
return `
<tr>
<td>${value}</td>
<td>${cssDisplayName}</td>
<td>${csgoDisplayName}</td>
<td>${cssDefaultValue}</td>
<td>${csgoDefaultValue}</td>
<td>${type}</td>
</tr>
`;
};
['new', 'removed', 'modified'].forEach(changeType => {
if (spawnflags[changeType]) {
if (Array.isArray(spawnflags[changeType])) {
spawnflags[changeType].forEach(flag => {
tableContent += processSpawnflag(flag.value, flag, capitalizeFirstLetter(changeType));
});
} else if (typeof spawnflags[changeType] === 'object') {
for (const [value, data] of Object.entries(spawnflags[changeType])) {
tableContent += processSpawnflag(value, data, capitalizeFirstLetter(changeType));
}
}
}
});
if (tableContent === table.innerHTML) {
tableContent += `
<tr>
<td colspan="6">No spawnflags data available</td>
</tr>
`;
}
tableContent += '</tbody>';
table.innerHTML = tableContent;
return table;
}
function formatValue(value) {
if (value === undefined || value === null) {
return "N/A";
}
if (typeof value === 'object') {
if (Array.isArray(value)) {
return value.map(item => formatValue(item)).join('<br>');
} else if (value.choices) {
return formatChoices(value.choices);
} else if (value.css !== undefined || value.csgo !== undefined) {
return `CS:S: ${formatValue(value.css)}<br>CS:GO: ${formatValue(value.csgo)}`;
} else if (value.value_type) {
return `Value Type: ${formatValue(value.value_type)}<br>Choices: ${formatValue(value.choices)}`;
} else {
return Object.entries(value)
.map(([k, v]) => `${k}: ${formatValue(v)}`)
.join('<br>');
}
}
return String(value);
}
function formatChoices(choices) {
if (!choices) {
return "No choices available";
}
if (Array.isArray(choices)) {
return choices.map(choice => `${choice.value}: ${choice.display_name}`).join('<br>');
}
return Object.entries(choices)
.map(([value, displayName]) => `${value}: ${displayName}`)
.join('<br>');
}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
// Initialize the page on load
document.addEventListener('DOMContentLoaded', init);
</script>
</body>
</html>