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

              
                <body>
	<div id='chatbox'>
		<header id='nav'>
			<div id='all' class='selected options'>
				<a>All</a>
				<b class="notch"></b>
			</div>
			<div id='online' class='options'>
				<a>Online</a>
				<b class="notch"></b>
			</div>
			<div id='offline' class='options'>
				<a>Offline</a>
				<b class="notch"></b>
			</div>
		</header>
		<ul class='user-list'>
		</ul>
		<footer id='searchbar'>
			<input type='text' id='searchbox'></input>
			<i class="fa fa-search"></i>
		</footer>
	</div>
</body>
              
            
!

CSS

              
                body {
	background: rgba(0, 80, 180, 0.6);
	font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

#chatbox {
	display: block;
	position: relative;
	box-shadow: 1px 23px 1px rgba(0, 0, 0, .3);
	width: 20%;
	height: auto;
	min-width: 350px;
	min-height: 150px;
	background: rgba(255, 255, 255, 1.0);
	margin: 0 auto;
	top: 100px;
	text-align: center;
}



/*User Status Selection*/
#nav {
	display: inline;
	height: 20px;
	margin: 0;
}

.options {
	position: relative;
	float: left;
	width: 33.3333%;
	padding: 10px 0px 10px 0px;
	background: rgba(0, 107, 178, 0.8);
	border-right: 1px solid rgba(255,255,255, 0.4);
}

.options:last-child {
	border-right: none;
}

.options > a {
	color: white;
}

.options > a:hover {
	text-decoration: none;
	color: white;
}

.options:hover {
	background: rgb(0, 153, 255);
	cursor: pointer;
}

.selected {
	background: rgb(0, 153, 255);
}

.selected .notch {
	 	position: absolute;
    top: 40px;
    left: 41%;
    margin: 0;
    border-bottom: 0;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-top: 8px solid rgb(0, 153, 255);
    padding: 0;
    width: 0;
    height: 0;
}



/*User container*/
.user-list {
	height: 500px;
	overflow: scroll;
	padding-left: 1px;
	list-style-type: none;
	z-index: -20;
}

.user {
	text-align: left;
	padding-top: 5px;
	padding-bottom: 5px;
}

.user-img {
	float: left;
	border-radius: 50%;
	margin-left: 36px;
	margin-right: 20px;
	margin-top: 10px;
	height: 60px;
	width: 60px;
}

.user-txt {
	color: rgba(0, 0, 0, .4);
	overflow: hidden;
	height: 20px;
}

.user h1 {
	font-size: 20px;
	margin-bottom: 0px;
}

.user:hover {
  background: rgba(0, 153, 255, 0.2);
	cursor: pointer;
}

.gray-border {
	border: 5px solid rgba(0, 0, 0, .2);
}

.green-border {
	border: 5px solid rgba(20, 150, 60, .8);
}

/*Search bar*/
#searchbar {
	position: absolute;
	bottom: -20px;
	width: 100%;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
	min-height: 40px;
	background: white;
}

#searchbox {
	position: relative;
	padding: 0px 15px 0px 15px;
	overflow: hidden;
	top: 8px;
	width: 65%;
	min-width: 200px;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 50px;
	vertical-align: center;
	margin: 0 auto;
}

#searchbox:focus {
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 50px;
}

.fa-search {
	position: absolute;
	display: inline-block;
	top: 12px;
	left: 12%;
	color: rgba(0, 0, 0, .3);
}

/*Overrides*/
input:focus {
	outline: none;
}

a {
	color: inherit;
}

a:hover {
	color: inherit;
	text-decoration: none;
}

a:focus {
	text-decoration: none;
	color: inherit;
}

              
            
!

JS

              
                var usersList = ["GeoffStorbeck", "terakilobyte", "Habathcx","RobotCaleb","Comster404","Brunofin","thomasballinger","noobs2ninjas","Beohoff", "MedryBW", "FreeCodeCamp"];

var allUsers = [];
var onlineUsers = [];
var offlineUsers = [];

var twitchEndpt = 'https://api.twitch.tv/kraken/';
var cid = '?client_id=5j0r5b7qb7kro03fvka3o8kbq262wwm&callback=?';

$(document).ready(function() {	
	getAllUsers();
	
	$('.options').click(function(event){
		$('.selected').removeClass('selected');
		$(event.currentTarget).addClass('selected');
	});
	
	$('#online').click(function(event) {
		addAllToList(onlineUsers);
	});
	
	$('#offline').click(function(event) {
		addAllToList(offlineUsers);
	});
	
	$('#all').click(function(event) {
		addAllToList(allUsers);
	});
	
	//Search functionality using filter
	$('#searchbox').keyup(function(){
		var input = $('#searchbox').val().toLowerCase();
		console.log('Keyup: ' + input);
		
		if(!input) {
			$('.user').show();
		}
		else {
			$('.user').filter(function() {
				return $(this).children('h1').text().toLowerCase().indexOf(input) === -1;
			}).hide();
		}
	});
});

function getAllUsers() {
	for(var user in usersList) {
		var currentUser = usersList[user];
		$.when(getName(currentUser), getStatus(currentUser))
			.done(function(result1, result2) {
			var nameResult = result1[0];
			var statusResult = result2[0];
			
			var userUrl = 'https://www.twitch.tv/' + nameResult['display_name'];
			var imgUrl = nameResult['logo'] || 'http://placehold.it/50x50';
			var onlineStatusClass = 'gray-border';
			var name = nameResult['display_name'];
			var statusMsg = 'Offline';
			if(statusResult['stream']) {
				onlineStatusClass = 'green-border';
				statusMsg = statusResult['stream']['channel']['status'];
			}
			
			var userObj = {
				'name': name,
				'logo': imgUrl,
				'message': statusMsg,
				'onlineClass': onlineStatusClass,
				'streamUrl': userUrl
			};
			
			allUsers.push(userObj);
			if(statusResult['stream'])
				onlineUsers.push(userObj);
			else
				offlineUsers.push(userObj);
			addToList(userUrl, imgUrl, onlineStatusClass, name, statusMsg);
		});
	}
}

function getName(user) {
	return $.getJSON(twitchEndpt + 'users/' + user + cid);
}

function getStatus(user) {
		return $.getJSON(twitchEndpt + 'streams/' + user + cid);
}

function addAllToList(list) {
	$('.user-list').empty();
		//Start from the end so that the online users appear first
	for(var i = list.length - 1; i >= 0; i--) {
		var currUsr = list[i];
		addToList(currUsr['streamUrl'], currUsr['logo'], currUsr['onlineClass'], currUsr['name'], currUsr['message']);
	}
}

function addToList(streamUrl, imgUrl, onlineStatus, username, status) {
	$('.user-list').append("<a href='" + streamUrl + "' target='_blank'><li class='user'><img class='user-img " + onlineStatus + "' src=" + imgUrl + "><h1>" + username + "</h1><p class='user-txt'>" + status + "</p></li></a>");	
}
              
            
!
999px

Console