123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>twitch<span>.tv</span></h1>
<div class='container'>
  <div class='row' id='row'>
     <div class="col-xs-12 user" id="user">
       <div class="btn-group btn-group-justified">
         <div class="btn-group buttons" role='group'>
          <button class="btn btn-primary">All</button>
         </div>
         <div class="btn-group buttons" role='group'>
          <button class="btn btn-success">Online</button>
         </div>
         <div class="btn-group buttons" role='group'>
          <button class ='btn btn-danger'>Offline</button>
         </div>
       </div>
       <div class="input-group" id="input-group">
         <input type="text" class="form-control" id="input">
         <i class="fa fa-search fa-2x" aria-hidden="true"></i>
        </div>
       </div>
    </div>
  </div>
</div>
  
  
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Bungee+Inline');


body {
  background-color: #2ecc71;
  margin: none;
  padding: none;
  background-image: url('https://dl.dropbox.com/s/pxviil1svbvdz8g/congruent_pentagon.png?dl=0');
}

h1 {
  font-family: 'Bungee Inline', cursive;
  font-size: 600%;
  color: #34495e;
  text-align: center;
  margin: 3% 0 2% 0;
}

h1 span {
  color: #8e44ad;
}

.container { /* The main content section of the page */
  background-color: #34495e;
  background-image: url('https://dl.dropbox.com/s/6uwubavc6ukxv1i/congruent_outline.png?dl=0');
  color: white;
  text-align: center;
  margin: 20px auto;
  max-width: 360px;
  padding-bottom: 9px;
  border-radius: 10px;
-webkit-box-shadow: inset 0px 0px 20px 4px rgba(140,142,148,1);
-moz-box-shadow: inset 0px 0px 20px 4px rgba(140,142,148,1);
box-shadow: inset 0px 0px 20px 4px rgba(140,142,148,1), 0px 0px 23px 4px rgba(89,150,47,.6);
}

.btn-group-justified {
  margin: 20px 0 14px 0;
}

#input-group {  /*Input group and input refer to the search box*/
  width: 100%;
  margin-bottom: 14px;
  border-radius: 5px;
}

#input {
  border-radius: 5px;
  position: relative;
  z-index: 0;
}

.fa-search { /* Font-awesome magnifying glass icon */
  z-index: 1;
  color: gray;
  position: absolute;
  right: 15px;
  top: 1px;
}

a { /* There is one <a> with a <div> inside for each streamer */
  color: white;
  text-decoration: none;
}

a:hover, a:visited {
  color: white;
  text-decoration: none;
}

img { /* logos */
  width: 20%;
  border-radius: 25%;
  margin: 12px 0px 10px 15px;
}

.streamer {
  margin: 4px 0px;
  border-radius: 5px;
  -webkit-box-shadow: inset 0px 0px 2px 4px rgba(100,208,224,1);
-moz-box-shadow: inset 0px 0px 2px 4px rgba(100,208,224,1);
box-shadow: inset 0px 0px 10px 4px rgba(100,208,224,1);
}

.streamer:hover {
  background-color: rgba(44, 62, 80, 0.5);
}

.green {
  color: #2ecc71;
}

.red {
  color: #e74c3c;
}

#info {
  color: yellow;
}

@media only screen and (max-width : 360px) {
  h1 {
    font-size: 4.4em;
  }
}
            
          
!
            
              //Possible features to add:
// - Sort search results by...(whatever)
// - Add/Remove streamers
// - Default sort alphabetically


var getStreams = function () { // This function gets called at the bottom of the script when the window loads
  
  $('div.streamer').remove();
  
  var userArray = ['chu8','freecodecamp', 'Giantwaffle', 'riotgames','ESL_SC2', 'comster404', 'followgrubby'];
  var url1 = 'https://wind-bow.gomix.me/twitch-api/';
  var url2 = '?callback=?';
  
  //Probably should have used a regular for loop for better performance
  userArray.forEach(function(user) { 
    $.getJSON(url1 + 'channels/' + user + url2, function(response) {
      
      console.log(response);

        var name = response.display_name; //Streamer's name
        var logo = '<img class="pull-left" src="' + response.logo + '"><br>'; //Streamer's logo
        var mode = '<p id="' + user + '"></p><br>'; //Online or Offline. Set later with the # + user jquery.
        var info = '<p id="info">' + response.status + '</p>'; //Extra info about what's streaming.
      
        $('.user').append('<a href="https://twitch.tv/' + name + '" target="_blank"><div id="' + user + '" class="row streamer">' + logo + '<b>' + name + '</b>' + mode + '</div></a>'); //Add a div for each user
      
        if (response.status == 404) {
            $('div#'+ user).empty();
            $('div#'+ user).append('<img class="pull-left" src="https://dl.dropbox.com/s/9kdu8gba6stadxi/nope.jpg?dl=0"><br>');
            $('div#'+ user).append('<b>' + response.message + '</b>');
            $('div#'+ user).addClass('404');
          }
      
        $.getJSON(url1 + "streams/" + user + url2, function (responseText) {
          
          if(responseText.stream !== null && responseText.status !== 404) {
            $('p#'+ user).text('Streaming Now!').addClass('green');
            $('p#'+ user).append(info);
          } else {
            $('p#'+ user).text('Offline').addClass('red');
          }//if-else
        });//Second API call
    });//First API call
  });//userArray.forEach
};//getStreams

$('.btn-success').on('click', function() {
  $('.red').parent().css('display', 'none');
  $('.404').parent().css('display', 'none');
  $('.green').parent().css('display', '');  
});

$('.btn-danger').on('click', function() {
  $('.green').parent().css('display', 'none');
  $('.404').parent().css('display', '');
  $('.red').parent().css('display', '');  
});

$('.btn-primary').on('click', function() {
  getStreams();
  $('.red').parent().css('display', '');
  $('.green').parent().css('display', '');
  $('.404').parent().css('display', '');
});

window.onload = getStreams();

$(document).ready(function() {
  
  $('#input').keyup(function() {
    
    var searchText = $(this).val();
    
    $('div.streamer').each(function() {
      if ($(this).text().search(new RegExp(searchText, "i")) < 0) {
          $(this).fadeOut();
      } else {
          $(this).show();
      }//if-else
    });//#streamer.each    
  });//#input.keyup
});//document.ready
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console