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

Auto Save

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

              
                <div class="wrap">
  <header>
    <div class="container">
      <div class="text-center">
        <img class="twitch-logo" src="https://res.cloudinary.com/nhast25cs/image/upload/v1520366699/twitchApp/Twitch_White_50h.png" alt="Official Twitch Logo" />
        <h1><i class="fas fa-angle-double-left"></i> Currently Streaming <i class="fas fa-angle-double-right"></i></h1>
         <div id="status">
           <button id="btn-all" class="btn btn-primary"><i class="fas fa-reply-all"></i> All</button>
          <button id="btn-online" class="btn btn-success"><i class="far fa-lightbulb"></i> Online</button>
          <button id="btn-offline" class="btn btn-danger"><i class="fas fa-power-off"></i> Offline</button>
           <button id="btn-reload" class="btn btn-primary"><i class="fas fa-redo-alt"></i> Reload</button>
        </div>
      </div>
    </div>
  </header>
  
  <section>
    <div class="container">
      <div class="row">
        <div id="box1" class="col-sm-6 col-md-3">
          <div class="streamers stream1">
          </div>
        </div>
        <div id="box2" class="col-sm-6 col-md-3">
          <div class="streamers stream2">
            
          </div>
        </div>
        <div id="box3" class="col-sm-6 col-md-3">
          <div class="streamers stream3">
          </div>
        </div>
        <div id="box4" class="col-sm-6 col-md-3">
          <div class="streamers stream4">
          </div>
        </div>
        <div id="box5" class="col-sm-6 col-md-3">
          <div class="streamers stream5">
          </div>
        </div>
        <div id="box6" class="col-sm-6 col-md-3">
          <div class="streamers stream6">
          </div>
        </div>
        <div id="box7" class="col-sm-6 col-md-3">
          <div class="streamers stream7">
          </div>
        </div>
        <div id="box8" class="col-sm-6 col-md-3">
          <div class="streamers stream8">
          </div>
        </div>
      </div>
    </div>
  </section>
  
  <footer>Made by <a href="https://twitter.com/nicki_hastings" target="_blank">@nicki_hastings</a> - a freecodecamp project</footer>
  
</div>
              
            
!

CSS

              
                body{
  font-family: 'Jura', sans-serif;
/*   font-family: 'Wire One', sans-serif; */
  font-size: 2em;
  background-color: #172141; /*dark blue*/
  color: #5387e8; /*mid blue*/
}
.twitch-logo{margin-top: 30px;}
.streamers{
  border: 8px solid #5387e8;
  border-radius: 8px;
/*   background-color: #a4bef1;*/ /*light blue*/ 
  min-height: 460px;
  padding: 1em;
  margin-top: 2em;
}
.btn-primary{
  background-color:#5387e8;
}

section{
 margin-bottom: 2em;  
}

section p{
  margin-bottom: 5px;
}
.profile img{
  max-width: 100%;
}
.username {
  text-align: right;
  font-size: 0.9em;
  color: #a4bef1; /*light blue*/
}
.game{font-size: 22px}
.streaming{
  font-size: 16px;
  line-height: 20px;
}
.title {
  color: #a4bef1; /*light blue*/
  font-size: 18px;
}
.streamlink{
  float: right;
}
.streamlink a{
  color: #a4bef1; /*light blue*/
  text-align:right;
}
.status {
  color: #a4bef1;/*light blue*/
}
.online .status{
  color: #4cae4c; /*green*/
}
.offline .status{
  color: #d43f3a; /*red*/
}

footer{
  text-align: center;
  font-size: 0.75em;
  padding-bottom: 1em;
}

footer a{
  color: #a4bef1;/*light blue*/
}
footer a:hover{
  color: #5387e8;/*light blue*/
}
    


              
            
!

JS

              
                $(document).ready(function(){
  var streamers = ["ESL_SC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "OgamingSC2", "RobotCaleb", "noobs2ninjas"];
  var streamInfo = {};
  var count = 0; /* counts number of times ajax call is made to fill object.*/
  
  function updateStreamers(){
    /* because ajax is asyncronous and needs to be called 8 times, check
    the array is full before going further */
    if(count != 8){
      return;
    }
    console.log(streamInfo);
    count = 0;
    var html = "";
    for(var i = 0; i < 8; i++ ){
      var username = streamers[i];
      
      if(streamInfo[username].stream != null){
        html += '<div class="profile">';
        html += '<img src="' + streamInfo[username].stream.channel.logo + '" /></div>';
        html += '<div class="username">' + streamInfo[username].stream.channel.display_name + '</div>';
        html += '<div class="game"><span class="title">Game: </span>' + streamInfo[username].stream.channel.game + '<p class="streaming"><span class="title">Streaming: </span>'+ streamInfo[username].stream.channel.status +'</p>';
        html += '<div class="streamlink"><a href="https://www.twitch.tv/' + username + '" target="_blank">visit <i class="fas fa-angle-right"></i></a></div>';
        html += '<p class="status">Online</p>';
        /*create class/id targets from variable */
        var idclass = '.stream'+ (i + 1);
        var idbox = '#box' + (i + 1);
        $(idclass).html(html);
        html = '';
        $(idbox).addClass('online');
      } /*end if online*/
      else {
        html += '<div class="profile">';
        html += '<img src="https://res.cloudinary.com/nhast25cs/image/upload/v1520368131/twitchApp/offline.png" /></div>';
        html += '<div class="username">' + username + '</div>';
        html += '<div class="streamlink"><a href="https://www.twitch.tv/' + username + '" target="_blank">visit <i class="fas fa-angle-right"></i></a></div>';
        html += '<p class="status">Offline</p>';
        
        var idclass = '.stream'+ (i + 1);
        var idbox = '#box' + (i + 1);
        
        $(idclass).html(html);
        html = '';
        $(idbox).addClass('offline');
      } /*end else offline*/
    } /*end for*/
  }
  
  function getStreamers(){
    streamers.forEach(function(userid){
    var twitchurl = "https://wind-bow.glitch.me/twitch-api/streams/" + userid /*+ "?callback=?"*/;
  
    $.ajax( {
      type: "GET",
      url: twitchurl,
      dataType: 'json',
      
      success: function(data) {
        streamInfo[userid] = data;
        count ++;
      },
      error: function(err) { console.log("Failed to get stream..."+userid); console.log(err); },
     complete: updateStreamers
      } ); /* end ajax */
    }); /* end foreach*/
    //console.log(streamInfo);
  } /*end getStreamers*/
  
  getStreamers(); /*call the api*/
  
  /* Show or Hide streamers who are online or offline */
  /*button listeners for online/offline switch*/
  $('#btn-online').on("click", function(){
    $('.offline').hide(700);
    $('.online').show(700);
  } );
  $('#btn-offline').on("click", function(){
    $('.offline').show(700);
    $('.online').hide(700);
  } );
  $('#btn-all').on("click", function(){
    $('.offline').show(700);
    $('.online').show(700);
  } );
  $('#btn-reload').on("click", function() {
    location.reload(true);
  } );
});
              
            
!
999px

Console