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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

HTML

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

CSS

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

JS

              
                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

Console