Skip to content

Commit

Permalink
Create CaseConvert.html
Browse files Browse the repository at this point in the history
  • Loading branch information
asubodh authored Oct 2, 2022
1 parent 369ce08 commit 8123736
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions Javascripts/CaseConvert.html
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>

0 comments on commit 8123736

Please sign in to comment.