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

              
                <div class="container">
<!--Header--><div class="row">
    <div class="col-sm-10 col-sm-offset-1 col-xs-12" style="margin-top:20px; margin-bottom:10px">
      <h2 style="text-align:center;">Browse through Tiwtch.tv</h2>
    </div>
  </div>
<!--Menu--><div class="row">
    <div class="col-sm-10 col-sm-offset-1 col-xs-12">
      <ul class="nav nav-pills nav-justified">
        <li class="active"><a data-toggle="pill" onClick="displayAll()">All</a></li>
        <li><a data-toggle="pill" onClick="displayOnline()">Online</a></li>
        <li><a data-toggle="pill" onClick="displayOffline()">Offline</a></li>
      </ul>
    </div>
  </div>
<!-- --><div class="row"><div class="col-xs-8 col-xs-offset-2 search">
  <input type="text" id="search" placeholder="Search..">
</div></div>
<!--Content--><div class="row">
    <div class="col-sm-10 col-sm-offset-1 col-xs-12">
      <div class="separator"></div>
      <div id="streamContent">
      </div>

    </div>
  </div>
</div>
              
            
!

CSS

              
                @media screen and (min-width: 769px) {
  .streamRow {display: -webkit-flex;display: flex;},
}
@media screen and (max-width: 769px) {
  .icon {margin-top:7px;}
}

body{
  font-family: 'Open Sans', sans-serif;
  background-color:#C2C25F;
  color:#873954;
}

h1,h2,h3,h4,h5,h6{font-family: 'Megrim', cursive;}
.separator {height:10px;}
.nav-pills>li.active>a, .nav-pills>li.active>a:focus, .nav-pills>li.active>a:hover {background-color:#873954}
.nav-pills>li>a:hover,.nav-pills>li>a:focus {background-color:#998593;color:white;}
.nav-pills>li>a{color:#87535C}

.search {
  padding:10px 0px 0px 0px;
  display: -webkit-flex;display: flex;
  align-items:center;justify-content:center;
}
#search {
  border-radius:7px;
    width: 30%;
    -webkit-transition: width 0.4s ease-in-out;
    transition: width 0.4s ease-in-out;
}
#search:focus {
    width: 80%;
}

.streamRow {
  border-radius:10px;
  border:0px;
  margin:10px auto 10px auto;
  padding:10px;
}
.streamCol {
  display: -webkit-flex;display: flex;
  align-items:center;
  font-size:20px;}

.usrn a {font-size:14px;color:white;font-family: 'Megrim', cursive;padding-left:4%}
.description a {color:white;font-size:14px;}
.icon {height:50px;width:auto;margin-right:10px;display:inline-block;}
a:hover, a {text-docoration:none;}

.off {
  background-color:#506967;
}

.on {
  background-color:#86B0AD;
}
              
            
!

JS

              
                var streamArr = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
  function displayAll() { $(".on,.off").show(); }
  function displayOnline() { $(".off").hide(); $(".on").show(); }
  function displayOffline() { $(".on").hide(); $(".off").show(); }
  $("#search").on("keyup", function(){
    var searchStr = $("#search").val().toLowerCase();
    if (searchStr!=="") {
      $(".streamRow").show();
      $("#streamContent").children().children().children(".usrn").each(function() {
        var userStr= $(this).text().toLowerCase();
        var usrnElement = this;
        if (userStr.indexOf(searchStr) == -1) {
          $(usrnElement).parent().parent().hide();
        } else {
          $(usrnElement).parent().parent().show();
        }
      });
    } else {$(".on,.off").show();}
  })
// Start getting data
$(document).ready(function() {
  getInfo();
});

function getInfo() {
  streamArr.forEach(function(channel) {
    var imgsrc;
    var usrn;
    var description;
    var linkUsr;
    var linkStream;
    var url;
    var status;

    function makeURL(type, name) {
      return 'https://api.twitch.tv/kraken/' + type + '/' + name + '?callback=?';
    };
    $.getJSON(makeURL("users", channel), function(data) {
      if (data.status == 404 || data.status == 422) { //if user not found or account closed
        description = cap(data.message);
        imgsrc = "http://placehold.it/100x100?text=?/";
        usrn = data.message.split("'")[1];
        linkUsr = "#";
        console.log("User function Check, dtat status = 404 or 422: usrn = " + usrn + "; description = " + description + "; linkUsr = " + linkUsr + "; imgsrc =" + imgsrc);
      } else {
        usrn = data.display_name;
        imgsrc = data.logo; //window.alert(imgsrc);
        linkUsr = "https://www.twitch.tv/" + data.name;
        console.log("User function Check, status being fine: usrn = " + usrn + "; linkUsr = " + linkUsr + "; imgsrc =" + imgsrc);
      }
      url = "https://api.twitch.tv/kraken/streams/" + data.name + "?callback=";
      $.getJSON(makeURL("streams", channel), function(data) {
        if (data.stream == null) {
          description = "Offline";
          linkStream = "#";
          status = "off";
          console.log("Stream function Check: usrn = " + usrn + "; description = " + description + "; linkUsr = " + linkUsr + "; imgsrc =" + imgsrc + "; linkStream =" + linkStream);
        } else {
          description = data.stream.channel.status;
          description.length > 40 ? description=description.slice(0,36)+"..." : "";
          linkStream = data.stream.channel.url;
          status = "on";
          console.log("Stream function Check: usrn = " + usrn + "; description = " + description + "; linkUsr = " + linkUsr + "; imgsrc =" + imgsrc + "; linkStream =" + linkStream);
        }
        var streamHTML = "<div class=\"row streamRow " + status + "\"><div class=\"col-xs-2 streamCol\"><img class=\"icon img-circle\" src=\"" + imgsrc + "\"></div><div class=\"col-xs-10 col-sm-4 streamCol\"><span class=\"usrn\"><a target=\"_blank\" href=\"" + linkUsr + "\">" + usrn + "</a></span></div><div class=\"col-xs-10 col-sm-6 streamCol\"><span class=\"description\"><a target=\"_blank\" href=\"" + linkStream + "\">" + description + "</a></span></div></div>"
        if (status=="off") {
          $("#streamContent").append(streamHTML);
        } else {
          $("#streamContent").prepend(streamHTML);
        }
      });
    });
  });
}

//function capitalise first letter
function cap(str) {
  var strSplit = str.split(" ");
  for (i = 0; i < strSplit.length; i++) { //i<array.length;
    strSplit[i] = strSplit[i].split("");
    strSplit[i][0] = strSplit[i][0].toUpperCase();
    strSplit[i] = strSplit[i].join("")
  }
  return strSplit.join(" ");
}
              
            
!
999px

Console