Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="container-fluid">
  <div id="content">
      <div class="title">Twitch TV Streaming
      </div>
      <div id="signature"><i>by Laura Barluzzi</i></div>
    
      <div class="menu">
        <span class="list-item" id="online">ONLINE</span>
        <span class="active list-item" id="all">ALL</span>
        <span class="list-item" id="offline">OFFLINE</span>
      </div><!--menu-->

      <div id="display">    
    
      </div> <!--display-->
  </div> <!--content-->
</div> <!--container-fluid-->
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lobster);

html, body {
  text-align: center;
  background-color: #00162B;
  color: white;
  padding-top: 30px;
}

.container-fluid {
  padding-right: 0px;
  padding-left: 0px;
}

.title {
  font-size: 50px;
  font-family: Lobster;
  width: 100%;
  background-color: #2b0016;
}

#signature {
  font-style: italic;
  color: #EE8D00;
  padding-top: 10px;
  margin-bottom: 30px;
}

.menu {
  margin-bottom: 30px;
}
.menu span {
  font-size: 20px;
  padding: 10px 20px;
  maring: 0px;
  cursor: pointer;
}

.menu span:hover {
  border-style: solid;
  border-color: #D3D3D3;
  text-decoration: underline;
}

.active {
  color: #333;
  background-color: #D3D3D3;
  font-weight: 600;
}

#display {
 display: inline-block; 
}

.line {
  height: 50px;
  width: 600px;
  color: #333;
  margin-top: 10px;
  margin-bottom: 10px;
  padding: 10px 20px;
}

.line:hover {
  border-left-style: solid;
  border-left-color: #EE8D00;
}

#name {
  font-size: 20px;
  font-weight: 600;
  margin: 0px 10px;
  float: left;
  color: #2b0016;
}

.logo {
  max-width: 100%;
  max-height: 100%;
  border-radius: 50%;
  float: left;
  margin-right: 5px;
}

#streaming {
  font-size: 20px;
  font-weight: 500;
  margin: 0px 10px;
  float: right;
  color: #00162B;
  font-style: italic;
}

.online {
  background-color: #a5f29b;
}

.offline {
  background-color: #D3D3D3;
}

              
            
!

JS

              
                function displayHtml(logo, channel_name, description, url, status) {
  console.log("in displayHtml");
  console.log(description);
  console.log("current channel name is: " + channel_name);
  
  var html = '<a href="' + url + '" target="_blank"><div class="line ' + status +'"><img src="' + logo + '" class="logo img-responsive"><span id="name">' + channel_name + '</span><span id="streaming">' + description + '</span></div></a>';

  if (status === "online") {
    $("#display").prepend(html);
  } else {
    $("#display").append(html);
  } 
}

function handleStreamFetch(streamUrl, channelUrl, streamer) {
  return function(data) {
      var description, status;
      
      if (data.stream === null) {
        description = "offline";
        status = "offline";
      }  else {
        status = "online";
        description = data.stream.game + " - " + status;
      };
      
      $.getJSON(channelUrl, function(data) {
        var logo = data.logo;
        var name = data.display_name;
        
        if (name === undefined) {
            name = streamer;
            status = "offline";
            description = "This channel does not exist";
        }
     
        displayHtml(logo, name, description, data.url, status);
      });
    };
}

function getChannelsInfo() {
  console.log("in getChannelsInfo");
  var channels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas", "comster404"];
  
  for (var i = 0; i < channels.length; i++) { 
    var streamUrl = "https://wind-bow.gomix.me/twitch-api/streams/" + channels[i] + "?callback=?";
    var channelUrl = "https://wind-bow.gomix.me/twitch-api/channels/" + channels[i] + "?callback=?";
    var streamer = channels[i];
    
    $.getJSON(streamUrl, handleStreamFetch(streamUrl, channelUrl, streamer));
  }; //for loop
}; // function getChannelsInfo

function filterView(event) {
  
  var clicked = $(event.target);  
  $(".list-item").removeClass("active");
  $(event.target).addClass("active");  
  var status = $(event.target).attr('id');
  
  if (status === "all") {
      $(".online, .offline").removeClass("hidden");
    } else if (status === "online") {
      $(".online").removeClass("hidden");
      $(".offline").addClass("hidden");
    } else {
      $(".offline").removeClass("hidden");
      $(".online").addClass("hidden");
    };  
};

$(document).ready(function() {
  console.log("in ready");
  getChannelsInfo();
  
  $(".list-item").click(filterView);
});
              
            
!
999px

Console