123

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>
  <div class="container background">

    <h1 class="heading"> Wiki Search</h1>

    <div class="machine">

      <form>
        <input type="text" id="searchterm" placeholder="Search"></input>
      
        <button id="search" type="submit" class="button"> Search   </ button>
     
      <a href ='https://en.wikipedia.org/wiki/Special:Random' target ="_blank"> 
</form>
     <button  class="button" >Random Wiki Page! </button>
        </a>

        <div>
          <ul class="results" id="output">

          </ul>
        </div>


    </div>
  </div>
</body>
            
          
!
            
               body {
  background-color:  white;
   background-image: url("http://static1.squarespace.com/static/563e3eefe4b0fd5a100038cb/563e427ee4b0345c9b1703e1/56beaf4d2b8dde7190bd832f/1455534051010/?format=1500w");
}

.heading {
  color: aqua;
  text-decoration: underline;
  font-size: 130px;
  font-weight: bold;
  text-align: center;
  text-shadow: 4px 3px black;
}


.machine {
  background-color:aqua;
  align: center;
  border: 5px solid black;
  margin-left:auto;
    margin-right:auto;
  border-radius: 4px;
}
.form{
  text-align:center;
  font-size:40px;
  font-weight:bold;
  text-decoration:underline;
  text-shadow: 1px 1px grey;
  color:black;
}

input[type=text] {
    width: 70%;
    padding: 12px 10px;
    margin: 1px ;
    box-sizing: border-box;
  border:4px solid black;
  border-radius: 6px;
  
}
.button{
  border:3px solid black;
  border-radius:6px;
}

.results{
  text-align:left;
  display: inline-block;
 list-style-type:none;
}
.liresults{
  background-color:#aaa;
  color:black;
  border:2px solid black;
     margin-left: -10pt;
width: 540px;
  }
            
          
!
            
              $(document).ready(function() {
  $("#search").click(function() {
    //Corresponds to button ID which when clicked runs this function
    $("form").submit(function(e) {
            e.preventDefault()
            //This STOPS the form doing the default action 
    });

    var searchterm = $("#searchterm").val();
    //define searchterm as value of input box (ID =searchterm)

    var url = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchterm + "&format=json&callback=?";
   
    var output = "#output";
   
    $.ajax({
      type: "GET",
      url: url,
      
      dataType: "jsonp",
      success: function(data)

      {
        $(output).empty();
        //Clear last search AND
        $(output).append( 
          //Append a list item with 1:array title 2:array descrip 3: Link
 "<li>" +  data[1][0] + ": " + data[2][0] + "<br>" + "<a  href="+ data[3][0]+ ">" +data[3][0] + "</a>"  + "</li>" + "<br><br>" +
 "<li>" + data[1][1] + ": " + data[2][1] + "<br>" + "<a  href="+ data[3][1]+ ">" +data[3][1] + "</a>"  + "</li> " + "<br> <br>" + 
"<li>" +  data[1][2] + ": " + data[2][2] + "<br>" + "<a  href="+ data[3][2]+ ">" +data[3][2] + "</a>" +"</li>" + 
          "<br> <br>" + "<li>"  +  data[1][3] + ": " + data[2][3]+ "<br>"+ "<a  href="+ data[3][3]+ ">" +data[3][3] + "</a>" + "</li>"  +"<br> <br>" + 
  "<li>"  +  data[1][4] + ": " + data[2][4] + "<br>" + "<a  href="+ data[3][4]+ ">" +data[3][4] + "</a>"  +"</li>"
         )
        
        $("li").wrap("<div class='liresults'></div>");
        //This wraps all LI ids with a div styled to liresults!

      },

      error: function(errormesage) {
        alert("error");
        //if function doesnt work let user know with alert message
      }
    });
  });
});

            
          
!
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.

Console