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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div class="container">
  <div class="row">
    <div class="col-xs-12">
      <div class="col-xs-4">
        <span class="pull-right">
          <img class="twitch-logo" src="https://i.imgur.com/9m8R8e2.png"/>
        </span>
      </div>
      <div class="col-xs-6">
        <h2>STREAMERS</h2>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-xs-12 col-md-5 col-lg-5 col-md-push-2 col-lg-push-2">
      <!-- Nav tabs -->
      <ul class="nav nav-tabs" id="myTabs">
        <li class="active"><a class="" href="#online" data-url="/embed/62805/view">Online</a></li>
        <li><a href="#offline" data-url="/embed/62806/view">Offline</a></li>
      </ul>
      <div class="tab-content">
        <div class="tab-pane active" id="online"></div>
        <div class="tab-pane" id="offline"></div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  background-color:#DBC7FD;
  font-family:Helvetica Neue;
}
.pl0 {
  padding-left:0;
}

.container {
  margin:0 auto;
}

.twitch-logo{
  width:130px;
  position:relative;
    top:2.25rem;
    left:2rem;
}
h2 {
  color:#6445A2;
  position:relative;
    top: 1.5rem;
    left:.5rem;
}
strong {
  text-transform: uppercase;
}

.logo {
  height:75px;
  width:75px;
  
}
.userDeets {
  color:#4a4a4a;
  font-family:Roboto;
  text-transform: uppercase;
  text-align:left;
}
.offlineDeets {
  margin-left:2rem;  
}
.gameDeets {
  text-transform: uppercase;
}

.wrapper {
  margin-left:2rem;
  padding-top:2rem;
}

.card {
  display:flex;
}

.card, .offline-card {
background-color:#f3e5f5;
margin-bottom:.5rem;
}

.online-info {
  margin-top:2rem;
  color:black;
}

.nav-tabs {
  margin-top:4rem;
}

.nav-tabs>li>a {
  color:#6445A2;
  font-weight:bold;
}

.nav-tabs>li.active>a, .nav-tabs>li.active>a:focus, .nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:active {
  background-color:transparent;
  border-top:2px solid #6445A2;
  border-left:2px solid #6445A2;
  border-right:2px solid #6445A2;
}
.nav>li>a:hover {
  background-color:transparent;
  font-weight:bold;
}



              
            
!

JS

              
                //API endpoints
var root = "https://wind-bow.glitch.me/twitch-api";
var root2 =
  "https://api.twitch.tv/kraken/channels/freecodecamp/follows?client_id=xg79yiambs1xupljgn3jot22w2fu3z";
var offlineLogo;

//ajax call to channels endpoint
$.ajax({
  url: root2,
  method: "GET"
}).then(function(data2) {
  //loop through followers
  for (var i = 0; i < data2.follows.length; i++) {
    //user display names pushed to follower array
    var displayFollower = data2.follows[i].user.display_name;
    following.push(displayFollower);
  }

  // Loop through following array
  for (var i = 0; i < following.length; i++) {
    var url =
      "https://api.twitch.tv/kraken/streams/" +
      following[i] +
      "/?client_id=xg79yiambs1xupljgn3jot22w2fu3z";

    $.getJSON(url).done(function(data3) {
      if (data3.stream) {
        var logo = data3.stream.channel.logo;
        var userName = data3.stream.channel.display_name;
        var game = data3.stream.channel.game;
        $("#online").tab("show");
        $("#online").append(
          "<div class='card'>" + 
            "<img class='logo' src='" + logo + "'/>" 
          + "<div class='wrapper'><strong>User </strong>" + 
          "<a class='userDeets online-info' href='https://www.twitch.tv/" + userName + "'>"
          + userName +"</a>" +
            "<div class='gameDeets'><strong>Streaming </strong>" +
            game +  "</div></div>"
           
        );
        //if user is not streaming gets username from link property using string method slice
      } else {
        var offlineUserName = data3._links.self;
        var res = offlineUserName.slice(37);
 //api call to users steam to get offline image
        var root3 = "https://api.twitch.tv/kraken/users/" + res;
        $.ajax({
          url: root3,
          headers: {
            "Client-ID": "xg79yiambs1xupljgn3jot22w2fu3z"
          },
          method: "GET"
        }).then(function(data4) {
        offlineLogo = data4.logo;
           $("#offline").append(
          "<div class='offline-card'><img class='logo' src='" + offlineLogo + "'/>"+ "<a class='userDeets offlineDeets' href='https://www.twitch.tv/" + res + "'>" + res + "</a></div>"
        );
        });
      }
    });
  }
});

//Array of users
var following = [
  "ESL_SC2",
  "xbox",
  "freecodecamp",
  "opl",
  "rocketleague",
  "kaitlyn",
  "capcomfighters",
  "the_t",
  "lirik"
];

///LOADS FIRST TAB
$("#myTabs a").click(function(e) {
  e.preventDefault();

  var url = $(this).attr("data-url");
  var href = this.hash;
  var pane = $(this);

  // ajax load from data-url
  $(href).load(url, function(result) {
    pane.tab("show");
  });
});

// load first tab content
$("#online").load($(".active a").attr("data-url"), function(result) {
  $(".active a").tab("show");
});

              
            
!
999px

Console