cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

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


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

  <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>
            
          
!
            
              html,
body {
  padding: 0;
  margin: 0;
  background: #fff;
  font-family: "Open Sans";  
}

.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%;
}
}
            
          
!
            
              $(document).ready(function() {

  /*
   * Default Profile Image
   */

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

  /*
   * Search Button Click Function
   */

  $('#searchBtn').on('click', function() {
    var user = $('#search').val();
    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);

      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>');

    }

  });

    /*
     * Empty search field
     */

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

  /*
   * FreeCodeCamp onLoad Information
   */

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

    $('#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);
  });

  $.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>');

    }

  });

});
            
          
!
999px
Loading ..................

Console