cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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 lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Twitch.TV JSON App</title>
        <!-- Bootstrap CDN-->
    </head>
    <body>
        <nav class="navbar fixed-top navbar-toggleable-sm navbar-inverse">
              <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
              </button>
              <a class="navbar-brand" href="https://www.twitch.tv/"><i class="fa fa-twitch fa-2x" aria-hidden="true"></i></a>
              <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
                <div class="navbar-nav">
                  <a class="nav-item nav-link" href="#home">Home <span class="sr-only">(current)</span></a>
                  <a class="nav-item nav-link" href="#featured">Featured</a>
                  <a class="nav-item nav-link" href="#search">Search</a>
                  <a class="nav-item nav-link" href="#contact">Contact</a>
                </div>
              </div>
        </nav><!--END OF NAVIGATION-->
        
        <div id="home" class="jumbotron text-center">
            <h1><i class="fa fa-twitch" style="font-size:1.5em;"></i> Twitch.TV App</h1>
        </div>
        
        <div id="featured" class="container">
                <h3 class="headings">Online Featured Channels <i class="fa fa-rss" aria-hidden="true"></i> </h3>
                <div id="titles" class="row">
            </div>   
        </div> <!-- END OF JUMBOTRON-->
    
        <div id="search" class="container-fluid" >
            <div class="container searchContainer">
                <h2>Search for a channel:</h2> 
                <div id="results-error"></div> <!--DISPLAY ERROR MSG-->
                <!-- SEARCH FORM-->
                <div class="row"> 
                  <div class="col-md-12 col-lg-12">
                    <div class="input-group text-center">
                        <input class="form-control" id="input" type="text" name="search" placeholder="eg. free code camp">
                        <span class="input-group-btn">
                            <button id="searchBtn" class="btn btn-warning" type="button">
                                <i class="fa fa-search" aria-hidden="true"></i>
                            </button>
                        </span>
                    </div>
                  </div> 
                </div><!--END OF SEARCH FORM-->
            </div><!--END OF SEARCH BAR CONTAINER-->
            
            <div class="container searchContainer">
                
                <div class = "row">
                    <div class ="col-lg-6 col-md-6 text-center border-left">
                        <div id="results-image"></div>
                    </div>     
                    <div class ="col-lg-6 col-md-6 text-left ">
                            <div id="results-title"></div>
                            <div id="results-followers"></div>
                            <div id="results-status"></div>
                    </div>
                </div>
            </div><!--END OF SEARC CONTAINER FLUID-->
        </div> <!--END OF BODY CONTAINER-->
        
        <div id="contact" class="container-fluid text-center">
            <p>Contact</p>
            <a href="https://github.com/sergrdz7" alt="GitHub" target="_blank"><i class="fa fa-github fa-2x" aria-hidden="true"></i></a>
            <a href="https://www.freecodecamp.com/sergrdz7" alt="FreeCodeCamp" target="_blank"><i class="fa fa-free-code-camp fa-2x" aria-hidden="true"></i></a>
            <a href="https://twitter.com/Serg_io92" alt="Twitter" target="_blank"><i class="fa fa-twitter fa-2x" aria-hidden="true"></i></a>
            <a href="https://codepen.io/serg_92/" alt="Codepen" target="_blank"><i class="fa fa-codepen fa-2x" aria-hidden="true"></i></a>
        </div> <!--END OF CONTACT CONTAINER-->
            
          
!
            
              body{
    padding-top: 55px;
    font-family: 'Source Sans Pro', sans-serif;
    color:#be8ccd;
}
/*Navigation*/
nav{
    background-color: #393939;
}
/*Jumbotron*/
.jumbotron{
    
    background-color:#775881;
    border-radius: 0;
    margin-bottom: -25px;
}
.jumbotron h1{
    color: white;
    font-size: 4em;
    font-weight: bold;
    text-shadow: 3px 3px #b997c4;
}

#featured{
    margin-top: 0; 
    padding-top: 63px;
}

.headings{
    margin-top: 0;
    padding: 0;
    margin-bottom: 30px; 
}
.col-colors{
    padding-top: 10px;
    background-color: white; 
    margin-bottom: 25px;
    border-left: 2px solid #f1c1ff;
    text-align: left: 
}
.col-colors h4{
    font-size: 1.25em;
}
p{
    padding-top: 12px; 
}

/*Customize buttons*/
.btn.outline {
	background: none;
	padding: 10px 20px;
}
.btn-primary.outline {
	border: 2px solid #f1c1ff;
	color: #f1c1ff;
}
.btn-primary.outline:hover, .btn-primary.outline:focus, .btn-primary.outline:active, .btn-primary.outline.active, .open > .dropdown-toggle.btn-primary {
	color: #3f2e44;
	border-color: #3f2e44;
}
.btn-primary.outline:active, .btn-primary.outline.active {
	border-color: #b644db;
	color: #b644db;
	box-shadow: none;
}

