-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patharchive.html
More file actions
71 lines (57 loc) · 2.54 KB
/
archive.html
File metadata and controls
71 lines (57 loc) · 2.54 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Syllabus Archive</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gradient-to-r from-blue-400 to-blue-500 min-h-screen flex flex-col items-center justify-center">
<!-- Navbar -->
<div class="w-full max-w-2xl bg-white shadow-lg rounded-lg p-4 flex justify-between items-center mb-6 mt-4">
<h1 class="text-lg font-semibold text-gray-700">Syllabus Archive</h1>
<button class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg shadow-md">Logout</button>
</div>
<!-- Archive Container -->
<div class="w-full max-w-2xl bg-white p-6 rounded-lg shadow-xl">
<h2 class="text-xl font-semibold text-gray-700 mb-4">All Available Syllabus</h2>
<!-- List of PDFs (Dynamically Added) -->
<div id="pdf-list" class="space-y-4">
<!-- List items will be inserted here -->
</div>
<!-- Add new PDF button -->
</div>
<script>
// Fetch the list of PDFs from the PHP server
fetch('archive.php')
.then(response => response.json())
.then(pdfFiles => {
// Display the PDFs dynamically
const listContainer = document.getElementById('pdf-list');
pdfFiles.forEach(pdfFile => {
const pdfItem = document.createElement('div');
pdfItem.classList.add('bg-gray-100', 'p-4', 'rounded-lg', 'shadow-md', 'flex', 'justify-between', 'items-center');
const pdfDetails = document.createElement('div');
pdfDetails.classList.add('flex', 'flex-col');
pdfDetails.innerHTML = `
<h3 class="font-semibold text-gray-800">${pdfFile}</h3>
<p class="text-gray-600">Course Code: TBD</p>
<p class="text-gray-600">Stream: TBD</p>
`;
const downloadBtn = document.createElement('button');
downloadBtn.classList.add('bg-green-500', 'hover:bg-green-600', 'text-white', 'px-4', 'py-2', 'rounded-lg', 'shadow-md');
downloadBtn.textContent = 'Download PDF';
downloadBtn.onclick = () => downloadPdf(pdfFile);
pdfItem.appendChild(pdfDetails);
pdfItem.appendChild(downloadBtn);
listContainer.appendChild(pdfItem);
});
})
.catch(error => console.error('Error fetching PDF list:', error));
function downloadPdf(fileName) {
const downloadUrl = `uploads/${fileName}`;
window.location.href = downloadUrl;
}
</script>
</body>
</html>