forked from SHabaj-dev/Hactoberfest-2022
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 changed file
with
101 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<style> | ||
.heading{ | ||
font-size: 2rem; | ||
font-family: Verdana, Geneva, Tahoma, sans-serif; | ||
} | ||
.form-control{ | ||
height: 505px; | ||
max-height: 505px; | ||
width: 70%; | ||
max-width: 70%; | ||
resize: none; | ||
padding: 10px; | ||
border-radius: 10px; | ||
} | ||
button{ | ||
padding: 10px; | ||
border-radius: 10px; | ||
cursor: pointer; | ||
} | ||
button:active{ | ||
scale: 0.98; | ||
} | ||
</style> | ||
<body> | ||
<center> | ||
<form> | ||
<h2 class="heading">Case Converter</h2> | ||
</label> | ||
<textarea class="form-control" id="caseconvert"></textarea> | ||
</form> | ||
<div className='functionbutton'> | ||
<button type="button" id="uppercaseconvert" >Upper Case</button> | ||
<button type="button" id="lowercaseconvert" >Lower Case</button> | ||
<button type="button" id="titlecaseconvert" >Title Case</button> | ||
<button type="button" id="sentencecaseconvert" >Sentence Case</button> | ||
<button type="button" id="inversecaseconvert" >Inverse Case</button> | ||
<button type="button" id="downloadtxt" >Download</button> | ||
<button type="button" id="copytxt" >Copy To Clibboard</button> | ||
</div> | ||
</div> | ||
</center> | ||
<script type="text/javascript"> | ||
|
||
document.getElementById('uppercaseconvert').addEventListener("click", uppercaseconvert_fun); | ||
document.getElementById('lowercaseconvert').addEventListener("click", lowercaseconvert_fun); | ||
document.getElementById('titlecaseconvert').addEventListener("click", titleconvert_fun); | ||
document.getElementById('sentencecaseconvert').addEventListener("click", Setenceconvert_fun); | ||
document.getElementById('inversecaseconvert').addEventListener("click", Inverseconvert_fun); | ||
document.getElementById('downloadtxt').addEventListener("click", Downloadtxt_fun); | ||
document.getElementById('copytxt').addEventListener("click", caseconvertcopy_fun); | ||
|
||
function uppercaseconvert_fun() { | ||
var str = document.getElementById('caseconvert').value | ||
document.getElementById('caseconvert').value = str.toUpperCase(); | ||
}; | ||
|
||
function lowercaseconvert_fun() { | ||
|
||
var s = document.getElementById('caseconvert').value | ||
document.getElementById('caseconvert').value = s.toLowerCase(); | ||
}; | ||
|
||
function titleconvert_fun() { | ||
|
||
var s = document.getElementById('caseconvert').value | ||
document.getElementById('caseconvert').value = s.replace(/\b(\w)/g, s => s.toUpperCase()); | ||
}; | ||
|
||
function Setenceconvert_fun() { | ||
|
||
var s = document.getElementById('caseconvert').value | ||
// eslint-disable-next-line | ||
document.getElementById('caseconvert').value = s.replace(/\.\s+([a-z])[^\.]|^(\s*[a-z])[^\.]/g, s => s | ||
.replace(/([a-z])/, s => s.toUpperCase())) | ||
}; | ||
|
||
function Inverseconvert_fun() { | ||
|
||
var s = document.getElementById('caseconvert').value | ||
document.getElementById('caseconvert').value = s.replace(/./g, c => c === c.toUpperCase() ? c | ||
.toLowerCase() : c.toUpperCase()); | ||
} | ||
function Downloadtxt_fun() { | ||
var l = document.createElement("a"); | ||
l.href = "data:text/plain;charset=UTF-8," + document.getElementById("caseconvert").value; | ||
const name = document.getElementById("caseconvert").value.split(' ').slice(0, 2).join(' '); | ||
l.setAttribute("download", (name + " (YourFileName).txt")); | ||
l.click(); | ||
} | ||
|
||
function caseconvertcopy_fun() { | ||
var copyText = document.getElementById("caseconvert"); | ||
copyText.select(); | ||
copyText.setSelectionRange(0, 99999) | ||
document.execCommand("copy"); | ||
}; | ||
</script> | ||
</body> | ||
</html> |