css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              

<div>

   <section class='body'> 
     
     
    
  </section>
  
  <br>
  <section class='body2' id='bod2'>
   
    
  </section>
  <br>
  <section class='body3'>
    

    
  </section>
  
  <section class='body4'> 

    
  </section>
  
  <section class='body5'> 

   
  </section>
  
   <section class='body6'> 

   
  </section>
  
   <section class='body7'> 

    
  </section>
  
  <section class='body8'> 

    
  </section>
  
   <section class='body9'> 

     
     
  </section>
  
</div>

            
          
!
            
              $(document).ready(function() {

  var stream2 = [];
  var stream3 = [];
  var memChannel = [];

  //Array of users.
  var members = ["Twitch", "ESL_SC2", "OgamingSC2", "storbeck", "RobotCaleb", "FreeCodeCamp", , "noobs2ninjas", "sheevergaming", "comster404", "thomasballinger", "terakilobyte", "Test_channel", "brunofin", "xbox", "Nathanias", "cretetion", "habathcx"];

  var body = $('.body');
  var body2 = $('.body2');
  var body3 = $('.body3');
  var body4 = $('.body4');
  var body5 = $('.body5');
  var body6 = $('.body6');
  var body7 = $('.body7');

  var t = 0;
  var j = 0;
  var d;
  var memLength = members.length;

  //var i = 0;

  var stream = [];
  for (var j=0; j < members.length; j++)
    $.getJSON('https://api.twitch.tv/kraken/streams/' + members[j], function(data) {

      //Push list of users that are currently streaming into array.

      body.append("<br>" + data.stream.channel.display_name.link("https://www.twitch.tv/" + data.stream.channel.display_name) + "is currently streaming" + data.stream.game + data.stream.channel.status + "on Twitchtv." + "<br>");
      $.each(data, function(j) {
          stream.push(data.stream.channel.display_name);
        }
      )
    })
    //When currently streaming users have     been added to array, proceed to next       task.

 
  for (var y=0; y < members.length; y++) {
    $.getJSON('https://api.twitch.tv/kraken/channels/' + members[y], function(data2) {

      //Push all users with active TwitchTV account into 'memChannel' array.            
      memChannel.push(data2.display_name);
    })
  }
  var i = 0;
 $.when($.getJSON('https://api.twitch.tv/kraken/streams/' + members[members.length - 1]).then(function() {

      for (var i=0; i < members.length; i++)

      // members[members.length-1]  
        $.getJSON('https://api.twitch.tv/kraken/channels/' + members[i], function(data3) {

          var stream2 = [];
          var t = 0;
          var trash = [];
 //body2.append(data3.display_name);
          var ee = stream.length;
          //Append number of items in 'stream' array. This is just for me to see when and how it malfunctions, not intended to be in final version.
          body5.append(ee);
          body5.append(stream);
          while (t < stream.length) {

            if (stream[t] != data3.display_name) {

              if (data3.display_name === 'Undefined') {

                //If an item named 'Undefined' passes through, keep it out of primary arrays.
                trash.push(data3.display_name);

              } else
                stream2.push(data3.display_name.link("https://www.twitch.tv/" + data3.display_name) + "is not currently streaming" + "<br>");
            }
            t++;
          }          body6.append(stream2[stream.length - 1]);

          //Acquire total number of inactive accounts in 'members' array by subtracting number of active accounts from total number of names in array.
          var len = memLength - memChannel.length;

          var index = members.indexOf(data3.display_name);

          //Remove active accounts from 'member' array.
          members.splice(index, 1);

          //Once 'members' has been reduced to the length of its inactive accounts, append said accounts.
          if (len >= members.length - 1) {
 body7.append(members[members.length - 1] + "is not an active account" + "<br>");
          }
        }

      )
    })
  )
})
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console