Skip to content

Commit 2668080

Browse files
committed
replace JS alert with custom alert
1 parent da07c0e commit 2668080

File tree

4 files changed

+94
-15
lines changed

4 files changed

+94
-15
lines changed

LongevityWorldCup.Website/wwwroot/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ <h2><i class="fas fa-calendar-alt"></i> Once/Year Newsletter</h2>
588588
document.getElementById('newsletter-form').reset();
589589
})
590590
.catch(error => {
591-
alert(error.message);
591+
customAlert(error.message);
592592
});
593593
} else {
594-
alert('Please enter a valid email address.');
594+
customAlert('Please enter a valid email address.');
595595
}
596596
});
597597

@@ -646,7 +646,7 @@ <h2><i class="fas fa-calendar-alt"></i> Once/Year Newsletter</h2>
646646
// copiedTextElement.classList.remove('fade-in-out');
647647
}, 2000); // Duration is 0.5s * 4 flashes = 2s
648648
}, function (err) {
649-
alert('Failed to copy the address');
649+
customAlert('Failed to copy the address');
650650
});
651651
}
652652

LongevityWorldCup.Website/wwwroot/onboarding/convergence.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="400">1. Character Cr
346346
// Get the biomarker data from localStorage
347347
const biomarkerData = JSON.parse(localStorage.getItem('biomarkerData'));
348348
if (!biomarkerData) {
349-
alert('Biomarker data is missing. Please complete the biomarker form.');
349+
customAlert('Biomarker data is missing. Please complete the biomarker form.');
350350
return;
351351
}
352352
console.log(biomarkerData);
@@ -577,7 +577,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="400">1. Character Cr
577577
if (files.length > 0) {
578578
// Limit the total number of images to 9
579579
if (proofPics.length + files.length > 9) {
580-
alert('You can upload a maximum of 9 images.');
580+
customAlert('You can upload a maximum of 9 images.');
581581
return;
582582
}
583583

@@ -869,15 +869,15 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="400">1. Character Cr
869869

870870
if (!accountEmail) {
871871
isValid = false;
872-
alert('Please enter your email.');
872+
customAlert('Please enter your email.');
873873
} else if (!validator.isEmail(accountEmail)) {
874874
isValid = false;
875-
alert('Please enter a valid email address.');
875+
customAlert('Please enter a valid email address.');
876876
}
877877

878878
if (personalLink && !validator.isURL(personalLink)) {
879879
isValid = false;
880-
alert('Please enter a valid URL for your personal link.');
880+
customAlert('Please enter a valid URL for your personal link.');
881881
}
882882

883883
if (isValid) {
@@ -902,7 +902,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="400">1. Character Cr
902902

903903
if (response.ok) {
904904
// Handle success, perhaps redirect or show a success message
905-
alert('Application submitted successfully!');
905+
customAlert('Application submitted successfully!');
906906
localStorage.setItem('contactEmail', applicantData.accountEmail);
907907
// Clear the image variables
908908
profilePic = null;
@@ -911,15 +911,15 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="400">1. Character Cr
911911
window.location.href = '/onboarding/application-review.html#appReviewTitle';
912912
} else {
913913
// Handle error
914-
alert('Failed to submit application. Please try again later.');
914+
customAlert('Failed to submit application. Please try again later.');
915915
applyButton.disabled = false;
916916
applyButton.textContent = 'Apply';
917917
}
918918

919919
})
920920
.catch(error => {
921921
console.error('Error submitting application:', error);
922-
alert('An error occurred while submitting your application.');
922+
customAlert('An error occurred while submitting your application.');
923923
applyButton.disabled = false;
924924
applyButton.textContent = 'Apply';
925925
});

LongevityWorldCup.Website/wwwroot/onboarding/pheno-age.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,15 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">
478478
const day = dayInput ? parseInt(dayInput) : 31; // Default to last day
479479

480480
if (!year) {
481-
alert("Please select a year.");
481+
customAlert("Please select a year.");
482482
return;
483483
}
484484

485485
const dobValue = new Date(year, month, day); // Month is 0-based (0 = Jan), Day is 1-based (1 = 1st day, 0 = last day of previous month)
486486
const chronologicalAge = window.PhenoAge.calculateAgeFromDOB(dobValue);
487487

