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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <head>
  <meta charset="utf-8">   
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.min.css">
  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
</head>

<body>
  <div class="container">
    <div class="container center-align">
      <img id="title" src="http://blog.maniaplanet.com/wp-content/uploads/2013/03/new-twitchtv-logo.png" class="responsive-img">
    </div>
    <div class="container center-align">
      <button id="all" class="waves-effect waves-light btn purple lighten-3">All</button>
      <button id="online-button" class="waves-effect waves-light btn purple lighten-3">Online</button>
      <button id="offline-button" class="waves-effect waves-light btn purple lighten-3">Offline</button>
    </div>
    <div id="streamers" class="container">
      <div id="online" class="container">
      </div>
      <div id="offline" class="container">
      </div>
      <div id="closed" class="container">
      </div>
    </div>
  </div>
  <script src="https://code.jquery.com/jquery-3.1.0.min.js"   integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s="   crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js"></script>
</body>

<footer>
    <p style="text-align: center">Created with <i class="fa fa-heart"></i> by <a href="https://codepen.io/bethqiang/">Beth Qiang</a> as part of <a href="https://www.freecodecamp.com/challenges/use-the-twitchtv-json-api" target="_blank">a Free Code Camp project</a></p>
</footer>
              
            
!

CSS

              
                html {
  height: 100%;
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  position: relative;
  margin: 0;
  padding-bottom: 4.5em;
  min-height: 100%;
  background-color: #DDDFDF;
}

#title {
  margin: 3em auto 1.2em auto;
}

#all, #online-button, #offline-button {
  margin: .1em;
  padding: 0 1.7em;
}

#streamers {
  margin-top: 2.5em;
  width: 100%;
  max-width: 45em;
}

#online,
#offline,
#closed {
  width: 100%;
  max-width: 45em;
}

.online,
.offline,
.closed {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 6.5em;
  border: .13em solid #FFFFFF;
  margin: -.75em auto;
  padding: .3em;
}

.online {
  background-color: #B5E582;
  color: #3A3838;
}

.offline {
  background-color: #4DB6AC;
  color: #E6EBF4;
}

.closed {
  background-color: #C5DAC1;
  color: #3A3838;
}

.name {
  font-size: 1.6em;
  font-weight: bold;
}

.logo-style {
  max-width: 4.5em;
  max-height: 4.5em;
  min-width: 2.5em;
  min-height: 2.5em;
  margin: 0 auto;
}

.flexCenter {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

p {
  line-height: .9em;
}

footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: .5em;
  text-align: center;
}
              
            
!

JS

              
                $(document).ready(function() {
  var streamers = ["freecodecamp", "trumpsc", "pokespeedrunbots", "food", "cookingfornoobs", "austenmarie", "automateallthethings", "pajlada", "drathy", "acotn", "comster404", "brunofin", "RobotCaleb", "failstream", "HardlyDifficult", "Guude"]
  
  var name; //display name
  var logo; //logo
  var message; //if they don't exist, get error message
  var status; //if they exist, online or offline
  var game; //if they're streaming, what they're "playing" (creative, starcraft, etc.)
  var description; //if they're streaming, details about what they're streaming
  var url; //channel url
  
  
  for (var i=0; i<streamers.length; i++) {
    $.getJSON("https://api.twitch.tv/kraken/streams/" + streamers[i] + "?callback=?")
    .done(function(data) {
      if(data.stream === null) {
        getInfoOffline(data);
      } else if (data.stream === undefined) {
        getInfoClosed(data);
      } else {
        getInfoOnline(data);
      };
    }); //end done
    
    //get info from channel json if offline and add to html
    
    function getInfoOffline(data) {
      $.getJSON(data._links.channel, function(dataOff) {
        name = dataOff.display_name;
        logo = dataOff.logo;
        game = dataOff.game;
        url = dataOff.url;
        
        offlineHTML = '<a href="' + url + '" target="_blank">' +
          '<div class="row offline z-depth-1 hoverable">' +
          '<div class="col s3 col m2">' +
          '<div class="flexCenter">' + //flexbox allows icon to be vertically aligned
          '<img src="' + logo + '" class="responsive-img circle logo-style">' +
          '</div></div>' +
          '<div class="col s9 col m10"><h5 class="name">' + name + '</h5><p>' + game + '</p></div></div></a>';
        $("#offline").append(offlineHTML);
      }); //end getJSON
    }; //end getInfoOffline
    
    //get info for closed accounts and add to html
    
    function getInfoClosed(data) {
      message = data.message;
      //extract channel name from error message
      var tmpStr  = data.message.match("'(.*)'");
      var newStr = tmpStr[1];;
      logo = "http://tcteks.com/wp-content/uploads/2014/09/Blank-person-photo-e1412191714122.png";
      
      closedHTML = '<div class="row closed z-depth-1 hoverable">' +
          '<div class="col s3 col m2">' +
          '<div class="flexCenter">' +
          '<img src="' + logo + '" class="responsive-img circle logo-style">' +
          '</div></div>' +
          '<div class="col s9 col m10"><h5 class="name">' + newStr + '</h5><p>' + message + '</p></div></div></a>';
        $("#closed").append(closedHTML);
    }; //end getInfoClosed
    
    //get info from stream (original json pull) if online and add to html
    
    function getInfoOnline(data) {
      name = data.stream.channel.display_name;
      logo = data.stream.channel.logo;
      game = data.stream.game;
      description = data.stream.channel.status;
      url = data.stream.channel.url;
      
      onlineHTML = '<a href="' + url + '" target="_blank">' +
          '<div class="row online z-depth-1 hoverable">' +
          '<div class="col s3 col m2">' +
          '<div class="flexCenter">' +
          '<img src="' + logo + '" class="responsive-img circle logo-style">' +
          '</div></div>' +
          '<div class="col s9 col m10"><h5 class="name">' + name + '</h5><p>' + game + ': ' + description + '</p></div></div></a>';
        $("#online").prepend(onlineHTML);
    }; //end getInfoOnline
  }; //end for/orignal getJSON
  
  //click functions for buttons
  $("#all").click(function() {
    $("#online").hide();
    $("#offline").hide();
    $("#closed").hide();
    $("#online").fadeIn(1300);
    $("#offline").fadeIn(1300);
    $("#closed").fadeIn(1300);
  });
  $("#online-button").click(function() {
    $("#online").hide();
    $("#offline").hide();
    $("#closed").hide();
    $("#online").fadeIn(1300);
  });
  $("#offline-button").click(function() {
    $("#online").hide();
    $("#offline").hide();
    $("#closed").hide();
    $("#offline").fadeIn(1300);
    $("#closed").fadeIn(1300);
  }); //end buttons
}); //end ready
              
            
!
999px

Console