css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .container
  h1 FCC on Twitch.TV
  .ui.top.attached.tabular.menu
    a(data-tab="first").item.active#all All Users
    a(data-tab="second").item#online Online
    a(data-tab="third").item#offline Offline
  .ui.bottom.attached.active.tab.segment(data-tab="first")#tab-one
    .ui.centered.link.cards#all-users     
  .ui.bottom.attached.tab.segment(data-tab="second")#tab-two
    .ui.centered.link.cards#online-users
  .ui.bottom.attached.tab.segment(data-tab="third")#tab-three
    .ui.centered.link.cards#offline-users


            
          
!
            
              body
  color #6441A5
  padding 4em
  a
    text-decoration none
  .container
    margin 0 auto
    width 80%
    h1
      text-align center
      font 300 3em 'Open Sans'
    #all,
    #online,
    #offline
      &:hover
        cursor pointer
            
          
!
            
              $ ->
  ## Array of Free Code Camp channels on Twitch.TV
  channels = [
    "ESL_SC2", 
    "OgamingSC2", 
    "cretetion", 
    "freecodecamp", 
    "storbeck", 
    "habathcx", 
    "RobotCaleb", 
    "noobs2ninjas"
  ]
   
    
  ## Call on the Twitch.TV API to retrieve channel information
  twitchChannels = ->
    baseURL = 'https://wind-bow.gomix.me/twitch-api'
    ## Twitch.TV API channel call
    twitchChannelsURL = baseURL + '/channels/'   
    ## Iterate over each channel
    $.each channels, (key, value) ->
      ## For each channel make an API call
      $.ajax 
        dataType: 'jsonp'
        url: twitchChannelsURL + value
        crossDomain: true
        success: (data) ->
        ## Channel data
          name = data.display_name
          description = data.game
          logo = data.logo
          url = data.url
          views = data.views
          followers = data.followers
          status = data.status
          
          ## Set of default values if certain data is not available
          if logo == null 
            logo = 'https://unsplash.it/500?image=0'
          if description == null
            description = 'Programming'
          if status == 422
            description = 'No longer a user on Twitch.tv'
            name = value
            logo = 'https://unsplash.it/500?image=0&blur'
            followers = ''
            views = ''
            url = '#'
          
          ## For each channel create a card that includes the data retreived
          $('#all-users')
            .append '<div class="card" id='+name+'>
                        <a class="image" href='+url+' target="_blank">
                          <img src='+logo+' >
                        </a>
                        <div class="content">
                          <div class="header">'+name+'</div>
                          <div class="description">
                            '+description+'
                          </div>
                        </div>
                        <div class="extra content">
                          <i class="unhide icon"></i>
                          '+views+'
                          &nbsp;
                          <i class="user icon"></i>
                          '+followers+'
                        </div>
                      </div>'
            return
          return
       return
  
  ## Use the Twitch.TV streams API to check whether the channel is live
  twitchStreams = ->
    ## Twitch.TV API streams call
    twitchStreamsURL = 'https://api.twitch.tv/kraken/streams/'
    ## Iterate over each channel
    $.each channels, (key, value) ->
      ## For each channel make an API Call
      $.ajax 
        dataType: 'jsonp'
        url: twitchStreamsURL + value
        crossDomain: true
        success: (data) ->
        ## Stream data
          if data['stream'] == null
            $('#'+value).addClass 'red'
            $('#'+value).clone().appendTo $('#offline-users')
            return
          else if data.status == 422
            $('#'+value).addClass 'yellow'
            return
          else
            $('#'+value).addClass 'green'
            $('#'+value).clone().appendTo $('#online-users')
            $('#'+value+' .description')
              .replaceWith('<div class="description">' + data.stream.channel.status + '</div>')
          return
       return
  
  ## Tabs
  tabs = ->
    
    allTab = ->
      $('#all').click ->
        $('#all').addClass 'active'
        $('#offline').removeClass 'active'
        $('#online').removeClass 'active'
        $('#tab-one').addClass 'active'
        $('#tab-two').removeClass 'active'
        $('#tab-three').removeClass 'active'
        return
      return

    onlineTab = ->
      $('#online').click ->
        $('#online').addClass 'active'
        $('#all').removeClass 'active'
        $('#offline').removeClass 'active'
        $('#tab-one').removeClass 'active'
        $('#tab-two').addClass 'active'
        $('#tab-three').removeClass 'active'
        return
      return

    offlineTab = ->
      $('#offline').click ->
        $('#offline').addClass 'active'
        $('#all').removeClass 'active'
        $('#online').removeClass 'active'
        $('#tab-one').removeClass 'active'
        $('#tab-two').removeClass 'active'
        $('#tab-three').addClass 'active'
        return
      return
    
    allTab()
    onlineTab()
    offlineTab()
  
  twitchChannels()
  twitchStreams()
  tabs()
    
  return
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console