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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 lang="en">
<head>
  <meta charset="utf-8">

  <title>Twitch TV</title>
  <meta name="description" content="The HTML5 Herald">
  <meta name="author" content="SitePoint">
  <!-- Latest compiled and minified CSS -->

   
  <!-- Optional theme -->
  
  <link href="https://fonts.googleapis.com/css?family=Raleway|Ubuntu" rel="stylesheet">
  
  <!-- Latest compiled and minified JavaScript -->
  
  
  <link rel="stylesheet" href="style.css?v=1.0">

  <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
    <![endif]-->
  </head>

  <body>
    <div class="container-fluid">       
      <div class="container bg">
        <div class="row">  
          <div class="col-lg-8 col-lg-offset-2 text-center">
            <h2 >Twitch TV</h2>
            <input id="searchBox" placeholder="Searching...?" type="text"/> 
            <div class="btn-status">
              <button class="btn btn-primary" id="bAll" type="button" >All <span class="badge">0</span></button>
              <button class="btn btn-success" id="bOnline" type="button">Online <span class="badge">0</span></button>
              <button class="btn btn-default" id="bOffline" type="button">Offline <span class="badge">0</span></button>               
            </div><!-- end button status -->
          </div><!-- /.col-lg-6 -->
        </div><!-- /.row -->

        <div class="row">  
          <div class="col-md-12">
            <div class="display-user">
              
              
            </div> <!-- end Display user -->           
        </div><!-- /.row -->
        </div>
      </div> <!-- end container -->   
      </div> <!--  end container fluid      -->
      <script src="script.js"></script>
    </body>
    </html>
              
            
!

CSS

              
                body {
	margin-top: 0;	
	background: #E5E5E5;	
	font-family: 'Ubuntu', sans-serif;
} 
h4{
	font-family: 'Ubuntu', sans-serif;
}
h2{
	font-family: 'Raleway', sans-serif;
} 
 
 .btn-status {
 	margin-top: 10px;
 	font-family:'Raleway', sans-serif;
 }
 .display-user {
 	margin-top: 20px;
 }
 
              
            
!

