<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<body>
<textarea id="inputElement" autofocus></textarea>
<div>
<label><input id="optionStartCapital" type="checkbox" checked>First Letter Capitalized</label>
<label><input id="optionByWord" type="checkbox">By Word</label>
</div>
<button id="runButton">SpOnGeBoB!</button>
<textarea id="outputElement" readonly></textarea>
<style>
:root {
color-scheme: light dark;
}
body {
display: flex;
flex-direction: column;
}
textarea {
flex-grow: 1;
width: 100%;
resize: none;
}
button {
margin-right: auto;
margin-left: auto;
padding-top: 3px;
padding-bottom: 3px;
font-size: 1.1em;
zoom: 1.2;
}
</style>
<script>
runButton.addEventListener("click", (event) => {
outputElement.value = inputElement.value.split("\n").map((line) => {
let result = "";
let shouldUppercase = optionStartCapital.checked;
for (let c of line) {
if (!/\s/.test(c)) {
c = c[shouldUppercase ? "toUpperCase" : "toLowerCase"]();
shouldUppercase = !shouldUppercase;
} else if (optionByWord.checked)
shouldUppercase = optionStartCapital.checked;
result += c;
}
return result;
}).join("\n");
outputElement.focus();
outputElement.select();
document.execCommand("copy");
});
inputElement.addEventListener("keydown", (event) => {
switch (event.keyCode) {
case 13:
event.preventDefault();
if (event.shiftKey)
inputElement.value += "\n";
else
runButton.click();
return;
}
});
</script>