cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
              <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<div class="vertical-align" id="vert">
<div class="input-group">
      <input type="text" class="form-control" placeholder="Search Wikipedia..." id="query">
      <span class="input-group-btn">
        <button class="btn btn-default" type="button"  id="go"><i class="fa fa-search"></i></button>
      </span>
    </div><!-- /input-group -->
</div><!-- /vert-align -->
  <div class="vert-div">
  <a href="http://en.wikipedia.org/wiki/Special:Random" target="_blank"><div class="btn btn-primary random" id="random">I'm Feeling Random
</div></a> <!-- /btn -->
</div>
<div id="link">
<div id="create">
  </div>
</div>
<!--<div class="text-center" style="padding-bottom: 50px; color:white;">
  <a href="http://robertvalmassoi.com" target="_blank">by valmassoi</a></div> -->
            
          
!
            
              
body{
  margin-top: 20px;
  background: grey;

}
a {
    color: black !important;
    text-decoration: none !important;
}
.input-group{
  width: 450px;
  margin: 0px auto;
  text-align: center;
  /*height: 100px;*/
}
.vertical-align {
   position: absolute;
   top: 50%;
   margin-top: -17px;/* half of #content height*/
   left: 0;
   width: 100%;
}
.vert-div{
 width: 170px !important;
  margin: 0px auto !important;
  text-align: center !important;
}
.random{
   margin-top: 35px;
}


.hide{
 visiblity: hidden;
}
.hideCallout{
 visiblity: hidden;
}
.bs-callout {
    padding: 20px;
    margin: 20px 0;
    border: 1px solid #eee;
    border-left-width: 5px;
    border-radius: 3px;
  width: 80%;
  background: white;
  margin: 30px auto;
}
.bs-callout:hover {
  background: #eee !important;
  box-shadow: 5px 5px 5px rgba(100,100,100, 0.5);
}
.bs-callout h4 {
    margin-top: 0;
    margin-bottom: 5px;
}
.bs-callout p:last-child {
    margin-bottom: 0;
}
.bs-callout code {
    border-radius: 3px;
}
.bs-callout+.bs-callout {
    margin-top: -5px;
}
.bs-callout-default {
    border-left-color: #777;
}
.bs-callout-default h4 {
    color: #777;
}
.bs-callout-primary {
    border-left-color: #428bca;
}
.bs-callout-primary h4 {
    color: #428bca;
}
.bs-callout-success {
    border-left-color: #5cb85c;
}
.bs-callout-success h4 {
    color: #5cb85c;
}
.bs-callout-danger {
    border-left-color: #d9534f;
}
.bs-callout-danger h4 {
    color: #d9534f;
}
.bs-callout-warning {
    border-left-color: #f0ad4e;
}
.bs-callout-warning h4 {
    color: #f0ad4e;
}
.bs-callout-info {
    border-left-color: #5bc0de;
}
.bs-callout-info h4 {
    color: #5bc0de;
}
            
          
!
            
              //http://en.wikipedia.org/wiki/Special:Random
// https://www.mediawiki.org/wiki/API:Main_page
var url;
$(function() {//ready short hand
});
function jsonFun(url){
    $.getJSON(url, function(json) {
      console.log(JSON.stringify(json));
      labeler(json);
    });
}
$("#query").keyup(function(event){//adds return
    if(event.keyCode == 13){
        $("#go").click();
    }
});
$("#go").on("click", function(){
  var query = document.getElementById('query').value;
  //console.log(query);
  $("#vert").removeClass("vertical-align");//animate?
  $("#random").addClass("hide");
  var nospaceQuery = query.replace(/\s+/g,"%20");
  //url = "https://en.wikipedia.org/w/api.php?action=query&titles=" + nospaceQuery + "&prop=revisions&rvprop=content&format=json&callback=?";
  url = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=" + nospaceQuery + "&callback=?";
  jsonFun(url);
});
function labeler(json){
  $(".input-group").removeClass("animated shake");
  if(json[2].length==0){
    console.log("EMPTY");
    $(".input-group").addClass("animated shake");
    $("#create").html(
        "<div class='bs-callout bs-callout-primary' id='callout'>"
  +"<h4>No Results</h4>"
  +"<p>Please Search Again</p>"
+"</div>"
        );
  }else{$("#create").html("");//clears if no search res b4
    // info type //
    var titles = json[1];
    var descriptions = json[2];
    var urls = json[3];
    for (i=0; i<titles.length; i++){
      // Callouts //
        $("#create").append(//APPEND NOT HTML
        "<a href='" + urls[i] + "' target='_blank'>" +
          "<div class='bs-callout bs-callout-primary' id='callout"+i+"'>"
  +"<h4>"+titles[i]+"</h4>"
  +"<p>"+descriptions[i]+"</p>"
+"</div>" + "</a>"
        );
      // Add Url //
    // $("#descrp"+i).html("<a href='" + urls[i] "' target'_blank'>" "</a>"); 
    }
  }
}

            
          
!
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