-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcaretaker-add_photos.html
257 lines (221 loc) · 9.42 KB
/
caretaker-add_photos.html
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!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/[email protected]/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 type="module" src="./js/sign-up.js" defer></script>
<style>
.upload-section {
text-align: center;
margin-top: 30px;
margin-bottom: 30px;
}
.upload-section h1 {
font-size: 2rem;
margin-bottom: 20px;
font-family: 'DM Serif Display', serif;
color: #333;
}
#fileInput {
display: inline-block;
padding: 10px 20px;
background-color: #f5f5f5;
border: 2px dashed #ccc;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
color: #333;
transition: background-color 0.3s ease;
}
#fileInput:hover {
background-color: #eee;
}
#uploadBtn {
display: inline-block;
margin-top: 20px;
padding: 10px 20px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 5px;
font-size: 1rem;
cursor: pointer;
transition: background-color 0.3s ease;
}
#uploadBtn:hover {
background-color: #0056b3;
}
.file-input-container {
display: flex;
flex-direction: column;
align-items: center;
}
/* Gallery section styling */
#gallery {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 15px;
padding: 10px;
margin-top: 20px;
}
.image-container {
max-width: 300px;
position: relative;
}
.image-container img {
width: 100%;
height: auto;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.delete-btn {
position: absolute;
top: 5px;
right: 5px;
background-color: red;
color: white;
border: none;
border-radius: 10%;
width: 100px;
height: 50px;
cursor: pointer;
font-size: 1rem;
}
</style>
</head>
<body>
<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>
<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 In</a>
</button>
</div>
</ul>
</nav>
</div>
</header>
<section class="upload-section">
<div class="container mx-auto">
<h1>Upload Photos</h1>
<div class="file-input-container">
<input type="file" id="fileInput" multiple accept="image/*">
<button id="uploadBtn">Upload Photos</button>
</div>
<div id="gallery"></div>
</div>
</section>
<footer class="bg-white m-4">
<div class="w-full max-w-screen-xl mx-auto p-4 md:py-8">
<hr class="my-6 border-gray-200 sm:mx-auto lg:my-8" />
<span class="block text-sm text-gray-500 sm:text-center dark:text-gray-400">© 2022 <a href="index.html" class="hover:underline">Memory Lane™</a>. All Rights Reserved.</span>
</div>
</footer>
<script>
// Open or create IndexedDB instance
const request = indexedDB.open('imageDB', 1);
request.onupgradeneeded = function(event) {
const db = event.target.result;
if (!db.objectStoreNames.contains('images')) {
db.createObjectStore('images', { keyPath: 'id', autoIncrement: true });
}
};
function storeImageInIndexedDB(imageData) {
const dbRequest = indexedDB.open('imageDB', 1);
dbRequest.onsuccess = function(event) {
const db = event.target.result;
const transaction = db.transaction('images', 'readwrite');
const store = transaction.objectStore('images');
store.add({ image: imageData });
transaction.oncomplete = function() {
displayImages(); // Refresh gallery after adding images
};
transaction.onerror = function() {
console.error('Error saving image');
};
};
}
function displayImages() {
const dbRequest = indexedDB.open('imageDB', 1);
dbRequest.onsuccess = function(event) {
const db = event.target.result;
const transaction = db.transaction('images', 'readonly');
const store = transaction.objectStore('images');
const getRequest = store.getAll();
getRequest.onsuccess = function() {
const imagesArray = getRequest.result;
const galleryDiv = document.getElementById('gallery');
galleryDiv.innerHTML = ''; // Clear current gallery
imagesArray.forEach(imageObj => {
const imgContainer = document.createElement('div');
imgContainer.className = 'image-container';
const img = document.createElement('img');
img.src = imageObj.image;
imgContainer.appendChild(img);
const deleteBtn = document.createElement('button');
deleteBtn.className = 'delete-btn';
deleteBtn.textContent = 'Delete';
deleteBtn.onclick = function() {
deleteImage(imageObj.id);
};
imgContainer.appendChild(deleteBtn);
galleryDiv.appendChild(imgContainer);
});
};
};
}
function deleteImage(id) {
const dbRequest = indexedDB.open('imageDB', 1);
dbRequest.onsuccess = function(event) {
const db = event.target.result;
const transaction = db.transaction('images', 'readwrite');
const store = transaction.objectStore('images');
store.delete(id);
transaction.oncomplete = function() {
displayImages(); // Refresh gallery after deletion
};
transaction.onerror = function() {
console.error('Error deleting image');
};
};
}
document.getElementById('uploadBtn').addEventListener('click', function() {
const fileInput = document.getElementById('fileInput');
const files = fileInput.files;
for (const file of files) {
const reader = new FileReader();
reader.onload = function(e) {
storeImageInIndexedDB(e.target.result);
};
reader.readAsDataURL(file);
}
alert('Images uploaded successfully!');
});
// Display stored images on page load
window.onload = displayImages;
</script>
</body>
</html>