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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              main(ng-app='TwitchApi')
  section(ng-controller='MainCtrl')
    header
      ul#mainMenu
        li(data-display='allUsers').activeMenu All
        li(data-display='onlineUsers') Online
        li(data-display='offlineUsers') Offline
    #searchMenu
      i#searchIcon.fa.fa-search
      input(type='text' ng-model='searchText')#searchBar
    ul#people
      a(href='https://twitch.tv/{{user.username}}' target='_blank' ng-repeat='user in profile | filter:searchText')
        li
          img(ng-src='{{user.logo}}' err-src='http://placehold.it/50x50').pic
          span.name {{user.name}}
          span.status {{user.name}}
            i(class='{{user.status}}')
          span.title {{user.streamTitle}}
            
          
!
            
              @import "bourbon";

@import url(https://fonts.googleapis.com/css?family=Roboto:300);

// colors
$red: #F47564;
$grey: #E4E0E1;
$green: #8FD7D6;

// variables
$font: Roboto, Arial, Sans-Serif;

body {
  background: lighten($red, 10);
}

main {
  margin: 0 auto;
  width: 300px;
  border: 1px solid $red;
  background: white;
  
  // Menu bar
  header {
    height: 50px;
    background-color: $red;
    position: relative;
    
    ul {
      margin-top: 0;
      padding-left: 0;
    }
    
    li {
      position: relative;
      list-style-type: none;
      display: inline-block;
      font-family: $font;
      color: white;
      padding-left: 30px;
      padding-top: 15px;
      padding-bottom: 16px;
      padding-right: 25px;
      border-right: 1px solid lighten($red, 10);
      
      &:first-child {
        padding-right: 35px;
      }
      
      &:last-child {
        border-right: none;
      }
      
      &:hover {
        cursor: pointer;
      }
    }
    
    .activeMenu {
      
      &:after, &:before {
        top: 100%;
        left: 50%;
        border: solid transparent;
        content: " ";
        height: 0;
        width: 0;
        position: absolute;
        pointer-events: none;
      }
      
      &:after {
        border-top-color: $red;
        border-width: 10px;
        margin-left: -10px;
        z-index: 10;
      }
    }
  }
  
  // Search bar
  #searchMenu {
    text-align: center;
    position: relative;
    padding-top: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid $grey;
    
    #searchBar {
      position: relative;
      width: 70%;
      text-align: left;
      line-height: 20px;
      border-radius: 20px;
      border: 1px solid $grey;
      outline: none;
      padding-left: 40px;
      padding-right: 20px;
      font-size: .8em;
      font-family: $font;
    }
    
    #searchIcon {
      position: absolute;
      z-index: 1;
      padding-top: 3px;
      left: 25px;
      color: $grey;
    }
  }
  
  #people {
    padding-left: 0;
    
    a {
      text-decoration: none;
    }
    
    li {
      list-style-type: none;
      display: block;
      padding-left: 20px;
      position: relative;
      font-family: $font;
      padding-top: 5px;
      padding-bottom: 5px;
      
      &:nth-child(even) {
        background-color: lighten($grey, 8);
      }
      
      .pic {
        height: 50px;
        width: 50px;
        border-radius: 50%;
      }
      
      .name, .status {
        position: absolute;
        line-height: 50px;
      }
      
      .name {
        left: 80px;
        color: $red;
      }
      
      .status {
        right: 20px;
      }
      
      .title {
        color: darken($grey, 20);
        font-size: .7em;
      }
    }
  }
}

// Classes to apply colors to the status
.green {
  color: $green;
}

.red {
  color: $red;
}
            
          
!
            
              // Angular controller to get Twitch users
var app = angular.module('TwitchApi', []);
app.controller('MainCtrl', function($scope, $http) {
  
  // Scope variables
	$scope.allUsers = [];
  $scope.onlineUsers = [];
  $scope.offlineUsers = [];
  
  // Local variables
  var streamers = ["freecodecamp", "GeoffStorbeck", "terakilobyte", "habathcx","notmichaelmcdonald","RobotCaleb","medrybw","comster404","brunofin","thomasballinger","joe_at_underflow","noobs2ninjas","mdwasp","beohoff","xenocomagain"];
  var cb = '?client_id=5j0r5b7qb7kro03fvka3o8kbq262wwm&callback=?';
	var url = 'https://api.twitch.tv/kraken/';
  
  // Get information for streamers
	streamers.forEach(function(stream) {
    
    // Temporary object
    var obj = {};
    
    // Check if streaming
		$.getJSON(url + 'streams/' + stream + cb).success(function(data) {
      var streaming = (data.stream === null) ? false : true;
      if (streaming) {
        obj.status = 'green fa fa-check';
        var streamTitle = data.stream.channel.status;
        
        if (streamTitle.length > 36) {
          streamTitle = streamTitle.substring(0,33);
          streamTitle += '...';
        }
        obj.streamTitle = streamTitle;
      } else {
        obj.status = 'red fa fa-exclamation';
        data.streamTitle = '';
      }
      obj.username = stream;
      
      // Get user name and image
      $.getJSON(url + 'users/' + stream + cb).success(function(data) {
        obj.name = data.display_name;
        obj.logo = data.logo;
        
        $scope.allUsers.push(obj);
        if (streaming) {
          $scope.onlineUsers.push(obj);
        } else {
          $scope.offlineUsers.push(obj);
        }
        $scope.profile = $scope.allUsers;
        $scope.$apply();
      });
    });
  });
  
  // Change arrow on main menu
  $('#mainMenu li').on('click', function() {
   
    if ($(this).data('display') === 'allUsers') {
      $scope.profile = $scope.allUsers;
    } else if ($(this).data('display') === 'onlineUsers') {
      $scope.profile = $scope.onlineUsers;
    } else {
      $scope.profile = $scope.offlineUsers;
    }
    $scope.$apply();
    
    // Change arrow
    $('#mainMenu li').removeClass('activeMenu');
    $(this).addClass('activeMenu');
    
  })
});

app.directive('errSrc', function() {
  return {
    link: function(scope, element, attrs) {

      scope.$watch(function() {
          return attrs['ngSrc'];
        }, function (value) {
          if (!value) {
            element.attr('src', attrs.errSrc);  
          }
      });

      element.bind('error', function() {
        element.attr('src', attrs.errSrc);
      });
    }
  }
});
            
          
!
999px
Loading ..................

Console