css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body>
  <h1> Wikipedia Search </h1>
  <h3> or click <a href = "https://en.wikipedia.org/wiki/Special:Random" target = "_blank"> here </a> for a random article...<h3>
  
   <!-- This is the input box and search button -->
    
  <div class = "container" id = "inputBox">
    <div class = "input-box">
     
      <input type = "form-control" id = "inputText" placeholder = "Search Wikipedia here!">
      <button class = "btn btn-primary" id = "search">Search</button>
      
    </div>                                  
  </div>
    
    <br>
    <div class = "container" id = "results">
      <ul>
        <a class = "links" id = "resName1" href = "#" target = "_blank">
        </a>
        <div id = "resText1"> 
        </div>
        <br>
        <a class = "links" id = "resName2" href = "#" target = "_blank">
        </a>
        <div id = "resText2">
        </div>
        <br>
        <a class = "links" id = "resName3" href = "#" target = "_blank">
        </a>
        <div id = "resText3">
        </div>
        <br>
        <a class = "links" id = "resName4" href = "#" target = "_blank">
        </a>
        <div id = "resText4"> 
        </div>
        <br>
        <a class = "links" id = "resName5" href = "#" target = "_blank">
        </a>
        <div id = "resText5">
        </div>
        <br>
        <a class = "links" id = "resName6" href = "#" target = "_blank">
        </a>
        <div id = "resText6">
        </div>        
      </ul>
    </div>
  <div id = "closer" style = "font-size: 0.6em">
    Written and Coded by <a target = "_blank" href = "https://jwolfgang.info">Jim C-M</a> 2018
    </div>
</body>
            
          
!
            
              body {
   background-color: white;
}

h1 {
  margin-top: 200px;
  text-align: center;
}

.links {
  font-size: 125%;
}

h3 {
  text-align:center;
}

.inputBox {
 text-align: center;
}

#results {
  margin-top: 50px;
  text-align:left;
  height: 1000px;
  width: 1000px;
  overflow: auto;
  /*border: 2px solid black;*/
}


            
          
!
            
              $(document).ready(function() {
  //Creates variable that stores input on click
  // Get the input field
var input = document.getElementById("inputText");

// Execute a function when the user releases a key on the keyboard
input.addEventListener("keyup", function(event) {
  // Cancel the default action, if needed
  event.preventDefault();
  // Number 13 is the "Enter" key on the keyboard
  if (event.keyCode === 13) {
    // Trigger the button element with a click
    document.getElementById("search").click();
  }
});
  $('#search').click(function(){
    var wikiSearch = $('#inputText').val();
    //console.log(wikiSearch);
    var searchURL = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + wikiSearch +"&format=json&callback=?";
  $.ajax({
    type: "GET",
    url: searchURL,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data, textStatus, jqXHR){
      console.log(data);
      var res1 = data[1][0]; //This gets the name of the first hit
      var resText1 = data[2][0]; //This gets a short description of the first hit
      var res2 = data[1][1]; //This gets the name of the first hit
      var resText2 = data[2][1]; //This gets a short description of the first hit
      var res3 = data[1][2]; //This gets the name of the first hit
      var resText3 = data[2][2]; //This gets a short description of the first hit
      $('#resName1').html(res1);
      $('#resText1').html(resText1); 
      $('#resName2').html(res2);
      $('#resText2').html(resText2); 
      $('#resName3').html(res3);
      $('#resText3').html(resText3); 
      $('#resName1').attr("href", data[3][0]);
      $('#resName2').attr("href", data[3][1]);
      $('#resName3').attr("href", data[3][2]);

      var res4 = data[1][3]; //This gets the name of the first hit
      var resText4 = data[2][3]; //This gets a short description of the first hit
      var res5 = data[1][4]; //This gets the name of the first hit
      var resText5 = data[2][4]; //This gets a short description of the first hit
      var res6 = data[1][5]; //This gets the name of the first hit
      var resText6 = data[2][5]; //This gets a short description of the first hit
      $('#resName4').html(res4);
      $('#resText4').html(resText4); 
      $('#resName5').html(res5);
      $('#resText5').html(resText5); 
      $('#resName6').html(res6);
      $('#resText6').html(resText6); 
      $('#resName4').attr("href", data[3][3]);
      $('#resName5').attr("href", data[3][4]);
      $('#resName6').attr("href", data[3][5]);

          }    
    }
    
    )
  })
  
  
});
            
          
!
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