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

              
                body
  table(id="main-table", title="Twitch Streamers")
    th Twitch Streamers Status!
    tr
      td.firstRow
        .cell.firstCell#all All
        .cell.active#online Online
        .cell.inactive#offline Offline
  
              
            
!

CSS

              
                body {
  background-color: #d8e0e3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
#main-table {
  width: 50%;
  border: solid;
  margin: 50px 0 50px;
  border-bottom: 0;
  border-collapse: collapse;
}
th {
  padding: 30px;
  font-family: "Viga", sans-serif;
  font-size: 3em;
  background-color: #8366b6;
}
td {
  border-bottom: solid;
  padding: 20px;
  font-family: "Montserrat Alternates", sans-serif;
  display: block;
}

img {
  height: 40px;
  width: 40px;
  vertical-align: middle;
  margin-right: 15px;
  border-radius: 0.5em;
  border: 0.1em solid black;
}
a {
  display: inline;
  text-decoration: none;
  color: black;
  line-height: 45px;
}
.active {
  background-color: #82d488;
}
.inactive {
  background-color: #c95f5f;
}
.unresponsive {
  background-color: #dbe1ae;
  line-height: 45px;
}

.firstRow {
  display: table;
  text-align: center;
  width: 100%;
  table-layout: fixed;
  border-top: solid;
}

.cell {
  cursor: pointer;
  display: table-cell;
  line-height: 45px;
}

.firstCell {
  background-color: #8366b6;
}


              
            
!

JS

              
                $(document).ready(function() {
  $("#main-table").append(
    '<tr id="activeStreamers"></tr>' +
      '<tr id="inactiveStreamers"></tr>' +
      '<tr id="unresponsiveStreamers"></tr>'
  );

  var streamers = [
    "wargodyasa",
    "OgamingSC2",
    "cretetion",
    "freecodecamp",
    "storbeck",
    "habathcx",
    "RobotCaleb",
    "noobs2ninjas",
    "brunofin",
    "comster404"
  ];
  
  streamers.forEach(function(select) {
    var user = select;
    $.ajax({
      type: "GET",
      url: "https://api.twitch.tv/kraken/streams/" + user,
      format: "json",
      headers: {
        "Client-ID": "qpyxap0u7muu6ci4xfjdsuf3avbxr0v"
      },
      success: function(data) {
        var online = data["stream"];
        if (online === null) {
          var channelInfo = data["_links"]["channel"];
          $.ajax({
            type: "GET",
            url: channelInfo,
            headers: {
              "Client-ID": "qpyxap0u7muu6ci4xfjdsuf3avbxr0v"
            },
            success: function(data) {
              var url = data["url"];
              var user = data["display_name"];
              var logo = data["logo"];
              if (logo === null) {
                logo =
                  "https://pbs.twimg.com/profile_images/509073338191183872/fYdty6yd.png";
              }
              var status = data["updated_at"];
              $("#inactiveStreamers").append(
                '<td class="inactive"><a href="' +
                  url +
                  '" target="_blank"><img src="' +
                  logo +
                  '">The user ' +
                  user +
                  " is currently offline.</a></td>"
              );
            },
            error: function(data) {
              var user = data["responseJSON"]["message"];
              $("#unresponsiveStreamers").append(
                '<td class="unresponsive"><img src="https://pbs.twimg.com/profile_images/509073338191183872/fYdty6yd.png">' +
                  user.replace('"', "").replace('"', "") +
                  "." +
                  "</td>"
              );
            }
          });
        } else {
          var logo = data["stream"]["channel"]["logo"];
          var channel = data["stream"]["channel"]["url"];
          var user = data["stream"]["channel"]["display_name"];
          var game = data["stream"]["channel"]["game"];
          $("#activeStreamers").append(
            '<td class="active"><a href="' +
              channel +
              '" target="_blank"><img src="' +
              logo +
              '">The user ' +
              user +
              " is currently streaming the game " +
              game +
              "!</a></td>"
          );
        }
      }
    });
  });
});

$(".cell").on("click", function(event) {
  var input = this.id;

  if (input === "online") {
    $(".inactive").hide();
    $(".active").show();
    $("#online").hide();
    $("#offline").show();
    $(".unresponsive").hide();
  } else if (input === "offline") {
    $(".active").hide();
    $(".inactive").show();
    $("#online").show();
    $("#offline").hide();
    $(".unresponsive").hide();
  } else if (input === "all") {
    $(".active").show();
    $(".inactive").show();
    $(".unresponsive").show();
  }
});

              
            
!
999px

Console