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="panel-default panel">
  <div class="panel-heading">
    <h1>Twitch Streamers</h1>
    
    <div class="pull-right">
      <form>
        <input type="text" name="searchChannel" id="searchChannel" placeholder="Search..."/>
      </form>
      <ul>
      <li id="showAll" class="btn-default activeBorder" title="Show All">All</li>
      <li id="showOnline" class="btn-success"><i class="glyphicon glyphicon-eye-open" title="Online"></i></li>
      <li id="showOffline" class="btn-warning"><i class="glyphicon glyphicon-eye-close" title="Offline"></i></li>
    </ul>      
  </div>
    </div>

  <div class="flex" id="displayBox">

  </div>
</div>
              
            
!

CSS

              
                *{
  overflow: auto;
  transition: all .25s ease-in-out;
}
body{
  margin: 2% auto auto auto;
  background: url("https://ak9.picdn.net/shutterstock/videos/16138189/thumb/1.jpg");
}
h1{
  margin: 0;
  float: left;
}
.panel-heading ul{
  list-style: none;
  margin: 0;
  padding: 0;
}
.panel-heading ul li{
  display: inline-block;
  height: 2em;
  width: 50px;
  text-align: center;
  line-height: 2em;
  font-size: 1.25em;
  cursor: pointer;
  border: 2px transparent solid;
  border-radius: 10px;
}
.panel-heading ul li.activeBorder{
  border: 2px #000 solid;
}
#displayBox{
  display: flex;
    flex-flow: row wrap;
    justify-content: space-around;
  min-height: 200px;

}
#displayBox img{
  border-radius: 50px;
  max-width: 50px;
}
#displayBox .channelBox{
  overflow: auto;
  margin: 5px auto;
  padding: 5px;
  height: 175px;
  width: 300px;
  float: left;
  box-sizing: content-box;
  margin: 5px;
}
#displayBox .channelBox img{
  margin: 2px 10px 2px 5px;
  float: left;
}
#displayBox .channelBox .banner{
  display: block;
  height: 100px;
  width: 100%;
  margin-bottom: 5px;
}
#displayBox .channelBox .status{
  text-transform: uppercase;
  margin-top: 5px;
  background-color: rgb(76, 174, 76);
  color: #fff;
  font-weight: bold;
}
form{
  float: left;
}
.gray{
  color: #999; 
}
              
            
!

JS

              
                var streams = [
  "ESL_SC2",
  "OgamingSC2",
  "cretetion",
  "freecodecamp",
  "storbeck",
  "habathcx",
  "RobotCaleb",
  "noobs2ninjas",
  "syntag",
  "playoverwatch",
  "sonicofficial",
  "kongregate",
  "japanese_restream",
  "riotgames"
];

function getChannelInfo(type, name) {
  return "https://wind-bow.glitch.me/twitch-api/" + type + "/" + name;
}

function loadDefault(list) {
        $('#displayBox').empty();

  
  list.forEach(function(channel) {
    var game, status;
    // determine whether or not the channel is streaming
    $.getJSON(getChannelInfo("streams", channel), function(streamData) {
      //console.log("Checking " + streamData.stream + " for " + channel);
      //console.debug(streamData.stream === null);
      if (streamData.stream === null) {
        game = "Offline";
        status = "warning";
      } else if (streamData.stream === undefined) {
        game = "Account Closed";
        status = "danger";
      } else {
        game = "Playing: <strong>"+streamData.stream.game+"</strong>";
        status = "success";
      }
      
      //console.log("Displaying "+ channel + " as "+ game);

      // display channel information
      $.getJSON(getChannelInfo("channels", channel), function(infoData) {
        
        var img = infoData.logo != null ? infoData.logo : "http://lorempixel.com/150/150/";
        var url = infoData.url;
        var banner = infoData.profile_banner != null ? infoData.profile_banner : "http://via.placeholder.com/300x100?text=:(";
        var followers = infoData.followers;
        var display_name = infoData.display_name != null ? infoData.display_name : channel;
        //console.log(infoData);

        $("#displayBox").append(
          showChannel(status, banner, channel, display_name, img, game, url)
        );
      });
    });
  });
}

function showChannel(status, banner, channel, display_name, img, game, url) {
  
    var channelBox = '<div class="panel animated fadeInUp channelBox"><div class="alert-'+status+'">' +
    '<a href="'+url+'" target="_blank">' +
    '<div class="banner" style="background: url(\''+banner+'\'); background-size: cover;"></div>'+
    '<div><img src="'+img+'" alt="'+channel +'">' +
    display_name + "<div class=\"small gray\">" +game + "</div>" +
    "</a></div>";
    if (status == "success")
      channelBox += '<div class="status small text-center">Online Now</div>';
    channelBox += "</div></div>"
  return (channelBox);
}

function makeActive(box){
     $('.panel-heading ul li').removeClass("activeBorder");
    $(box).addClass("activeBorder");
  }

$('#showAll').on('click', function(){
    $('.channelBox .alert-warning').parent().fadeIn();
    $('.channelBox .alert-success').parent().fadeIn();
   makeActive(this);
  });
  $('#showOnline').on('click', function(){
    $('.channelBox .alert-warning').parent().fadeOut();
    $('.channelBox .alert-success').parent().fadeIn();
     makeActive(this);
  });
  $('#showOffline').on('click', function(){
    $('.channelBox .alert-success').parent().fadeOut();
    $('.channelBox .alert-warning').parent().fadeIn();
     makeActive(this);
  });
  
  $("form").on('submit', function(){
    event.preventDefault();
  });
  
  // Thanks https://stackoverflow.com/a/35045402
  function debounce(fn, duration) {
  var timer;
  return function(){
    clearTimeout(timer);
    timer = setTimeout(fn, duration);
  }
}
  
  $('#searchChannel').on('keyup', debounce(function(){
    var term = $('#searchChannel').val();


    if (term.length > 0){
      // search through our users and re-load
      var results = "";
      results = streams.filter(function(s){
        return s.toLowerCase().indexOf(term.toLowerCase()) > -1;
      });
      console.log("Results: "+results);
      loadDefault(results);   
    } else {
      loadDefault(streams);
      $('#showAll').click();
    }
  }, 500));

$(function() {
  loadDefault(streams);
});

              
            
!
999px

Console