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-fluid">
    <h1 class="text-center">Search several Wikipedia pages!</h1> 
    <p class="text-center"> just write down the search query below and press Enter key!</p>
<div class="row">
    <div class="col-md-8">
       <form  id="demo-2">
	      <input type="search" id="searchWord"  placeholder="Search..." autofocus>
        </form>
        </div>
    <div class="col-md-4">
        <button id="randomArticleButton" type="btn btn-default" class="btn btn-def">Random Search</button>
        </div>
	</div>
  <div id="textOutput">
  <font size="4"><ul id="queryOutput"></ul></font>
    </div>
</div>
<br>
<br>
<footer class="text-center" id="foot">Written and coded by <a href="https://www.freecodecamp.com/sharkantropo">Sharkantropo</a></footer>


              
            
!

CSS

              
                body {
	background: #660033;
	font: 90%/180% Arial, Helvetica, sans-serif;
	width: 800px;
	max-width: 96%;
	margin: 0 auto;
}

h1{color:white;}

p{
    color: white;
    font-size:16px;
}

input {
	outline: none;
}
input[type=search] {
	-webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
	display: none; 
}


input[type=search] {
	background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
	border: solid 1px #ccc;
	padding: 9px 10px 9px 32px;
	width: 55px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
}
input[type=search]:focus {
	width: 130px;
	background-color: #fff;
	border-color: #66CC75;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
}


input:-moz-placeholder {
	color: #999;
}
input::-webkit-input-placeholder {
	color: #999;
}

#textOutput {
	background: rgba(255, 255, 255, 0.5);
	margin-right: 1em;
	margin-left: 1em;
	padding: 1em;
	-webkit-border-radius: 5px;
	-moz-border-radius-: 5px;
	border-radius: 5px;
	box-shadow: -.5em .5em .5em #888888;
}


#demo-2 input[type=search] {
	width: 15px;
	padding-left: 10px;
	color: transparent;
	cursor: pointer;
}
#demo-2 input[type=search]:hover {
	background-color: #fff;
}
#demo-2 input[type=search]:focus {
	width: 400px;
	padding-left: 32px;
	color: #000;
	background-color: #fff;
	cursor: auto;
}
#demo-2 input:-moz-placeholder {
	color: transparent;
}
#demo-2 input::-webkit-input-placeholder {
	color: transparent;
}

#searchWord
{
    font-size: 18px;
}

.center {
    margin: auto;
    width: 30%;
    padding: 10px;
}

.btn-def {
    background-color:  #99004d;
    border: none;
    color: white;
    padding: 7px 16px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}

#foot
{
    font-size: 16px;
    color: white;
}
              
            
!

JS

              
                $("#textOutput").hide();
$(document).ready(function(){ 
    // Perform search when enter is pressed
    
       $("#searchWord").keydown(function (event) {
           // if the key enter is pressed, it will retrieve the keyword from the input and call a function to obtain results
           if(event.which == 13)
               {
                  var searchTerm = $("#searchWord").val();
		          if (searchTerm !== "") {
                             $("#textOutput").show();           
			                  ajaxAgent(searchTerm);             
                               event.preventDefault();
                		                } 
                   else {
			              alert("Please enter a term to search");
		                }
              }
      });
});
    // Just a simple "I'm gunna be lucky" random search button, it will open a random wiki page.
		$('#randomArticleButton').click(function() {
			window.location = "https://en.wikipedia.org/wiki/Special:Random";
		});    



function ajaxAgent (keyword) { //Ajax Agent Request from wikipedia
	$.ajax({ 
		url: "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + keyword + "&format=json&callback=?",
		dataType: "jsonp",
		success: function(cb) {
                 dispResults(cb);
		},
		error: function () {
			alert("Error, please refresh the page or try again");
		}
	});
}

function dispResults(cb)
{
    // Clear previous results
    $("#queryOutput").html("");
    // Iterates through the results obtained from the wiki API, then it displays the link contained at heading and summary. It will display every result obtained.
    for (var i = 0; i < cb[1].length; i++) {
		var heading = cb[1][i];
		var summary = cb[2][i];
		var pageLink = cb[3][i];
		var urlString = "<li><a href= " + pageLink + ">" + heading + "</a><p>" + summary + "</p></li>";
		//Now, It'll add it to #queryOutput first child
        $("#queryOutput").prepend(urlString);
}
}
    
              
            
!
999px

Console