Varun Hemachandran commited on
Commit
b0f8cf3
·
1 Parent(s): 8f99300

Enhance HTML viewer with improved UI, document categories, and built-in PDF viewer

Browse files
Files changed (1) hide show
  1. index.html +374 -88
index.html CHANGED
@@ -4,135 +4,421 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>JFK Document Release 2025</title>
 
7
  <style>
8
  body {
9
- font-family: Arial, sans-serif;
10
  line-height: 1.6;
11
- margin: 0;
12
- padding: 20px;
 
 
 
 
13
  max-width: 1200px;
14
- margin: 0 auto;
 
 
 
 
 
 
15
  }
16
  h1 {
17
- color: #333;
18
- border-bottom: 2px solid #ddd;
19
- padding-bottom: 10px;
20
  }
21
  .search-container {
22
  margin: 20px 0;
23
  }
24
- #search {
25
- padding: 8px;
26
- width: 300px;
27
- font-size: 16px;
28
  }
29
- table {
30
- width: 100%;
31
- border-collapse: collapse;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  margin-top: 20px;
33
  }
34
- th, td {
35
- padding: 12px;
36
- text-align: left;
37
- border-bottom: 1px solid #ddd;
 
 
 
 
 
 
 
38
  }
39
- th {
40
- background-color: #f2f2f2;
41
- font-weight: bold;
42
  }
43
- tr:hover {
44
- background-color: #f5f5f5;
 
45
  }
46
- a {
47
- color: #0066cc;
48
- text-decoration: none;
49
  }
50
- a:hover {
51
- text-decoration: underline;
 
 
 
 
 
52
  }
53
  .footer {
54
  margin-top: 30px;
55
- padding-top: 10px;
56
- border-top: 1px solid #ddd;
57
- color: #666;
 
 
 
 
 
 
 
 
 
58
  }
59
  </style>
60
  </head>
61
  <body>