JS

              
                $(document).ready(function(){
	//var alls;

	var twitchUsernameinfo=[];
	var twitchUserOnline=[];
	var twitchUsername = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", 
	"habathcx", "RobotCaleb", "noobs2ninjas","Reckful", "noobs2ninjas",
	"sodapoppin","ProLeagueCSGO","C9Sneaky","YoDa",
	"reynad27","LIRIK","ESL_BiDa"];
	twitchUsername.sort();
	//Getting some user infor
	// var userInfo=[1]; 
	// var channel ={};
	 
	//  for (var i = 0; i < twitchUsername.length; i++) {

	// 	$.ajax({
	// 		url:'https://api.twitch.tv/kraken/users/'+ twitchUsername[i],
	// 		dataType:'jsonp', 
	// 		type:'get',
	// 		success:function(data){				 			 
	// 	 		// userInfo.push(data);
	// 	 		var userInfo=[]; 
	// 	 		var obj = JSON.stringify(data);		
	// 	 		userInfo.push(obj); 		
	// 		} 

	// 	});

	//  }	
 
	//  console.log(typeof(userInfo[1])); 
  

 
	 

	//Make above array into string each to use in jquery
	var userList="";
	for(var i =0 ; i< twitchUsername.length; i++){
		userList+= twitchUsername[i]+',';
	}
  
	$.ajax({
		url:'https://api.twitch.tv/kraken/streams/',		
		data:{channel:userList},		
		dataType:'jsonp',
		type:'get',
		success:function(data){	 
			var allChName=[];		 
			var online=[];
			var offline=[];
			var onlineUser =  data.streams;
			//console.log(data.streams);

			//console.log(onlineUser);
			var onl=onlineUser.length; //display onl on button
			for(var i=0 ; i< data.streams.length ; i++){
				allChName[i]= data.streams[i].channel.display_name;		
			}

			//c
			var test=[];
			//sort All name
			allChName.sort();
			// var str = allChName.join('');
			// var str1 = twitchUsername.join('');
			
			function removeSameElement(arr){
			 	for(var i=0 ; i< allChName.length ; i++){
					arr = arr.filter(function(val){
						return val !== (allChName[i]);
					});
				}
				return arr;

			 }
			test = removeSameElement(twitchUsername);

			console.log("All User: ");
			console.log(twitchUsername);	
			console.log("All channel: ");
			console.log(allChName);
			console.log("Test: ");
			console.log(test);
			 


			//Find offline users
					 
			
			// Put Online And Offline in one object
			var allUsers=[];
			var displayNameForSearchBox=[];
			for(var k=0 ; k< onlineUser.length ;k++){
				allUsers[k] = onlineUser[k];
				 
			} 
			//console.log(twitchUsername);

			var m =allUsers.length;
			for(var l=0 ; l< offline.length ; l++){
				allUsers[m] = offline[l];
				m++;
			}
			//=====Show number of all online offline in buttons
			var numberToDisplayOnStatusButton = function(eleId, stat){
				var tagName = document.getElementById(eleId).getElementsByTagName('span');				 	 
				return $(tagName).html(stat);				 
			}

			numberToDisplayOnStatusButton('bAll',allUsers.length);
			numberToDisplayOnStatusButton('bOnline',onl);
			numberToDisplayOnStatusButton('bOffline',offline.length);
			//=========================================================	
	 
	 
		 // Search box -------------------------------------------
		 // end search box ---------------------------------------
		 
			// Display ALL USERS----------------------------------------------
		 
			var html;
			$('#bAll').on("click",function(){
				$("searchBox").html('');
				html="";				 
			  	html+='<div class="row">';					 
				html+='<div class="col-md-8 col-md-offset-2"><table class="table">';
				html+='<tr><th>Logo</th><th>Name</th><th>Game</th><th>Status</th></tr>';

				for(var n = 0 ; n < allUsers.length; n++){	 					
 					html+='<tr><td><img class="img-circle" width="70" src="'+allUsers[n].channel.logo+'" alt="..."></td><td><a target="_blank" href="https://www.twitch.tv/'+ allUsers[n].channel.display_name + '">'+ allUsers[n].channel.display_name + '</a></td><td>'+ allUsers[n].game+'</td><td>Online</td></tr>';
				}	 
				html+='</table></div>';					
			 	 
				$('.display-user').html(html);
			});//End all user

			
// ONLINE USER--------------------------------------------
			$('#bOnline').on("click",function(){	
				searchTitle="";			   
					html="";				 
				  	html+='<div class="row">';					 
					html+='<div class="col-md-8 col-md-offset-2"><table class="table">';
					html+='<tr><th>Logo</th><th>Name</th><th>Game</th><th>Status</th></tr>';

					for(var n = 0 ; n < onlineUser.length; n++){	 					
	 					html+='<tr><td><img class="img-circle" width="70" src="'+onlineUser[n].channel.logo+'" alt="..."></td><td><a target="_blank" href="https://www.twitch.tv/'+ onlineUser[n].channel.display_name + '">'+ onlineUser[n].channel.display_name + '</a></td><td>'+ onlineUser[n].game+'</td><td>Online</td></tr>';
					}	 
					html+='</table></div>';
 					html+='</div>';//Close Row 	 
				$('.display-user').html(html);
				 
			});
			//==============OFFLINE user
			$('#bOffline').on("click",function(){		 
				
				html="";				 
				  	html+='<div class="row">';					 
					html+='<div class="col-md-8 col-md-offset-2"><table class="table">';
					html+='<tr><th>Logo</th><th>Name</th><th>Game</th><th>Status</th></tr>';
					for(var n = 0 ; n < offline.length; n++){	 					
	 					html+='<tr><td><img class="img-circle" width="70" src="'+offline[n].channel.logo+'" alt="..."></td><td><a target="_blank" href="https://www.twitch.tv/'+ offline[n].channel.display_name + '">'+ offline[n].channel.display_name + '</a></td><td>Not available</td><td>Offine</td></tr>';
					}	 
					html+='</table></div>';
 					html+='</div>';//Close Row 					
		 
				$('.display-user').html(html);
			 			 

			});
		}//End Success 

	});
	
	
});// END OF document.ready
              
            
!
999px

Console