forked from Nishka30/PixMender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
244 lines (214 loc) · 8.16 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adamas</title>
<link rel="stylesheet" type="text/css" href="src/style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
<link rel="icon" href="src/ADAMAS_logo.png" type="image/x-icon">
<style>
/* Add this style to your existing styles or create a new CSS file */
#imagePreviewContainer {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
#imagePreviewContainer img {
max-width: 150px; /* Set the maximum width for the image preview */
max-height: 150px; /* Set the maximum height for the image preview */
border: 1px solid #ddd; /* Add a border for better visibility */
border-radius: 4px; /* Add border-radius for rounded corners */
cursor: pointer; /* Add cursor pointer for better user experience */
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.9);
}
.modal-content {
margin: 5% auto;
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: center;
}
.modal-content img {
max-width: 80%;
max-height: 80%;
}
.close {
color: #fff;
position: absolute;
top: 10px;
right: 25px;
font-size: 30px;
font-weight: bold;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<img src="src/ADAMAS_logo.png" alt="Adamas logo" class="logo" />
</div>
<div class="top-buttons">
<button class="button-circle">
<i class="fas fa-info-circle"></i>
<span class="official-font">General Information</span>
</button>
<button class="button-circle">
<i class="fas fa-graduation-cap"></i>
<span class="official-font">Academic Qualification</span>
</button>
<button class="button-circle">
<i class="fas fa-upload"></i>
<span class="official-font">Upload Documents</span>
</button>
<button class="button-circle">
<i class="fas fa-file-signature"></i>
<span class="official-font">Declaration</span>
</button>
</div>
<p style="margin-top: 60px; color: red; font-weight: bold; font-size: 1.2em;">Upload Documents*</p>
<div class="upload-documents">
<div class="photo-upload">
<p><b>Upload Your Recent Passport Size Photograph and Signature *</b></p>
<label for="photo-input">
<input style="margin: 20px; transform: scale(1.4);" type="file" id="imageInput" accept="image/*" multiple>
<button onclick="uploadImage()" style="margin: 20px; transform: scale(1.4);">Upload</button>
<div id="result"></div>
<div id="imagePreviewContainer"></div>
</label>
<p class="allowed-format"><i>Allowed Format: Jpg, Png, Jpeg.</i></p>
<p style = "color: red;"class="allowed-format"><i>Maximum Size Limit is 4MB</i></p>
<!-- Add a Preview button -->
</div>
</div>
</div>
<a href="pr/photo.html" target="_blank">
<button style="font-style: normal; background-color: rgb(203, 153, 153);" class="button-circle"><b>Photo Generator</b>
</button>
</a>
<a href="pr/sign.html" target="_blank">
<button style="font-style: normal; background-color: rgb(149, 149, 255);" class="button-circle"><b>Digital Signature</b>
</button>
</a>
<div class="tr">
<h6></h6>
<div style="border-radius:5px;" id="google_translate_element" class="xyz"></div>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
</script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-storage.js"></script>
<script src="src/main.js"></script>
<script src="server/index.js"></script>
<!-- Modal for image preview -->
<div id="imageModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeModal()">×</span>
<div id="modalImageContainer"></div>
</div>
</div>
<script>
function uploadImage() {
var files = document.getElementById("imageInput").files;
var fileInput = document.getElementById("imageInput");
var files = fileInput.files;
if (files.length > 0) {
var formData = new FormData();
// Append each file to the formData and check file size
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file.size <= 4 * 1024 * 1024) { // Check if the file size is within 4 MB
formData.append("files", file);
} else {
console.error(`File ${file.name} exceeds the 4 MB size limit and will not be uploaded.`);
alert("File size is more than 4MB. Please choose a smaller file.");
return; // Exit the function if a file exceeds the limit
}
}
// Proceed with uploading valid files
if (formData.getAll("files").length > 0) {
fetch('http://localhost:3000/uploadAndQuery', {
method: 'POST',
body: formData,
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
// Upload all files to Firebase
uploadAllToFirebase(data, files);
// Display preview of all uploaded images with captions
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imagePreview = document.createElement("img");
// Set image properties
imagePreview.src = URL.createObjectURL(file);
imagePreview.setAttribute("onclick", `showImagePreview('${imagePreview.src}', 'Caption for Image ${i + 1}')`);
// Append image to preview container
document.getElementById("imagePreviewContainer").appendChild(imagePreview);
}
})
.catch(error => {
console.error('Error:', error);
document.getElementById('result').innerText = 'An error occurred while processing the images. Please try again.';
});
} else {
console.error('No valid files selected.');
}
} else {
console.error('No files selected.');
}
}
function showImagePreview(imageSrc, caption) {
// You can customize this function to display a larger preview as needed
alert("Clicked image preview: " + imageSrc + "\nCaption: " + caption);
}
function openModal() {
var modal = document.getElementById("imageModal");
var modalImageContainer = document.getElementById("modalImageContainer");
var imagePreviewContainer = document.getElementById("imagePreviewContainer").cloneNode(true);
// Remove the cursor pointer style from the cloned images to avoid confusion
var images = imagePreviewContainer.getElementsByTagName("img");
for (var i = 0; i < images.length; i++) {
images[i].style.cursor = "auto";
}
modalImageContainer.innerHTML = ""; // Clear the modal container
modalImageContainer.appendChild(imagePreviewContainer);
modal.style.display = "block";
}
function closeModal() {
var modal = document.getElementById("imageModal");
modal.style.display = "none";
}
// Close the modal if the user clicks outside of it
window.onclick = function (event) {
var modal = document.getElementById("imageModal");
if (event.target == modal) {
modal.style.display = "none";
}
};
</script>
</body>
</html>