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.

            
              <link rel="stylesheet" media="screen" href="dimitri_TTF" type="text/css" />


<body>
 <div class="container">


  <div class="text-center jumbotron">


   <!--Title-->
   <a href="JavaScript: location.reload(true);">
    <img class="img-fluid title1" src="https://image.ibb.co/krZA7Q/twitch1.png">
    <img class="img-fluid title2" src="https://image.ibb.co/cQjSnQ/twitch2.png">
   </a>
   <br></br>

   <!--Search bar-->
   <div class="searchBar">

    <button id="searchIcon"></button>

    <input id="searchTerm" class="margin" autocomplete="off" type="text" name="search" placeholder="Search">

   </div>


   <!--Output-->

   <div class="row">

    <div id="output"></div>

   </div>

  </div>

  <footer>
   <p class="text-center">By Uriel Guzmán</p>
  </footer>

 </div>
</body>
            
          
!
            
              .searchBar {
	margin-right: 50px;
	margin-bottom: 20px;
}
input {
	/* Input */
	width: 70%;
	max-width: 700px;
	box-sizing: border-box;
	border: 2px solid #ccc;

	border-radius: 4px;
	font-size: 24px;

	background-color: rgba(50, 0, 100, 0.7);

	padding: 12px 10px 12px 80px;
	-webkit-transition: width 0.4s ease-in-out;
	transition: width 0.4s ease-in-out;
}

input:focus {
	width: 75%;
}

#searchIcon {
	background-image: url('https://image.ibb.co/hQS2Ta/binoicon.png');
	width: 45px;
	height: 45px;
	background-color: rgba(3, 3, 3, 0);

	border: 0;

	position: relative;
	left: 70px;
	top: 15px;
}

#searchTerm {
	font-size: 0.6cm;
	color: white;
	margin-bottom: 10px;
}

body {
	margin-top: 15px;
	background-image: url('https://slate.adobe.com/a/wKryJ/images/69077D17-0426-4B67-9BEF-8903C33153CA.jpg');
	overflow-y: scroll;
	background-color: #111;

	background-position: center center;
}
.title1 {
	width: 65%;
	max-width: 300px;
}

.title2 {
	width: 100%;
	max-width: 450px;
}

.title-well {
	width: 40%;
}
#img {
	width: 60px;
	border: 2px solid white;
	border-radius: 50%;
}

.well-onlineSearched, .well {
	background-color: rgba(50, 0, 100, 0.7);
}
.well-offlineSearched {
	background-color: rgba(30, 0, 60, 0.7);
}

.well-online {
	background-color: rgba(50, 0, 100, 0.7);
	width: 31.3%;
	margin-left: 1%;
	margin-right: 1%;
	height: 380px;
	float: left;
}
.well-offline {
	background-color: rgba(30, 0, 60, 0.7);
	width: 31.3%;
	margin-left: 1%;
	margin-right: 1%;
	height: 380px;
	float: left;
}

@media only screen and (max-width: 1200px) {
	.well-online, .well-offline {
		width: 31.3%;
		height: 390px;
	}
}
@media only screen and (max-width: 1000px) {
	.well-online, .well-offline {
		width: 48%;
	}
}

@media only screen and (max-width: 768px) {
	.well-online, .well-offline {
		width: 90%;
		height: auto;
		margin-left: 5%;
		margin-right: 5%;
	}
}

#name {
	font-size: 30px;
	color: white;
	text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
	font-family: sans-serif;
}

#online {
	color: #00FF00;
	text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
	font-family: sans-serif;
	font-size: 20px;
}

#offline {
	color: #FF0000;
	text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
	font-family: sans-serif;
	font-size: 20px;
}

#status {
	color: white;
	text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
	font-family: sans-serif;
	font-size: 20px;
}

.jumbotron {
	background-color: rgba(230, 230, 250, 0.6);
}

footer {
	font-size: 20px;
	color: white;
	font-family: sans-serif;
	text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}

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

