css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <header class="row header">
	<div class="small-12 columns text-center">
		<img class="header-logo" src="https://cdn1.iconfinder.com/data/icons/simple-icons/512/twitch-512-black.png" alt="logo">
	</div>
	<div class="small-12 columns text-center">
		<h1 class="header-title">TWITCH STREAMS</h1>
	</div>
	<div class="row status">
		<div class="small-12 columns text-center status">
			<span id="all">All</span>
			<span id="online">Online</span>
			<span id="offline">Offline</span>
		</div>
	</div>
</header>

<section class="streams text-center"></section>

<footer>
	<hr/>
	<div class="row">
		<div class="small-12 columns text-center">
			<span>By <a href="https://www.freecodecamp.com/ritvarsz" target="_blank">RitvarsZ</a></span>
		</div>
	</div>
</footer>
            
          
!
            
              //variables
$twitch: #6441a5
$twitch-hover: #4B317C
$online: #9CC7E4
$online-hover: #7595AB
$offline: #939798
$offline-hover: #252626
$dark: #4A4C4D
$black: #2F3133

//Vertical center
@media all and (min-width: 1024px)
	.stream
		display: flex
		align-items: center
		justify-content: center

//Reset CSS
*
	padding: 0
	margin: 0

body
	background-color: #dddfff
	font-family: 'Press Start 2P'

//Header
.header-logo
	max-height: 230px
	max-width: 230px

.header-title
	color: black
	font-family: 'Press Start 2P'
	margin-bottom: 50px

//Online - Offline modes
.online, #online
	background-color: $online

.offline, #offline
	background-color: $dark

.notfound
	background-color: $black

#all
	background-color: $twitch

.status
	margin: 20px
	span
		padding: 5px
		border-radius: 7px

.status
	font-size: 16px
	
#all:hover,
#online:hover,
#offline:hover
	cursor: pointer
	font-weight: bold

#online:hover
	background-color: $online-hover

#all:hover
	background-color: $twitch-hover

#offline:hover
	background-color: $offline-hover

//Section
.stream
	margin-top: 11px
	margin-bottom: 11px
	border-radius: 11px
	
.streams
	margin: 0 25px 0 25px

.logo, 
.channel, 
.game, 
.description
	margin: 7px 0 7px 0

//Footer
footer 
	margin-bottom: 15px
	font-weight: 900
	font-size: 11px

//Links
a, 
a:hover, 
a:visited, 
a:active
	text-decoration: none
	color: #000
            
          
!
            
              //Set variables;
var streamers = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas", "comster404", "brunofin "];
var urlCheck = "https://wind-bow.gomix.me/twitch-api/channels/"; //Used for checking if channel is not deleted
var urlData = "https://wind-bow.gomix.me/twitch-api/streams/"; //Used for getting data from streams
var dataCheck, dataStream, url, logo, name, game, status, description, className;

//Iterate through every user from array, to get data
for (var i = 0; i < streamers.length; i++) {
	$.when(
		$.getJSON(urlCheck + streamers[i] + "?callback=?"),
		$.getJSON(urlData + streamers[i] + "?callback=?")
	).done(displayData);
}

//Function for displaying data on page
function displayData(dataCheck, dataStream) {
	
	//Set status
	if (typeof dataCheck[0].error === 'string') {
		status = "Not Found";
		logo = "http://wewanaplay.com/wp-content/uploads/2013/02/Space_invader-vilain-300x300.jpg";
		description = "This account is closed";
		url = "#";
		name = (dataStream[0]._links.channel).split("/").pop();
		className = "notfound";
	} else if (dataStream[0].stream !== null) {
		status = "Online";
		className = "online";
	} else {
		status = "Offline";
		className = "offline";
	}
	
	//Set variables channel if exists
	if (status != "Not Found") {
		url = dataCheck[0].url;
		logo = dataCheck[0].logo;
		name = dataCheck[0].display_name;
		description = (dataCheck[0].status !== null ? dataCheck[0].status : "Description not available");
		game = dataCheck[0].game;
	}
	
	//Display data
	$(".streams").append(
		'<a href=' + url + ' target='+ (url == "#" ? "_self" : "_blank") +'>' +
		'<div class="row stream ' + className + '">' +
		'<div class="small-12 medium-12 large-2 logo v_align columns">' +
		'<img class="logo" src=' + logo + ' alt="Channel logo">' +
		'</div>' +

		'<div class="channel small-12 medium-12 large-3 columns v_align">' +
		'<p>' + name + '</p>' +
		'</div>' +

		'<div class="game small-12 medium-12 large-2 columns">' +
		'<p>' + (status == "Online" ? game : status) + '</p>' +
		'</div>' +

		'<div class="description medium-12 small-12 large-5 columns">' +
		'<p>' + description + '</p>' +
		'</div>' +
		'</div>' +
		'</a>'
	);
}//End of displayData();

//Function for switching between modes(All, Online, Offline)
function toggle() {
	
	//t=time(ms), used for animation
	var t = 500;
	
	//Functions for toggling between modes
	$("#all").click(function() {
		$(".online").show(t);
		$(".offline").show(t);
		$(".notfound").show(t);
	});
	$("#online").click(function() {
		$(".online").show(t);
		$(".offline").hide(t);
		$(".notfound").hide(t);
	});
	$("#offline").click(function() {
		$(".online").hide(t);
		$(".offline").show(t);
		$(".notfound").show(t);
	});
}

$(document).ready(function() {
	
	//When page has loaded, run toggle function
	toggle();
	
});
            
          
!
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.
Loading ..................

Console