488488
if (chronologicalAge < 0) {
489-
alert("Date of birth cannot be in the future.");
489+
customAlert("Date of birth cannot be in the future.");
490490
return;
491491
}
492492

@@ -506,7 +506,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">
506506

507507
// Check for invalid input
508508
if (isNaN(rawValue)) {
509-
alert(`Please enter a valid value for ${biomarker.name}.`);
509+
customAlert(`Please enter a valid value for ${biomarker.name}.`);
510510
document.getElementById('continueButton').classList.remove('show');
511511
updateCalculateButton();
512512
return;
@@ -528,7 +528,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">
528528
const wbcUnitConversion = parseFloat(wbcUnitElement.value);
529529

530530
if (isNaN(wbcRawValue)) {
531-
alert("Please provide White Blood Cell Count to calculate Lymphocyte percentage.");
531+
customAlert("Please provide White Blood Cell Count to calculate Lymphocyte percentage.");
532532
document.getElementById('continueButton').classList.remove('show');
533533
updateCalculateButton();
534534
return;

LongevityWorldCup.Website/wwwroot/partials/header.html

+79
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,70 @@
296296
.smaller-text {
297297
font-size: 0.85em;
298298
}
299+
300+
#custom-alert {
301+
border: none;
302+
border-radius: 15px;
303+
padding: 20px;
304+
max-width: 400px;
305+
width: 90%;
306+
background: var(--card-bg);
307+
color: var(--dark-text-color);
308+
text-align: center;
309+
font-family: 'Roboto', sans-serif;
310+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
311+
animation: fadeInDialog 0.3s ease-out;
312+
}
313+
314+
#custom-alert::backdrop {
315+
background: rgba(0, 0, 0, 0.5);
316+
}
317+
318+
#custom-alert p {
319+
margin-bottom: 1rem;
320+
font-size: 1rem;
321+
line-height: 1.5;
322+
}
323+
324+
#custom-alert button {
325+
display: block;
326+
margin: 0 auto;
327+
padding: 0.7rem 1.5rem;
328+
font-size: 1rem;
329+
background: var(--main-action-color);
330+
color: var(--light-text-color);
331+
border: none;
332+
border-radius: 25px;
333+
cursor: pointer;
334+
transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
335+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
336+
}
337+
338+
#custom-alert button:hover {
339+
background: var(--main-action-selected-color);
340+
transform: scale(1.05);
341+
}
342+
343+
@keyframes fadeInDialog {
344+
from {
345+
opacity: 0;
346+
transform: scale(0.9);
347+
}
348+
349+
to {
350+
opacity: 1;
351+
transform: scale(1);
352+
}
353+
}
354+
355+
@media (max-width: 480px) {
356+
#custom-alert {
357+
margin: 0 1rem;
358+
width: auto;
359+
top: 50%;
360+
transform: translateY(-50%);
361+
}
362+
}
299363
</style>
300364

301365
<header role="banner">
@@ -319,6 +383,10 @@ <h1 data-aos="fade" data-aos-duration="700" data-aos-delay="150">2025</h1>
319383
<button onclick="window.location.href='/onboarding/join-game.html#mainProgressBar'" class="join-game scrolled-button" aria-label="Play the Game" style="display: none;" data-aos="fade" data-aos-duration="700" data-aos-delay="200">
320384
<strong>PLAY</strong>
321385
</button>
386+
<dialog id="custom-alert">
387+
<p id="custom-alert-message"></p>
388+
<button id="custom-alert-close">OK</button>
389+
</dialog>
322390
</header>
323391

324392
<script>
@@ -347,4 +415,15 @@ <h1 data-aos="fade" data-aos-duration="700" data-aos-delay="150">2025</h1>
347415
scrolledJoinButton.style.display = 'none';
348416
}
349417
}
418+
419+
function customAlert(message) {
420+
const dialog = document.getElementById('custom-alert');
421+
const messageEl = document.getElementById('custom-alert-message');
422+
messageEl.textContent = message;
423+
dialog.showModal();
424+
}
425+
426+
document.getElementById('custom-alert-close').addEventListener('click', function () {
427+
document.getElementById('custom-alert').close();
428+
});
350429
</script>

0 commit comments

Comments
 (0)