Skip to content

Commit 95da760

Browse files
committed
add us locale defaults
1 parent d2fce11 commit 95da760

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed

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

+60-4
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">The Blood Pact
386386
// Setting up the animated counter effect
387387
let displayAge = 0;
388388
resultElement.innerHTML = `
389-
<div style="font-size: 1rem; color: #2c3e50; text-align: center;">Your biological age is:</div>
390-
<div style="font-size: 2.5rem; color: #4CAF50; font-weight: bold; text-align: center;"><span id="animatedAge">0</span></div>
391-
<div id="yearsText" style="font-size: 1rem; color: #2c3e50; text-align: center;">years</div>
392-
`;
389+
<div style="font-size: 1rem; color: #2c3e50; text-align: center;">Your biological age is:</div>
390+
<div style="font-size: 2.5rem; color: #4CAF50; font-weight: bold; text-align: center;"><span id="animatedAge">0</span></div>
391+
<div id="yearsText" style="font-size: 1rem; color: #2c3e50; text-align: center;">years</div>
392+
`;
393393

394394
if (isFirstTimeAnimation) {
395395
// Set the flag to false after the first run
@@ -430,6 +430,43 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">The Blood Pact
430430
isResultCalculated = true;
431431
}
432432

433+
// Mapping language or country codes to unit preferences
434+
const unitPreferences = {
435+
US: {
436+
albuminUnit: '0.1', // g/dL
437+
creatinineUnit: '0.0113', // mg/dL
438+
glucoseUnit: '18.016', // mg/dL
439+
crpUnit: '10', // mg/L
440+
lymphocyteUnit: '1', // %
441+
mcvUnit: '1', // fL
442+
rcdwUnit: '1', // %
443+
apUnit: '1', // U/L
444+
wbcUnit: '1' // 1000 cells/μL
445+
},
446+
en_GB: {
447+
albuminUnit: '1', // g/L (SI unit, common in the UK)
448+
creatinineUnit: '1', // µmol/L
449+
glucoseUnit: '1', // mmol/L
450+
crpUnit: '10', // mg/L
451+
lymphocyteUnit: '1', // %
452+
mcvUnit: '1', // fL
453+
rcdwUnit: '1', // %
454+
apUnit: '1', // U/L
455+
wbcUnit: '1' // 1000 cells/μL
456+
},
457+
default: {
458+
albuminUnit: '1', // g/L
459+
creatinineUnit: '1', // µmol/L
460+
glucoseUnit: '1', // mmol/L
461+
crpUnit: '10', // mg/L
462+
lymphocyteUnit: '1', // %
463+
mcvUnit: '1', // fL
464+
rcdwUnit: '1', // %
465+
apUnit: '1', // U/L
466+
wbcUnit: '1' // 1000 cells/μL
467+
}
468+
};
469+
433470
document.addEventListener('DOMContentLoaded', function () {
434471
const unitSelects = document.querySelectorAll('.input-group select');
435472
let maxWidth = 0;
@@ -470,7 +507,26 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">The Blood Pact
470507
if (isFake) {
471508
fillFakeData();
472509
}
510+
511+
// Apply preferences on page load
512+
applyLanguagePreferences();
473513
});
514+
515+
// Detect and apply preferences based on language
516+
function applyLanguagePreferences() {
517+
const language = navigator.language || 'default'; // Get browser language
518+
const languageKey = language.replace('-', '_'); // Replace dash with underscore
519+
const preferences = unitPreferences[languageKey] || unitPreferences.default;
520+
521+
// Apply preferences to unit select elements
522+
for (const [unitId, unitValue] of Object.entries(preferences)) {
523+
const unitSelect = document.getElementById(unitId);
524+
if (unitSelect) {
525+
unitSelect.value = unitValue;
526+
}
527+
}
528+
}
529+
474530
function proceedToNextPage() {
475531
const yearInput = document.getElementById('dob-year').value;
476532
const monthInput = document.getElementById('dob-month').value;

0 commit comments

Comments
 (0)