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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="container text-center">
	<nav class="navbar navbar-toggleable-sm">
		<button class="navbar-toggler navbar-toggler-right navbar-light" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                    </button>
		<h1 class="navbar-brand"><a href="https://www.twitch.tv/" target="_blank">Twitch</a> <i class="fa fa-twitch" aria-hidden="true"></i> Streamers</h1>
		<div class="navbar-collapse" id="navbarSupportedContent">
			<ul class="navbar-nav">
				<li class="nav-item active">
					<button id="all-streamers" class="btn" type="button">All<span class="sr-only"> (current)</span></button>
				</li>
				<li class="nav-item">
					<button id="online-streamers" class="btn" type="button">Online</button>
				</li>
				<li class="nav-item">
					<button id="offline-streamers" class="btn" type="button">Offline</button>
				</li>
			</ul>
			<!--                        <form class="form-inline my-2 my-lg-0">
                            <input id="search-term" class="form-control mr-sm-2" type="text" placeholder="Search for streamer...">
                            <button id="submit-search" class="btn btn-outline-success my-2 my-sm-0" type="button">Search</button>
                        </form>-->
		</div>
	</nav>
	<section>
		<table class="table table-sm table-bordered table-hover">
			<thead class="thead-inverse">
				<tr>
					<th></th>
					<th></th>
					<th>Channel</th>
					<th>Bio</th>
					<th>Status</th>
					<th>Views</th>
					<th>Followers</th>
				</tr>
			</thead>
			<tbody class="streamer-info">
			</tbody>
		</table>
	</section>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Noto+Sans|Droid+Sans");
$hover-color: lavender;
$twitch-purple: #6441A4;
* {
	margin: 0;
	padding: 0;
}

nav {
	font: 1.1em "Droid Sans", sans-serif;
	width: 100%;
	background-color: $twitch-purple;
	a {
		text-decoration: none;
		color: inherit;
		&:hover {
			color: inherit;
		}
	}
	ul {
		background: white;
		border-radius: .3em;
	}
	button {
		color: black;
		background: white;
		&:hover {
			font-weight: bold;
			cursor: pointer;
		}
		&:active {
			font-size: 1.1em;
		}
	}
}

h1 {
	font: lighter 3em "Noto Sans", sans-serif;
	color: white;
}

img {
	width: 75%;
	height: 75%;
}

table {
	text-align: justify;
	.table-text {
		font-size: 0.75em;
	}
}

button#submit-search {
	background: white;
	color: black;
	&:hover {
		background-color: $hover-color;
	}
}

ul {
	margin-right: 6px;
}
              
            
!

JS

              
                const streamers = [
	"ESL_SC2",
	"OgamingSC2",
	"cretetion",
	"freecodecamp",
	"storbeck",
	"habathcx",
	"RobotCaleb",
	"noobs2ninjas"
];
const twitchAPI = "https://wind-bow.gomix.me/twitch-api/";

class Channel {
	constructor(name, statusCheck = "all") {

		const streamsAPI = `${twitchAPI}streams/${name}`;
		const usersAPI = `${twitchAPI}users/${name}`;
		const channelsAPI = `${twitchAPI}channels/${name}`;

		let dataCount = 0;

		$.getJSON(usersAPI, data => {
			if (data.hasOwnProperty("message")) this.message = data.message;
			this.name = data.display_name;
			data.bio === null ? this.bio = "" : this.bio = data.bio;
			this.logo = data.logo;
		}).then(() => {
			dataCount++;
			if (dataCount === 3) {
				Channel.appendStreamer(this, statusCheck);
			}
		});

		$.getJSON(streamsAPI, data => {
			if (data.stream === null) this.onlineStatus = `<i class="fa fa-times"></i>`;
			else if (data.stream !== null && data.stream !== undefined) this.onlineStatus = `<i class="fa fa-check"></i>`;
		}).then(() => {
			dataCount++;
			if (dataCount === 3) {
				Channel.appendStreamer(this, statusCheck);
			}
		});

		$.getJSON(channelsAPI, data => {
			data.status === null ? this.status = "" : this.status = data.status;
			this.url = data.url;
			this.totalViews = data.views;
			this.followers = data.followers;
		}).then(() => {
			dataCount++;
			if (dataCount === 3) {
				Channel.appendStreamer(this, statusCheck);
			}
		});
	}

	static appendStreamer(streamer, statusCheck) {
		streamer.hasOwnProperty("message") ?
			streamer.tableString = `<th scope="row" colspan="2"></th>
                <td colspan="5">${streamer.message}</td>
            </tr>` :
			streamer.tableString = `<th scope="row">${streamer.onlineStatus}</th>
                <td><img src="${streamer.logo}" alt="${streamer.name} channel logo"></td>
                <td><a href="${streamer.url}" target="_blank">${streamer.name}</a></td>
                <td class="table-text">${streamer.bio}</td>
                <td class="table-text">${streamer.status}</td>
                <td>${streamer.totalViews}</td>
                <td>${streamer.followers}</td>
            </tr>`;

		if (statusCheck === "all") {
			streamer.onlineStatus === `<i class="fa fa-check"></i>` ?
				$(".streamer-info").append(`<tr class="table-success">${streamer.tableString}`) :
				$(".streamer-info").append(`<tr class="table-warning">${streamer.tableString}`);
		} else if (statusCheck === "online") {
			if (streamer.onlineStatus === `<i class="fa fa-check"></i>`)
				$(".streamer-info").append(`<tr class="table-success">${streamer.tableString}`);
		} else if (statusCheck === "offline") {
			if (streamer.onlineStatus !== `<i class="fa fa-check"></i>`)
				$(".streamer-info").append(`<tr class="table-warning">${streamer.tableString}`);
		}
	}
}

$(document).ready(() => {

	streamers.map(x => new Channel(x));

	$("#all-streamers").on("click", () => {
		$(".streamer-info").html("");
		streamers.map(x => new Channel(x));
	});

	$("#online-streamers").on("click", () => {
		$(".streamer-info").html("");
		streamers.map(x => new Channel(x, "online"));
	});

	$("#offline-streamers").on("click", () => {
		$(".streamer-info").html("");
		streamers.map(x => new Channel(x, "offline"));
	});

});
              
            
!
999px

Console