-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration-form.html
More file actions
773 lines (662 loc) · 33.4 KB
/
Copy pathregistration-form.html
File metadata and controls
773 lines (662 loc) · 33.4 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
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Event Registration Form 2025</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #111, #333);
color: white;
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.05);
border-radius: 15px;
padding: 30px;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.header {
text-align: center;
margin-bottom: 30px;
}
.header img {
width: 120px;
height: auto;
margin-bottom: 15px;
}
.header h1 {
color: #FFD700;
font-size: 2.5em;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
.header p {
font-size: 1.2em;
color: #ccc;
}
.form-section {
margin-bottom: 25px;
padding: 20px;
background: rgba(255, 255, 255, 0.03);
border-radius: 10px;
border-left: 4px solid #FFD700;
}
.section-title {
font-size: 1.3em;
color: #FFD700;
margin-bottom: 15px;
font-weight: bold;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #fff;
}
.required {
color: #ff4444;
}
input, select, textarea {
width: 100%;
padding: 12px 15px;
border: 2px solid rgba(255, 255, 255, 0.2);
border-radius: 8px;
background: rgba(255, 255, 255, 0.1);
color: white;
font-size: 16px;
transition: all 0.3s ease;
}
input:focus, select:focus, textarea:focus {
outline: none;
border-color: #FFD700;
background: rgba(255, 255, 255, 0.15);
box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}
input::placeholder, textarea::placeholder {
color: rgba(255, 255, 255, 0.6);
}
.radio-group, .checkbox-group {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-top: 10px;
}
.radio-item, .checkbox-item {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
padding: 8px 12px;
background: rgba(255, 255, 255, 0.05);
border-radius: 6px;
transition: background 0.3s ease;
}
.radio-item:hover, .checkbox-item:hover {
background: rgba(255, 255, 255, 0.1);
}
input[type="radio"], input[type="checkbox"] {
width: auto;
margin: 0;
}
input[type="file"] {
padding: 8px;
background: rgba(255, 255, 255, 0.05);
border: 2px dashed rgba(255, 255, 255, 0.3);
cursor: pointer;
}
input[type="file"]:hover {
border-color: #FFD700;
background: rgba(255, 215, 0, 0.1);
}
.file-info {
font-size: 12px;
color: #ccc;
margin-top: 5px;
font-style: italic;
}
.row {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
.submit-section {
text-align: center;
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.submit-btn {
background: linear-gradient(45deg, #FFD700, #FFA500);
color: #000;
padding: 15px 40px;
border: none;
border-radius: 8px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
}
.submit-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
}
.submit-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.error-message {
color: #ff4444;
font-size: 14px;
margin-top: 5px;
display: none;
}
.success-message {
background: rgba(76, 175, 80, 0.2);
border: 1px solid #4CAF50;
color: #4CAF50;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
text-align: center;
display: none;
}
@media (max-width: 768px) {
.container {
padding: 20px;
margin: 10px;
}
.header h1 {
font-size: 2em;
}
.row {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<img src="logo.png" alt="Event Logo">
<h1>EVENT NAME 2025</h1>
<p><strong>EVENT DATE: DD MONTH YYYY</strong></p>
<p>@Your College/Institution Name, City – PIN CODE</p>
<p style="margin-top: 15px; font-size: 1em;">
<strong>ON STAGE EVENT:</strong> VENUE 1<br>
<strong>OFF STAGE EVENT:</strong> VENUE 2
</p>
</div>
<div class="success-message" id="successMessage">
Registration submitted successfully! Files uploaded to GitHub Pages storage.
<br><br>
<div id="redirectMessage" style="font-size: 0.9em; opacity: 0.8;">
Redirecting to main page in <span id="countdown">3</span> seconds...
</div>
</div>
<!-- Load the file handler -->
<script src="upload-handler.js"></script>
<form id="registrationForm">
<!-- Basic Information Section -->
<div class="form-section">
<h2 class="section-title">Participant Information</h2>
<div class="form-group">
<label for="email">Email <span class="required">*</span></label>
<input type="email" id="email" name="email" required>
<div class="error-message" id="emailError">Please enter a valid email address</div>
</div>
<div class="form-group">
<label for="participantName">NAME OF THE PARTICIPANT <span class="required">*</span></label>
<input type="text" id="participantName" name="participantName" required>
<div class="error-message" id="participantNameError">Please enter participant name</div>
</div>
<div class="form-group">
<label for="collegeName">COLLEGE NAME <span class="required">*</span></label>
<input type="text" id="collegeName" name="collegeName" required>
<div class="error-message" id="collegeNameError">Please enter college name</div>
</div>
<div class="form-group">
<label for="departmentName">DEPARTMENT NAME <span class="required">*</span></label>
<input type="text" id="departmentName" name="departmentName" required>
<div class="error-message" id="departmentNameError">Please enter department name</div>
</div>
<div class="form-group">
<label for="contactNumber">CONTACT NUMBER <span class="required">*</span></label>
<input type="tel" id="contactNumber" name="contactNumber" required>
<div class="error-message" id="contactNumberError">Please enter contact number</div>
</div>
<div class="form-group">
<label for="studentEmail">STUDENT MAIL ID <span class="required">*</span></label>
<input type="email" id="studentEmail" name="studentEmail" required>
<div class="error-message" id="studentEmailError">Please enter student email</div>
</div>
<div class="form-group">
<label for="studentIdPhoto">STUDENT ID CARD PHOTO <span class="required">*</span></label>
<p style="color: #ccc; font-size: 14px; margin-bottom: 10px;">NOTE: Photo must be in JPG format</p>
<p style="color: #FFD700; font-size: 12px; margin-bottom: 8px;">
📁 <strong>File Storage:</strong> Files will be stored using GitHub Pages + Git LFS (1GB FREE).
<br>Secure, version-controlled storage with free hosting.
</p>
<input type="file" id="studentIdPhoto" name="studentIdPhoto" accept=".jpg,.jpeg" required>
<div class="error-message" id="studentIdPhotoError">Please upload student ID card photo</div>
<div id="studentIdUploadStatus" class="file-info"></div>
</div>
</div>
<!-- Event Selection Section -->
<div class="form-section">
<h2 class="section-title">Event Selection</h2>
<div class="form-group">
<label>EVENTS: SELECT ANY ONE OF THE STAGE EVENTS <span class="required">*</span></label>
<div class="radio-group">
<div class="radio-item">
<input type="radio" id="onStage" name="eventType" value="on-stage" required>
<label for="onStage">ON STAGE</label>
</div>
<div class="radio-item">
<input type="radio" id="offStage" name="eventType" value="off-stage" required>
<label for="offStage">OFF STAGE</label>
</div>
</div>
<div class="error-message" id="eventTypeError">Please select event type</div>
</div>
<!-- On Stage Events Section -->
<div class="form-group" id="onStageSection" style="display: none;">
<h3 style="color: #FFD700; margin-bottom: 15px;">ON STAGE EVENTS</h3>
<p style="color: #ccc; font-size: 14px; margin-bottom: 15px;">EXAMPLE: ON STAGE - SOLO (OR) GROUP</p>
<label>ON STAGE:</label>
<div class="radio-group">
<div class="radio-item">
<input type="radio" id="onStageSolo" name="onStageType" value="solo">
<label for="onStageSolo">SOLO</label>
</div>
<div class="radio-item">
<input type="radio" id="onStageGroup" name="onStageType" value="group">
<label for="onStageGroup">GROUP</label>
</div>
</div>
</div>
<!-- Off Stage Events Section -->
<div class="form-group" id="offStageSection" style="display: none;">
<h3 style="color: #FFD700; margin-bottom: 15px;">OFF STAGE EVENTS</h3>
<p style="color: #ccc; font-size: 14px; margin-bottom: 15px;">EXAMPLE: OFF STAGE - SOLO (OR) GROUP</p>
<label>OFF STAGE EVENTS:</label>
<div class="radio-group">
<div class="radio-item">
<input type="radio" id="offStageSolo" name="offStageType" value="solo">
<label for="offStageSolo">SOLO</label>
</div>
<div class="radio-item">
<input type="radio" id="offStageGroup" name="offStageType" value="group">
<label for="offStageGroup">GROUP</label>
</div>
</div>
</div>
<!-- Off Stage Solo Events -->
<div class="form-group" id="offStageSoloEvents" style="display: none;">
<h3 style="color: #FFD700; margin-bottom: 15px;">OFF STAGE: SOLO EVENTS</h3>
<label for="offStageEvent">OFF STAGE EVENTS <span class="required">*</span></label>
<select id="offStageEvent" name="offStageEvent">
<option value="">Select Event</option>
<option value="frame-it-right">FRAME IT RIGHT (PHOTOGRAPHY)</option>
<option value="other-event-1">Other Event 1</option>
<option value="other-event-2">Other Event 2</option>
</select>
<div style="margin-top: 20px;">
<div class="form-group">
<label for="eventParticipantName">PARTICIPANT NAME <span class="required">*</span></label>
<input type="text" id="eventParticipantName" name="eventParticipantName">
</div>
<div class="form-group">
<label for="eventContactNumber">CONTACT NUMBER <span class="required">*</span></label>
<input type="tel" id="eventContactNumber" name="eventContactNumber">
</div>
<div class="form-group">
<label for="gpayReference">GPAY REFERENCE NUMBER</label>
<input type="text" id="gpayReference" name="gpayReference">
<p style="color: #ccc; font-size: 14px; margin-top: 5px;">
IF REGISTRATION QUERIES CONTACT THIS NUMBER: <strong>XXXXXXXXXX</strong>
</p>
</div>
</div>
</div>
</div>
<!-- Payment Details Section -->
<div class="form-section">
<h2 class="section-title">Payment Details</h2>
<div style="background: rgba(255, 255, 255, 0.1); padding: 15px; border-radius: 8px; margin-bottom: 20px;">
<h3 style="color: #FFD700; margin-bottom: 10px;">NOTE:</h3>
<p style="line-height: 1.6; color: #ccc;">
If a person is willing to participate in the event, they must pay a fee of <strong>₹50</strong>.
In the case of a group performance, the total fee will be <strong>₹50 per member</strong>.
For example, if there are 8 members in a group, the total payment will be ₹50 × 8 = ₹400.
The payment for group performances should be made by a single person, and the payment screenshot
must be submitted in the form without fail.<br><br>
If a person has already paid for one event, they are allowed to participate in other events as well.
In such cases, they can upload the same payment details in the form for the additional events.
</p>
</div>
<div class="form-group">
<label for="paymentProof">UPLOAD YOUR PAYMENT DETAILS <span class="required">*</span></label>
<p style="color: #FFD700; font-weight: bold; margin-bottom: 10px;">PER PERSON ₹50</p>
<p style="color: #ccc; font-size: 14px; margin-bottom: 10px;">
NOTE: Photo must be in JPG format<br>
The person who is paying either group (or) solo events the name should be mentioned along with transaction id
</p>
<p style="color: #FFD700; font-size: 12px; margin-bottom: 8px;">
📁 <strong>File Storage:</strong> Payment screenshots stored using GitHub Pages + Git LFS.
<br>Secure, version-controlled storage with 1GB FREE allowance.
</p>
<input type="file" id="paymentProof" name="paymentProof" accept=".jpg,.jpeg,.png,.pdf" required>
<div class="error-message" id="paymentProofError">Please upload payment proof</div>
<div id="paymentUploadStatus" class="file-info"></div>
</div>
</div>
<div class="submit-section">
<button type="submit" class="submit-btn" id="submitBtn">
Submit Registration
</button>
<p style="margin-top: 15px; color: #ccc; font-size: 14px;">
Registration fee: ₹50 per participant<br>
For registration queries contact: <strong>XXXXXXXXXX</strong>
</p>
</div>
</form>
</div>
<script>
// Initialize file handler
const fileHandler = new GitHubPagesFileHandler();
// Show/hide event sections based on selection
document.querySelectorAll('input[name="eventType"]').forEach(radio => {
radio.addEventListener('change', function() {
const onStageSection = document.getElementById('onStageSection');
const offStageSection = document.getElementById('offStageSection');
const offStageSoloEvents = document.getElementById('offStageSoloEvents');
if (this.value === 'on-stage') {
onStageSection.style.display = 'block';
offStageSection.style.display = 'none';
offStageSoloEvents.style.display = 'none';
} else if (this.value === 'off-stage') {
onStageSection.style.display = 'none';
offStageSection.style.display = 'block';
offStageSoloEvents.style.display = 'none';
}
});
});
// Show off stage solo events when solo is selected
document.querySelectorAll('input[name="offStageType"]').forEach(radio => {
radio.addEventListener('change', function() {
const offStageSoloEvents = document.getElementById('offStageSoloEvents');
if (this.value === 'solo') {
offStageSoloEvents.style.display = 'block';
document.getElementById('offStageEvent').required = true;
document.getElementById('eventParticipantName').required = true;
document.getElementById('eventContactNumber').required = true;
} else {
offStageSoloEvents.style.display = 'none';
document.getElementById('offStageEvent').required = false;
document.getElementById('eventParticipantName').required = false;
document.getElementById('eventContactNumber').required = false;
}
});
});
// Form validation
function validateForm() {
let isValid = true;
const requiredFields = ['email', 'participantName', 'collegeName', 'departmentName', 'contactNumber', 'studentEmail'];
// Check required text fields
requiredFields.forEach(field => {
const element = document.getElementById(field);
const errorElement = document.getElementById(field + 'Error');
if (!element.value.trim()) {
if (errorElement) {
errorElement.style.display = 'block';
}
isValid = false;
} else {
if (errorElement) {
errorElement.style.display = 'none';
}
}
});
// Check email format
const email = document.getElementById('email');
const emailError = document.getElementById('emailError');
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (email.value && !emailRegex.test(email.value)) {
emailError.textContent = 'Please enter a valid email address';
emailError.style.display = 'block';
isValid = false;
}
// Check student email format
const studentEmail = document.getElementById('studentEmail');
const studentEmailError = document.getElementById('studentEmailError');
if (studentEmail.value && !emailRegex.test(studentEmail.value)) {
studentEmailError.textContent = 'Please enter a valid student email address';
studentEmailError.style.display = 'block';
isValid = false;
}
// Check event type selection
const eventType = document.querySelector('input[name="eventType"]:checked');
const eventTypeError = document.getElementById('eventTypeError');
if (!eventType) {
eventTypeError.style.display = 'block';
isValid = false;
} else {
eventTypeError.style.display = 'none';
}
// Check file uploads
const studentIdPhoto = document.getElementById('studentIdPhoto');
const studentIdPhotoError = document.getElementById('studentIdPhotoError');
if (!studentIdPhoto.files.length) {
studentIdPhotoError.style.display = 'block';
isValid = false;
} else {
studentIdPhotoError.style.display = 'none';
}
const paymentProof = document.getElementById('paymentProof');
const paymentProofError = document.getElementById('paymentProofError');
if (!paymentProof.files.length) {
paymentProofError.style.display = 'block';
isValid = false;
} else {
paymentProofError.style.display = 'none';
}
return isValid;
}
// Google Sheets Integration
async function sendToGoogleSheets(data) {
// Google Apps Script Web App URL (you need to create this)
const GOOGLE_SCRIPT_URL = 'https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec';
// Prepare data for Google Sheets
const sheetData = {
timestamp: new Date().toLocaleString('en-IN', {timeZone: 'Asia/Kolkata'}),
email: data.email || '',
participantName: data.participantName || '',
collegeName: data.collegeName || '',
departmentName: data.departmentName || '',
contactNumber: data.contactNumber || '',
studentEmail: data.studentEmail || '',
eventType: data.eventType || '',
onStageType: data.onStageType || '',
offStageType: data.offStageType || '',
offStageEvent: data.offStageEvent || '',
eventParticipantName: data.eventParticipantName || '',
eventContactNumber: data.eventContactNumber || '',
gpayReference: data.gpayReference || '',
studentIdFileName: data.studentIdFileName || '',
paymentFileName: data.paymentFileName || '',
submissionTime: data.submissionTime || ''
};
try {
const response = await fetch(GOOGLE_SCRIPT_URL, {
method: 'POST',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(sheetData)
});
console.log('Data sent to Google Sheets');
return true;
} catch (error) {
console.error('Google Sheets error:', error);
// Fallback: Store in localStorage for manual export
const existingSubmissions = JSON.parse(localStorage.getItem('rizoraSubmissions') || '[]');
existingSubmissions.push(sheetData);
localStorage.setItem('rizoraSubmissions', JSON.stringify(existingSubmissions));
throw error;
}
}
// Form submission
document.getElementById('registrationForm').addEventListener('submit', function(e) {
e.preventDefault();
if (validateForm()) {
const submitBtn = document.getElementById('submitBtn');
const successMessage = document.getElementById('successMessage');
// Disable submit button and show loading state
submitBtn.disabled = true;
submitBtn.textContent = 'Submitting...';
// Simulate form submission (replace with actual form submission logic)
setTimeout(async () => {
successMessage.style.display = 'block';
// Collect form data
const formData = new FormData(this);
const registrationData = {};
for (let [key, value] of formData.entries()) {
registrationData[key] = value;
}
// Add uploaded file information
const studentIdFile = document.getElementById('studentIdPhoto');
const paymentFile = document.getElementById('paymentProof');
registrationData.studentIdFileName = studentIdFile.dataset.uploadedFile || 'Not uploaded';
registrationData.paymentFileName = paymentFile.dataset.uploadedFile || 'Not uploaded';
registrationData.submissionTime = new Date().toISOString();
// Store registration data in localStorage
localStorage.setItem('rizoraRegistration', JSON.stringify(registrationData));
// Send to Google Sheets
try {
await sendToGoogleSheets(registrationData);
console.log('Data sent to Google Sheets successfully');
} catch (error) {
console.error('Failed to send to Google Sheets:', error);
// Continue even if Google Sheets fails
}
// Show success message
alert('Registration submitted successfully! Thank you for registering for EVENT NAME 2025. You will be redirected to the main page.');
// Reset form
this.reset();
submitBtn.disabled = false;
submitBtn.textContent = 'Submit Registration';
// Start countdown and redirect
let countdown = 3;
const countdownElement = document.getElementById('countdown');
const redirectMessage = document.getElementById('redirectMessage');
const countdownTimer = setInterval(() => {
countdown--;
if (countdownElement) {
countdownElement.textContent = countdown;
}
if (countdown <= 0) {
clearInterval(countdownTimer);
window.location.href = 'index.html';
}
}, 1000);
}, 1000);
}
});
// Real-time validation
document.querySelectorAll('input, select, textarea').forEach(element => {
element.addEventListener('blur', function() {
// Only validate this specific field
const errorElement = document.getElementById(this.id + 'Error');
if (this.hasAttribute('required') && !this.value.trim()) {
if (errorElement) {
errorElement.style.display = 'block';
}
} else {
if (errorElement) {
errorElement.style.display = 'none';
}
}
});
});
// File input styling and handling with GitHub Pages integration
document.querySelectorAll('input[type="file"]').forEach(input => {
input.addEventListener('change', async function() {
if (this.files.length > 0) {
const file = this.files[0];
const fileName = file.name;
const fileSize = (file.size / 1024 / 1024).toFixed(2); // Size in MB
const label = this.parentNode.querySelector('label');
const statusElement = this.parentNode.querySelector('.file-info');
// Show uploading status
if (statusElement) {
statusElement.innerHTML = '🔄 Uploading to GitHub Pages...';
statusElement.style.color = '#FFD700';
}
// Determine category
const category = this.name === 'studentIdPhoto' ? 'student-ids' : 'payment-proofs';
try {
// Upload file using GitHub Pages handler
const result = await fileHandler.handleFileUpload(file, category);
if (result.success) {
// Show success status
if (label) {
const originalText = label.textContent.split('\n')[0];
label.innerHTML = originalText + '<br><small style="color: #4CAF50;">✓ ' + fileName + ' (' + fileSize + ' MB)</small>';
}
if (statusElement) {
statusElement.innerHTML = '✅ Successfully uploaded to GitHub Pages storage';
statusElement.style.color = '#4CAF50';
}
// Store file reference for form submission
this.dataset.uploadedFile = result.fileName;
this.dataset.uploadUrl = result.url;
console.log('File uploaded successfully:', result);
} else {
throw new Error(result.error);
}
} catch (error) {
console.error('Upload failed:', error);
if (statusElement) {
statusElement.innerHTML = '❌ Upload failed: ' + error.message;
statusElement.style.color = '#ff4444';
}
// Clear the file input
this.value = '';
}
}
});
});
// Function to download stored files (for demonstration)
function downloadStoredFile(fileName) {
const files = JSON.parse(localStorage.getItem('githubPagesFiles') || '[]');
const file = files.find(f => f.fileName === fileName);
if (file) {
const link = document.createElement('a');
link.href = file.data;
link.download = file.originalName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
</script>
</body>
</html>