Skip to content

Instantly share code, notes, and snippets.

@HarryStevens
Last active December 5, 2017 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HarryStevens/95f85e0043f520dcbe115f3f9cfbcdd3 to your computer and use it in GitHub Desktop.
Save HarryStevens/95f85e0043f520dcbe115f3f9cfbcdd3 to your computer and use it in GitHub Desktop.
Cases
license: gpl-3.0
height: 620
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
margin: 10px;
}
.title {
font-weight: bold;
margin-bottom: 4px;
font-size: 1.1em;
}
.description {
font-size: .9em;
color: #888;
margin-bottom: 12px;
}
.output {
margin-bottom: 24px;
min-height: 18px;
}
textarea {
width: 100%;
margin-bottom: 12px;
}
</style>
</head>
<body>
<textarea></textarea>
<script src="https://unpkg.com/jeezy@1.12.4/lib/jeezy.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(go);
function go(){
var cases = [{
case: "Camel",
desc: "Capitalize every word but the first. Remove punctuation and spaces."
}, {
case: "Sentence",
desc: "Capitalize the first letter of every sentence."
}, {
case: "Slug",
desc: "Remove punctuation, replace spaces with hyphens."
}, {
case: "Snake",
desc: "Remove punctuation, replace spaces with underscores."
}, {
case: "Start",
desc: "Capitalize the first letter of every word."
}, {
case: "Title",
desc: "Capitalize the first letter of every word except for prepositions, conjunctions, and articles."
}];
cases.forEach(function(c){
$("body").append("<div class='title'>" + c.case + "</div><div class='description'>" + c.desc + "</div><div class='output' id='" + c.case + "'></div>");
});
$("textarea").keyup(function(){
cases.forEach(function(c){
$("#" + c.case).html(jz.str["to" + c.case + "Case"]($("textarea").val()));
});
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment