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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

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

CSS

              
                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;
}
              
            
!

JS

              
                $(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

Console