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 id="container">
  <div id="makeSearch">
    <h1>Welcome!</h1>
    <h5>What would you like to know?</h5>
    <input type="text" name="wikiSearch" class="search" placeholder="Search Me!"/>
    <span class="toSearch">Search</span>
    <span class="reset">Reset</span>
    <span class="rLucky"><a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">Feeling Lucky?</a></span>
  </div>
  
  <div class="displaySearch">
    
  </div>
</div>
<footer><p>Project for <a href="https://www.freecodecamp.org" target='_blank'>FreeCodeCamp</a> with help from JashuHB. Made by Ogechi Ike &copy;<span id='currentYear'></span>.</p></footer>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Lora:400,700');

body{
  background-color:#f1c58a;
  font-family: 'Lora', Georgia, serif;
}

#makeSearch{
  width: 95%;
  margin: 0 auto;
  padding-top: 11%;
  text-align: center;
  
  h1{
    padding-bottom: 1.65%;
    font-size: 3.9em;
  }
  
  h5{
    padding-bottom: 5.5%;
  }
  
  
  .search {
  width: 90px;
  border-radius: 5px;  
  transition: .4s; 
  box-shadow: none;  
  }
  
  .search-active{
    width: 300px;
    transition: .4s;
  }
  
  a{
    text-decoration: none;
    color: #28202f;
    transition: .4s;
  }
  
  a:hover{
    color: #fbf8f4;
    transition: .4s;
  }
  
  
  .rLucky{
    transition: .4s;
    border: 1.5px solid #0b3e1f;
    border-radius: 5px;
  }

  .rLucky:hover{
    background-color: #0b3e1f;
    border-radius: 5px;
    transition: .4s;
    padding: 10px;
  }
  
  .reset{
    transition: .4s;
    border: 1.5px solid #5d0808;
    border-radius: 5px;
  }
  
  .reset:hover {
    background-color: #5d0808;
    border-radius: 5px;
    transition: .4s;
    padding: 10px;
  }
  
  .toSearch{
    transition: .4s;
    border: 1.5px solid #0a729a;
    border-radius: 5px;
  }
  
  .toSearch:hover{
    background-color: #0a729a;
    border-radius: 5px;
    transition: .4s;
    padding: 10px;
  }
  
}

span{
  padding: 6px;
  cursor: pointer;
}

span:hover{
  color: #fbf8f4;
}



.displaySearch{
  width: 85%;
  max-width: 810px;
  margin: 0 auto;
  padding-top: 8%;
  
  .results{
    background-color: #fbf8f4;
    padding: 10px;
    border-radius: 8px;
    margin: 10px;
    opacity: .7;
    transition: .3s;
  }
  
    li{
      list-style: none;
    }
  
    a{
      text-decoration: none;
      color: #28202f;
    }
    
  .results:hover{
    transform: scale(1.017);
    opacity: 1;
    transition: .3s;
  }
}  

footer{
  text-align: center;
  background-color: #28202f;
  color: #fbf8f4;
  bottom: 0;
  
    p{
      padding: 20px;
      margin-bottom: 0;
  }
}
              
            
!

JS

              
                //set up the main function

function search(){
  //set up the variables 
 var search = $('.search').val();
function getSearch (){
//calling the API
  var url = 'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search='+search+'&namespace=0&limit=20&profile=fuzzy&suggest=1&redirects=resolve&utf8=1&callback=';
  $.ajax({
    url : url,
    Accept: 'application/json',
    Headers: {'Api-User-Agent': 'Search-Here'},
    ContentType: "application/x-www-form-urlencoded",
    type: 'GET',
    //the list we got from the wikipedia API sandbox
    data: {
      "action": "opensearch",
	    "format": "json",
	    "search": search,
	    "namespace": "0",
	    "limit": "20",
	    "profile": "fuzzy",
	    "suggest": 1,
	    "redirects": "resolve",
      "UTF-8": 1
    },
    dataType: 'jsonp',
    success: function(data, status){
      //group the items together based on order in object
      //set the vaiables    
      var link = '';
      var title = '';
      var define = '';
      
      function reset(){
    //grab what I want to reset/ clear
    //clear the field 
        var childRemove = $('.results').remove();
    return childRemove;
  }
     reset(); 
     //when pressed again, search will act like the reset button 
      for(var i = 0; i < data[1].length; i++){
        //set the variables to position in the data object
        link = data[3][i],
        define = data[2][i],
        title = data[1][i];
        
        //the template the results will display as
        var results = ('<li class="results"><a target= "_blank" href='+link+'> <h3>'+ title+'</h3><p>'+ define+'</p></a></li>');
        
        //each time that the loop goes through
        //append to displaySearch
        $('.displaySearch').append(results);
      }
      
      //moves the welcome text to the top
      $('#makeSearch').animate({
        paddingTop: '18px'
      },850);

    },//sucess function
    
    error: function(err){
      //alert('Sorry, something went wrong!');
      $('.displaySearch').append('<p>Sorry, Something went wrong!</p>').addClass('fadeIn');
    }//error function
    
  });
}
  getSearch();
}

function reset(){
    //grab what I want to reset/ clear
    //clear the field 
    var childRemove = $('.results').remove();
    return childRemove;
  }

var date = new Date();
var year = date.getFullYear();

document.getElementById("currentYear").innerHTML = year;



$(document).ready(function(){
  $('.toSearch').on('click', search);
  $('.reset').on("click", reset);
  //animates the search bar
  $('.search').on('click', function(){
         $(this).addClass('search-active');         
     });
  
});


              
            
!
999px

Console