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

              
                <div class='container'>
   <div class'row'>
     <div class='col-xs-8 col-xs-offset-2 col-md-6 col-md-offset-3'>
       <div class='nameLogo'>
         <h1 id='siteName'>WIKIHOO!</h1>
         <img id='wikiLogo' class='img-responsive' src="http://chrisparente.com/wp-content/uploads/2015/08/WikiImage.jpg" alt="cartoon picture of wikipedia logo">
       </div>
       <div class="input-group">
          <input type="text" id='searchbox' autofocus class="form-control" placeholder="Wiki Search">
         <span class="input-group-btn">
           <button id='search' class='btn btn-default' type='submit'><i class="fa fa-search"></i></button>
         </span>
       </div>
       <div id='randomContainer'>
         <button type="button" class="btn btn-default" id='random'>What's In Here?</button>
       </div>
      </div>
    </div>
    <div class='row'>
      <div class= 'col-xs-10 col-xs-offset-1 col-md-10 col-md-offset-1'>
        <div id='results'>
        </div>
      </div>
    </div>
  </div>
  <footer id='copyright'><p>Created by <a href='https://www.linkedin.com/in/william-kwon-b3ab3b132' target='_blank'>Will Kwon</a></p></footer>

              
            
!

CSS

              
                body {
  font-family: Palatino, Georgia, "Times New Roman";
}

#siteName {
  text-align: center;
  margin-top: 60px;
  text-shadow: 1px 2px 3px #666;
  color: #7B0099;
}
#siteName:hover {
  cursor: pointer;
}

#results {
  margin-top: 45px;
}

#search{
  color: #0000ff;
  background-color: #d2d2d2;
}

#random {
  background-color: #d2d2d2;
  color: #0000ff;
}

#randomContainer {
  margin-top: 30px;
  text-align: right;
}

.input-group {
  margin-top: 30px;
}

#title a {
  color: #009900;
  text-decoration: underline;
}

#results p {
  font-size: 16px;
}

#searchbox {
  font-size: 16px;
}

#copyright p{
  text-align: center;
}

#copyright a {
  text-decoration: underline;
  color: #4099FF;
}


              
            
!

JS

              
                $(document).ready(function() {
  
  $('#random').click(function() {
  //click event hander for button with id of random//
  window.open("https://en.wikipedia.org/wiki/Special:Random")
    /*open a random wikipedia page*/
  });
  
  $('#search').click(function() {
    //click event for when button with id of search is clicked
    var searchTerm=$('#searchbox').val();
    
    //Variable searchterm is assigned the value of the input that's in #searchbox
    if (searchTerm.length>0) {
      
    fetchData(searchTerm);
      /*invoke function fetchData and pass parameter of searchTerm if length of searchTerm>0*/
          $('#randomContainer').hide();
      $('#wikiLogo').hide();
    //hide button with id of random and the image//
  }
  });
  
  $('h1').click(function() {
    //h1 tag click event handler
    location.reload(true);
    
    //reload page when h1 tag is clicked
  });
  
  $('#searchbox').keypress(function(key) {
    //keypress event is tied to input field #searchbox with a key parameter
    if(key.which===13) {
      //if a key with id strictly equal to 13 i.e. enter/return key is pressed ...
      $('#search').click();
      //invoke the click event handler that is tied to #search button
      
  }
  });
  
  function fetchData(searchTerm){
    $.ajax({
      url: "https://en.wikipedia.org/w/api.php",
      data: {
        action: 'opensearch',
        search: searchTerm, 
        data: 'json',
        origin: '*',
        limit: 20,
        formatversion: 2
      },
       /*fetchData takes in a searchTerm as parameter and makes an ajax call to the wikipedia opensearch api*/
       success: function(response){
         console.log(response);
      /*upon a successful ajax call, the wikipedia opensearch api sends a response array.  And in that response array there are 3 arrays*/
       var title=response[1],
       description=response[2],
       link=response[3],
       searchResults='',
       i;
    /*declare variable names for each of the arrays that will be processed and i to loop through the arrays.  searchResults will be used to concatenate a string.*/  
         if (title.length===0) {
          //if title array has no elements//
           return $('#results').html('<h2><p>Your search - '+searchTerm+' - did not return any results</p></h2>');
           /*return a statement stating that the search did not return any results*/ 
               }
       else for(i=0; i<title.length; i++) {
        //else for loop through the arrays//
         searchResults+='<div class="well"><p id="title"><a href="'+ link[i] + '">' + title[i] + '</a></p><p id="description">' + description[i]+'</p></div>';
         /*var searchResults is assigned the contents of the same index value from each array and a string is concantenated*/
        $('#results').html(searchResults);
         /*var searchResults is then added to the div #results and presented in html format.*/
           }
         }
  });
 };
});


              
            
!
999px

Console