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

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

              
                <html>
  <body>
    <div>
      <h1>Wikipedia Viewer</h1>
    </div>    
    <div class="container-fluid" id="control">
      <label>Search random article </label>
      <input id="input" type-"text" name="Search" placeholder="search...">
      <button class="btn brn-default" id="btn_search">Search</button>
      <button class="btn brn-default" id="btn_rand">Random article</button>
    </div>
    <div class="container" id="display">
    </div>
    <div class="panel-footer" id="footer">Developed by Felnyr 2017</div>
  </body>
</html>

              
            
!

CSS

              
                body{
  text-align:center;
  margin:auto;
  color:lightgrey;
}
h1{
  color:black;
}
div{
  width:auto;
  padding:10px;
  margin:5px;
}
button{
  color:black;
  margin:3px 3px 0 0;
}
a{
  font-size:20px;
  margin:0;
  color:orange;
}
a:link, a:visited{
  font-size:20px;
  margin:0;
  color:orange;
  text-decoration:none;
}
a:hover, a:active{
  font-size:20px;
  color:white;
  text-decoration:none; 
}
a:focus{
  outline:none;
}
#control{
  padding:10px;
  background:orange;
}
#input{
  color:black;
  margin-bottom:5px;
  padding:5px 50px 6px 5px;
}
#footer{
  color:grey;
}


              
            
!

JS

              
                $(document).ready(function(){
  
  $(document).keypress(function(e){
    if(e.which == 13) {
     $("#btn_search").click()
    }
  });
$("#btn_search").on("click", function(){
  var SearchValue = $("#input").val();
  var url = "https://en.wikipedia.org/w/api.php?action=opensearch&search="+SearchValue;
  $("#display").empty();
  $.ajax({   
    url: url,
    type:"GET",
    dataType:"jsonp",
    async:true,
    success: function(data){
      for(var i=0;i<data[1].length;i++){
      $("#display").append("<div id=\"term"+i+"\"><a href=\""+data[3][i]+"\" target=\"_blank\">"+data[1][i]+"</a><br>"+data[2][i]+"</div>");
      $('#term'+i).hide();
      }
      
      //Random Color&slide script by Felnyr

      for(var i=0;i<data[1].length;i++){
      $("#term"+i).css("background-color", "#"+Math.floor(Math.random()*10)+Math.floor(Math.random()*10)+Math.floor(Math.random()*10));
      $("#term"+i).css("border-radius","6px");
      $("#term"+i).show(200*i+300);  
      }//end script
      
    },
    error: function(error){
      alert("You typed nothing");    
    }
    
  }); // ajax req end for normal search
});//btn search end

$("#btn_rand").on("click", function(){
  $("#display").empty();
  $.ajax({
    type: "GET",
    url: "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=random&grnnamespace=0&grnlimit=5&prop=extracts&exsentences=5&exintro=true&exlimit=5excontinue=1",
    dataType: "jsonp",
    async: false,
    success:function(randId){ 
     
     console.log(Object.values(randId.query.pages));
     var randId2 = Object.values(randId.query.pages);
     $.each(randId2, function(index, val) {
     $("#display").append("<div id=\"term"+index+"\"><p><a href=\"https://en.wikipedia.org/?curid="+val.pageid+"\" target=\"_blank\">"+val.title+"</a></p><p>"+val.extract+"</p></div>");
     $('#term'+index).hide();  
       
     //Random Color&slide script by Felnyr

      for(var i=0;i<5;i++){
      $("#term"+i).css("background-color", "#"+Math.floor(Math.random()*10)+Math.floor(Math.random()*10)+Math.floor(Math.random()*10));
      $("#term"+i).css("border-radius","6px");
      $("#term"+i).show(200*i+300);  
      }//end script
       
    }) //end ajax for random         
    },
    error:function(errorRand){
     alert("Cannot load articles. Try again");
    }
  });

  
});//btn rand end  
});//doc ready end 


              
            
!
999px

Console