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.

            
              <html ng-app="twitchClient">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
	<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css"  media="screen,projection"/>
	<link href="https://cdnjs.cloudflare.com/ajax/libs/typicons/2.0.7/typicons.min.css" rel="stylesheet" />
	<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css" />
</head>
<body>
	<div ng-controller="TwitchClientController as twitchClient">
		<div class="row">
			<div class="spinner" ng-show="!isLoaded">
			  <div class="rect1"></div>
			  <div class="rect2"></div>
			  <div class="rect3"></div>
			  <div class="rect4"></div>
			  <div class="rect5"></div>
			</div>
		</div>
		<div class="row" ng-show="isLoaded" ng-cloak>
			<div class="content col s12 m8 l6 offset-l3 offset-m2">
				<header>
					<nav>
						<div class="nav-wrapper">
							<a href="#" class="brand-logo"><h4>Twitch.tv Streamers</h4></a>
						</div>
					</nav>
				</header>
				<main class="site-content">	
					<ul class="collection with-header" ng-hide="users == null">
						<li class="collection-header left-align">
							<p>
								<input name="statusgroup" type="radio" id="statusall" ng-model="statusFilter" value="all" />
								<label for="statusall">All</label>

								<input name="statusgroup" type="radio" id="statuson" ng-model="statusFilter" value="online" />
								<label for="statuson">Online</label>

								<input class="with-gap" name="statusgroup" type="radio" id="statusoff" ng-model="statusFilter" value="offline" />
								<label for="statusoff">Offline</label>

								<input name="statusgroup" type="radio" id="statusradio" disabled="disabled" ng-model="statusFilter" />
							</p>
						</li>
						<li class="collection-item avatar" ng-repeat="user in users | orderBy:['!isOnline', '!isAccountExists', 'displayName']" ng-hide="hideByStatus(user)">
							<a ng-href="{{user.url}}" class="center-align" target="_blank">
								<img ng-src="{{user.logo}}" alt="" class="circle">
							</a>
							<span class="title">{{user.displayName}}</span>
							<span class="secondary-content">
								<div ng-hide="!user.isAccountExists">
									<i ng-hide="user.isOnline" class="typcn typcn-lock-closed"></i>
									<i ng-hide="!user.isOnline" class="typcn typcn-lock-open-outline"></i>
								</div>
								<div ng-hide="user.isAccountExists">
									<i class="typcn typcn-cancel"></i>
								</div>
							</span>
							<br />
							<span class="stream" ng-hide="!user.isOnline">
								{{user.streamGame}}<span ng-hide="user.status == null">: </span>{{user.status}} 
							</span>
							<span class="stream" ng-hide="user.isOnline">
								<span ng-hide="user.isAccountExists" class="red-text lighten-1">Invalid user</span>
								<span ng-hide="!user.isAccountExists">Offline</span>
							</span>
							<!--<span class="secondary-content"><i class="material-icons">grade</i></a>-->
						</li>
					</ul>
				</main>
				<footer class="page-footer">
					<div class="container">
						<div class="row ">
							<div class="col l12 s12">
								<p class="grey-text text-lighten-4">Twitch.tv JSON API client done for freecodecamp.org.</p>
								<p class="grey-text text-lighten-4"> Built with AngularJS, Materialize CSS, SpinKit and Typicons.</p>
							</div>
						</div>
						<div class="footer-copyright">
							<div class="container">

								<a class="grey-text text-lighten-4 right" href="https://twitter.com/nickrfer" target='_blank'>
									<i class="typcn typcn-social-twitter"></i>
								</a>	
								<a class="grey-text text-lighten-4 right" href="https://codepen.io/nickrfer" target='_blank'>
									<i class="typcn typcn-code"></i>
								</a>
								<a class="grey-text text-lighten-4 right" href="https://www.freecodecamp.com/nickrfer" target='_blank'>
									<i class="typcn typcn-chart-area"></i>
								</a>
								<a class="grey-text text-lighten-4 right" href="https://www.linkedin.com/in/nickrfer" target='_blank'>
									<i class="typcn typcn-social-linkedin"></i>
								</a>
								<a class="grey-text text-lighten-4 right"  href="https://github.com/nickrfer" target='_blank'>
									<i class="typcn typcn-social-github"></i>
								</a>
								<span class="grey-text text-lighten-4 right">by nickrfer</span>

							</div>
						</div></div>
					</footer>
				</div>
			</div>
			<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
			<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script>
			<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
		</body>
		</html>

            
          
