-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
242 lines (207 loc) · 7.21 KB
/
index.html
File metadata and controls
242 lines (207 loc) · 7.21 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
236
237
238
239
240
241
242
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IPO Details</title>
<style>
.ipo-table {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f9f9f9;
color: #333;
.container {
width: 90%;
margin: 20px auto;
overflow-x: auto;
}
h1 {
text-align: center;
margin-bottom: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th,
td {
border: 1px solid #ddd;
text-align: left;
padding: 8px;
}
th {
background-color: #4CAF50;
color: white;
cursor: pointer;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
a {
color: #4CAF50;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.chip {
display: inline-block;
padding: 5px 10px;
font-size: 14px;
color: white;
border-radius: 15px;
}
.chip.open {
background-color: #28a745;
}
.chip.closed {
background-color: #dc3545;
}
.chip.upcoming {
background-color: #ffc107;
color: #333;
}
.pagination {
text-align: center;
margin: 20px 0;
}
.pagination button {
padding: 10px 15px;
margin: 0 5px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
border-radius: 5px;
}
.pagination button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
}
</style>
</head>
<body>
<div class="ipo-table">
<div class="container">
<h1>IPO Details</h1>
<table id="ipoTable">
<thead>
<tr>
<th onclick="sortTable('name')">IPO Name</th>
<th onclick="sortTable('symbol')">Symbol</th>
<th onclick="sortTable('dates')">Dates</th>
<th onclick="sortTable('price')">Price Range</th>
<th onclick="sortTable('amount')">Amount</th>
<th onclick="sortTable('quantity')">Quantity</th>
<th>
<select id="statusFilter" onchange="filterByStatus()">
<option value="all">All</option>
<option value="open">Open</option>
<option value="closed">Closed</option>
<option value="upcoming">Upcoming</option>
</select>
</th>
</tr>
</thead>
<tbody>
<!-- Data will be dynamically inserted here -->
</tbody>
</table>
<div class="pagination" id="pagination">
<!-- Pagination buttons will be dynamically inserted here -->
</div>
</div>
</div>
<script>
let currentPage = 1;
const rowsPerPage = 15;
let filteredData = [];
let originalData = [];
// Fetch IPO data from external source
fetch('ipodata.json')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
originalData = data;
filteredData = data;
renderTable();
renderPagination();
})
.catch(error => {
console.error('Error fetching IPO data:', error);
});
function renderTable() {
const tableBody = document.getElementById('ipoTable').querySelector('tbody');
tableBody.innerHTML = '';
const start = (currentPage - 1) * rowsPerPage;
const end = start + rowsPerPage;
const pageData = filteredData.slice(start, end);
pageData.forEach(ipo => {
const row = document.createElement('tr');
// Extract URL and name
const [url, name] = ipo.name.split('||');
// Determine status chip
let statusClass = '';
if (ipo.status.toLowerCase() === 'open') {
statusClass = 'chip open';
} else if (ipo.status.toLowerCase() === 'closed') {
statusClass = 'chip closed';
} else if (ipo.status.toLowerCase() === 'upcoming') {
statusClass = 'chip upcoming';
}
row.innerHTML = `
<td><a href="${url}" target="_blank">${name}</a></td>
<td>${ipo.symbol}</td>
<td>${ipo.dates}</td>
<td>${ipo.price}</td>
<td>₹${ipo.amount.toLocaleString()}</td>
<td>${ipo.quantity}</td>
<td><span class="${statusClass}">${ipo.status}</span></td>
`;
tableBody.appendChild(row);
});
}
function renderPagination() {
const pagination = document.getElementById('pagination');
pagination.innerHTML = '';
const totalPages = Math.ceil(filteredData.length / rowsPerPage);
for (let i = 1; i <= totalPages; i++) {
const button = document.createElement('button');
button.textContent = i;
button.disabled = i === currentPage;
button.onclick = () => {
currentPage = i;
renderTable();
renderPagination();
};
pagination.appendChild(button);
}
}
function sortTable(key) {
filteredData.sort((a, b) => {
if (key === 'amount' || key === 'quantity') {
return a[key] - b[key];
}
return a[key].localeCompare(b[key]);
});
currentPage = 1;
renderTable();
renderPagination();
}
function filterByStatus() {
const status = document.getElementById('statusFilter').value;
filteredData = status === 'all' ? originalData : originalData.filter(ipo => ipo.status.toLowerCase() === status);
currentPage = 1;
renderTable();
renderPagination();
}
</script>
</body>
</html>