block by harrystevens 95f85e0043f520dcbe115f3f9cfbcdd3

Cases

Full Screen

A demonstration of jeezy‘s case functions.

index.html

<!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>