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.

            
              <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
Loading ..................

Console