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.

            
              <div class="container">
  <div class="row">
    <div class="col-xs-12 col-lg-9 col-lg-push-3">
      <h1 class="title">Wiki Viewer</h1>
    </div>
  </div>
  <div class="row text-center search-row">
    <div class="col-xs-12 col-lg-10 col-lg-push-1">
      <form action="#">
        <input id="search" placeholder="Search Wikipedia" type="text" name="search" class="input">
        <input onclick="performSearch()" class="btn search-btn" type="button" value="Search">
        <button onclick="randomPage()" class="btn btn-secondary random-btn" id="random">Random Article</button>
      </form>
    </div>
  </div>
  
  <div class="row">
    <div class="col-xs-12 col-lg-9 col-lg-push-2">
      <div class="" id="wikiFrame">

      </div>
    </div>
  </div>
</div>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Chicle');

body {
  background-color: #ffcc80;
}

.red {
  border:2px solid red;
}

.title {
  font-family: 'Chicle', cursive;
  letter-spacing: 2px;
  margin-top:4rem;
  margin-bottom:4rem;
  position:relative;
  right:4rem;
  
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: none;
}

.input {
  width: 46rem; 
  border-bottom:2px solid black;
  border-top:none;
  border-left:0;
  border-right:0;
}
input, #search {
/*   border:2px solid red; */
  padding:.7rem;
  background-color:transparent;
  font-size:24px;
}

.search-row {
  padding-top:2rem;
  padding-bottom:2rem;
}
.search-btn {
  border: 2px solid #242424;
  border-radius:0;
  background-color:#ffffb0;
  
}
.search-btn:hover {
  color:orange;
  border:2px solid orange;
}
.random-btn {
  background-color:#ffffb0;
  border: 2px solid #242424;
  border-radius:0;
}
.random-btn:hover {
  color:orange;
  border:2px solid orange;
}

.wikiCard {
/*   border:2px solid red;  */
  background-color:#fafafa;
  margin: 0 auto 30px auto;
  padding:20px 25px 8px 25px;
  border: 2px solid #242424;
  box-shadow: 5px 5px 0px 0px #242424;
}
            
          
!
            
              var root =
  "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages%7Cextracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=";
var cb = "&callback=?";
var root2 = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=random&limit=1";

function performSearch() {
  //on click prevents default page load and captures the value of input
  // in variable query
  $("input.btn").click(function(e) {
    // e.preventDefault();
    var query = $("#search").val();
    // ajax request
    $.ajax({
      url: root + query + cb,
      data: query,
      dataType: "json",
      type: "POST",
      headers: { "Api-User-Agent": "Example/1.0" },
      success: function(data) {
        // do something with data
        $("#wikiFrame").html(" ");
        var pages = data.query.pages;
        var page = Object.keys(pages);
        for (page in pages) {
          if (pages.hasOwnProperty(page)) {
            var wikiTitle = pages[page].title;
            var wikiExtract = pages[page].extract;
            var html =
              "<div class='wikiCard'><h3>" +
              wikiTitle +
              "</h3><br><p>" +
              wikiExtract +
              "</p></div>";
            $("#wikiFrame").append(html);
          }
        }
      }
    });
  });
}


function randomPage() {
  $("#random").click(function(e) {
    e.preventDefault;
     $.ajax({
       url: "https://en.wikipedia.org/w/api.php?action=query&format=json&list=random&rnlimit=1" + cb,
      dataType: "json",
      type: "POST",
      // headers: { "Api-User-Agent": "Example/1.0" },
      success: function(data) {
        $("#wikiFrame").html(" ");
        console.log(data.query.random);
        var randomPages = data.query.random;
        var randomPage = Object.keys(randomPages);
          for (randomPage in randomPages) {
            if (randomPages.hasOwnProperty(randomPage)) {
              var randomTitle = randomPages[randomPage].title;
              var html =
              "<div class='wikiCard'><h3>" +
              randomTitle +
              "</h3><br></div>";
              $("#wikiFrame").append(html);
              // console.log(randomTitle);
            }
          }
      }
     });
   
    
    
  });
}




            
          
!
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