css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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 id="title" class="container">
      <!--twitch logo-->
      <h1>Twitch Streamers</h1>
      <!--search box eventually??-->
      <button>All</button>
      <button>Online</button>
      <button>Offline</button>
    </div>
    <div id="streamers" class="container">
    </div>
    <div id="empty" class="container">
    </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>
</footer>
            
          
!
            
              body {
  background-color: #F1FFE7;
}

#streamers {
  width: 100%;
  max-width: 50em;
}

.offline,
.closed,
.online {
  border: .1em solid black;
}

.offline {
  background-color: #383B53;
  color: white;
  display: flex;
}

.closed {
  background-color: #BAA7B0;
}

.online {
  background-color: #A7D49B;
}

.name {
  font-size: 1.3em;
}

.logo-style {
  width: 4.5em;
  height: 4.5em;
  border-radius: 50%;
  margin: 0 auto;
}

.center {
  text-align: center;
}

.flexCenter {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
            
          
!
            
              $(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;

  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);
        }
      });

    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">' +
          '<div class="col s3 col m2">' +
          '<div class="flexCenter">' +
          '<img src="' + logo + '" class="logo-style">' +
          '</div></div>' +
          '<div class="col s9 col m10"><p class="name">' + name + '</p><p>' + game + '</p></div></div></a>';
        $("#streamers").append(offlineHTML);

      });

    };

    function getInfoClosed(data) {
      message = data.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"><div class="col s3 col m2"><img src="' + logo + '" class="logo-style"></div><div class="col s9 m10"><p class="name">' + newStr + '</p><p>' + message + '</p></div>';
      $("#streamers").append(closedHTML);

    };

    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"><div class="col s3 m2 center"><img src="' + logo + '" class="logo-style"></div><div class="col s9 m10"><p class="name">' + name + '</p><p>' + game + ': ' + description + '</p></div></a>';
      $("#streamers").prepend(onlineHTML);

    };
  };
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console