::-webkit-input-placeholder {
	/* WebKit, Blink, Edge */
	color: #cccccc;
}
:-moz-placeholder {
	/* Mozilla Firefox 4 to 18 */
	color: #cccccc;
	opacity: 1;
}
::-moz-placeholder {
	/* Mozilla Firefox 19+ */
	color: #cccccc;
	opacity: 1;
}
:-ms-input-placeholder {
	/* Internet Explorer 10-11 */
	color: #cccccc;
}
::-ms-input-placeholder {
	/* Microsoft Edge */
	color: #cccccc;
}

mark {
	color: rgb(0, 250, 0);
	background-color: rgba(0, 0, 0, 0);
}

.text-white {
	font-family: sans-serif;
	font-size: 25px !important;
}

            
          
!
            
              $(document).ready(function() {
	var streamers = [
		// Pool of streamers to loop for.
		"freecodecamp",
		"OgamingSC2",
		"cretetion",
		"ESL_SC2",
		"storbeck",
		"habathcx",
		"RobotCaleb",
		"noobs2ninjas",
		"Faker"
	];

	function searchCode() {
		$(".row").removeClass();
		$("#output").empty();
		var searchTerm = $("#searchTerm").val();
		searchTerm = searchTerm.replace(/\s/g, "");
		if (searchTerm == "") {JavaScript: location.reload(true);}
		console.log(searchTerm);
		// Iterate through streamers and get the API of each one of them.
		$.ajax({
			type: "GET",
			url: "https://api.twitch.tv/kraken/streams/" + searchTerm + "?callback?", // Each streamer's user name gets added to URL.
			headers: {
				"client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
			},
			success: function(twitch) {
				// This contains each streamer's API.

				if (twitch.stream !== null) {
					// If streamers are online...
					var logo = twitch.stream.channel.logo;
					var name = twitch.stream.channel.display_name;
					var status = twitch.stream.channel.status;
					var game = twitch.stream.channel.game;
					var url = twitch.stream.channel.url;

					$("#output").append(
						// Append to #output div.
						"<a target = '_blank' href=" +
							url +
							"><div class = 'well well-onlineSearched'>" +
							"<img id = 'img' src =" +
							logo +
							">" +
							"<br></br>" +
							"<p id = 'name'>" +
							name +
							"</p>" +
							"<hr></hr>" +
							"<p id = 'status'>" +
							status +
							"</p>" +
							"<hr></hr>" +
							"<p id = 'online'>Online</p>" +
							"</div></a>"
					); // End of online append.
				} else if (twitch.stream === null) {
					$.ajax({
						// If streamers are offline...
						type: "GET",
						url: "https://api.twitch.tv/kraken/channels/" + searchTerm + "?callback?", // Get info from their channel instead of stream.
						headers: {
							"client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
						},
						success: function(twitchOffline) {
							console.log(twitchOffline.status);
							// API of streamer's channel.

							var logo = twitchOffline.logo != null // If logo exists,
								? (logo = twitchOffline.logo) // logo conserves properties.
								: (logo =
										"https://pre06.deviantart.net/1a10/th/pre/f/2015/291/5/1/logo_twitch_iosversion_by_akiruuu-d9djk9s.png"); // If not, logo is now this image.
							var url = twitchOffline.url;
							var status = twitchOffline.status != null // If status exists,
								? (status = twitchOffline.status) // status conserves properties.
								: (status = "Status not found"); // If not, status displays "404 not found".
							var displayName = twitchOffline.display_name;
							$("#output").append(
								// Append to the same #output div.
								"<a target = '_blank' href =" +
									url +
									"><div class = 'well well-offlineSearched'>" +
									"<img id = 'img' src =" +
									logo +
									"><br></br>" +
									"<p id = 'name'>" +
									displayName +
									"</p>" +
									"<hr></hr>" +
									"<p id = 'status'>" +
									status +
									"</p>" +
									"<hr></hr>" +
									"<p id = 'offline'>Offline</p>" +
									"</div></a>"
							); // End of offline append.
						},
						error: function() {
							$("#output").append(
								"<div class = 'well'>" +
									"<p class = text-white>Sorry :(, " +
									'<mark>"' +
									searchTerm +
									'"</mark> ' +
									"<p class = text-white>didn't return any results. Try checking for spelling mistakes.</p></div>"
							);
						} // End of nested success function.
					}); // End of nested ajax call.
				} // End of else statement.
			} // End of success function.
		}); // End of ajax call.
	}
	// -----------------------ON KEYPRESS-------------------------
	$("#searchTerm").keypress(function(e) {
		// Keypress.
		if (e.keyCode === 13) {
			// When spacebar is pressed.
			searchCode();
		} // End of if statement.
	}); // End of searchTerm function.
	// -------------------END OF ON KEYPRESS-------------------

	// -----------------------ON CLICK-------------------------
	$("#searchIcon").on("click", function() {
		// onClick.
		searchCode();
	}); // End of searchTerm function.
	// --------------------END OF ON CLICK-------------------

	// --------------------DEFAULT STREAMERS-----------------
	for (let x = 0; x < streamers.length; x++) {
		// Iterate through streamers and get the API of each one of them.
		$.ajax({
			type: "GET",
			url: "https://api.twitch.tv/kraken/streams/" + streamers[x] + "?callback?", // Each streamer's user name gets added to URL.
			headers: {
				"client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
			},
			success: function(twitch) {
				// This contains each streamer's API.

				if (twitch.stream !== null) {
					// If streamers are online...
					var logo = twitch.stream.channel.logo;
					var name = twitch.stream.channel.display_name;
					var status = twitch.stream.channel.status;
					var game = twitch.stream.channel.game;
					var url = twitch.stream.channel.url;

					$("#output").append(
						// Append to #output div.
						"<a target = '_blank' href=" +
							url +
							"><div class = 'well well-online'>" +
							"<img id = 'img' src =" +
							logo +
							">" +
							"<br></br>" +
							"<p id = 'name'>" +
							name +
							"</p>" +
							"<hr></hr>" +
							"<p id = 'status'>" +
							status +
							"</p>" +
							"<hr></hr>" +
							"<p id = 'online'>Online</p>" +
							"</div></a>"
					); // End of online append.
				} else if (twitch.stream === null) {
					$.ajax({
						// If streamers are offline...
						type: "GET",
						url:
							"https://api.twitch.tv/kraken/channels/" + streamers[x] + "?callback?", // Get info from their channel instead of stream.
						headers: {
							"client-ID": "8wp64ky5gj2bqordmiocrwdw4oivc0"
						},
						success: function(twitchOffline) {
							// API of streamer's channel.

							var logo = twitchOffline.logo != null // If logo exists,
								? (logo = twitchOffline.logo) // logo conserves properties.
								: (logo =
										"https://pre06.deviantart.net/1a10/th/pre/f/2015/291/5/1/logo_twitch_iosversion_by_akiruuu-d9djk9s.png"); // If not, logo is now this image.
							var url = twitchOffline.url;
							var status = twitchOffline.status != null // If status exists,
								? (status = twitchOffline.status) // status conserves properties.
								: (status = "Status not found"); // If not, status displays "404 not found".
							var displayName = twitchOffline.display_name;

							$("#output").append(
								// Append to the same #output div.
								"<a target = '_blank' href =" +
									url +
									"><div class = 'well well-offline'>" +
									"<img id = 'img' src =" +
									logo +
									"><br></br>" +
									"<p id = 'name'>" +
									displayName +
									"</p>" +
									"<hr></hr>" +
									"<p id = 'status'>" +
									status +
									"</p>" +
									"<hr></hr>" +
									"<p id = 'offline'>Offline</p>" +
									"</div></a>"
							); // End of offline append.
						} // End of nested success function.
					}); // End of nested ajax call.
				} // End of else statement.
			} // End of success function.
		}); // End of ajax call.
	} // End of x for loop.
}); // End of document function.

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

Console