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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>Twitch.tv JSON API - Free Code Camp, Intermediate Front End Development Projects</title>
</head>
<body>
<div class="container-fluid row marge-20">
	<div id="twitchHeader" class="container-fluid col-md-6 col-md-offset-3 col-sm-10 col-sm-offset-1 col-xs-12 bg-primary">
     	<div>
     		<h1>Twitch.tv Streamers</h1>
     	</div>
     <div class="pull-right">
     	<span id="allOf">All</span> | 
     	<span id="onlineOnly">Online Only</span> | 
     	<span id="offlineOnly">Offline Only</span></div>
     </div>
	<div id="twitchBody" class="container-fluid col-md-6 col-md-offset-3 col-sm-10 col-sm-offset-1 col-xs-12"></div>
	<div id="twitchFooter" class="container-fluid col-md-6 col-md-offset-3 col-sm-10 col-sm-offset-1 col-xs-12 bg-primary text-center"><a href="http://raymondrizzo.com/Portfolio" target="_blank">Raymond Rizzo</a></div>
</div>
<div id="invisibleDiv"></div>
</body>
</html>
              
            
!

CSS

              
                body {
  background-color: #333333;
  font-family: "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif !important;
  font-size: 20px;
  font-style: normal;
  font-variant: small-caps;
  font-weight: 500;
}

#twitchHeader {}

#twitchBody {
  background-color: #ffffff;
  padding: 2%;
}

#twitchFooter {
  padding: 1%;
}

.marge-20 {
  margin-top: 20px;
}

.eachStreamer {
  border-width: 1px 0px 0px 0px;
  border-style: solid;
  border-color: #dddddd;
}

#invisibleDiv {
  visibility: hidden;
}

#twitchFooter a, #twitchFooter a:hover, #twitchFooter a:active, #twitchFooter a:visited, #twitchFooter a:link{
  color: #ffffff;
}
              
            
!

JS

              
                // JavaScript Document

var twitchStreamers = ['esl_sc2', 'ogamingsc2', 'cretetion', 'freecodecamp', 'storbeck', 'habathcx', 'robotcaleb', 'noobs2ninjas', 'comster404'];
var twitchUserArray = [];
var twitchStreamArray = [];

$(document).ready(function() {
	'use strict';
	$('#allOf').on('click', function() {
		window.setTimeout(appendThing, 600, '.bg-success', '#twitchBody');
		window.setTimeout(appendThing, 600, '.bg-danger', '#twitchBody');
	}); 

	$('#onlineOnly').on('click', function() {
		$('.bg-danger').addClass('animated bounceOut');
		window.setTimeout(appendThing, 600, '.bg-danger', '#invisibleDiv');
		window.setTimeout(appendThing, 600, '.bg-success', '#twitchBody');
	});

	$('#offlineOnly').on('click', function() {
		$('.bg-success').addClass('animated bounceOut');
		window.setTimeout(appendThing, 600, '.bg-success', '#invisibleDiv');
		window.setTimeout(appendThing, 600, '.bg-danger', '#twitchBody');
	});

  twitchStreamers.forEach(function(streamer) {
    loadList('users/', streamer);
  });

});

function loadList(type, element) {
		'use strict';
		$.ajax({
			url: 'https://api.twitch.tv/kraken/' + type + element,
			type: 'GET',
			headers: {
				'Client-ID': 'os6gq0a35dfnvg9h5cceuw5zhoj115z',
				'Accept': 'application/vnd.twitchtv.v3+json'
				},
			success: function(data){
				twitchUserArray.push(data);
				$.ajax({
					url: 'https://api.twitch.tv/kraken/streams/' + element,
					type: 'GET',
					headers: {
						'Client-ID': 'os6gq0a35dfnvg9h5cceuw5zhoj115z',
						'Accept': 'application/vnd.twitchtv.v3+json'
					},
					success: function(dataTwo){
						twitchStreamArray.push(dataTwo);
						if(twitchStreamArray.length === 8){
							//console.log(twitchUserArray[0]['name']);
							//console.log(twitchStreamArray[0]['stream']['channel']['display_name'].toLowerCase());
							populateScreen();
						}
					}
					
				});
			}
		});
}
	
function populateScreen() {
	'use strict';
    var userDivID = '';
	twitchUserArray.forEach(function(userObject){
		userDivID = '#' + userObject.name;
		$('#twitchBody').append('<div id="' + userObject.name + '" class="container-fluid row"><div class="container-fluid col-md-2 col-sm-2 col-xs-2"><img class="img-responsive container-fluid" src="' + userObject.logo + '" />' + '</div><div id="' + userObject.name + 'State' + '" class="container-fluid col-md-10 col-sm-10 col-xs-10"><p><a href="https://twitch.tv/' + userObject.name + '" target="_blank">' + userObject.name + '</a></p>');
		$('#' + userObject.name + 'State').append('No active stream</div>');
		$(userDivID).addClass('bg-danger');	
		twitchStreamArray.forEach(function(streamObject){
			if(streamObject.stream !== null){
				if(streamObject.stream.channel.name === userObject.name){
					$(userDivID).remove();
					console.log('Online user: ' + userObject.name);
					$('#twitchBody').append('<div id="' + userObject.name + '" class="container-fluid row"><div class="container-fluid col-md-2 col-sm-2 col-xs-2"><img class="img-responsive container-fluid" src="' + userObject.logo + '" />' + '</div><div id="' + userObject.name + 'State' + '"class="container-fluid col-md-10 col-sm-10 col-xs-10"><p><a href="https://twitch.tv/' + userObject.name + '" target="_blank">' + userObject.name + '</a></p>');
					$('#' + userObject.name + 'State').append(streamObject.stream.game + '</div>');
					$(userDivID).addClass('bg-success');
					twitchStreamers[twitchStreamers.indexOf(userObject.name)] = '';
				}
			} else {
					twitchStreamers[twitchStreamers.indexOf(userObject.name)] = '';
			}		
		});
	});
	twitchStreamers.forEach(function(streamer){
		if(streamer !== ''){
			//alert(streamer);
			$('#twitchBody').append('<div id="' + streamer + '" class="container-fluid row"><div class="container-fluid col-md-2 col-sm-2 col-xs-2">' + '</div><div id="' + streamer + 'State' + '"class="container-fluid col-md-10 col-sm-10 col-xs-10"><p><a href="https://twitch.tv/' + streamer + '" target="_blank">' + streamer + '</a></p>');
			$('#' + streamer + 'State').append('Twitch.tv user does not exist</div>');
			$('#' + streamer).addClass('btn-warning');	
		}
		
	});
	console.log(twitchStreamers);
}


function appendThing(what, where) {
		'use strict';
  $(what).appendTo(where);
  $(what).removeClass('animated bounceOut');

  $(what).removeClass('animated bounceInUp');
}


              
            
!
999px

Console