diff options
| author | Fuwn <[email protected]> | 2025-12-02 00:29:53 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-12-02 00:29:53 -0800 |
| commit | 34b9869ab5f776be0d2f9711d2fda3e689e88485 (patch) | |
| tree | b8e9b2b9921af37f50207935abe63ba2a34ca1a8 /js | |
| parent | feat(index.html): Match file upload button to theme (diff) | |
| download | rysk-34b9869ab5f776be0d2f9711d2fda3e689e88485.tar.xz rysk-34b9869ab5f776be0d2f9711d2fda3e689e88485.zip | |
feat(index.js): Capitalise table content
Diffstat (limited to 'js')
| -rw-r--r-- | js/index.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/js/index.js b/js/index.js index 13c8520..0f3c309 100644 --- a/js/index.js +++ b/js/index.js @@ -249,12 +249,30 @@ if (gradingToggle) { }; } + // Helper function to capitalize first letter + const capitalizeFirst = (str) => { + if (!str) return str; + // Handle HTML strings - capitalize first letter of text content after tags + if (str.includes('<')) { + // Capitalize first letter after opening tag (handle whitespace) + return str.replace(/>\s*([a-z])/g, (match, letter) => { + return match.replace(letter, letter.toUpperCase()); + }); + } + // Handle plain strings - capitalize first letter if it's alphabetic + // Skip if it starts with a number or special character + if (str.length > 0 && /^[a-z]/.test(str)) { + return str.charAt(0).toUpperCase() + str.slice(1); + } + return str; + }; + let calculate = () => { for (let i of Object.values(analysis.criteria)) { i.analysis.calculate(); - i.render.innerHTML = i.analysis.render(); - i.ideal.innerHTML = i.analysis.ideal(); - i.assessment.innerHTML = i.analysis.assess(); + i.render.innerHTML = capitalizeFirst(i.analysis.render()); + i.ideal.innerHTML = capitalizeFirst(i.analysis.ideal()); + i.assessment.innerHTML = capitalizeFirst(i.analysis.assess()); } analysis.criteria.eyeColor.analysis.detect( |