-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstore-report.html
More file actions
215 lines (191 loc) · 8.82 KB
/
store-report.html
File metadata and controls
215 lines (191 loc) · 8.82 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Memory Lane</title>
<!--CSS-->
<link rel="stylesheet" href="./dist/output.css">
<!--ICONS-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/remixicon@4.3.0/fonts/remixicon.min.css">
<!--Fonts-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Jost:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">
<script src="./js/main.js" defer></script>
<style>
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 50;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.8);
}
.modal-content {
margin: 15% auto;
padding: 20px;
width: 80%;
max-width: 600px;
background-color: white;
text-align: center;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.modal-image {
width: 100%;
height: auto;
}
</style>
</head>
<body>
<!--Navbar-->
<header class="sticky top-0 h-[90px] shadow-xl z-30 bg-white">
<div class="container mx-auto flex justify-between h-full items-center">
<a href="#">
<img src="./assets/logo.jpeg" alt="" class="w-[200px]">
</a>
<nav>
<div class="cursor-pointer lg:hidden" id="nav_trigger_btn">
<i class="ri-menu-4-line text-4xl text-primary"></i>
</div>
<ul class="fixed w-full h-0 p-0 bg-white overflow-hidden border-t top-[90px] left-0 right-0 flex flex-col gap-4 lg:relative lg:flex-row lg:p-0 lg:top-0 lg:border-none lg:h-full transition-all duration-300" id="nav_menu">
<li class="p-2"><a href="./caretaker-dashboard.html">Dashboard</a></li>
<li class="p-2"><a href="./index.html">Home</a></li>
<li class="p-2"><a href="./index.html#about">About</a></li>
<li class="p-2"><a href="./index.html#contact">Contact Us</a></li>
<!-- Placeholder for user info or sign-in button -->
<div id="user-auth-section">
<button class="btn-accent w-[120px] h-[50px] lg:p-0 p-2 rounded-lg">
<a href="./sign-up.html" class="text-white hover:text-black" id="auth-btn">Sign Up</a>
</button>
</div>
</ul>
</nav>
</div>
</header>
<main class="max-w-[1920px] mx-auto bg-white overflow-hidden">
<h2 class="flex justify-center items-center mt-10 h2">Store Reports</h2>
<form id="uploadForm" enctype="multipart/form-data" class="mb-6 flex justify-center items-center gap-4 mt-8">
<input type="file" id="fileInput" accept="image/*,application/pdf" class="block p-2 border border-gray-300 rounded-md" required>
<button type="submit" class="btn-accent text-white px-6 py-2 rounded-lg">Upload</button>
</form>
<div id="ocrResult" class="mt-4 mx-auto w-full max-w-md">
<h3 class="h3 flex justify-center items-center">Patients Reports</h3>
<ul id="medicineList" class="list-none space-y-2"></ul>
</div>
</main>
<!-- Modal -->
<div id="imageModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<img id="modalImage" class="modal-image" src="" alt="Report Image">
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const fileInput = document.getElementById('fileInput');
const uploadForm = document.getElementById('uploadForm');
const medicineList = document.getElementById('medicineList');
const modal = document.getElementById('imageModal');
const modalImage = document.getElementById('modalImage');
const closeModalBtn = document.getElementsByClassName('close')[0];
// Function to display the uploaded files
function displayFiles() {
const storedFiles = JSON.parse(localStorage.getItem('prescriptions')) || [];
medicineList.innerHTML = ''; // Clear existing list
storedFiles.forEach((file, index) => {
const listItem = document.createElement('li');
listItem.className = 'border p-2 rounded-md flex justify-between items-center';
if (file.type === 'image') {
const img = document.createElement('img');
img.src = file.url;
img.alt = `Report ${index + 1}`;
img.className = 'w-[100px] h-[100px] object-cover cursor-pointer';
img.addEventListener('click', function () {
openModal(file.url); // Open modal on click
});
listItem.appendChild(img);
} else if (file.type === 'pdf') {
const pdfLink = document.createElement('a');
pdfLink.href = file.url;
pdfLink.textContent = `Report ${index + 1} (PDF)`;
pdfLink.target = '_blank';
pdfLink.className = 'text-blue-600 underline';
listItem.appendChild(pdfLink);
}
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.className = 'bg-red-500 text-white px-4 py-1 rounded';
deleteButton.addEventListener('click', function () {
deleteFile(index);
});
listItem.appendChild(deleteButton);
medicineList.appendChild(listItem);
});
}
// Function to save files to localStorage
function saveFile(fileUrl, fileType) {
const storedFiles = JSON.parse(localStorage.getItem('prescriptions')) || [];
storedFiles.push({ url: fileUrl, type: fileType });
localStorage.setItem('prescriptions', JSON.stringify(storedFiles));
displayFiles();
}
// Handle form submission and file upload
uploadForm.addEventListener('submit', function (event) {
event.preventDefault();
const file = fileInput.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function (e) {
const fileUrl = e.target.result;
const fileType = file.type.startsWith('image') ? 'image' : 'pdf';
saveFile(fileUrl, fileType);
};
if (file.type.startsWith('image')) {
reader.readAsDataURL(file); // Read image files as Data URL
} else if (file.type === 'application/pdf') {
reader.readAsDataURL(file); // Read PDF files as Data URL
}
});
// Function to delete file from localStorage
function deleteFile(index) {
const storedFiles = JSON.parse(localStorage.getItem('prescriptions')) || [];
storedFiles.splice(index, 1);
localStorage.setItem('prescriptions', JSON.stringify(storedFiles));
displayFiles();
}
// Modal control functions
function openModal(imageSrc) {
modal.style.display = 'block';
modalImage.src = imageSrc;
}
closeModalBtn.addEventListener('click', function () {
modal.style.display = 'none';
});
window.addEventListener('click', function (event) {
if (event.target === modal) {
modal.style.display = 'none';
}
});
// Load files from localStorage when the page loads
displayFiles();
});
</script>
</body>
</html>