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

              
                <!--
TODO:

Display past videos below live stream √

Set default images√

-->
<html>

<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body>

  <div id="searchResult">
    <section class="searchInput">
      <input type="text" id="searchTerm">
    </section>
    <ul id="resultUl">
      <li><i class="fa fa-star"></i>esl_csgo</li>
      <li><i class="fa fa-star"></i>OgamingSC2</li>
      <li><i class="fa fa-star"></i>noobs2ninjas</li>
      <li><i class="fa fa-star"></i>RobotCaleb</li>
      <li><i class="fa fa-star"></i>freecodecamp</li>
      <section id="toClear">
      </section>
    </ul>
  </div>

  <!--   <section class="userSearch">

    <input list="users" type="text" id="search" placeholder="username">
    <datalist id="users">
    <option value="OgamingSC2">
    <option value="cretetion">
    <option value="esl_csgo">
    <option value="habathcx">
    <option value="RobotCaleb">
    <option value="noobs2ninjas">
    <option value="freecodecamp">    
  </datalist>
    <button id="searchBtn"><i class="fa fa-search"></i></button>
  </section>
 -->
  <button type="button" class="searchBtn" id="searchBtn"><i class="fa fa-search"></i></button>

  <div class="header" id="header">
    <div class="overlay"></div>
  </div>

  <div class="logo" id="logo"></div>

  <section class="top">
    <div class="stream" id="stream"></div>
    <div class="totalViews" id="totalViews"></div>
    <div class="followers" id="followers"></div>
  </section>
  <div class="status" id="status"></div>

  <div class="bio" id="bio"></div>
  <div class="vid" id="vid"></div>
  <div class="streamInfo" id="streamInfo">
    <div id="title"></div>
    <div id="viewers"></div>
  </div>

  <section class="vidInformation">
    <span class="pastVids" id="pastVids">Recorded Videos</span><span class="vidCnt" id="vidCnt"></span>
  </section>

  <div class="hide">
    <div class="videos" id="videos"></div>
  </div>

  <section class="vidInformation">
    <span class="following" id="following">Following </span><span class="followCnt" id="followCnt"></span>
  </section>

  <div class="follows" id="follows"></div>

</body>

</html>
              
            
!

CSS

              
                html,
body {
  padding: 0;
  margin: 0;
  background: #fff;
  font-family: "Open Sans";
}

.searchBtn {
  position: absolute;
  height: 35px;
  width: 35px;
  right: 10px;
  top: 10px;
  border: none;
  border-radius: 50%;
  opacity: 0.4;
  transition: all 0.3s;
}

.searchBtn:hover {
  opacity: 1;
}

#searchResult {
  position: fixed;
  margin-top: 50px;
  margin-left: auto;
  margin-right: auto;
  background: #fff;
  height: 90%;
  width: 55%;
  left: 0;
  right: 0;
  z-index: 999;
  overflow-y: auto;
  box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.2);
  display: none;
  .searchInput {
    display: flex;
    justify-content: center;
    padding: 10px;
    background: #333;
    input {
      border: none;
      height: 25px;
      border-radius: 5px;
      background: rgba(255, 255, 255, 0.2);
      color: #fff;
      text-indent: 15px;
      font-size: 16px;
    }
  }
}

#searchResult::-webkit-scrollbar {
  background-color: #fff;
  width: 10px;
}

#searchResult::-webkit-scrollbar-thumb {
  background-color: #5C5C5C;
}

#searchResult::-webkit-scrollbar-track {
  background-color: #fff;
}

#resultUl {
  margin: 0;
  padding: 0;
}

#resultUl li {
  list-style-type: none;
  padding: 10px;
  margin: 2px;
  background: #fcfcfc;
  color: #888;
  .fa {
    padding-right: 5px;
  }
}

#resultUl li:hover {
  cursor: pointer;
}

