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.

              <!DOCTYPE html>
	<title>Twitch.tv JSON API</title>
	<meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <!-- Jquery -->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Abel" rel="stylesheet">
<!-- Title -->
<h1>Twitch JSON API</h1>
<!-- online streamers -->
<div class="container">
<h2>Online Streamers</h2>
	<div class="display">

<!-- offline streamers -->
<div class="container">
	<h2>Offline streamers</h2>
	<div class="offline-display">


<div class="container">
	<h1>Twitch Streamers</h1>
	<div class="padding">
	<div class="row">
		<div class="col-xs-6 col-md-6 col-lg-6">
			<div id="img-online"></div>
		<div class="col-xs-6 col-md-6 col-lg-6">
			<div id="content"></div>


	<div class="container">
	<h1> Offline Streamers</h1>
		<div class="row">
			<div class="col-xs-6 col-md-6 col-lg-6">
				<div class="img-offline"></div>
			<div class="offline">
			<div class="col-xs-6 col-md-6 col-lg-6">

<script type="text/javascript" src="js/index.js"></script>

              body, html {
  background-color: blue !important;
  color: white !important; }

img {
  border-radius: 50%;
  max-width: 80px;
  max-height: 80px; }

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

.display {
  background-color: green; }

.display a {
  color: white; }

h1 {
  text-transform: uppercase;
  text-align: center; }

.offline-display {
  background-color: black; }

/*# sourceMappingURL=style.css.map */

$(document).ready(function() {

var streamers = ["ESL_SC2", "freecodecamp", "xPeke", "rivalxfactor", "boxbox", "Scarra"];

$.each(streamers, function(i, val) {
	var url = "https://wind-bow.gomix.me/twitch-api/streams/" + val + "?callback=?";

	$.getJSON(url, function(data){
		if(data.stream !== null) {
			// if the data is not null (streaming online) , call the online function, that will display data (all the online channels)
		} else if (data.stream === null ){
			// if the data is null (streaming offline), call the offline function, that will display data  (all the offline channels)

	}); // end getJSON
});  // end $.each

// if the streamers are online i'll get the data and display it
function online(data) {
	 // getting data from the API
	var name = data.stream.channel.display_name;
	var game = data.stream.channel.game;
	var logo = data.stream.channel.logo;
	var status = data.stream.channel.status;
	var url = data.stream.channel.url;
	var description = data.stream.channel.status;

	 //displaying data on the website
	// $('.row').append('<div class="col-xs-2 col-md2 col-lg-2"><img src=\"' + logo + '\" class=\"stream-logo\"></div>');
	// $('#mycontent').append('<a href=\"' + url + '\" target=\"_blank\" class=\"link\">\"'+ name +'\"</a> </div>');
	// $('#mycontent').append('<p class=\"title\">\"' + status + '\" </p> </div>');
	// $('#mycontent').append('<p class=\"game\"> Game : \"' + game + '\" </p> </div> <br>');

	var displayData = '<div class="row ' + 
          status + '"><div class="col-xs-2 col-sm-1"><img src="' + 
          logo + '"></div><div class="col-xs-10 col-sm-3"><a href="' + 
          url + '" target="_blank">' + 
          name + '</a></div><div class="col-xs-10 col-sm-8">'+ 
          description + '</div></div>';



// if it's offline, i have to call the api from a different url ("https://wind-bow.gomix.me/twitch-api/channels/") instead of ("https://wind-bow.gomix.me/twitch-api/streams/")
function getUserData(val) {
	var channelUrl = "https://wind-bow.gomix.me/twitch-api/channels/" + val + "?callback=?";
	$.getJSON(channelUrl, function(data) {

// if streamers are offline i'll get the data and display it
function offline(data) {
	// getting data from the API
	var status = data.status;
	var name = data.display_name;
	var logo = data.logo;
	var url = data.url;
	var game = "Offline";
	var description = data.description;

	var displayOfflineData = '<div class="row ' + 
          status + '"><div class="col-xs-2 col-md-1"><img src="' + 
          logo + '" class="img-responsive"></div><div class="col-xs-8 col-md-3" id="name"><a href="' + 
          url + '" target="_blank">' + 
          name + '</a></div><div class="col-xs-2 col-md-8">'+ 
          game + '</div></div>';



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