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.

            
              <div class="tabs is-medium is-centered">
  <ul>
    <li id="all" class="is-active"><a onclick="allClicked()">All</a></li>
    <li id="online"><a onclick="onlineClicked()">Online</a></li>
    <li id="offline"><a onclick="offlineClicked()">Offline</a></li>
  </ul>
</div>

<div class="columns is-multiline">
  <div id="notifications" class="container">
  </div>
</div>

<div class="columns is-multiline">
  <div id="channel-list" class="column is-half is-offset-one-quarter">
  </div>
</div>
            
          
!
            
              .card {
  margin-top: 1em;
}

.online {
  background-color: #2ecc71;
}

.offline {
  background-color: #ecf0f1;
}
            
          
!
            
              let twitterEndpoint = 'https://cors-anywhere.herokuapp.com/https://wind-bow.gomix.me/twitch-api';

let list = 'all';
let channels = [
  'ESL_SC2',
  'OgamingSC2',
  'cretetion',
  'freecodecamp',
  'habathcx',
  'RobotCaleb',
  'noobs2ninjas',
  'clickerheroesbot',
];

function createWarning(msg) {
  return $(`<div class="notification is-warning">${msg}</div>`);
}

function createCard(isOnline, data) {
  
  let card = `<div class="card is-fullwidth ${isOnline ? 'online' : 'offline'}">
          <div class="card-content">
            <div class="media">
              <div class="media-left">
                <figure class="image is-32x32">
                  <img src="${data.logo}">
                </figure>
              </div>
              <div class="media-content">
                <p class="title is-5">
                  ${data.display_name}
                </p>
                <p class='subtitle is-6'>
                  <a href="${data.url}">@${data.name}</a>
                </p>
              </div>
            </div>
          <div class="content"></div>
          ${data.status ? data.status : '<em>No status.</em>'} 
      </div>
    </div>`;

  return $(card);
}

function setActive(id) {
  $('#notifications').empty();
  $('#channel-list').empty();

  $('#all').removeClass('is-active');
  $('#online').removeClass('is-active');
  $('#offline').removeClass('is-active');

  $('#' + id).addClass('is-active');
}

function listChannel(isOnline, name) {
  $.getJSON(twitterEndpoint + '/channels/' + name + '/', function(data) {
    if (data.status === 404) {
      var warning = createWarning(data.message);
      $('#notifications').append(warning);
      return;
    }
    var card = createCard(isOnline, data);
    $('#channel-list').append(card);
  });
}

function updateList() {
  channels.forEach(function(channel) {
    $.getJSON(twitterEndpoint + '/streams/' + channel + '/', function(data) {
      if (data.stream) {
        // channel is online
        if (list === 'online' || list === 'all') {
          listChannel(true, channel);
        }
      } else {
        // channel is offline
        if (list === 'offline' || list === 'all') {
          listChannel(false, channel);
        }
      }
    });
  });
}

function allClicked() {
  list = 'all';
  setActive('all');
  updateList();
}

function onlineClicked() {
  list = 'online';
  setActive('online');
  updateList();
}

function offlineClicked() {
  list = 'offline';
  setActive('offline');
  updateList();
}

$(document).ready(function() {
  updateList();
});

            
          
!
999px
Loading ..................

Console