A demonstration of jeezy's case functions.
Last active
December 5, 2017 10:56
-
-
Save HarryStevens/95f85e0043f520dcbe115f3f9cfbcdd3 to your computer and use it in GitHub Desktop.
Cases
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
license: gpl-3.0 | |
height: 620 |
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
<!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