cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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 lang="en">
<head>
	<meta charset="utf-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="width=device-width, initial-scale=1" name="viewport">
	<!-- Bootstrap says:  The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->


	<title>Wikipedia Viewer</title><!-- Bootstrap -->
	<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
	<link href="main.css" rel="stylesheet"><!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<div class="container-fluid">
		<header>
			<h1>Wikipedia Viewer</h1>
		</header>
	</div>


	<div class="container-fluid">
		<div class="main">
			<div class="centered">
				<ul>
					<li>
						<a class="big-button" href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">Random</a>
					</li>


					<li>
						<a class="big-button" href="#" id="searchButton">Search</a>
					</li>
				</ul>


				<div class="form-group">
					<form>
						<label for="usr"></label> <input class="form-control" id="usr" placeholder="Search Terms" type="text">
					</form>
				</div>
			</div>


			<div class="second-centered" id="wiki-search-results">
			</div>
		</div>
		<!--main -->


		<footer class="footer">
			<div class="container">
			</div>
		</footer>
	</div>
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
	</script> <!-- Include all compiled plugins (below), or include individual files as needed -->
	 
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js">
	</script> 
	<script src="app.js">
	</script>
</body>
</html>
            
          
!
            
              /* Sticky footer styles
-------------------------------------------------- */
html {
	position: relative;
	min-height: 100%;
	}

body {
/* Margin bottom by footer height */
	margin-bottom: 60px;/* bad codepen ignores */
	background-color: #ffe4e1;
	margin-top: 60px;/* bad codepen ignores */
	color: #8b4513;
}

.footer {
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
/* Set the fixed height of the footer here */
	height: 60px;
	background-color: #faf0e6;
	text-align: center;
}

.centered {
	margin: auto;
	width: 250px;
  padding: 50px /* only use on codepen to make up for the ignored margin on the body. */
}

.second-centered {
	margin: 0 auto;
	width: auto;
	max-width: 1000px;
}

.err-div {
	text-align: center;
}

ul {
	text-align: center;
	list-style: none;
	margin-top: 30px;
	padding: 10px;
}

li {
	background-color: #ff7f50;
	border-radius: 45%;
	font-size: 2em;
}

.big-button {
	display: block;
	margin: 10px 5px 50px;
	padding: 25px 5px;
	border-radius: 45%;
}

a:hover {
	font-weight: 700;
	text-decoration: underline overline;
}

header {
	background-color: #faf0e6;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 60px;
	font: red;
	text-align: center;
}

.text-muted {
	color: #8b4513;
}

.ff {
	border: 1px dotted #ffdab9;
	height: auto;
	background-color: #faf0e6;
	padding: 5px;
}

.link-list {
	margin: 10px;
}

.row {
	height: auto;
	padding: 0;
}
            
          
!
            
              /*Freebootcamp Project - take user data and search wikipedia May 2016

Wikipedia urls where search term = zyz, returning up to the number items specified in by limit=
//https://en.wikipedia.org/w/api.php?action=opensearch&search=zyz&limit=10&namespace=0&format=jsonfm - human readable
//https://en.wikipedia.org/w/api.php?action=opensearch&search=zyz&limit=10&namespace=0&format=json - machine readable */
//free code camp used 'https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=zyz&callback=JSON_CALLBACK'
function getWikis(searchTerms)
	{
		$.ajax(
		{
			url: 'https://en.wikipedia.org/w/api.php?action=opensearch&search=' + searchTerms + '&limit=10&namespace=0&format=json&callback=wikiCallback',
			type: 'GET',
			dataType: 'jsonp'
		}).done(function(json)
		{
			//	$('#wiki-search-results').append('stuff lands here');
			//	htmlifyJSON(json);
			console.log("stuff " + json);
			updateresults(json);
		}).fail(function(xhr, status, errorThrown)
		{
			alert("Sorry, there was a problem!");
			console.log("Error: " + errorThrown);
			console.log("Status: " + status);
			console.dir(xhr);
		}).always(function(xhr, status)
		{
			console.log("The request is complete!");
		});
	} //end getWikis
	//reads an object that is an array of four arrays: name, description, link  index in last three arrays identifies search result. first array is single value equal to search term
	// put the wiki search results on the page in 2 columns for large screens and 1 for phones

function updateresults(json)
	{
		var wikiLink1 = '',
			wikiLink2 = ''; // this will appear on the page as link to a search result
		console.log('updating results' + json);
		if (json[1].length < 1)
		{ //No results, add an error message
			$('#wiki-search-results').html('<div class = "err-div">No results found<div>');
		}
		for (var i = 0; i < json[1].length; i += 2)
		{ // build the rows, testing to see if results include a description
			if (json[2][i].length > 0)
			{
				wikiLink1 = '<div class = "link-list"><a href = ' + json[3][i] + '> <b>' + json[1][i] + ': </b> ' + json[2][i] + '</a></div>';
			}
			else
			{
				wikiLink1 = '<div class = "link-list"><a href = ' + json[3][i] + '> <b>' + json[1][i] + ': </b> No description available </a></div>';
			}
			if (json[2][i + 1].length > 0)
			{
				wikiLink2 = '<div class = "link-list"><a href = ' + json[3][i + 1] + '> <b>' + json[1][i + 1] + ': </b> ' + json[2][i + 1] + '</a></div>';
			}
			else
			{
				wikiLink2 = '<div class = "link-list"><a href = ' + json[3][i + 1] + '> <b>' + json[1][i + 1] + ': </b> No description available </a></div>';
			}
			if (i % 2 === 0)
			{ //start a row every two items
				$('#wiki-search-results').append('<div class="wiki-result row"><div class = "col-xs-12 col-sm-6 ff">' + wikiLink1 +
					'</div><div class = "col-xs-12 col-sm-6 ff">' + wikiLink2 + '</div></div>');
			}
		}
	}
	// assign event handlers after the page loads
$(document).ready(function()
{
	$('#searchButton').on('click', function(e)
	{
		var searchTerm = $('#usr').val(); //here an extra time in case it needs that to catch updates?
		$('#wiki-search-results').html(''); // clear any previous search results
		console.log(searchTerm + ' is search term');
		getWikis(searchTerm);
	});
	// Thanks http://stackoverflow.com/questions/6524288/jquery-event-for-user-pressing-enter-in-a-textbox
	$('#usr').bind("enterKey", function(e)
	{
		//do stuff here.  does not work on ie or codepen. dont know why yet.
		var searchTerm = $('#usr').val(); //here an extra time in case it needs that to catch updates?
		$('#wiki-search-results').html(''); // clear any previous search results
		console.log(searchTerm + ' is search term');
		getWikis(searchTerm);
	});
	$('#usr').keyup(function(e)
	{
		if (e.keyCode == 13)
		{
			$(this).trigger("enterKey");
		}
	});
}); // end doc ready
            
          
!
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.
Loading ..................

Console