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">
  <div class="row header">
    <div class="title">
      <h1> Twitch API Browser</h1>
      <h2>Who is streaming right now?</h2>
    </div>
    <div class="menu">
      <div class="selector all active">
        <div class="circle all"></div>
        <div class="select-label"><p>All</p></div>
      </div>
        <div class="selector on">
          <div class="circle on"></div>
          <div class="select-label"><p>On</p></div>
        </div>
        <div class="selector off">
          <div class="circle off"></div>
          <div class="select-label"><p>Off</p></div>
        </div>
      </div>
    </div>
  </div>

  <div class="container" id="main">

  </div>
              
            
!

CSS

              
                img {
  width: 50px;
  height: 50px;
  border-radius: 25px;
}

.row { 
  margin: 2px 0px;
    padding: 5px;
    line-height: 50px;
}

.header {
  margin: 10px 0 0 0;
  padding: 0 80px ;
  background-color: #555;
  color: #eee;

}

.title {
  float: left;
}
.menu {
  margin: 30px 0 0 0;
  color: #111;
  width: 80px;
  height: 72px; 
  float: right;
}

.selector {
  height: 20px;
  width: 30px;
  clear: both;
  line-height: 20px;
  font-size: 1em;
  cursor: pointer;
  margin: 1px;
  padding: 2px 10px;
  transition: width 0.4s;
}

.selector p {
  display: none;
  float: left;
}

.selector.active {
  width: 80px;
  background-color: #eee;
}

.selector.active p {
  display: inline;
}
.circle {
  padding: 1px 0 0 0;
  height: 12px;
  width: 12px;
  border-radius: 10px;
  background-color: #333;
  float: right;
}

.circle.all {
  background-color: #abc;
}

.circle.on {
  background-color: #B8CCA6;
}

.circle.off {
  background-color: #4A5E82;
}

.select-label {
  float: right;
}
.online, .online a
{
  color: #4a5e82;
  background-color: #B8CCA6;
}

.offline, .offline a, .closed, .closed a
{
  color: #b8cca6;
  background-color: #4A5E82;
}
              
            
!

JS

              
                   $(document).ready(function() {

     var userMatrix = [];
     var fccTwitchUsers = ["freecodecamp", "storbeck", "medrybw", "terakilobyte", "habathcx", "RobotCaleb", "thomasballinger", "noobs2ninjas", "beohoff", "brunofin", "comster404", "ESL_SC2", "OgamingSC2", "cretetion"];

     fccTwitchUsers.forEach(function(user) {

       var userObj = {};
       userObj.name = user;
       userObj.stream = "https://api.twitch.tv/kraken/streams/" + user;

       //console.log("User Stream: ", userObj.url);

       $.get(userObj.stream, function(data) {
         //console.log("data: ", data);

         if (!data.status) {

           if (data.stream !== undefined) {

             if (!data.stream) {

               userObj.online = "Offline";
               userObj.rowClass = ".offline";

             } else {
               userObj.online = "Online";
               userObj.rowClass = ".online";
               userObj.title = data.stream.game;
               userObj.viewers = data.stream.viewers;
             }

             var channel = data._links.channel;

             $.get(channel, function(channelData) {
               userObj.url = channelData.url;
               userObj.displayName = channelData.display_name;

               userObj.logo = (channelData.logo == undefined ?
                 "https://placeholdit.imgix.net/~text?txtsize=6&txt=50%C3%9750&w=50&h=50" :
                 userObj.logo = channelData.logo);

               outputRow(user, userObj, data);

             }, "jsonp")
           }

         } else if (data.status = 422) {

           outputAcctClosed(user);

         }

         console.log("Outside of inner function:" + user + ", " + userObj.online + ", " + data.status);

       }, "jsonp");

     })

     $('.selector.on').click(function() {
       $(this).addClass("active");
       $('.selector.off').removeClass("active");
       $('.selector.all').removeClass("active");
       $('.online').show();
       $('.offline').hide();
       $('.closed').hide();
    
       console.log('On clicked');
     })

     $('.selector.off').click(function() {
       $(this).addClass("active");
       $('.selector.on').removeClass("active");
       $('.selector.all').removeClass("active");
       $('.online').hide();
       $('.offline').show();
       $('.closed').show();
       console.log('Off clicked');
     })

     $('.selector.all').click(function() {
       $(this).addClass("active");
       $('.selector.off').removeClass("active");
       $('.selector.on').removeClass("active");
       $('.online').show();
       $('.offline').show();
       $('.closed').show();
       console.log('All clicked');
     })

   });

   function outputRow(user, obj, data) {

     var html = "";

     if (!data.stream) {
       html += '<div class="row offline">';
     } else {
       html += '<div class="row online">';
     }

     html += '<div class="col-sm-2">' + '<img src=' + obj.logo + ' /></div>';
     html += '<div class="col-sm-2">' + '<a  target="_blank" href=' + obj.url + '>' + user + '</a></div>';

     if (!data.stream) {
       html += '<div class="col-sm-8 text-center">' + obj.online + '</div>';
     } else {
       html += '<div class=" col-sm-8 text-center">' + '<a href=' + obj.url + '>' + obj.title + '</a>, Viewing: ' + obj.viewers + '</div>';
     }

     html += '</div>';

     (!data.stream ? $('#main').append(html) : $('#main').prepend(html));

   }

   function outputAcctClosed(user) {
     var html = '';
     html += '<div class="row closed">';
     html += '<div class="col-sm-2">' + '<img src=https://dummyimage.com/50x50/ecf0e7/5c5457.jpg&text=0x3F /></div>';
     html += '<div class="col-sm-2">' + user + '</a></div>';
     html += '<div class="col-sm-8 text-center">Account Closed</div>';
     html += '</div>';

     $('#main').append(html);
   };
              
            
!
999px

Console