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

              
                <!-- Container Div -->
<div class="container">
  
  <!-- Twitch-Box DIV -->
  <div class="twitch-box">
    <!-- CONTENT DIV -->
    <div class="content">
      
      <!-- Twitch-Banner DIV -->
      <div class="twitch.banner">
      <img src="http://i65.tinypic.com/bi16dz.png" alt="Twitch.TV Banner">
      </div><!-- Twitch-Banner END -->
      
      <!-- STATUS-BUTTONS DIV -->
      <div class="status-buttons">
        <a id="all-button" class="button">All</a>
        <a id="online-button" class="button">Online</a>
        <a id="offline-button" class="button">Offline</a>
      </div><!-- STATUS-BUTTONS END -->
      
      <!-- Online -->
      <div class="online">
        
      </div><!-- STREAMERS DIV END -->
      
      <div class="offline">
        
      </div>
      
    </div><!-- Content END -->
  </div><!-- Twitch-Box END -->
  
</div><!-- Container END -->
              
            
!

CSS

              
                /* BODY */
body {
  background-color: #6441A5;
  font-family: arial, sans-serif;
}

/* TWITCH-BOX DIV */
.twitch-box {
  max-width: 750px;
  background-color: white;
  border-radius: .5%;
  margin: 0 auto;
  margin-top: 25px;
}

.twitch-box img {
  max-width: 100%;
}

/* CONTENT DIV */
.content {
  max-width: 650px;
  padding: 25px;
  margin: 0 auto;
}

/* BUTTONS */
.status-buttons {
  text-align: center;
  margin-top: 15px;
  margin-bottom: 15px;
}

.button {
  padding-top: 15px;
  padding-bottom: 15px;
  background-color: #6441A5;
  border-radius: 3%;
  margin: 0px 15px 0px 15px;
  color: white;
  cursor: pointer;
}

.button:hover {
  opacity: 0.8;
}

/* INDIVIDUAL BUTTONS */
#all-button{
  padding-right: 40px;
  padding-left: 40px;
}
#online-button{
  padding-right: 25px;
  padding-left: 25px;
}
#offline-button{
  padding-right: 25px;
  padding-left: 25px;
}

/* BUTTON MEDIA QUERIES TO MAKE RESPONSIVE */
@media(max-width:460px) {
  .button{
    margin: 0;
  }
}

@media(max-width:370px) {
  .status-buttons {
    margin-top: 25px;
  }  
  #all-button{
  padding-right: 25px;
  padding-left: 25px;
  }
  #online-button{
    padding-right: 10px;
    padding-left: 10px;
  }
  #offline-button{
    padding-right: 10px;
    padding-left: 10px;
  }
}

/* STREAMERS (RESULTS) DIV */
.online {
  margin-top: 35px;
}

/* ONLINE USERS */
.online-user {
  background-color: white;
  border-radius: 1%;
  width: 95%;
  padding: 10px;
  margin: 5px;
  overflow: hidden;
  color: #6441A5;
}

.online-user:hover {
  background-color: #6441A5;
  cursor: pointer;
  color: white;
}

/* OFFLINE USERS */
.offline-user {
  background-color: lightgrey;
  border-radius: 1%;
  width: 95%;
  overflow: hidden;
  padding: 10px;
  margin: 5px;
  color: #6441A5;
}

.offline-user:hover {
  background-color: #6441A5;
  cursor: pointer;
  color: white;
}

.streamer-logo img {
  width: 100px;
  border-radius: 50%;
}

/* ONLINE/OFFLINE DIV MEDIA QUERIES */
@media(max-width: 785px) {
  .online-user {
    padding: 2px;
    margin: 0;
  }
  
  .offline-user {
    padding: 2px;
    margin: 0;
  }
}

/* INDIVIIDUAL RESULT DIVS */
.streamer-logo {
  float: left;
  width: 20%;
}

.streamer-name {
  float: left;
  text-align: center;
  padding-top: 30px;
  width: 35%;
}

.streamer-status {
  float: left;
  text-align: center;
  width: 45%;
  padding-top: 10px;
}

/* REMOVE IMAGE AND ADJUST FONT WHEN WINDOW IS RESIZED TO 590PX */
@media(max-width: 590px) {

  .streamer-logo {
    display:none;
  }
  
  .streamer-name {
    width: 30%;
    text-align: left;
    padding-top: 20px;
  }
  
  .streamer-status {
    width: 70%;
    font-size: .8em;
  }
  
}

              
            
!

