cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <body>
  <div class="container">

    <h1 class="title">Twitch Channels</h1>

    <div class="menu">
      <div class="selector active" id="all">
        <div class="circle-all"></div>
        <p>All</p>
      </div>
      <div class="selector" id="online">
        <div class="circle-online"></div>
        <p>Online</p>
      </div>
      <div class="selector" id="offline">
        <div class="circle-offline"></div>
        <p>Offline</p>
      </div>
    </div>

  </div>
  <div class="container">
    <div id="display">
    </div>
  </div>

  </div>

  </div>
  <div id="footer">
    Inspired by FreeCodeCamp, coded by Alexandre ROBIN</div>
</body>
            
          
!
            
              body {
  background-color: #1B5E20;
}

.title {
  text-align: left;
  padding: 50px;
  color: white;
  text-transform: uppercase;
}

.container {
  background-color: #1B5E20;
  margin: 0 auto;
  padding: 0;
  max-width: 700px;
}

.row {
  margin: 2px 0;
  padding: 5px;
  line-height: 50px;
}

.logo {
  max-width: 50px;
  max-height: 50px;
  border-radius: 50%;
  border: 3px solid #4CAF50;
}

#name,
#streaming {
  line-height: 25px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
}

#streaming {
  font-style: italic;
}

.offline {
  background-color: #E8F5E9;
}

.online {
  background-color: white;
}

.channel {
  border: 2px solid #E8F5E9;
  border-radius: 10px;
}


/* selector from FCC codepen : https://codepen.io/freeCodeCamp/pen/Myvqmo */

.menu {
  position: absolute;
  right: 0px;
  bottom: 5px;
  color: black;
  font-size: 0.5em;
  font-weight: bold;
  text-transform: uppercase;
}

.circle-online {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: green;
  border: 1px solid green;
  float: left;
  margin: 5px 5px 5px 0px;
}

.circle-offline {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: red;
  border: 1px solid red;
  float: left;
  margin: 5px 5px 5px 0px;
  ;
}

.active,
.selector:hover {
  width: 65px !important;
  transition: $grow;
  cursor: pointer;
}

.selector {
  line-height: 20px;
  height: 20px;
  background-color: white;
  padding: 0px 5px;
  margin: 2px 0px;
  width: 20px;
  overflow: hidden;
  float: right;
  clear: right;
}

.circle-all {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: black;
  border: 1px solid black;
  float: left;
  margin: 5px 5px 5px 0px;
}

p {
  float: right;
  margin: 0px;
}

#footer {
  padding-top: 50px;
  text-align:center;
}
.hidden{
  display:none;
}
            
          
!
            
              /*Adress to use for calling Twitch API. 2 arguments : type & name 
          https://wind-bow.gomix.me/twitch-api/type/name?callback=?*/

var channels = [{
  name: "ESL_SC2",
  game: undefined,
  status: undefined,
}, {
  name: "OgamingSC2",
  game: undefined,
  status: undefined,
}, {
  name: "cretetion",
  game: undefined,
  status: undefined,
}, {
  name: "freecodecamp",
  game: undefined,
  status: undefined,
}, {
  name: "storbeck",
  game: undefined,
  status: undefined,
}, {
  name: "habathcx",
  game: undefined,
  status: undefined,
}, {
  name: "RobotCaleb",
  game: undefined,
  status: undefined,
}, {
  name: "noobs2ninjas",
  game: undefined,
  status: undefined,
}];

//We set our global function :
function getInfo() {
  //We look into our array channels and get data for each channel
  channels.forEach(function(c) {
    var channel = c.name;
    //We set our URL API call with our two arguments
    function makeURL(type, channel) {
      return 'https://wind-bow.gomix.me/twitch-api/' + type + '/' + channel + '?callback=?';
    };
    console.log(makeURL('streams', channel));
    $.getJSON(makeURL('streams', channel), function(json) {
      $.getJSON(makeURL("channels", channel), function(json) {
        var logo = json.logo != null ? json.logo : "http://amr-asso.com/wp-content/uploads/2014/11/avatar-johndoe.png";
        var name = json.display_name != null ? json.display_name : channel;
        var description = c.status === "online" ? ': ' + json.status : "";
        var url = json.url;
        var html = '<div class="channel row ' +
          c.status + '"><div class="col-xs-2 col-sm-1" id="icon"><img src="' +
          logo + '" class="logo"></div><div class="col-xs-10 col-sm-3" id="name"><a href="' +
          url + '" target="_blank">' +
          name + '</a></div><div class="col-xs-10 col-sm-8" id="streaming">' +
          c.game + '<span class="hidden-xs">' +
          description + '</span></div></div>';
        c.status === "online" ? $("#display").prepend(html) : $("#display").append(html);

      });

      //We have all the data stored into JSON, we want to know the game title and the status of the channel : online or offline
      //console.log(json.stream);
      if (json.stream === null) {
        c.game = "Offline";
        c.status = "offline";
      } else if (json.stream === undefined) {
        c.game = "Account Closed";
        c.status = "offline";
      } else {
        c.game = json.stream.game;
        c.status = "online";
      };
    });

  });
};

// });
$(function() {
  getInfo();
  $(".selector").click(function() {
    $(".selector").removeClass("active");
    $(this).addClass("active");
    var status = $(this).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");
    }
  })
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console