62
- <h1>JFK Document Release 2025</h1>
63
- <p>Browse and search through declassified documents related to the assassination of President John F. Kennedy.</p>
64
-
65
- <div class="search-container">
66
- <input type="text" id="search" placeholder="Search documents..." onkeyup="filterDocuments()">
67
- </div>
68
-
69
- <table id="documents-table">
70
- <thead>
71
- <tr>
72
- <th>Document Name</th>
73
- <th>View Document</th>
74
- </tr>
75
- </thead>
76
- <tbody id="documents-list">
77
- <!-- Documents will be populated here by JavaScript -->
78
- </tbody>
79
- </table>
80
-
81
- <div class="footer">
82
- <p>This collection contains declassified documents related to the assassination of President John F. Kennedy.
83
- The documents were released by the National Archives and Records Administration (NARA) as part of the JFK Records Act.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  </div>
85
 
 
86
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  // Function to load document list
88
  async function loadDocuments() {
89
- const response = await fetch('https://huggingface.co/api/datasets/varunh/jfk-files-2025/tree/main/data');
90
- const data = await response.json();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
 
92
  const documentsList = document.getElementById('documents-list');
 
93
 
94
- // Sort files alphabetically
95
- data.sort((a, b) => a.path.localeCompare(b.path));
 
 
 
 
 
 
96
 
97
- data.forEach(file => {
98
- if (file.path.endsWith('.pdf')) {
99
- const fileName = file.path.split('/').pop();
100
-
101
- const row = document.createElement('tr');
102
-
103
- const nameCell = document.createElement('td');
104
- nameCell.textContent = fileName;
105
-
106
- const linkCell = document.createElement('td');
107
- const link = document.createElement('a');
108
- link.href = `https://huggingface.co/datasets/varunh/jfk-files-2025/resolve/main/${file.path}`;
109
- link.textContent = 'View PDF';
110
- link.target = '_blank';
111
- linkCell.appendChild(link);
112
-
113
- row.appendChild(nameCell);
114
- row.appendChild(linkCell);
115
-
116
- documentsList.appendChild(row);
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  });
 
 
 
119
  }
120
 
121
- // Function to filter documents based on search
122
- function filterDocuments() {
123
- const search = document.getElementById('search').value.toLowerCase();
124
- const rows = document.getElementById('documents-list').getElementsByTagName('tr');
125
 
126
- for (let i = 0; i < rows.length; i++) {
127
- const documentName = rows[i].getElementsByTagName('td')[0].textContent.toLowerCase();
128
- if (documentName.includes(search)) {
129
- rows[i].style.display = '';
130
- } else {
131
- rows[i].style.display = 'none';
 
 
 
 
 
 
132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  // Load documents when page loads
137
  window.onload = loadDocuments;
138
  </script>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>JFK Document Release 2025</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
  <style>
9
  body {
10
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
11
  line-height: 1.6;
12
+ color: #333;
13
+ background-color: #f8f9fa;
14
+ padding-top: 20px;
15
+ padding-bottom: 40px;
16
+ }
17
+ .container {
18
  max-width: 1200px;
19
+ }
20
+ .header {
21
+ background-color: #fff;
22
+ border-radius: 8px;
23
+ padding: 20px;
24
+ margin-bottom: 20px;
25
+ box-shadow: 0 2px 4px rgba(0,0,0,0.05);
26
  }
27
  h1 {
28
+ color: #212529;
29
+ margin-bottom: 15px;
 
30
  }
31
  .search-container {
32
  margin: 20px 0;
33
  }
34
+ .card {
35
+ margin-bottom: 20px;
36
+ box-shadow: 0 2px 4px rgba(0,0,0,0.05);
 
37
  }
38
+ .document-card:hover {
39
+ transform: translateY(-2px);
40
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
41
+ transition: all 0.3s ease;
42
+ }
43
+ .table {
44
+ background-color: #fff;
45
+ border-radius: 8px;
46
+ overflow: hidden;
47
+ box-shadow: 0 2px 4px rgba(0,0,0,0.05);
48
+ }
49
+ .table th {
50
+ background-color: #f1f3f5;
51
+ border-top: none;
52
+ }
53
+ .pagination {
54
+ justify-content: center;
55
  margin-top: 20px;
56
  }
57
+ .document-category {
58
+ display: inline-block;
59
+ padding: 2px 8px;
60
+ border-radius: 4px;
61
+ font-size: 12px;
62
+ font-weight: 600;
63
+ margin-right: 5px;
64
+ }
65
+ .category-CIA {
66
+ background-color: #e3f2fd;
67
+ color: #0d6efd;
68
  }
69
+ .category-FBI {
70
+ background-color: #fff3cd;
71
+ color: #ffc107;
72
  }
73
+ .category-HSCA {
74
+ background-color: #d1e7dd;
75
+ color: #198754;
76
  }
77
+ .category-Other {
78
+ background-color: #f8d7da;
79
+ color: #dc3545;
80
  }
81
+ .loading {
82
+ text-align: center;
83
+ padding: 40px;
84
+ }
85
+ .loading-spinner {
86
+ width: 3rem;
87
+ height: 3rem;
88
  }
89
  .footer {
90
  margin-top: 30px;
91
+ padding: 20px;
92
+ background-color: #fff;
93
+ border-radius: 8px;
94
+ box-shadow: 0 2px 4px rgba(0,0,0,0.05);
95
+ }
96
+ #documentViewer {
97
+ height: 600px;
98
+ width: 100%;
99
+ border: none;
100
+ }
101
+ .modal-xl {
102
+ max-width: 90%;
103
  }
104
  </style>
105
  </head>
106
  <body>
107
+ <div class="container">
108
+ <div class="header">
109
+ <h1>JFK Document Release 2025</h1>
110
+ <p class="lead">Browse and search through declassified documents related to the assassination of President John F. Kennedy.</p>
111
+ </div>
112
+
113
+ <div class="card">
114
+ <div class="card-body">
115
+ <div class="row">
116
+ <div class="col-md-6">
117
+ <div class="input-group mb-3">
118
+ <input type="text" id="search" class="form-control" placeholder="Search documents by name or content..." aria-label="Search documents">
119
+ <button class="btn btn-primary" type="button" onclick="filterDocuments()">Search</button>
120
+ </div>
121
+ </div>
122
+ <div class="col-md-6">
123
+ <div class="d-flex justify-content-end">
124
+ <div class="btn-group" role="group">
125
+ <button type="button" class="btn btn-outline-secondary" onclick="filterByCategory('all')">All</button>
126
+ <button type="button" class="btn btn-outline-primary" onclick="filterByCategory('CIA')">CIA</button>
127
+ <button type="button" class="btn btn-outline-warning" onclick="filterByCategory('FBI')">FBI</button>
128
+ <button type="button" class="btn btn-outline-success" onclick="filterByCategory('HSCA')">HSCA</button>
129
+ <button type="button" class="btn btn-outline-danger" onclick="filterByCategory('Other')">Other</button>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </div>
136
+
137
+ <div class="loading" id="loading">
138
+ <div class="spinner-border loading-spinner text-primary" role="status">
139
+ <span class="visually-hidden">Loading...</span>
140
+ </div>
141
+ <p class="mt-3">Loading documents...</p>
142
+ </div>
143
+
144
+ <div id="documentsContainer" style="display: none;">
145
+ <table class="table table-hover" id="documents-table">
146
+ <thead>
147
+ <tr>
148
+ <th scope="col">Document Name</th>
149
+ <th scope="col">Category</th>
150
+ <th scope="col">Size</th>
151
+ <th scope="col">Actions</th>
152
+ </tr>
153
+ </thead>
154
+ <tbody id="documents-list">
155
+ <!-- Documents will be populated here by JavaScript -->
156
+ </tbody>
157
+ </table>
158
+
159
+ <nav aria-label="Document pagination">
160
+ <ul class="pagination" id="pagination">
161
+ <!-- Pagination will be populated here by JavaScript -->
162
+ </ul>
163
+ </nav>
164
+ </div>
165
+
166
+ <!-- Document Viewer Modal -->
167
+ <div class="modal fade" id="documentModal" tabindex="-1" aria-labelledby="documentModalLabel" aria-hidden="true">
168
+ <div class="modal-dialog modal-xl modal-dialog-centered">
169
+ <div class="modal-content">
170
+ <div class="modal-header">
171
+ <h5 class="modal-title" id="documentModalLabel">Document Viewer</h5>
172
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
173
+ </div>
174
+ <div class="modal-body">
175
+ <iframe id="documentViewer" title="Document Viewer"></iframe>
176
+ </div>
177
+ <div class="modal-footer">
178
+ <a id="downloadLink" href="#" class="btn btn-primary" download>Download Document</a>
179
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
180
+ </div>
181
+ </div>
182
+ </div>
183
+ </div>
184
+
185
+ <div class="footer">
186
+ <h4>About this Collection</h4>
187
+ <p>This collection contains declassified documents related to the assassination of President John F. Kennedy.
188
+ The documents were released by the National Archives and Records Administration (NARA) as part of the JFK Records Act.</p>
189
+ <p>The documents follow the National Archives naming convention: <code>104-XXXXX-XXXXX.pdf</code></p>
190
+ <p>For more information, visit the <a href="https://github.com/varun-heman/jfk-files-2025" target="_blank">GitHub repository</a>.</p>
191
+ </div>
192
  </div>
193
 
194
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
195
  <script>
196
+ // Global variables
197
+ let allDocuments = [];
198
+ let currentPage = 1;
199
+ let documentsPerPage = 20;
200
+ let currentCategory = 'all';
201
+ let currentSearch = '';
202
+
203
+ // Document modal
204
+ const documentModal = new bootstrap.Modal(document.getElementById('documentModal'));
205
+
206
+ // Function to determine document category based on filename
207
+ function getDocumentCategory(fileName) {
208
+ if (fileName.includes('104-10')) return 'FBI';
209
+ if (fileName.includes('157-10')) return 'CIA';
210
+ if (fileName.includes('180-10')) return 'HSCA';
211
+ return 'Other';
212
+ }
213
+
214
+ // Function to format file size
215
+ function formatFileSize(bytes) {
216
+ if (bytes < 1024) return bytes + ' B';
217
+ if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB';
218
+ return (bytes / (1024 * 1024)).toFixed(2) + ' MB';
219
+ }
220
+
221
  // Function to load document list
222
  async function loadDocuments() {
223
+ try {
224
+ const response = await fetch('https://huggingface.co/api/datasets/varunh/jfk-files-2025/tree/main/data');
225
+ const data = await response.json();
226
+
227
+ // Sort files alphabetically
228
+ allDocuments = data
229
+ .filter(file => file.path.endsWith('.pdf'))
230
+ .map(file => {
231
+ const fileName = file.path.split('/').pop();
232
+ return {
233
+ name: fileName,
234
+ path: file.path,
235
+ size: file.size || 0,
236
+ category: getDocumentCategory(fileName)
237
+ };
238
+ })
239
+ .sort((a, b) => a.name.localeCompare(b.name));
240
+
241
+ // Hide loading indicator and show documents
242
+ document.getElementById('loading').style.display = 'none';
243
+ document.getElementById('documentsContainer').style.display = 'block';
244
+
245
+ // Display the documents
246
+ displayDocuments();
247
+ } catch (error) {
248
+ console.error('Error loading documents:', error);
249
+ document.getElementById('loading').innerHTML = `
250
+ <div class="alert alert-danger" role="alert">
251
+ Error loading documents. Please try again later.
252
+ </div>
253
+ `;
254
+ }
255
+ }
256
+
257
+ // Function to display documents with pagination
258
+ function displayDocuments() {
259
+ // Filter documents based on search and category
260
+ let filteredDocuments = allDocuments.filter(doc => {
261
+ const matchesSearch = currentSearch === '' ||
262
+ doc.name.toLowerCase().includes(currentSearch.toLowerCase());
263
+ const matchesCategory = currentCategory === 'all' ||
264
+ doc.category === currentCategory;
265
+ return matchesSearch && matchesCategory;
266
+ });
267
+
268
+ // Calculate pagination
269
+ const totalPages = Math.ceil(filteredDocuments.length / documentsPerPage);
270
+ const startIndex = (currentPage - 1) * documentsPerPage;
271
+ const endIndex = Math.min(startIndex + documentsPerPage, filteredDocuments.length);
272
+ const currentDocuments = filteredDocuments.slice(startIndex, endIndex);
273
 
274
+ // Display documents
275
  const documentsList = document.getElementById('documents-list');
276
+ documentsList.innerHTML = '';
277
 
278
+ if (currentDocuments.length === 0) {
279
+ documentsList.innerHTML = `
280
+ <tr>
281
+ <td colspan="4" class="text-center">No documents found matching your criteria.</td>
282
+ </tr>
283
+ `;
284
+ return;
285
+ }
286
 
287
+ currentDocuments.forEach(doc => {
288
+ const row = document.createElement('tr');
289
+ row.className = 'document-card';
290
+
291
+ const nameCell = document.createElement('td');
292
+ nameCell.textContent = doc.name;
293
+
294
+ const categoryCell = document.createElement('td');
295
+ const categorySpan = document.createElement('span');
296
+ categorySpan.className = `document-category category-${doc.category}`;
297
+ categorySpan.textContent = doc.category;
298
+ categoryCell.appendChild(categorySpan);
299
+
300
+ const sizeCell = document.createElement('td');
301
+ sizeCell.textContent = formatFileSize(doc.size);
302
+
303
+ const actionsCell = document.createElement('td');
304
+
305
+ const viewButton = document.createElement('button');
306
+ viewButton.className = 'btn btn-sm btn-primary me-2';
307
+ viewButton.textContent = 'View';
308
+ viewButton.onclick = () => viewDocument(doc);
309
+
310
+ const downloadLink = document.createElement('a');
311
+ downloadLink.className = 'btn btn-sm btn-outline-secondary';
312
+ downloadLink.href = `https://huggingface.co/datasets/varunh/jfk-files-2025/resolve/main/${doc.path}`;
313
+ downloadLink.textContent = 'Download';
314
+ downloadLink.download = doc.name;
315
+
316
+ actionsCell.appendChild(viewButton);
317
+ actionsCell.appendChild(downloadLink);
318
+
319
+ row.appendChild(nameCell);
320
+ row.appendChild(categoryCell);
321
+ row.appendChild(sizeCell);
322
+ row.appendChild(actionsCell);
323
+
324
+ documentsList.appendChild(row);
325
  });
326
+
327
+ // Update pagination
328
+ updatePagination(totalPages);
329
  }
330
 
331
+ // Function to update pagination controls
332
+ function updatePagination(totalPages) {
333
+ const pagination = document.getElementById('pagination');
334
+ pagination.innerHTML = '';
335
 
336
+ // Previous button
337
+ const prevItem = document.createElement('li');
338
+ prevItem.className = `page-item ${currentPage === 1 ? 'disabled' : ''}`;
339
+ const prevLink = document.createElement('a');
340
+ prevLink.className = 'page-link';
341
+ prevLink.href = '#';
342
+ prevLink.textContent = 'Previous';
343
+ prevLink.onclick = (e) => {
344
+ e.preventDefault();
345
+ if (currentPage > 1) {
346
+ currentPage--;
347
+ displayDocuments();
348
  }
349
+ };
350
+ prevItem.appendChild(prevLink);
351
+ pagination.appendChild(prevItem);
352
+
353
+ // Page numbers
354
+ const maxVisiblePages = 5;
355
+ const startPage = Math.max(1, currentPage - Math.floor(maxVisiblePages / 2));
356
+ const endPage = Math.min(totalPages, startPage + maxVisiblePages - 1);
357
+
358
+ for (let i = startPage; i <= endPage; i++) {
359
+ const pageItem = document.createElement('li');
360
+ pageItem.className = `page-item ${i === currentPage ? 'active' : ''}`;
361
+ const pageLink = document.createElement('a');
362
+ pageLink.className = 'page-link';
363
+ pageLink.href = '#';
364
+ pageLink.textContent = i;
365
+ pageLink.onclick = (e) => {
366
+ e.preventDefault();
367
+ currentPage = i;
368
+ displayDocuments();
369
+ };
370
+ pageItem.appendChild(pageLink);
371
+ pagination.appendChild(pageItem);
372
  }
373
+
374
+ // Next button
375
+ const nextItem = document.createElement('li');
376
+ nextItem.className = `page-item ${currentPage === totalPages ? 'disabled' : ''}`;
377
+ const nextLink = document.createElement('a');
378
+ nextLink.className = 'page-link';
379
+ nextLink.href = '#';
380
+ nextLink.textContent = 'Next';
381
+ nextLink.onclick = (e) => {
382
+ e.preventDefault();
383
+ if (currentPage < totalPages) {
384
+ currentPage++;
385
+ displayDocuments();
386
+ }
387
+ };
388
+ nextItem.appendChild(nextLink);
389
+ pagination.appendChild(nextItem);
390
+ }
391
+
392
+ // Function to filter documents based on search
393
+ function filterDocuments() {
394
+ currentSearch = document.getElementById('search').value.toLowerCase();
395
+ currentPage = 1;
396
+ displayDocuments();
397
  }
398
 
399
+ // Function to filter by category
400
+ function filterByCategory(category) {
401
+ currentCategory = category;
402
+ currentPage = 1;
403
+ displayDocuments();
404
+ }
405
+
406
+ // Function to view document in modal
407
+ function viewDocument(doc) {
408
+ const viewerUrl = `https://huggingface.co/datasets/varunh/jfk-files-2025/resolve/main/${doc.path}`;
409
+ document.getElementById('documentViewer').src = viewerUrl;
410
+ document.getElementById('documentModalLabel').textContent = doc.name;
411
+ document.getElementById('downloadLink').href = viewerUrl;
412
+ documentModal.show();
413
+ }
414
+
415
+ // Add event listener for search input
416
+ document.getElementById('search').addEventListener('keyup', function(event) {
417
+ if (event.key === 'Enter') {
418
+ filterDocuments();
419
+ }
420
+ });
421
+
422
  // Load documents when page loads
423
  window.onload = loadDocuments;
424
  </script>