// .userSearch {
//   position: absolute;
//   display: flex;
//   right: 10px;
//   top: 10px;
//   opacity: 0.4;
//   transition: all 0.3s;
//   button {
//     height: 27px;
//     border: none;
//     color: #fff;
//     border-radius: 0 20px 20px 0;
//     background: #ccc;
//   }
//   input {
//     border: none;
//     height: 25px;
//     border-radius: 20px 0 0 20px;
//     text-indent: 10px;
//     background: #fff;
//   }
// }
// .userSearch:hover {
//   opacity: 1;
// }
.header {
  height: 170px;
  width: 100%;
  display: flex;
  align-items: center;
  background: #ccc;
  background-size: cover;
  background-position: center center;
}

.overlay {
  height: 100%;
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
}

.logo {
  display: flex;
  align-items: center;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.9);
  img {
    height: 75px;
    border-radius: 50%;
    margin: 0 10px;
    position: absolute;
    top: 125px;
  }
  p {
    position: absolute;
    top: 105px;
    left: 95px;
  }
  a {
    text-decoration: none;
    color: #fff;
  }
}

.sections {
  position: relative;
  margin: 0 auto;
  width: 65%;
}

.top {
  width: 65%;
  margin: 0 auto;
  margin-top: 50px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  font-weight: bold;
  color: #888;
}

.bio,
.status {
  @extend .sections;
  position: relative;
  margin: 40px auto;
  .fa {
    color: #888;
    font-size: 12px;
    position: relative;
    top: -5px;
  }
}

.vid {
  @extend .sections;
  margin-top: 40px;
  margin-bottom: 5px;
}

.streamInfo {
  @extend .sections;
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  color: #888;
  font-weight: bold;
  .fa {
    color: #888;
    font-size: 16px;
    position: relative;
  }
}

#viewers {
  display: flex;
  align-items: center;
}

.vid {
  display: flex;
  justify-content: center;
  background: black;
  height: auto;
}

.stream {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  .fa {
    font-size: 12px;
    padding-right: 5px;
  }
}

.green {
  color: green;
}

.videos {
  @extend .sections;
  display: flex;
  flex-direction: column;
  img {
    height: 75px;
    margin: 10px 10px 0 0;
  }
  section {
    display: flex;
    align-items: center;
  }
}

// .hide {
//   display: none;
// }
.vidInformation {
  display: flex;
  justify-content: center;
  a {
    text-decoration: underline;
    color: #888;
  }
}

.pastVids,
.vidCnt,
.following,
.followCnt {
  position: relative;
  font-size: 22px;
  font-weight: bold;
  color: #888;
  margin: 100px 5px 50px 5px;
}

.follows {
  @extend .sections;
  margin-bottom: 50px;
  img {
    height: 65px;
    border-radius: 50%;
    margin: 5px;
  }
}

@media only screen and (max-width: 768px) {
  .top {
    width: 90%;
    flex-direction: column;
    div {
      padding: 10px 0;
    }
  }
  .sections {
    width: 90%;
  }
  #searchResult {
    width: 95%;
  }
}
              
            
!

