Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="container-fluid text-center">
    <h1>Twitch Streamer</h1>
      <div class="container"></div>
      <button type="button" id="live">Live</button>
      <button type="button" id="offline">Offline</button>
      <button type="button" id="closed">Closed</button>
      <button type="button" id="all">All</button>
        <ul>
            <li id="result"></li><br/>
          
        </ul>
       </div>
              
            
!

CSS

              
                h1 {
  font-family: 'Comic Sans MS', serif;
  font-size: 30px;
  color: black;
  border: 1px solid black;
  margin: 5px auto;
  width: 50%;
  background-color: #F1D995;
  border-radius:15px;
  
}
body {
  background-color: #8A8888;
  
  
}

li{
  border: 1px solid black;
  background-color: #DADADA;
  margin: 5px 0;
  padding: 15px;
  border-radius:15px;
  font-weight: bold;
  text-align:left;
}

li.online {
  background: #ADF1B2;
  
}

.toRight {
  float: right;
}

li.unavailable{
  background: #ED7A8D;
}
li.offline{
  background:#9ED1F7;
}

ul {
  list-style:none;
  margin: 0 auto;
  width:50%;
  padding: 0;
 }

button{
  background-color:#1BAFBD;
  font-weight:bold;
}


              
            
!

JS

              
                $(document).ready(function() {
  //initiale and declare array of channels
  var channels = ["freecodecamp", "storbeck", "terakilobyte", "habathcx", "RobotCaleb", "thomasballinger", "noobs2ninjas", "beohoff", "monstercat", "comster404","streamerhouse"];

  //Loop through each element in the array to output which channel is online, offline, or closed
  for (var i = 0; i < channels.length; i++) {
    //var twitch = makerequest(i);
    //call API
    (function(i) {
      $.getJSON('https://api.twitch.tv/kraken/streams/' + channels[i] + '?callback=?', function(data) {
        console.log(data.stream);
        
        //If data stream from API =422 channel is closed
        if ( data.status===422) {
          $('#result').append(
            '<li class="unavailable">' + channels[i] + '<span class="toRight">'+' Closed' + '</span></li>');
        }
        
        //If there is an active data stream it is currently live.
        else if ( data.stream) {
          $('#result').prepend(
            '<a href="https://www.twitch.tv/' + channels[i] + '" target="_blank">' +
            '<li class="online">' + channels[i] + ' </a>' + '<span class="toRight">' + data.stream.game 
            +'</span></li>' 
          );
         } 
        
        //Else if the data stream is not null it is offline
        else {
          $('#result').append(
            '<a href="https://www.twitch.tv/' + channels[i] + '" target="_blank">' +
            '<li class="offline">' + channels[i] + '</a>'+ '<span class="toRight"> offline</span></li>' 
            
          );
        }
      });
    }(i));
  }
});

 //Filter to display offline channels
  $("#offline").click(function(){
        $('li.online').hide();
        $('li.unavailable').hide();
        $('li.offline').show();
        
    });
//Filter to display closed channels
    $("#closed").click(function(){
        $("li.online").hide();
        $("li.offline").hide();
        $("li.unavailable").show();
    });
//Filter to display live channels
    $("#live").click(function(){
        $('li.offline').hide();
        $("li.unavailable").hide();
        $("li.online").show();
    });
//Filter to show all channels
$("#all").click(function(){
        $('li.offline').show();
        $("li.unavailable").show();
        $("li.online").show();
    });


              
            
!
999px

Console