Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Blackout Poetry</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
  <div class="container">
    <div class="row">
      <div class="col-md-12">
      <h3>Instructions:</h3>
      <div class="info">
      <p>A blackout poem is made by selecting indivual words from a longer story. In the Story Snippet below, clicking individual words marks them in yellow and adds them to your poem in the order they appear. "block/unblock unmarked words" will block out all words that are not marked in yellow.Use the existing story below or copy and paste your own story into the window below and hit submit.</p></div>
        
     
  
        <div class="upload">
          <form class="upload" onSubmit="return newStory();">
            <textarea class="textarea"></textarea>
            <input type="submit" value="Submit">
          </form>
        </div>
      </div>
    
 
    
  </div>
  <div class = "row">
    <div class = "col-md-6 story-section">
      <h3>Story Snippet: (click words to add to poem)</h3>
      <div class="story">
      </div>
    </div>
    <div class = "col-md-6">
      <h3>Your Poem:</h3>
      <div class="poem">(your poem appears here)
      </div>
    </div>
  </div>
    <div class = "row">
  
   <div class="menu">
    <p>Click a word mark it. </p>
    <div class="btn blockOut">blockout/unblock unmarked words</div>
    <div class="btn clearMarked">clear marked words</div>
    <div class="btn reset">Reset all words</div>
  </div>
  </div>
    </div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <script src="js/app.js"></script>


</body>

              
            
!

CSS

              
                .poem {
  font-size: 28px;
}

.story-section{
  background-color: aliceblue
}

.blocked {
  background-color: #222222;
  transition: background-color 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;
  border-radius: 8px;
}


.faded {
  opacity: .0;
  transition: opacity 0.5s   ease-in-out;
  border-radius: 8px;
}

span {
  opacity: 1;
  transition: opacity 0.5s   ease-in-out;
  transition: background 0.5s   ease-in-out;
  border-radius: 8px;
}


.story {
  font-size:18px;
  margin-top:5px;

}



h3{
  padding-top:1em;
}

div.menu{
  background: #CCCCCC;
  padding: 3px;
  border: 1px solid black;
}

.marked {
  background-color: yellow;
}

div.btn.reset { background: red; }

div.btn {
  border-radius: 8px;
  background: #FFFFFF;
  /*display: inline-block;*/
  vertical-align: middle;
  margin: 4px 4px 4px 4px;
  padding: 5px 5px 5px 5px;
}



.active{
  background: yellow;
}

              
            
!

JS

              
                
var story = "I had scarcely thought of the theater for some years, when Kean arrived in this country; and it was more from curiosity than from any other motive, that I went to see, for the first time, the great actor of the age. I was soon lost to the recollection of being in a theater, or looking upon a great display of the \"mimic art.\" The simplicity, earnestness, and sincerity of his acting made me forgetful of the fiction, and bore me away with the power of reality and truth. If this be acting, said I, as I returned home, I may as well make the theater my school, and henceforward study nature at second hand. \nHow can I describe one who is almost as full of beauties as nature itself,—who grows upon us the more we become acquainted with him, and makes us sensible that the first time we saw him in any part, however much he may have moved us, we had but a partial apprehension of the many excellences of his acting? We cease to consider it as a mere amusement. It is an intellectual feast; and he who goes to it with a disposition and capacity to relish it, will receive from it more nourishment for his mind, than he would be likely to do in many other ways in twice the time. Our faculties are opened and enlivened by it; our reflections and recollections are of an elevated kind; and the voice which is sounding in our ears, long after we have left him, creates an inward harmony which is for our good. \nKean, in truth, stands very much in that relation to other players whom we have seen, that Shakspeare does to other dramatists. One player is called classical; another makes fine points here, and another there; Kean makes more fine points than all of them together; but in him these are only little prominences, showing their bright heads above a beautifully undulated surface. A continual change is going on in him, partaking of the nature of the varying scenes he is passing through, and the many thoughts and feelings which are shifting within him.";

// VARIABLES
var blockedOut = false;
var faded = false;
var punctuation = /([—.,?!;:"'])/;

// FUNCTIONS
function displayStory(storytext) {
  var poem = '';
  var array = storytext.split(' ');
  array.forEach(function(word){
    poem += "<span class>" + word + " </span>" 
  });
  $(".story").html(poem);
}





// Update text of poem
function updatePoem () {
  $("div.poem").html($("span.marked").text());
}


function newStory (){
  var storytext = $(".textarea").val()
  $('.story').html(displayStory(storytext));
  $(".textarea").val('');
  return false;
}

displayStory(story);








// CLICK RESET: Remove all classes, clear poem
$(".reset").on('click',function(){
$("span").removeClass('blocked faded marked');
$(".poem").html('(Marks words above to populate your poem)');
});


// Clicking on Words
$("div.story").on("click",function (evt){
  if (this === evt.target || $(evt.target).hasClass('faded') ){
  // do nothing
  } else {
      $(evt.target).removeClass("blocked")
      $(evt.target).toggleClass("marked")
  }
    updatePoem();
});


// Block out all words not "marked"
$(".blockOut").on('click', function(){
  if(blockedOut){
    $("span:not('.marked')").removeClass("blocked");
    blockedOut = false;
  } else {
    $("span:not('.marked')").addClass("blocked");
    blockedOut = true;
  }
});

// 
$(".clearMarked").on('click', function(){
  $("span").removeClass("marked");
  $(".poem").html('(Marks words above to populate your poem)');
});




              
            
!
999px

Console