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>
  <nav class="navbar navbar-default" id="twitch_nav">
    <span class="navbar-brand glyphicon glyphicon-th" id="nav_text">
      <span id="brand_name">Twitch TV</span>
    </span>
  </nav>
  <div class="container">
    <div class="row search">
      <form class="navbar-form navbar-left" role="search">
        <div class="form-group">
          <input id="search_bar" type="text" class="form-control" placeholder="Ex: Search for 'a'" required="required">
        </div>
        <a id="search_button" type="" class="btn btn-default">Search</a>

      </form>      
    </div>
    <div class="row main">
      <h1 class="text-center" id="default_message">Search your favorite channels....</h1>
    </div>
  </div>
</body>
              
            
!

CSS

              
                .body {
  font-family: roboto;
}

#brand_name
{
  font-family:mono;
}
.channel {
  height: 300px;
  margin: 0px;
  border: 1px solid grey;
  margin: 30px;
  padding: 0px;
}

.channel-viewers {
  color: white;
  padding-top: 5px;
  font-weight: 300;
  padding-left: 10px;
  background-color: rgba(1, 1, 1, 0.6)
}

.channel-button {
  border-radius: 100px;
  width: 100px;
  margin-left: 10px;
  background-color: #16a085;
}

.channel-button:hover {
  color: white;
  background-color: #f1c40f;
  border: 2px solid black;
}

.channel-button-div {
  margin-top: 50%;
}

#twitch_nav {
  background-color: #16a085;
}

#nav_text {
  color: white;
}

.channel-title {
  font-size: 24px;
  font-weight: 300;
  width: 100%;
  height: 70px;
  background-color: rgba(1, 1, 1, 0.6);
  padding-left: 15px;
  color: white;
}

#search_button {
  border-radius: 100px;
  border: none;
  background-color: #16a085;
  color: white;
}

#search_bar
{
  border-radius:100px;
  width:200px;
}

#default_message
{
  color:grey;
  font-weight:100;
  padding-top:100px;
}

#tool_tip
{
  background-color:#16a085;
  font-family:roboto;
}
              
            
!

JS

              
                $(document).ready(function() {
  $.getJSON('https://api.twitch.tv/kraken/streams?callback=?', function(data) {
    $("#search_button").click(function() {
      var text = $("#search_bar").val();
      if (text !== "") {
        $(".channel").remove();
        $("#default_message").hide();
        display(data, text);
      }
    });
  });

  // display function
  function display(data, text) {

    var id, id2;
    var heading;
    var viewers;
    var timestamp;
    var video_height;
    var video_banner;
    var video_url;
    var ct = 1;
    for (channel in data.streams) {
      id = "box_" + ct
      id2 = "button_" + ct;
      heading = data.streams[channel].game;
      viewers = data.streams[channel].viewers;
      timestamp = data.streams[channel].created_at;
      video_height = data.streams[channel].video_height;
      video_banner = data.streams[channel].channel.logo;
      video_url = data.streams[channel].channel.url;
      var str1 = heading.toLowerCase();
      var str2 = text.toLowerCase();
      console.log(str1);
      if (str1.indexOf(str2) !== -1) {
        console.log(video_url);
        createBox(id);
        //console.log(id2);
        writeHeadingInfo(id, heading);
        writeViewers(id, viewers);
        boxBG(id, video_banner);
        createButtonBox(id, id2, video_url);
        ct++;
      }
    }
    if (ct===1){
      $("#default_message").text("Sorry no results found...");
      $("#default_message").show();
    }

    // write geek stuff

  }

  // function creating a box
  function createBox(id) {
    html = "<div class='col-lg-3 channel'";
    html += ' id=' + '"' + id + '"';
    html += "></div>"
    $('.main').append(html);
  }

  //Writing basic info
  function writeHeadingInfo(id, heading) {
    html = "<div class='channel-title'>";
    html += heading;
    html += '</div>';
    var id = "#" + id;
    //console.log(id)
    $(id).append(html);
  }

  //Writing viewers
  function writeViewers(id, viewers) {
    var id = "#" + id;
    html = "<div class='channel-viewers'>";
    html += "<span class='glyphicon glyphicon-user'></span>";
    html += viewers;
    html += "</div>";
    $(id).append(html);
  }

  //Box BG
  function boxBG(id, banner) {
    var id = "#" + id;
    var imagePath = "url(";
    imagePath += banner;
    imagePath += ")";
    $(id).css("background-image", imagePath);

  }

  //function buttonbox
  function createButtonBox(id0, id, link) {
    var id0 = "#" + id0;
    var id = "#" + id;
    var html;
    html = '<div class="channel-button-div">'
    html += "<a class='btn btn-primary channel-button' href=";
    html += '"' + link + '"';
    html += ' target="_blank">';
    html += 'Visit</a>';
    html += '</div>'
      //console.log(html);
    $(id0).append(html);

  }

});
              
            
!
999px

Console