cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-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="twitch">
  <section ng-controller="StreamController">
    <header class="container col-md-4 col-md-offset-4">
      <h2 class="text-center">Coders on <i class="fa fa-twitch"></i> Twitch</h2>

      <div class="btn-group btn-group-justified" role="group">
        <div class="btn-group">
          <button type="button" class="btn btn-default selected" ng-click='toggleSelectedClass($event); showAll()'>ALL
        </div>
        <div class="btn-group">
          <button type="button" class="btn btn-default" ng-click='toggleSelectedClass($event); showOnline()'>Online</button>
        </div>
        <div class="btn-group">
          <button type="button" class="btn btn-default" ng-click='toggleSelectedClass($event); showOffline()'>Offline</button>
        </div>
      </div>
      <div class='streams'>
        <div class="input-group">
          <input type="text" ng-model="searchText.name" class="input-lg" placeholder="Filter" />
          <i class="fa fa-search-plus fa-4x filter-glass"></i>
        </div>
        <div class="row" >
          <a ng-repeat="user in currentView | filter:searchText" href="https://www.twitch.tv/{{user.name}}">
            <div class="col-sm-4 portfolio-item">
            <div class='stream'>
              <img class="user-logo img-circle" ng-src={{user.logo}} />
              <div class='stream-text'>
                <span class='username'>{{user.name}}<span class="online-icon glyphicon {{user.onlineIcon}}"></span></span>
                <span class='description'>{{user.desc}}</span>
              </div>
            </div>
            </div>
          </a>
        </div>
    </header>
  </section>
</main>
            
          
!
            
              * {
   /* border:1px solid black; */ 
  
  font-family: 'Montserrat', sans-serif;
}

body {
  background-color: white;
}

.clearfix {
  overflow: auto;
}

.description {
  display: block;
  margin: 0px 0px 10px 30px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 80%;
  color: grey;
}

.user-logo {
  width: 35%;
  margin: 20px 20px 0px 20px;
}
.green {
  color: green;
}
.red {
  color:red;
}
.username {
  display: block;
  font-size: 20px;
  text-align: center;
}
.stream-text {
  display: inline-block;
  width: 30%;
  position: absolute;
  top: 20px;
}
.input-lg {
  width: 100%;
  padding-left: 40px;
}

.input-group {
  width: 100%;
}

.btn-group .selected, .btn-group .selected:hover{
  background-color:#2780e3;
  color:white;
}

.filter-glass {
  float: left;
  position: absolute;
  left: 10px;
  top: 15px;
  font-size: 1.95em;
}


            
          
!
            
              var app = angular.module('twitch', []);

var usernames = ["jtbricker","freecodecamp", "storbeck", "terakilobyte", "noobs2ninjas", "beohoff", 'faceittv', 'medrybw']; //usernames to grab from API
var api_url = "https://api.twitch.tv/kraken/"; //base API url
var blank_logo = 'http://trythenaturalway.com/how-to-increase-height/sites/all/themes/business/images/anonymous.png'; //location of image for profiles without profile images
var onIcon = "glyphicon-ok green"
var offIcon = "glyphicon-remove red"

app.controller('StreamController', function($scope, $http) {
  $scope.toggleSelectedClass = function(event) {
    $('.selected').removeClass('selected');
    $(event.currentTarget).addClass('selected');
  }
  $scope.showAll = function() {
    $scope.currentView = $scope.all;
  }
  $scope.showOnline = function() {
    $scope.currentView = $scope.online;
  }
  $scope.showOffline = function() {
    $scope.currentView = $scope.offline;
  }

  $scope.online = [];
  $scope.offline = [];
  $scope.all = [];

usernames.forEach(function(username) {
    var temp = {};
//    var username = usernames[i];
    $.getJSON(api_url + 'streams/' + username + '?callback=?', function(data) {
      var isOnline = (data.stream !== null);
      temp.desc = isOnline ? data.stream.channel.status : "";
      $.getJSON(api_url + 'users/' + username + '?callback=?', function(data) {
        temp.name = data.display_name;
        temp.logo = data.logo !== null ? data.logo : blank_logo;
        //console.log(temp);
        if(isOnline){
          temp.onlineIcon = onIcon;
          $scope.online.push(temp);
        }else{
          temp.onlineIcon = offIcon;
          $scope.offline.push(temp);
        }
        $scope.all.push(temp);
        $scope.currentView = $scope.all;
        $scope.$apply();
      });
    });

  });


});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console