-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiles.html
100 lines (87 loc) · 3.17 KB
/
files.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>List Comparison</title>
<style>
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
padding: 10px;
text-align: center;
}
.highlight {
background-color: yellow;
}
</style>
</head>
<body>
<h2>List Comparison</h2>
<table id="comparisonTable">
<thead>
<tr>
<th>listABC</th>
<th>listXYZ</th>
</tr>
</thead>
<tbody>
<!-- Table rows will be generated dynamically using JavaScript -->
</tbody>
</table>
<script>
// Function to fetch text data from a file
function fetchTextFile(filename, callback) {
fetch(filename)
.then(response => response.text())
.then(data => callback(data))
.catch(error => console.error('Error:', error));
}
// Function to generate the table rows and compare/highlight items
function generateTable(listABCData, listXYZData) {
const table = document.getElementById("comparisonTable");
const tbody = table.querySelector("tbody");
const listABC = listABCData.split('\n').filter(Boolean); // Split by newline and remove empty lines
const listXYZ = listXYZData.split('\n').filter(Boolean); // Split by newline and remove empty lines
listABC.forEach((itemA) => {
const row = document.createElement("tr");
const cellA = document.createElement("td");
const cellB = document.createElement("td");
cellA.textContent = itemA;
if (listXYZ.includes(itemA)) {
cellB.textContent = itemA;
cellA.classList.add("highlight");
cellB.classList.add("highlight");
} else {
cellB.textContent = "";
}
row.appendChild(cellA);
row.appendChild(cellB);
tbody.appendChild(row);
});
listXYZ.forEach((itemB) => {
if (!listABC.includes(itemB)) {
const row = document.createElement("tr");
const cellA = document.createElement("td");
const cellB = document.createElement("td");
cellA.textContent = "";
cellB.textContent = itemB;
row.appendChild(cellA);
row.appendChild(cellB);
tbody.appendChild(row);
}
});
}
// Call the function to fetch text data for listABC and listXYZ
window.addEventListener("load", function () {
fetchTextFile('uat.txt', function (listABCData) {
fetchTextFile('prod.txt', function (listXYZData) {
generateTable(listABCData, listXYZData);
});
});
});
</script>
</body>
</html>