/*Search container*/
.searchContainer{
    padding-top: 20px;
    color: #f1c1ff;
    font-size: 16px; 
}
.searchContainer h2{
    padding-bottom: 20px;
    text-decoration: none;    
}
.searchContainer a{
    text-decoration: none;
    color: #f1c1ff;
}
.searchContainer a:hover{
    color: #ae74be;
}
.border-left{
    border-left: 3px solid #f1c1ff; 
}

.container-fluid{
    background-color: #775881;
    padding-bottom: 7px;
}
#contact{
    color: #F0AD4E;
    padding-top: 4px;
    background-color: #393939;
    height: 67px;
    margin-bottom: 0;
}
#contact p{
    padding: 1px 0 1px 0; 
    margin-top: 0;
    margin-bottom: 0;
}
#contact a{
    color: #F0AD4E;
    padding: 0 7px 0 7px;
    text-decoration: none;
}
#contact a:hover{
    color: #af7e39;
    text-decoration: none;
}
.form-control::-webkit-input-placeholder { color: #c2c2c2; }
            
          
!
            
              $(document).ready(function() {
        //GLOABALS
        var url = 'https://api.twitch.tv/kraken/streams/featured';    
        var clientID ="4p0c2fxilivn916bs0dqeie78o8qx3";
        var twitchUrl = "https://api.twitch.tv/kraken/channels?client_id="+clientID;
        
        $.getJSON(url).done(function(data) {  
						console.log(data);
            //LOOP THROUGH FEATURED ARRAY AND STORE TITLES
            for (var i = 0; i < data.featured.length;i++){                
                
                //POPULATE FEATURED CHANNELS HTML(IMAGE THUMBNAILS)        
                $("#titles").append('<div class="text-center col-lg-3 col-md-4 col-sm-6 col-colors"><h4>'+ data.featured[i].title + '</h4><img class=" img-thumbnail" src="' + data.featured[i].image + '"><p class="p-thumbnail">Followers: '+ data.featured[i].stream.channel.followers + '</p><p class="btn-position"><a href="' + data.featured[i].stream.channel.url +'" class="btn btn-primary outline" role="button" target="_blank">Go to channel <i class="fa fa-video-camera" aria-hidden="true"></i></a></p></div>');
            }  
        }).fail(function(data){
					console.log("getJSON not being called");
				});
        
        //GET STREAMING STATUS OF CURRENT CHANNEL    
        function getStatus(channel){
            $.getJSON("https://api.twitch.tv/kraken/streams/"+channel+"?client_id="+clientID).done(function(data2){
                console.log("Status: " + data2.stream);
                if (data2.stream === null) {
                    $("#results-status").prepend('</p>Status: Offline  <i class="fa fa-times-circle" aria-hidden="true"></i></p>');
                   }else {
                    $("#results-status").prepend('</p>Status: Online  <i class="fa fa-check-circle" aria-hidden="true"></i></p>'); 
                   } 
            });
        } 
        
        //USE THIS FUNCTION TO CLEAR DATA FROM SEARCH SECTION    
        function clearInfo(){
            $("#results-title").html('');
            $("#results-image").html('');
            $("#results-followers").html('');
            $("#results-status").html('');
            $("#results-error").html('');
            
        }    
            
        //USE CHANNEL INFO TO UPDATE SEARCH SECTION
        function getChannelInfo(channel){
            $.getJSON("https://api.twitch.tv/kraken/channels/"+channel+"?client_id="+clientID).done(function(data3){
                console.log(data3); 
                $("#results-title").prepend('<a href="'+data3.url+'"><h2>'+data3.display_name+'  <i class="fa fa-video-camera" aria-hidden="true"></i></h2></a>');
                $("#results-image").prepend('<p><img alt="Channel Logo" src="'+data3.logo+'"></p>');
                $("#results-followers").prepend('<p>Followers: '+data3.followers+'   <i class="fa fa-users" aria-hidden="true"></i></p>');
                
                //CHECK STREAMING STATUS OF CURRENT CHANNEL
                getStatus(channel);
                
            })
            //HANDLE JSON CALL ERROR 
            .fail(function(data3){
                console.log(data3);
                $("#results-error").prepend('<p><i class="fa fa-times-circle" aria-hidden="true"></i> Oops! Channel not found, try another one?</p>');
            })
        }
        
        //SEARCH EVENT HANDLER ON CLICK    
        $("#searchBtn").on('click',function(){
            
            var channel = $("#input").val().split(" ").join("");    
            //getStatus(channel);
            clearInfo();
            getChannelInfo(channel);
        });
            
        //SEARCH EVENT HANDLER ON ENTER     
        $("#input").keydown(function(event){
        if(event.keyCode == 13){
            var channel = $("#input").val().split(" ").join("");
            //getStatus(channel);
            clearInfo();
            getChannelInfo(channel);
        }
    });        
});    
            
          
!
999px
Loading ..................

Console