JS

              
                function getStreamers() {
  
  var streamers = [
    "forsenlol",
    "freecodecamp",
    "sodapoppin",
    "ice_poseidon",
    "imaqtpie",
    "towelliee",
    "reckful",
    "emilycc",
    "watchmeblink1",
    "woundman",
    "vallcor",
    "rioting_ruby",
    "sjow",
    "kaceytron",
    "gdhayward",
    "summit1g",
    "lirik"
];
  
streamers.sort();
  
  // "A" FOR LOOP
  for(var a = 0; a < streamers.length; a++) {
    //API URL to get Channel Info
    var twitchDataURL = 'https://api.twitch.tv/kraken/channels/' + streamers[a] + "?client_id=5d4ufb3tx5irs1dmbv2j3jakdv14xqd";
    
    //AJAX Call to Twitch to get Channel Info
     $.ajax({
      type: "GET",
      url: twitchDataURL,
      headers: {
        "Client-ID": "5d4ufb3tx5irs1dmbv2j3jakdv14xqd"
      },
      success: function(channelData){
        
      //Gets Name from previous JSON response
      var twitchOnlineURL = 'https://api.twitch.tv/kraken/streams/' + channelData.name + "?client_id=5d4ufb3tx5irs1dmbv2j3jakdv14xqd";
      
    //Ajax call to see if streamer is online
    $.ajax({
      type: "GET",
      url: twitchOnlineURL,
      headers: {
        "Client-ID": "5d4ufb3tx5irs1dmbv2j3jakdv14xqd"
      },
      success: function(onlineData){

      if(onlineData.stream !== null) {
        displayOnline(channelData);
     } else {
       displayOffline(channelData);
     }    
        
      } // 2nd ajax success function bracket end
       
    }); // 2nd ajax call end
        
  } // success function bracket end
       
}); // MAIN DATA ajax bracket end
    
} // "A" for loop Bracket end
  
} // getStreamers() bracket end

getStreamers();

// displayOnline function
function displayOnline(channelData) {
  var resultHTML = "";

  // Streamer Logo Div
    resultHTML += "<a class='online-link' href='https://www.twitch.tv/" + channelData.name + "' target='_blank'>";
    resultHTML += "<div class='online-user'>";
  resultHTML += "<div class='twitch-result'>";
     
  // Streamer Profile Image
  resultHTML += "<div class='streamer-logo'>";
  resultHTML += "<img src='" + channelData.logo + "' alt='" + channelData.name + " logo'>";
  resultHTML += "</div>";

  // Streamer Name Div
  resultHTML += "<div class='streamer-name'>";
  resultHTML += "<p>" + channelData.display_name + "</p>";
  resultHTML += "</div>";

  //Streamer Status Div
  resultHTML += "<div class='streamer-status'>";
  resultHTML += "<p class='online-stream-status' style='padding-top: 15px'>" + channelData.status + "</p>";
  resultHTML += "</div>";
 
  resultHTML += "</div>";
  resultHTML += "</div></a>";

  $(".online").append(resultHTML);
}

// displayOffline function
function displayOffline(channelData) {
  var resultHTML = "";

  // Streamer Logo Div
    resultHTML += "<a class='offline-link' href='https://www.twitch.tv/"+channelData.name+"' target='_blank'>";
    resultHTML += "<div class='offline-user'>";
  resultHTML += "<div class='twitch-result'>";
  
  // Streamer Profile Image
  resultHTML += "<div class='streamer-logo'>";
  resultHTML += "<img src='" + channelData.logo + "' alt='" + channelData.name + " logo'>";
  resultHTML += "</div>";

  // Streamer Profile Name Div
  resultHTML += "<div class='streamer-name'>";
  resultHTML += "<p>" + channelData.display_name + "</p>";
  resultHTML += "</div>";

  //Streamer Profile Status Div
  resultHTML += "<div class='streamer-status' style='padding-top:30px'>";
  resultHTML += "<p>Offline</p>";
  resultHTML += "</div>";
 
  resultHTML += "</div>";
  resultHTML += "</div></a>";;

  $(".offline").append(resultHTML);
}

// BUTTON FUNCTIONS
//ALL BUTTON
$("#all-button").on("click", function(){
  $(".online-user").css("display", "block");
  $(".offline-user").css("display", "block");
});

//ONLINE BUTTON
$("#online-button").on("click", function(){
  $(".online-user").css("display", "block");
  $(".offline-user").css("display", "none");
});

//OFFLINE BUTTON
$("#offline-button").on("click", function(){
  $(".online-user").css("display", "none");
  $(".offline-user").css("display", "block");
});
              
            
!
999px

Console