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>

    <section class="head">
      <div class="container">
        <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Twitch_logo_%28wordmark_only%29.svg/2000px-Twitch_logo_%28wordmark_only%29.svg.png" alt="twitch_logo" class="twitch_log img-responsive">
          <div>
            <form>
              <!--<input type="text" placeholder="Search..." class="form-control"  id="search-user"> -->
            </form>
          </div>
          <div class="buttons">
          <span>
            <button class="btn btn-success online-btn">Online</button>
            <button class="btn btn-primary all-btn">ALL</button>
            <button class="btn btn-danger offline-btn">Offline</button>
          </span>
        </div>
      </div>
    </section>

        <section class="container">
          <div class="card-deck row">



          </div>
        </section>

      <!--  <div class="test"></div> -->

  </body>

              
            
!

CSS

              
                body{
  padding: 0;
  margin: 0;
}

.head{
  /*background: url('img/science.png') center center no-repeat;*/
  background-color: rgba(0, 0, 0, 0.8);
  background-size: cover;
  height:  300px;
  width: 100%;
  text-align: center;
  margin-bottom: 2%;
}

.twitch_log{
  margin-top: 40px;
}

.head-form{
  text-align: center;
  margin: 14px auto;
}

form{
  margin: 20px auto;
  width: 300px;
  text-align: center;
}

.head img{
  height: 100px;
  width: 300px;
}

.buttons span button{
  margin: 0 10px;
}

.card-footer{
  display: inline;
}

.card{
  margin: 2%;
  padding: 0;
}

.fa-bolt{
  float: right;
  margin-top: 8px;
  color: #07EA25;
}

.fa-exclamation{
  float: right;
  margin-top: 8px;
  color: #F90000;
}

/*
box-shadow:
    0 0 4px 1px #fff,   inner white
    0 0 6px 3px #07EA25,  middle magenta
    0 0 12px 6px #A8F7B2;  outer cyan
.test {
    margin-left: 100px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow:
        0 0 30px 15px #fff,   inner white
        0 0 50px 30px #07EA25,  //middle magenta
        0 0 70px 45px #A8F7B2;  //outer cyan
}
*/

              
            
!

JS

              
                
$(document).ready(function(){

  //global decleration
  var html = "";
  //user names

  var userArr = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "annbmateo", "habathcx", "RobotCaleb", "noobs2ninjas", "blackmagealodia"];

  //function to loop thru the userArr
  function userLoop(users) {
    for(var i=0; i<users.length; i++) {
      userDataAndStatus(users[i]);
    }
  };
  userLoop(userArr);

  /////////////////////////////////////////////////////////////////////////////////////////

  //first we created a function for our nested JSON call
  //second created a condition to check if the user is online or offline
  //third passing the variable status to the html as a class either offline or online
    function userDataAndStatus(users) {
    $.getJSON('https://wind-bow.glitch.me/twitch-api/channels/'+ users, function(userData) {
        $.getJSON('https://wind-bow.glitch.me/twitch-api/streams/'+ users,function(userStatus) {
          var status = "";
          var statIcon;
          //console.log(users +' '+ userStatus.stream);
          if(userStatus.stream === null) {
            status = 'offline';
            statIcon = "<i class='fa fa-exclamation fa-lg'></i>";
          }else if(userStatus.stream !== null) {
            status = 'online';
            statIcon = "<i class='fa fa-bolt fa-lg'></i>";
          }

          html += "<div class='card col-md-4" +' '+ status + "'> <img class='card-img-top' src=" + userData.logo + ">";
          html += "<div class='card-block'> <h5 class='card-title'><i class='fa fa-user fa-lg'></i>" +' '+ userData.display_name + "</h5>";
          html += "<p class='card-text'><i class='fa fa-bullhorn fa-lg'></i>" +' '+ userData.status + "</p><h6><i class='fa fa-gamepad fa-lg'></i>"+' '+ userData.game + "</h6></div>";
          html += "<div class='card-footer'><small class='text-muted'> <a href="+ userData.url + " target='_blank'> <i class='fa fa-external-link fa-2x'></i></a></small>"+ statIcon +"</div></div>";

          $('.card-deck').html(html);
        })
      })
    };

  ////////////////////////////////////////////////////////////////////////////////////////

      //event click to return offline users
       $('.offline-btn').on('click', function() {
         $('.offline').show();
         $('.online').hide();
       });

     //////////////////////////////////////////////////////////////////////////////////////////////////////////

     //event click to return online users
     $('.online-btn').on('click', function() {
       $('.offline').hide();
       $('.online').show();
     });

     //////////////////////////////////////////////////////////////////////////////////////////////////////

      //return all users
      $('.all-btn').on('click', function() {
        $('.offline').show();
        $('.online').show();
      });

      //event to submit the value of the input to get the user
      //working but isnt on the user story challenge
      $('form').on('submit', function(e) {
        e.preventDefault();
        var user = $('#search-user').val();
      });

      /*
      var test=[];
      //event to live search. still not working.
      $('#search-user').keyup(function() {
        var searchUser = $('#search-user').val();
        var expression = new RegExp(searchUser,'i');
          for(var i=0; i<userArr.length; i++){
            test.push(userArr[i].search(expression));
          }
        })

        console.log(test);

        //shit solution
        $('#search-user').keyup(function() {
          var searchUser = $('#search-user').val();
          userDataAndStatus(searchUser);
        })

        $('#search-user').on('keyup',function() {
           var test=[];
           var searchUser = $('#search-user').val();
           var expression = new RegExp(searchUser,'i');
             for(var i=0; i<userArr.length; i++){
               if(userArr[i].search(expression) != -1)
                 test.push(userArr[i]);
             }
             userDataAndStatus(test);
           console.log(test);
           /*$.getJSON('https://wind-bow.glitch.me/twitch-api/channels/'+ test, function(data){
             if(data.status >= '400' || data.status <= '404'){
               console.log(data.status)
               $('.card-deck').html("");
             }else{

               $('.card-deck').html( "<div class='card col-md-4" +' '+ status + "'> <img class='card-img-top' src=" + data.logo + ">"
                + "<div class='card-block'> <h5 class='card-title'><i class='fa fa-user fa-lg'></i>" +' '+ data.display_name + "</h5>"
                + "<p class='card-text'><i class='fa fa-bullhorn fa-lg'></i>" +' '+ data.status + "</p><h6><i class='fa fa-gamepad fa-lg'></i>"+' '+ data.game + "</h6></div>"
                + "<div class='card-footer'><small class='text-muted'> <a href="+ data.url + " target='_blank'> <i class='fa fa-external-link fa-2x'></i></a></small>"+ 'statIcon' +"</div></div>");


             }
           })
       });*/

});
              
            
!
999px

Console