JS

              
                $(document).ready(function() {
  
  

  /*
   * Default Profile Image
   */

  var profileImg = 'https://myspace.com/common/images/user.png';
  
  

  /*
   * Search Button Click Function
   */
  
  $('#searchBtn').on('click', function(){
    
 $('#toClear').empty();
    $('#searchTerm').val('');
    $('#searchResult').toggle('slide', {direction: 'left'}, 500);

  });

  $(document).on('click', function (e) {
    if($(e.target).closest("#searchResult").length === 0 && !$(e.target).closest("#searchBtn").is('#searchBtn')) {
        $("#searchResult").hide('slide', {direction: 'left'}, 500);
    }
});

  /*
   * FreeCodeCamp onLoad Information
   */

  $('#vid').html('<iframe src="https://player.twitch.tv/?channel=freecodecamp&autoplay=true&muted=true" frameborder="0" scrolling="no" height="378" width="620" allowfullscreen="true"></iframe>');
  
  $.getJSON('https://wind-bow.gomix.me/twitch-api/users/freecodecamp?callback=?', function(data) {
    console.log('one:', data);
    
    var name = data.name;

    $('#logo').html('<img src="' + data.logo + '"/><p>' + '<a href="https://www.twitch.tv/freecodecamp" target="_blank">' + data.display_name + '</a></p>');

    $('#bio').html(data.bio);
    
    /*
    * Add to favorites
    */
    
   
  });

  $.ajax({
    type: 'GET',
    url: 'https://api.twitch.tv/kraken/channels/freecodecamp',
    headers: {
      'Client-ID': 'phpj3b779rpzcaoex3av4q6m8iiy9c'
    },
    success: function(data) {

      console.log('two:', data);

      $('#header').css('background-image', 'url(' + data.profile_banner + ')');

      $('#status').html('<i class="fa fa-quote-left"></i> ' + data.status + ' <i class="fa fa-quote-right"></i>');

      $('#totalViews').html('<i class="fa fa-eye"></i> ' + data.views + ' total views');

      $('#followers').html('<i class="fa fa-user"></i> ' + data.followers + ' followers');

      $('#vid').html('<iframe src="https://player.twitch.tv/?channel=freecodecamp&autoplay=true&muted=true" frameborder="0" scrolling="no" height="378" width="620" allowfullscreen="true"></iframe>');
    }
  });

  $.getJSON('https://wind-bow.gomix.me/twitch-api/streams/freecodecamp?callback=?', function(data) {
    console.log('three:', data);

    if (data.stream === null) {

      $('#stream').html('<i class="fa fa-circle"></i> Offline');

    } else {

      $('#stream').html('<i class="fa fa-circle green"></i> Online');

      $('#title').html(data.stream.game);

    }

  });

  $.getJSON('https://wind-bow.glitch.me/twitch-api/channels/freecodecamp/videos', function(data) {
    console.log('videos:', data);

    $('.vidCnt').html('(<a href="https://www.twitch.tv/freecodecamp/videos/all" target="_blank">' + data._total + '</a>)');

    for (var i = 0; i < 10; i++) {
      $('#videos').append('<section><a href="' + data.videos[i].url + '" target="_blank"><img src="' + data.videos[i].preview + '"></a>' + data.videos[i].title + '</section>');
    }

  });

  $('#pastVids').on('click', function() {
    $('.hide').slideToggle(1000);
  });

  $.getJSON('https://wind-bow.glitch.me/twitch-api/users/freecodecamp/follows/channels', function(data) {

    $('#followCnt').html('(<a href="https://www.twitch.tv/freecodecamp/following" target="_blank">' + data._total + '</a>)');

    for (var i = 0; i < 10; i++) {

      if (data.follows[i].channel.logo == null) {
        data.follows[i].channel.logo = profileImg;
      }
      $('#follows').append('<a href="' + data.follows[i].channel.url + '" target="_blank"><img src="' + data.follows[i].channel.logo + '"></a>');

    }

  });

  /*
   *
   * Search 
   *
   */

  $('#searchTerm').keyup(function() {
    $('#toClear').empty();
    
    /*
    * Set Regex and check against results
    */

    var searchTerm = $('#searchTerm').val();
    var expression = new RegExp('^'+searchTerm, 'i');
    $.getJSON('https://api.twitch.tv/kraken/search/channels?q=' + searchTerm + '&client_id=phpj3b779rpzcaoex3av4q6m8iiy9c', function(data) {
      $.each(data.channels, function(key, value){
        if(value.name.search(expression) != -1) {
           $('#toClear').append('<li>' + value.name + '</li>');
        }
      });
      
    });

  });
  
    /*
    * Display Results
    */

  $('#resultUl').on('click', 'li', function() {
    
    /*
    * Hide search box on li click
    */
    
 $('#searchResult').hide('slide', {direction: 'left'}, 500);
    
    var user = $(this).text();
    var url1 = 'https://wind-bow.gomix.me/twitch-api/users/' + user + '?callback=?';
    var url2 = 'https://wind-bow.gomix.me/twitch-api/channels/' + user + '?callback=?';
    var url3 = 'https://wind-bow.gomix.me/twitch-api/streams/' + user + '?callback=?';
    var url4 = 'https://wind-bow.glitch.me/twitch-api/channels/' + user + '/videos';

    $('#videos').empty();
    /*
     * Get Basic User Information
     */

    $.getJSON(url1, function(data) {
      console.log('one:', data);

      var name = data.name;
      if (data.logo == null) {
        data.logo = profileImg;
      }
      if (data.error == 'Not Found') {
        data.display_name = '-';
        $('#stream').html('<i class="fa fa-circle"></i> -');
        $('.vidCnt').html('(-)');
      }

      $('#logo').html('<img src="' + data.logo + '"/>' + '<p><a href="https://www.twitch.tv/' + data.display_name + '" target="_blank">' + data.display_name + '</a></p>');
      $('#bio').html(data.bio);

     
    });

    /*
     * Get Channel Information
     */

    $.getJSON(url2, function(data) {
      console.log('two:', data);

      /*
       * Error Information
       */

      if (data.error == 'Not Found') {

        $('#header').css('background-image', 'url(http://i1123.photobucket.com/albums/l557/danielcwr/WoT%20Checkerd_zpsoogl6bvd.png)');

        $('#bio').html(data.message);

        $('#totalViews').html('<i class="fa fa-eye"></i> - total views');

        $('#followers').html('<i class="fa fa-user"></i> - followers');

        $('#status').empty();

      } else {

        /*
         * User Information
         */

        $('#header').css('background-image', 'url(' + data.profile_banner + ')');

        $('#status').html('<i class="fa fa-quote-left"></i> ' + data.status + ' <i class="fa fa-quote-right"></i>');

        $('#totalViews').html('<i class="fa fa-eye"></i> - total views');

        $('#followers').html('<i class="fa fa-user"></i> - followers');

        $('#totalViews').html('<i class="fa fa-eye"></i> ' + data.views + ' total views');

        $('#followers').html('<i class="fa fa-user"></i> ' + data.followers + ' followers');
      }
    });

    /*
     * Get Stream Information
     */

    $.getJSON(url3, function(data) {

      console.log('three:', data);

      /*
       * Online Status
       */

      if (data.stream === null) {

        $('#stream').html('<i class="fa fa-circle"></i> Offline');

        $('#title').empty();

        $('#viewers').empty();

      } else {

        $('#stream').html('<i class="fa fa-circle green"></i> Online' + ' (' + data.stream.viewers + ' viewers)');

        $('#title').html('<i class="fa fa-play"></i> ' + data.stream.game);

        $('#viewers').html('<i class="fa fa-eye"></i> ' + data.stream.viewers);
      }

      $('#vid').html('<iframe src="https://player.twitch.tv/?channel=' + user + '&autoplay=true&muted=true" frameborder="0" scrolling="no" height="378" width="620" ></iframe>');

    });

    /*
     * Display Past Videos
     */

    $.getJSON(url4, function(data) {
      console.log('videos:', data);

      $('.vidCnt').html('(<a href="https://www.twitch.tv/' + user + '/videos/all" target="_blank">' + data._total + '</a>)');

      for (var i = 0; i < 10; i++) {
        $('#videos').append('<section><a href="' + data.videos[i].url + '" target="_blank"><img src="' + data.videos[i].preview + '"></a>' + data.videos[i].title + '</section>');
      }

    });

    /*
     * Display who user follows
     */

    $.getJSON('https://wind-bow.glitch.me/twitch-api/users/' + user + '/follows/channels', function(data) {

      $('#followCnt').html('(<a href="https://www.twitch.tv/' + user + '/following" target="_blank">' + data._total + '</a>)');

      for (var i = 0; i < 10; i++) {

        if (data.follows[i].channel.logo == null) {
          data.follows[i].channel.logo = profileImg;
        }
        $('#follows').append('<a href="' + data.follows[i].channel.url + '" target="_blank"><img src="' + data.follows[i].channel.logo + '"></a>');

      }

    });
    
      $('#follows').empty();
  });

});
              
            
!
999px

Console