// scripts.js
// Function to convert text to bold Unicode characters
function convertToBold(text) {
const normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const bold = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz𝘄𝘅𝘆𝘇";
return text.split('').map(char => {
const index = normal.indexOf(char);
return index >= 0 ? bold[index] : char;
}).join('');
}
// Function to convert text to italic Unicode characters
function convertToItalic(text) {
const normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const italic = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz𝘄𝘅𝑤𝑥𝑦𝑧";
return text.split('').map(char => {
const index = normal.indexOf(char);
return index >= 0 ? italic[index] : char;
}).join('');
}
// Function to add underline to text
function convertToUnderline(text) {
return `${text}`;
}
// Function to handle the text conversion when the button is clicked
document.getElementById('convert-button').addEventListener('click', function() {
const inputText = document.getElementById('input-text').value;
// Convert to different styles
const boldText = convertToBold(inputText);
const italicText = convertToItalic(inputText);
const underlineText = convertToUnderline(inputText);
// Display the converted text
document.getElementById('bold-text').innerText = boldText;
document.getElementById('italic-text').innerText = italicText;
document.getElementById('underline-text').innerHTML = underlineText; // Using innerHTML for underline
});
Text Styling Tool
Bold Text: | |
Italic Text: | |
Underline Text: |