UlrickBL commited on
Commit
c041a1a
·
verified ·
1 Parent(s): 429e7a2

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +169 -0
index.html ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>CSV Table Viewer</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background-color: #fdf6fb;
11
+ color: #333;
12
+ margin: 0;
13
+ padding: 20px;
14
+ }
15
+ h1 {
16
+ text-align: center;
17
+ color: #d16ba5;
18
+ }
19
+ .table-container {
20
+ overflow-x: auto;
21
+ margin-top: 20px;
22
+ }
23
+ table {
24
+ width: 100%;
25
+ border-collapse: collapse;
26
+ margin: 0 auto;
27
+ background-color: #fff;
28
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
29
+ }
30
+ th, td {
31
+ padding: 10px;
32
+ text-align: left;
33
+ border: 1px solid #ddd;
34
+ }
35
+ th {
36
+ background-color: #f7d9eb;
37
+ color: #333;
38
+ font-weight: bold;
39
+ }
40
+ td {
41
+ white-space: nowrap;
42
+ overflow: hidden;
43
+ text-overflow: ellipsis;
44
+ }
45
+ td.expandable {
46
+ cursor: pointer;
47
+ }
48
+ .filter {
49
+ margin-bottom: 20px;
50
+ text-align: center;
51
+ }
52
+ .filter label {
53
+ font-size: 16px;
54
+ margin-right: 10px;
55
+ color: #d16ba5;
56
+ }
57
+ .filter select {
58
+ padding: 5px;
59
+ font-size: 16px;
60
+ border: 1px solid #ccc;
61
+ border-radius: 5px;
62
+ }
63
+ .expanded {
64
+ white-space: normal;
65
+ background-color: #fcebf7;
66
+ }
67
+ </style>
68
+ </head>
69
+ <body>
70
+ <h1>CSV Table Viewer</h1>
71
+ <div class="filter">
72
+ <label for="metricFilter">Filter by Metric Type:</label>
73
+ <select id="metricFilter">
74
+ <option value="">All</option>
75
+ </select>
76
+ </div>
77
+ <div class="table-container">
78
+ <table id="csvTable">
79
+ <thead>
80
+ <tr>
81
+ <th>Metric Type</th>
82
+ <th>Benchmark</th>
83
+ <th>Output Type</th>
84
+ <th>Details</th>
85
+ <th>Metric Example</th>
86
+ <th>Question + Context Example</th>
87
+ <th>Answer Example</th>
88
+ </tr>
89
+ </thead>
90
+ <tbody>
91
+ <!-- Rows will be dynamically added here -->
92
+ </tbody>
93
+ </table>
94
+ </div>
95
+
96
+ <script>
97
+ // Function to parse CSV file
98
+ function parseCSV(content) {
99
+ const rows = content.split("\n").filter(row => row.trim() !== "");
100
+ const headers = rows.shift().split(",");
101
+ return rows.map(row => {
102
+ const values = row.split(",");
103
+ const obj = {};
104
+ headers.forEach((header, index) => {
105
+ obj[header.trim()] = values[index]?.trim() || "";
106
+ });
107
+ return obj;
108
+ });
109
+ }
110
+
111
+ // Load CSV file
112
+ async function loadCSV(filePath) {
113
+ const response = await fetch(filePath);
114
+ const content = await response.text();
115
+ return parseCSV(content);
116
+ }
117
+
118
+ // Populate filter options
119
+ const metricFilter = document.getElementById('metricFilter');
120
+ const tableBody = document.getElementById('csvTable').querySelector('tbody');
121
+
122
+ function populateFilterOptions(data) {
123
+ const uniqueMetricTypes = [...new Set(data.map(row => row["Metric Type"]))];
124
+ uniqueMetricTypes.forEach(type => {
125
+ const option = document.createElement('option');
126
+ option.value = type;
127
+ option.textContent = type;
128
+ metricFilter.appendChild(option);
129
+ });
130
+ }
131
+
132
+ // Populate table
133
+ function populateTable(filteredData) {
134
+ tableBody.innerHTML = '';
135
+ filteredData.forEach(row => {
136
+ const tr = document.createElement('tr');
137
+
138
+ Object.values(row).forEach((value, index) => {
139
+ const td = document.createElement('td');
140
+ td.textContent = value;
141
+ if (index >= 4) { // Long content
142
+ td.classList.add('expandable');
143
+ td.title = 'Click to expand';
144
+ td.addEventListener('click', () => {
145
+ td.classList.toggle('expanded');
146
+ });
147
+ }
148
+ tr.appendChild(td);
149
+ });
150
+ tableBody.appendChild(tr);
151
+ });
152
+ }
153
+
154
+ metricFilter.addEventListener('change', () => {
155
+ const filterValue = metricFilter.value;
156
+ const filteredData = filterValue ? tableData.filter(row => row["Metric Type"] === filterValue) : tableData;
157
+ populateTable(filteredData);
158
+ });
159
+
160
+ // Initial load
161
+ let tableData = [];
162
+ loadCSV('data.csv').then(data => {
163
+ tableData = data;
164
+ populateFilterOptions(data);
165
+ populateTable(data);
166
+ });
167
+ </script>
168
+ </body>
169
+ </html>