!
            
              html {
	font-family: 'Inconsolata', Monaco, Consolas, 'Andale Mono', monospace;
}
.nav-wrapper {
	padding-left: 27%;
	background-color: #540D6E;
}
.stream {
	font-size: 10px;
	font-style: italic;
}
footer {
	text-align: center;
}
footer p i {
	font-size: 12px;
}
a:hover {
	text-decoration: none !important;
}
.page-footer {
	background-color: #540D6E !important;
}
.typcn {
	font-size: 40px;
	margin-right: 5px;
}
.footer-copyright .typcn {
	font-size: 20px;
}

.secondary-content {
	position: static !important;
	margin-top: 20px;
}

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}
.spinner {
  margin: 100px auto;
  width: 50px;
  height: 40px;
  text-align: center;
  font-size: 10px;
  position: static;
  margin-top: 20em;
}
.spinner > div {
  background-color: #333;
  height: 100%;
  width: 6px;
  display: inline-block;
  
  -webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
  animation: sk-stretchdelay 1.2s infinite ease-in-out;
}

.spinner .rect2 {
  -webkit-animation-delay: -1.1s;
  animation-delay: -1.1s;
}

.spinner .rect3 {
  -webkit-animation-delay: -1.0s;
  animation-delay: -1.0s;
}

.spinner .rect4 {
  -webkit-animation-delay: -0.9s;
  animation-delay: -0.9s;
}

.spinner .rect5 {
  -webkit-animation-delay: -0.8s;
  animation-delay: -0.8s;
}

@-webkit-keyframes sk-stretchdelay {
  0%, 40%, 100% { -webkit-transform: scaleY(0.4) }  
  20% { -webkit-transform: scaleY(1.0) }
}

@keyframes sk-stretchdelay {
  0%, 40%, 100% { 
    transform: scaleY(0.4);
    -webkit-transform: scaleY(0.4);
  }  20% { 
    transform: scaleY(1.0);
    -webkit-transform: scaleY(1.0);
  }
}
            
          
!
            
              var app = angular.module('twitchClient', []);
var streamApiUrl = 'https://api.twitch.tv/kraken/streams/';
var channelApiUrl = 'https://api.twitch.tv/kraken/channels/';

app.controller('TwitchClientController', [ '$scope', '$http', '$timeout',
  function($scope, $http, $timeout) {
    $scope.statusFilter = "all";
    $scope.users = [];

    $scope.hideByStatus = function(user) {
      if (user.isOnline && $scope.statusFilter == 'offline') {
        return true;
      } else if ($scope.statusFilter != 'all' && !user.isAccountExists || (!user.isOnline && $scope.statusFilter == 'online')) {
        return true;
      }
      return false;
    };

    var createUser = function(streamData, channelData, channel) {
      var user;
      if (streamData != null) {
        user = new TwitchUser(streamData.channel, streamData);
      } else if (channelData != null) {
        user = new TwitchUser(channelData.data);
      } else {
        user = new TwitchUser();
        user.displayName = channel;
      }
      $scope.users.push(user);
      if (channelArr.length == $scope.users.length) {
        $scope.isLoaded = true;
      }
    };    

    $scope.fetchChannel = function(channel) {
      $http.get(channelApiUrl+channel).then(function(channelResponse) {
        createUser(null, channelResponse);
      });
    };

    channelArr.forEach(function(channel) {
      $http.get(streamApiUrl+channel).success(function(streamResponse) {
        if (streamResponse.stream == null) {
          $scope.fetchChannel(channel);
        } else {
          createUser(streamResponse.stream);
        }
      })
      .error(function(streamResponse) {
        createUser(null, null, channel);
      }); 
    });

  }]);

var TwitchUser = function(channel, streamData) {
  this.isOnline = false;
  this.isAccountExists = false;
  
  if (channel != null) {
    this.isAccountExists = true;
    this.logo = channel.logo;
    this.url = channel.url;
    this.displayName = channel.display_name;
    this.status = channel.status;

    if (streamData != null) {
      this.isOnline = true;
      this.streamGame = streamData.game;
    }
  }
}

var channelArr = [
"jackpattillo",
"sirlarr",
"funhausteam",
"freecodecamp",
"ESL_SC2", 
"OgamingSC2", 
"cretetion",  
"storbeck", 
"brunofin",
"comster404",
"habathcx", 
"RobotCaleb", 
"noobs2ninjas",
"MedryBW"
];
            
          
!
999px
Loading ..................

Console