-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
143 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta property="og:title" content="Pangram World" /> | ||
<meta property="og:description" | ||
content="Check if you have a pangram, add symbols or adjust your text to bold, italic, or even alternating caps/lower case for Facebook and other social media platforms. Additionally, enrich your science and math emails with a variety of mathematical symbols and Greek letters." /> | ||
<meta property="og:image" content="https://www.pangram-world.com/images/pangram-logo-192.png" /> | ||
<meta property="og:url" content="https://www.pangram-world.com" /> | ||
<title>Roman Numeral Generator</title> | ||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="style/bootstrap.css"> | ||
<link rel="stylesheet" href="style/styles.css"> | ||
<link rel="stylesheet" href="style/base.css"> | ||
<link rel="stylesheet" href="style/cards.css"> | ||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"> | ||
<link rel="icon" type="image/x-icon" href="images/favicon.ico"> | ||
<script src="scripts/main.js" defer></script> | ||
<script src="scripts/bootstrap.bundle.js"></script> | ||
<script src="https://kit.fontawesome.com/18fe617275.js" crossorigin="anonymous"></script> | ||
|
||
<!-- Add any additional meta tags and scripts here --> | ||
</head> | ||
<body> | ||
<!-- Main content area where your page content will go --> | ||
<header id="globalHeader"></header> | ||
<main> | ||
<h2>Roman Numeral Generator</h2> | ||
<p>Suitable to copy and paste into <i class="fab fa-facebook facebook-icon" font-size: 1em; vertical-align: | ||
middle; margin-left: 0.5em;"></i></p> | ||
<form id="alternatingTextForm"> | ||
<input type="number" id="textInput" placeholder="Enter your number here" required> | ||
<button type="submit" class="transform-btn">Transform</button> | ||
</form> | ||
<!-- Output textbox --> | ||
<textarea id="alternatingTextOutput" placeholder="Your Roman Numerals will appear here" readonly></textarea> | ||
<!-- Copy button --> | ||
<button id="copyButton" type="button" class="copy-btn">Copy Roman Numerals</button> | ||
<br> | ||
<h2>Convert from Roman Numerals</h2> | ||
<form id="romanToArabicForm"> | ||
<input type="text" id="romanInput" placeholder="Enter Roman numerals" required> | ||
<button type="submit" class="transform-btn">Convert</button> | ||
</form> | ||
<!-- Output textbox --> | ||
<textarea id="arabicNumberOutput" placeholder="Arabic numbers will appear here" readonly></textarea> | ||
<!-- Copy button --> | ||
<button id="copyArabicButton" type="button" class="copy-btn">Copy Number</button> | ||
</main> | ||
|
||
<footer id="globalFooter"></footer> | ||
<script src="scripts/toUnicodeVariant.js"></script> | ||
<script src="scripts/romanNumerals.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const form = document.getElementById('alternatingTextForm'); | ||
const numberInput = document.getElementById('textInput'); | ||
const romanOutput = document.getElementById('alternatingTextOutput'); | ||
const copyButton = document.getElementById('copyButton'); | ||
|
||
form.addEventListener('submit', function (e) { | ||
e.preventDefault(); | ||
const number = parseInt(numberInput.value); | ||
romanOutput.value = convertToRoman(number); | ||
}); | ||
|
||
copyButton.addEventListener('click', function () { | ||
navigator.clipboard.writeText(romanOutput.value).then(() => { | ||
copyButton.textContent = 'Copied!'; | ||
setTimeout(() => copyButton.textContent = 'Copy Roman Numerals', 5000); | ||
}).catch(err => console.error('Error copying text: ', err)); | ||
}); | ||
|
||
function convertToRoman(num) { | ||
if (num < 1 || num > 3999) return "Invalid Number"; // Roman numerals range | ||
const lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}; | ||
let roman = ''; | ||
for (let i in lookup ) { | ||
while ( num >= lookup[i] ) { | ||
roman += i; | ||
num -= lookup[i]; | ||
} | ||
} | ||
return roman; | ||
} | ||
}); | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
// ... [existing code for converting to Roman numerals] ... | ||
|
||
const romanToArabicForm = document.getElementById('romanToArabicForm'); | ||
const romanInput = document.getElementById('romanInput'); | ||
const arabicOutput = document.getElementById('arabicNumberOutput'); | ||
const copyArabicButton = document.getElementById('copyArabicButton'); | ||
|
||
romanToArabicForm.addEventListener('submit', function (e) { | ||
e.preventDefault(); | ||
arabicOutput.value = convertToArabic(romanInput.value.toUpperCase()); | ||
}); | ||
|
||
copyArabicButton.addEventListener('click', function () { | ||
navigator.clipboard.writeText(arabicOutput.value).then(() => { | ||
copyArabicButton.textContent = 'Copied!'; | ||
setTimeout(() => copyArabicButton.textContent = 'Copy Number', 5000); | ||
}).catch(err => console.error('Error copying text: ', err)); | ||
}); | ||
|
||
function convertToArabic(roman) { | ||
const romanNumerals = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}; | ||
let index = 0, num = 0; | ||
for (let i in romanNumerals) { | ||
while (roman.indexOf(i, index) === index) { | ||
num += romanNumerals[i]; | ||
index += i.length; | ||
} | ||
} | ||
return num; | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters