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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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

Console