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.

            
              <html>

<head>
	<meta charset="utf-8">
	<title>Twitch</title>

</head>
<body>
	<div class="container">

			<h1>Twitch Streamers</h1>
	<button class="btn btn-primary" id="online">ONLINE</button>
  			<button class="btn btn-primary" id="offline">OFFLINE</button>
  			<button class="btn btn-primary" id="all">ALL</button>
		

			<div id="streamerInfo">
				
			
			</div><!--end of c#streamerIinfo -->

		
		</div>
	</div> <!--end of container -->


</body>

</html>
            
          
!
            
              body{
	background-color: #7f8c8d;
	font-family: 'Noto Sans', sans-serif;
}
.container{
	text-align: center;
}
h1{
	color: teal;
	margin: 40px;
}
.box{
	text-align: center;
	width: 70%;
	margin: auto;
	height: 200px;
}
#tabs ul{
	padding: 50px;
}
ul{
	list-style: none;
	display: flex;
	justify-content: center;
	text-align: center;
	margin: auto;
}
#tabs,li{
	text-align: center;
	padding-left: 10px;
	padding-right: 10px;
	width: 60px

}



a{
  text-decoration: none;
}

.col-md-4{
  
  font-size: 20px;

}

#streamerInfo{
	display: flex;
	flex-direction:column;
	justify-content: center;
	align-items: center;
	
	
	
}
 img{
  width:50px;
  border-radius: 50%;
	
}
.row{
 	
  border: 2px white solid;
  border-radius: 15px;
 	margin: 10px;
	text-align: center;
	
	width: 100%;
	
}
#tabs{
	
	
	list-style: none;
	display: inline-block;
	text-align: center;
	display: flex;
	
}
#steramerInfo, .col-md-4{
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100px;
	font-family: 'Noto Sans', sans-serif;
}

.viewers{
	margin-top: 15px;
	
}
#streamerInfo a{
	color: white;
	text-decoration: none;
	
}
.offAcc{
	color: white;
	background-size: cover;
}
.onAcc{
	color: #2980b9;
	background-size: cover;
}
.closed{
	color: white;
}
.btn{
	background: #16a085;
	border: none;
}
.btn:hover{
	background: black;
}
            
          
!
            
              $(document).ready(function() {

	var usernames = ["ESL_SC2", "OgamingSC2", "freecodecamp", "habathcx", "RobotCaleb", "noobs2ninjas", "comster404", "brunofin", "nl_kripp"];

	var mode;

	// loop through the usernames array to call api
	usernames.forEach(function(channel) {

		$.getJSON("https://wind-bow.gomix.me/twitch-api/channels/" + channel + "?callback=?", function(data) {
			console.log(data.followers);

			var logo = data.logo;
			var name = data.display_name;
			var url = data.url;
			var status = data.status;
			var followers = data.followers;
			var views = data.views;
			var banner = data.profile_banner;

			$.getJSON("https://wind-bow.gomix.me/twitch-api/streams/" + channel + "?callback=?", function(data2) {
				if (status == '404') {
					logo = "https://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-error-icon.png";
					console.log(banner);
					$("#streamerInfo").append(

					`<div class='row closed all'>
							<div class='col-md-4'><img src="${logo}"></div> 
							<div class='col-md-4' > ${channel}</div>
							<div class='col-md-4'>${data.error}</div> 
						</div>`);
				} else if (data2.stream === null) {

					$("#streamerInfo").append(`<div class='row offAcc all' style="background:url(${banner})">
						<div class='col-md-4'><img src='${logo}'> 
						</div> 

						<div class='col-md-4' id='name'><a target='_blank'  href= '${url}'>${name}</a></div> 

						<div class='col-md-4'>OFFLINE
						</div>
						</div>`);
					
				} else {
					$("#streamerInfo").append(`<div class='row onAcc all' style="background:url(${banner})">

						<div class='col-md-4'><img src=${logo}>
						</div>

						<div class='col-md-4'> <a target='_blank' href=${url} > ${name}</a>
						</div>

						<div class='col-md-4'>Online</div>
						</div>`);
				}

			}); //end of 2nd getJSON
			//end of first else
		}); // end of first getJSON
	}); // end of forEach function

	$("#offline").click(function() {
		$(".onAcc").hide();
		
		$(".offAcc").show();
		
	});

	$("#online").click(function() {
		$(".offAcc").hide();
		$(".closed").hide();
		$(".onAcc").show();

	});

	$('#all').click(function() {
		$('.all').show();
		
	}); // toggle function

}); // end jquery function

/*if you use hide/show on the container which has all streamers as its children, they will be all gone because of the html structure.
If you hide a html element, also its child elements will be hidden (Since the hidden main element is a container holding the rest)
So if you want to hide only some of the children, there needs to be some identifier on the elements to target them properly and only hide/show the elements referred to*/

/*Don't use id="streamers" for every streamer - IDs need to be unique. But you can do something like class="row offline" (use a variable for offline/online/closed)*/
            
          
!
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