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.

            
              .container
  h1.text-center Twitch Streamers
  .row#filterBy
    .col-4
      button#btn-all All
    .col-4
      button#btn-online Online
    .col-4
      button#btn-offline Offline
  .row#streamers
    .col-2#logo
      // img(src="https://static-cdn.jtvnw.net/jtv_user_pictures/robotcaleb-profile_image-9422645f2f0f093c-300x300.png")
    .col-10#status
      // p Channel Robot Caleb is currently Offline
            
          
!
            
              /* READ THIS to learn more about promises jquery style, use DONE()
https://stackoverflow.com/questions/16026942/how-do-i-chain-three-asynchronous-calls-using-jquery-promises */
// https://medium.com/coding-design/writing-better-ajax-8ee4a7fb95f

body { background-color: lightblue; }
.container {background-color: lightgrey;}

.container {
  max-width: 700px;
  border: 1px solid black;
}

button { width: 100%; }

[class*="col-"] {
  padding-left: 4px;
  padding-right: 4px;
}
.col-10 {
  max-width: calc(100% - 75px); // offset from iamge size
}

img {
  max-width: 75px; /* so image doesn't expand past col */
  max-height: 75px;
  padding: 5px;
  border-radius: 50%;
}
#status { overflow: hidden}
#logo {min-width: 75px;}
p {
  text-align: center;
  font-size: 1.5rem;
  line-height: 60px;
  text-align: left;
  
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.hide { display: none; }

// Override Min query for bootstrap
@media (max-width: 240px) {
  .col-4 {
    max-width: 100%;
    flex: 0 0 100%;
  }
}


            
          
!
            
              var channels = ["freecodecamp","test_channel","ESL_SC2"];

function getChannelInfo() {
  channels.forEach(function(channel){
    // make URL
    function makeURL (type, name) {
      return 'https://wind-bow.glitch.me/twitch-api/' + type + '/' + name + '?callback=?';
    }
    
    // first chain
    $.getJSON(makeURL("users", channel), function(data1) {
      var logo;
      if(data1.logo==undefined) { 
        logo = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/867725/Image_not_available.png";
      }
      logo = data1.logo;
      
      // second chain, grab stream data
      $.getJSON(makeURL("streams", channel), function(data2) {
        var statusDisplay;
        var statusClass;
        if (data2.stream === undefined) { 
          statusDisplay = "not an account";
          statusClass = "offline";
        }
        else if (data2.stream === null) { 
          statusDisplay = "currently offline";
          statusClass = "offline";
        }
        else { 
          statusDisplay = "currently online";
          statusClass = "online";
        }
        
        // Append Data from global var. Add classes to toggle
        $("#logo").append('<img class="' + statusClass + '" src="' + logo + '"/>');
        $("#status").append('<p class="' + statusClass + '">' + channel + ' is ' + statusDisplay + '</p>')
      });
    });
  });
}

 

$(document).ready(function(){
  getChannelInfo();
  $("#btn-all").click(function(){
    $(".offline,.online").removeClass("hide");
  });
  $("#btn-online").click(function(){
    $(".offline, .online").removeClass("hide");
    $(".offline").addClass("hide");
  });
  $("#btn-offline").click(function(){
    $(".offline,.online").removeClass("hide");
    $(".online").addClass("hide");
  });
});
  
            
          
!
999px
Loading ..................

Console