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

              
                <head>
  <meta name="viewport" content="width=device-width.initial-scale=1">
  <link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=//" rel="stylesheet">
</head>

<body>
  <div class='container'>
    <div class='spacer'></div>
    <div class='title-block'>
      <div class="title">Twitch Viewer</div>
      <a href='https://www.twitch.tv/freecodecamp' class="undertitle" target='blank'><h3>FreeCodeCamp<span id='fcc'> ...</span></h3></a>
    </div>

    <div class='spacer'></div>

    <div class='block'>
      <div class='row'>
        <div class='col-md-4' id='user'>
          <strong>USER:<p>&nbsp;</p></strong><br>
        </div>

        <div class='col-md-4' id='status'>
          <strong>STATUS:<p>&nbsp;</p></strong><br>
        </div>

        <div class='col-md-4' id='game'>
          <strong>GAME:<p>&nbsp;</p></strong><br>
        </div>

      </div>
    </div>

    <div class='spacer'></div>

  </div>
</body>
              
            
!

CSS

              
                @media screen and (min-width: 766px) {

.title{
  font-size: 26px;
  font-family: 'Press Start 2P', cursive;
  font-weight: bold;
  padding-bottom: 10px;
}  

.undertitle{
  font-size: 22px;
  font-style: Arial;
  color: #492375;
} 

.title-block {
    background-color: white;
    opacity: .9;
    color: black;
    width: 50%;
    margin-right: auto;
    margin-left: auto;
    border: 0px solid black;
    border-radius: 1px;
    font-size: 1.5em;
    text-align: center;
    } 


.block {
    background-color: white;
    border-color: #5510d3;
    color: black;
    padding: 30px;
    width: 80%;
    margin-right: auto;
    margin-left: auto;
    border: 1px solid black;
    border-radius: 10px;
    font-size: 20px;
    padding-bottom: 2%;
    }
  
  .spacer {
    padding: 3%;
  }

a{
  color: #5510d3;
}
  
a:hover{
    text-decoration: none;
  }


#user{
  width: 50%;
  background-color: white;
  font-size: 20px;
}

}

@media screen and (max-width: 766px) {

.title{
  font-size: 20px;
  font-family: 'Press Start 2P', cursive;
  font-weight: bold;
  padding-bottom: 10px;
}  

.undertitle{
  font-size: 10px;
  font-style: Arial;
  color: #492375;
} 

.title-block {
    background-color: white;
    opacity: .9;
    color: black;
    width: 90%;
    margin-right: auto;
    margin-left: auto;
    border: 0px solid black;
    border-radius: 1px;
    text-align: center;
    } 


.block {
    background-color: white;
    color: black;
    padding: 30px;
    width: 95%;
    margin-right: auto;
    margin-left: auto;
    border: 1px solid black;
    border-radius: 10px;
    font-size: 20px;
    padding-bottom: 2%;
    }
  
.spacer {
    padding: 3%;
  }

a{
  color:#492375;
}
  
  a:hover{
    text-decoration: none;
  }


#user{
  width: 30%;
  background-color: white;
  font-size: 11px;
  margin-top: -10px;
  margin-bottom: 5px;
}
  
#status{
  width: 30%;
  background-color: white;
  font-size: 11px;
  margin-left: 10px;
  margin-top: -10px;
  margin-bottom: 5px;
}
  
#game{
  width: 30%;
  background-color: white;
  font-size: 11px;
  margin-left: 10px;
  margin-top: -10px;
  margin-bottom: 5px;
}
    
}
              
            
!

JS

              
                //["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "noobs2ninjas", "brunofin"];

$(function() {

  var streams = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "noobs2ninjas"];

  $.getJSON('https://api.twitch.tv/kraken/streams/freecodecamp?client_id=6zp99fg4ac3eebcprfbys8sykk15d6').done(function(data) {
    if (data.stream === null) {
      $("#fcc").html(" is offline");
    } else {
      $("#fcc").html(" is online");
    }
  });

  for (var i = 0; i < streams.length; i++) {

    $.ajax({ //since we want to handle an error, not use the shorthand
      type: "GET",
      url: "https://api.twitch.tv/kraken/channels/" + streams[i],
      headers: {
        "client-ID": "6zp99fg4ac3eebcprfbys8sykk15d6"
      },
      success: function(dataI) {

        $.getJSON('https://api.twitch.tv/kraken/streams/' + dataI.name + '?client_id=6zp99fg4ac3eebcprfbys8sykk15d6').done(function(data2) {

          var name = data2._links.self.slice(37); //get name of the channel from a link in json 
          // console.log(name);
          if (data2.stream === null) {
            $("#user").append('<strong><a target=_"blank" href = "https://www.twitch.tv/' + name + '">' + name + '</a><br></strong><hr />');
            $("#status").append('<span style="color:#FF0000;"><strong>Offline</strong></span><br><hr />')
            $("#game").append('<strong>//<br></strong><hr />')
          } else {
            $("#user").append('<strong><a target=_"blank" href = "https://www.twitch.tv/' + name + '">' + name + '</a></strong><br><hr />');
            $("#status").append('<span style="color:#008000;"><strong>Online</strong></span><br><hr />')
            $("#game").append('<strong>'+ data2.stream.game + '</strong><br><hr />');
          }
        });

      },
      error: function(err) { //field for error, change it
        //alert("Error: User not found");
        $("#user").append('Invalid User<br>');
        $("#status").append('Not found<br>')
        $("#game").append('N/A<br>')

      }

    })

  };
})
              
            
!
999px

Console