Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <body>
  <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
  <div class="container" id="outer">
    
    <p class="panel panel-default" id="jaws"> Just Another Wiki Searcher</p>
    <div class="search-container" id="search">
      <input type="text" id="toFind" placeholder="Search here"/>
    </div>
    
    <div class="btn-group" role="toolbar" id="buttons">
      <div class="btn btn-primary" role="group" title="Push to close" onclick="search()">Push it</div>
      <div class="btn btn-info" role="group" onclick="rndArticle()" title="Random article">?</div>
      <div class="btn btn-warning" id="clear" title="Clear">X</div>
    </div>
    <div class="panel panel-default" id="results-outer">
      <ul id="results"></ul>
    </div>
    <div class="panel panel-default" id="wiki"></div>
</div>
</body>
              
            
!

CSS

              
                @media (max-width: 640px) {
  #outer {
    min-width: 100% !important;
    width: auto !important;
  }
}

/*disable auto-zoom on mobile*/
@media screen and (-webkit-min-device-pixel-ratio:0) { 
  select,
  textarea,
  input {
    font-size: 18px;
  }
}

body {
  font-family: 'Open Sans', sans-serif;  
/*  background-image: url("https://bit.ly/2cORRuH");
  background-size: 21px 20px;
  background-repeat: repeat;*/
  background-color: lightgrey;
}

#outer {
  padding-top: 50px;
  width: 70%;
  text-align: center;
  min-width: 640px;
}

#toFind {
  border-radius: 10px;
  text-align: center;
}

#buttons {
  padding: 30px;
}

#wiki {
  text-align: left;
  display: none;
}

#results {
  text-align: left;  
}

#results-outer {
  border: 0px;
  opacity: 1;
  display: none;
}

#jaws {
  font-size: 20px;
}
              
            
!

JS

              
                //push enter to search
$(function() {
  $("#search input").keypress(function(key) {
    if (key.keyCode == 13) {
      search();
    }
  });
});

$("#clear").click(function() {
  $("#wiki").slideUp("slow");
  $("#results-outer").slideUp("slow");
  $("#toFind").val('');
  $("#toFind").focus(); //put cursor in box
});

//wrapper for findIt() (user input)
function search() {
  var q = $("#toFind").val();
  if(q == "") return;
  findIt("https://en.wikipedia.org/w/api.php?action=opensearch&search=" + q + "&format=json&callback=?", q);
}

//wrapper for findIt() (random article)
function rndArticle() {
  findIt("https://en.wikipedia.org/w/api.php?action=query&list=random&rnnamespace=0&format=json&callback=?", 'RND');
}

//get suggested articles
function findIt(url, q) {
  console.log(url);
  $("#wiki").slideUp("slow");
  $("#results-outer").slideUp("slow");
  document.getElementById("wiki").innerHTML = "";
  $.ajax({
    url: url,
    type: 'GET',
    dataType:'json',
    success: function(data) {
      console.log(data);
      $("ul").empty();
      //if random article, call getIt() & return
      if(q == 'RND') {
        return getIt(data.query.random[0].title);
      }
      document.getElementById("wiki").style.padding = "0px";
      document.getElementById("results").style.padding = "30px";         
      if(data[1].length == 0) {
        $("#results").append("<li><h4>(╯°□°)╯︵ ┻━┻</h4> (Nothing found)</li>");
        $("#results-outer").slideDown("slow");
        return;
      }
      var len = data[1].length;
      for(var i = 0; i < len; i++) {
        if(typeof data[1][i] != 'undefined') {
          //if it has a disambiguation page, open in new window
          if(data[2][i].includes("may refer to")) {
            $("#results").append("<li><h4>" + data[1][i] + "</h4><span>" + data[2][i] + "</span>..<a href='https://en.wikipedia.org/wiki/" + data[1][i] + "\' target='_blank'>Continue reading</a></li>");
          //else, add item to list
          } else {
            $("#results").append("<li><h4>" + data[1][i] + "</h4><span>" + data[2][i] + "</span>..<a href='#' onclick='return getIt(\"" + data[1][i] + "\")'>Continue reading</a></li>");
          }
        } 
      }
      $("#results-outer").slideDown("slow");
    }
  });
}

//get specific article
function getIt(toGet) {
  if(toGet == "") return;
  $("#wiki").slideUp("slow");
  $("#results-outer").slideUp("slow");
  document.getElementById("results-outer").style.padding = "0px";
  
  $("ul").empty();
  $.ajax({
    type: "GET",
    url: "https://en.wikipedia.org/w/api.php?action=parse&format=json&prop=text&section=0&page=" + toGet + "&callback=?",
    contentType: "application/json; charset=utf-8",
    async: false,
    dataType: "json",
    success: function (data) {
      $("#toFind").val(toGet);
      var html = data.parse.text["*"];
      var text = $('<div></div>').html(html);
      //remove links
      text.find('a').each(function() {
        $(this).replaceWith($(this).html());
      });
      //remove references
      text.find('sup').remove();
      //remove cite error
      text.find('.mw-ext-cite-error').remove();
      $('#wiki').html($(text).find('p'));
      $("#wiki").append("<a href='https://en.wikipedia.org/wiki/" + toGet + "'  target=\'_blank\'>Read full article at Wikipedia</a>");
      document.getElementById("wiki").style.padding = "30px";
      $("#wiki").slideDown("slow");
    },
    error: function (errorMessage) {
      console.log("something went wrong");
    }
  });
}

              
            
!
999px

Console