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">
	<h1 class="text-center">Wiki Search</h1>

	<div id="randomPage" class="myJumbotron addShadow textOne">
		<div class="row">
			<div class="theseOnes col-sm-10 xs-12">
				<h3 class="textOne">Random Wikipedia page</h3>
			</div>
			<div class="theseOnes col-sm-2 xs-12">
				<img class="img-fluid images" src="https://png.icons8.com/wired/100/000000/help.png"></div>
		</div>
	</div>

	<div class="myJumbotron addShadow">
		<div class="row">
			<div class="theseOnes textOne col-sm-10 xs-12">
				<form>
					<input id="searchInput" class="sameHeight" style="margin:5px;" type="text" placeholder="Search Wikipedia"></input>
				<button id="searchNow" class="btn btn-secondary"><span>Search</span></button>
			</form>
			</div>
			<div class="theseOnes col-sm-2 xs-12">
				<img class="img-center img-fluid images" src="https://png.icons8.com/wired/100/000000/search.png"></div>
		</div>
	</div>
<div id="results">
	
</div>
</div>
<footer class="footer">
	<div class="container text-center">
		<span style="padding-bottom:5px; font-size:12px;" class="text-muted"><a href="https://icons8.com">Icon pack by Icons8</a></span>
	</div>
</footer>
              
            
!

CSS

              
                * {
	font-family: "Nunito", sans-serif !important;
	font-weight: 700;
}
.addShadow {
	-webkit-box-shadow: 0px 1px 4px 1px rgba(153,153,153,1);
-moz-box-shadow: 0px 1px 4px 1px rgba(153,153,153,1);
box-shadow: 0px 1px 4px 1px rgba(153,153,153,1);
}

.container {
	padding-top: 20px;
}
.images {
	max-height: 100%;
	width: auto;
	max-height: 70px;

}
h3{
margin-top: 10px;
}

.myJumbotron {
	width: 100%;
	height: auto;
	margin: 15px auto;
	border-radius: 5px;
	background-color: #EEE;
	padding: 10px 30px 10px 20px;
	max-width: 500px;
}
.newJumbotron {
	width: 100%;
	height: auto;
	margin: 15px auto;
	border-radius: 5px;
	background-color: #eee;
	padding: 10px 30px 10px 20px;
	cursor: pointer;
}

input[type=text] {
/*     padding:5px;  */
    border:2px solid #EEE; 
    border-radius: 5px;
}

/* .btn:focus,.btn:active {
   outline: none !important;
   box-shadow: none;
} */

::-webkit-input-placeholder {
   text-align: center;
}

.textOne{
text-align: center;
}

.img-center {
    display: block;
    margin: 0 auto;
}

.sameHeight{
	height: 40px !important;
	padding: 5px !important;
	
}
#randomPage{
	cursor: pointer;
}

              
            
!

JS

              
                
var templateOpenOne='<div id="result" class="newJumbotron"';
var templateOpenTwo='">';
var clickLink = 'onClick="';
var templateClose='</div>';
function updateView(object){
	var results = "";
	for(var i = 0; i < object.query.search.length; i++){
		var resultToAdd = "";
		resultToAdd = templateOpenOne + clickLink + "window.open('https://en.wikipedia.org/wiki/" + encodeURI(object.query.search[i].title) + "')" + templateOpenTwo + "<h5><strong>" + object.query.search[i].title + "</strong></h5>" +  object.query.search[i].snippet + templateClose;
		results=results+resultToAdd;
	}
	$("#results").html(results);
}

$("#randomPage").click(function() {
  window.open("https://en.wikipedia.org/wiki/Special:Random");
});


$("#searchNow").click(function() {
	if($("#searchInput").val() === ""){
		$("#results").html(" ");
		$(this).blur();
		return false;
	}
	$.getJSON("https://en.wikipedia.org//w/api.php?action=query&format=json&prop=info&list=search&srsearch=" + $("#searchInput").val() + "&inprop=url&callback=?", function(a){

		updateView(a);
		console.log(a);
});
	
	console.log($("#searchInput").val());
	$(this).blur();
	return false;
});
              
            
!
999px

Console