123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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

            
              <div class="container">
	<div id="header" class="text-center row">
		<h2>Twitch Status Monitor</h2>
	</div>
	<div id="streamInfo">
	</div>
</div>
            
          
!
            
              div {
	border: solid 1px blue;
}

body {
	background-color: #F5F5F5;
}

.channel-logo {
	max-height: 50px;
	border-radius: 50%;
	margin: 0;
}

.channel-row {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	border-radius: 15px;
	margin: 5px auto;
	width: 600px;
}

.offline-row {
	background-color: #FFDCDC;
	border: 2px red solid;
}

.online-row {
	background-color: #D3FFD7;
	border: 2px green solid;
}

a, a:hover {
	text-decoration: none;
	color: black;
}
            
          
!
            
              

//RUN JQUERY
$(document).ready(function() {

	var streamers = ['brunofin', 'mightymouseufc125', 'rampageishuman', 'freecodecamp', 'wyld', 'ESL_SC2', 'OgamingSC2', 'cretetion', 'storbeck', 'habathcx', 'RobotCaleb', 'noobs2ninjas' ]

	//For Loop to call get stream status from
	for (i = 0; i < streamers.length; i++) {
		getStreamStatus(streamers[i]);
	};

	function getStreamStatus(stream) {
		$.ajax({
			type: "GET",
			url: "https://api.twitch.tv/kraken/streams/" + stream,
			headers: {
				'Client-ID': 'h3mu49px3gtkcregfk3wam5bob1swd'
			},
			success: function(data1){
				if	(data1.stream == null) {
					getChannelInfo(stream);
				}			
				else {
					var displayName = data1.stream.channel.display_name;
					var logo =  data1.stream.channel.logo;
					var status = data1.stream.channel.status;
					var channelURL = data1.stream.channel.url;
					if(logo == null) {logo = 'https://res.cloudinary.com/nascentnoob/image/upload/v1482710738/not-found-icon_lf5ouq.png'};
					$("#streamInfo").prepend("<a href='" + channelURL + "' target='_blank' ><div class='row channel-row online-row'>" +
																	 "<div class='col-md-2'>" + "<img class='channel-logo pull-right img-responsive' src='" + logo + "'>" + "</div>" + 
																	 "<div class='col-md-3'>" + displayName + "</div>" + 
																	 "<div class='col-md-7'>" + status + "</div>" +
																	 "</div></a>");
				}
			},
			error: function(xhr, textStatus, errorThrown){
				alert('request failed');
			}
		});
	};

	function getChannelInfo(channel) {
		$.ajax({
			type: "GET",
			url: "https://api.twitch.tv/kraken/channels/" + channel,
			headers: {
				'Client-ID': 'h3mu49px3gtkcregfk3wam5bob1swd'
			},
			success: function(data2){

				var displayName = data2.display_name;
				var logo =  data2.logo;
				var status = data2.status;
				var channelURL = data2.url;
				if(logo == null) {logo = 'https://res.cloudinary.com/nascentnoob/image/upload/v1482710738/not-found-icon_lf5ouq.png'};
				$("#streamInfo").append("<a href='" + channelURL + "' target='_blank' ><div class='row channel-row offline-row'>" +
																"<div class='col-md-2'>" + "<img class='channel-logo pull-right img-responsive' src='" + logo + "'>" + "</div>" + 
																"<div class='col-md-3'>" + displayName + "</div>" + 
																"<div class='col-md-7'>" + status + "</div>" +
																"</div></a>");
			}

		});
	};



});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console