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">


  <h1 id="heading">TwitchTV</h1>

  <div class="button-container">
    <button type="button" class="btn btn-default all">All</button>
    <button type="button" class="btn btn-primary offline">Offline</button>
    <button type="button" class="btn btn-success online">Online</button>
  </div>

  <div class="input-group">
    <span class="input-group-addon" id="sizing-addon2"><span class="glyphicon glyphicon-search"></span></span>
    <input type="text" class="form-control" placeholder="Username (type with lower case)" aria-describedby="sizing-addon2">
  </div>

  <div class="row">

  </div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Roboto');
@import url('https://fonts.googleapis.com/css?family=Abril+Fatface');
* {
  margin: 0px;
  padding: 0px;
}

.hidden {
  visibility: hidden;
}

.button-container {
  max-width: 600px;
  margin: 0 auto;
  margin-bottom: 50px;
}

button {
  width: 32.333333%;
  display: inline-block;
}

.container-fluid {
  width: 100%;
  margin: 0 auto;
  margin-bottom: 50px;
}

body {
  background-image: url("https://i.ytimg.com/vi/1qN8l6WoZQI/maxresdefault.jpg");
  background-repeat: no-repeat;
  background-size: cover;
}

#heading {
  margin-top: 50px;
  margin-bottom: 50px;
  text-align: center;
  font-family='Abril+Fatface'
}

.wrapper {
  border-radius: 10px;
  width: 300px;
  height: 200px;
  background-color: #ecfdff;
  margin: 0 auto;
  margin-top: 10px;
  box-shadow: 2px 2px 2px #757575;
  transition: box-shadow 1s;
}

.wrapper:hover {
  box-shadow: 4px 4px 4px #757575;
}

.col-md-3 {
  margin-bottom: 20px;
}

.image {
  position: relative;
  left: 5px;
  top: 5px;
  width: 100px;
  display: inline-block;
}

.image img {
  width: 100%;
}

.name {
  width: 150px;
  display: inline-block;
}

.name p {
  text-align: center;
  font-size: 18px;
  color: #010101;
  opacity: 0.6;
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
}

.status {
  width: 100%;
  height: 30px;
  margin-top: 20px;
}

.status p {
  text-align: center;
  font-size: 14px;
}

#colorNameOff {
  color: #5E35B1;
}

#colorNameOn {
  color: #827717;
}


              
            
!

JS

              
                $(document).ready(function() {
  var URL = "https://api.twitch.tv/kraken";
  var client_ID = "6q7bm79kl2oceoui1dgtvsr59vkezl9";

  var users = [
    "ThatBronzeGirl",
    "Cowsep",
    "nl_Kripp",
    "Lump",
    "vroksnak",
    "dendi",
    "ppd",
    "arteezy",
    "sing_sing",
    "universedota",
    "zai",
    "miracle_doto",
    "freecodecamp",
    "MedryBW"
  ];

  function action_function() {
    users.forEach(function(user) {
      var status;
      var streamURL = URL + '/streams/' + user + '?client_id=' + client_ID + '&callback=?';
      var userURL = URL + '/channels/' + user + '?client_id=' + client_ID + '&callback=?';
      $.getJSON(userURL).done(function(data) {
          //console.log(data);
          var logo = data.logo;
          var userURL = data.url;
          //console.log(userURL);
          //console.log(logo);
          var name = data.display_name;
          //console.log(name);
          //console.log(status);
          $.getJSON(streamURL).done(function(data2) {
            //console.log(data2);
            if (data2.stream == null) {
              status = '<strong id = "colorNameOff" data-status="Offline" class="offline-user">' + name + '</strong>' + " is offline";
              //console.log(data2);
              // click the button with "offline" class
              $('.offline').click(function() {
                //add class "hidden" to parent div of "online-user"
                $(".online-user").parent().parent().parent().parent().addClass("hidden");
                $(".offline-user").parent().parent().parent().parent().removeClass("hidden");
              })
            } else {
              status = '<strong id = "colorNameOn" data-status="Online" class="online-user">' + data.status + '</strong>';
              $('.online').click(function() {
                $(".offline-user").parent().parent().parent().parent().addClass("hidden");
                $(".online-user").parent().parent().parent().parent().removeClass("hidden");
              })

              $('.btn-default').click(function() {
                $(".online-user").parent().parent().parent().parent().removeClass("hidden");
                $(".offline-user").parent().parent().parent().parent().removeClass("hidden");
              })

              //console.log(status);
            }
            //console.log(data2);
            var result = builder(logo, name, status, userURL);
            $(".row").append(result);

            // search function

          }); // streamURL

        }) // userURL

    }); // forEach

  } // action_function

  function builder(logo, name, status, userURL) {
    return '<div class="col-md-3">' +
      '<div id="' + name.toLowerCase() + '" class="wrapper user">' +
      '<div class="image">' + '<img src="' + logo + '">' + '</div>' +
      '<div class="name">' +
      '<p class="grab-name">' + '<a href="' + userURL + '" target="_blank" >' + name + '</a>' + '</p>' +
      '</div>' +
      '<div class="status">' +
      '<p>' + status + '</p>' +
      '</div>'
    '</div>' +
    '</div>'
  }

  $(".form-control").on("input", function() {
    var searchItem = $(this).val();
    $(".user").each(function() {
      var userId = $(this).attr("id");
      if (userId.indexOf(searchItem) === -1) {
        $(this).parent().hide();
      } else {
        $(this).parent().show();
      }

    });
    console.log(userId);
    console.log(searchItem);
  });

  action_function();

});
              
            
!
999px

Console