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

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

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.

            
              <html>
  <head>
    
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    
  </head>
    <title></title>
  <body>
    <div id="container">
    
      <h2><a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank" class="random">A random article</a></h2>
      <h3>Click and Start Typing</h3>
      <form><input id="sbox" type="text" name="search" autocomplete="off" class="ui resize-input"><a class="resize-close"><i class="fa fa-times" aria-hidden="true"></i></a></form>
    <header>

</header>      
    </div>
      <footer>Coded by Oscar Salvatierra for a freeCodeCamp challenge</footer>
      <!--div id="output"></div>
  
    </div For testing json output results-->
    
  </body>
  
</html>
            
          
!
            
              html{ height: 100%;}
body {
  background-color: #f4fbfc;
  min-height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
}

footer {
  position: inherit;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  background-color: #efefef;
  text-align: center;
  font-size: 0.8em;
  margin-bottom: 0%;
}
#container {
  width: 100%;
  text-align: center; 
}

#sbox {
    border-color: #38bac1;
    border-style: solid;
    height: 36px;
    width: 38px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 23px;
    border-width: 5px;
    outline : none;
    
    z-index: 10
}

.resize-close {
    margin-left: -24px; 
    cursor: pointer;
}

a.random{
  color: #2fb5c6;
}
#tcontainer {
    border-color: #38bac1;
    border-style: solid;
    margin: 0 auto;
    height: 100%;
    width: 80%;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 23px;
    border-width: 5px;
    transition:all .3s;
    cursor: pointer;
    outline : none;
    padding: 11px 35px 10px 35px;
    text-align: left;
  margin-bottom: 20px;
opacity:0;  /* make things invisible upon start */
 -webkit-animation:fadeIn ease-in 1;  /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */
 -moz-animation:fadeIn ease-in 1;
 animation:fadeIn ease-in 1;
 
 -webkit-animation-fill-mode:forwards;  /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/
 -moz-animation-fill-mode:forwards;
 animation-fill-mode:forwards;
 
 -webkit-animation-duration:.5s;
 -moz-animation-duration:.5s;
 animation-duration:.5s;
}

@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
            
          
!
            
              //setup 'before' functions for countdown on keyup
    var typingTimer; //timer identifier
    var doneTypingInterval = 500;  //time in ms

     //on keyup, start the countdown
    $('.ui').keyup(function(){
      var value = $('.ui').val;
        clearTimeout(typingTimer);
        if (value) {
        typingTimer = setTimeout(doneTyping, doneTypingInterval);
        } 
    });

 //user is "finished typing," do something
    function doneTyping () {
     httprequest();
    }

function httprequest (){
// function to capture input and add to Wiki URL  
function add() {
  var up = document.getElementById('sbox').value;
  var tempurl = "";
  var urlsearchT = "https://en.wikipedia.org/w/api.php?action=query&format=json&origin=*&generator=search&gsrsearch=" + up + "&prop=extracts&gsrnamespace=0&gsrlimit=10&gsroffset=0&gsrwhat=text&exintro&explaintext&exsentences=1&exlimit=max";  
           if (up !== null) {
            return urlsearchT;
          } else if (up == ""){
            return tempurl;
           }
 };
  
var request = new XMLHttpRequest();
var method = 'GET';
var async = true;

// the request  
request.open(method, add(), async);
request.send(); 
request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
      var data = JSON.parse(request.responseText);      
      var header = document.querySelector('header');
    }

//populate function pull data variable above
request.onload = function() {  
  populate(data);
  }
  function populate() { 
    header.innerHTML = ""; 
 
//getobj, the variable used twice
var getobj = Object.entries(data['query']["pages"]);

    //gets the Title and text
    var title = [];    
    for (var i=0;i<getobj.length;i++){
    var output = Object.values(getobj[i][1]);
    var link = "https://en.wikipedia.org/wiki/";
      
    title.push(Object.values("<div id='tcontainer'><p><a href='" + link + output[2] + "'target='_blank'>" + output[2]+"</a></br>" + output[4] + "</p></div>"));
      
    var re = title.toString().replace(/,/g,"");
 }   
   var mytitle = document.createElement('h1');
    mytitle.innerHTML = re;
    header.appendChild(mytitle);
  }
};
 
}

//resize variables and jquery actions
var inputW = '200px';
var inputWreturn = '38px';

$('.resize-close').hide();
$('.resize-input').focus(function(){
  $(this).animate({
    width: inputW}, 400);
  $('.resize-close').show();
})
$('.resize-close').click(function(){
 $('.resize-input').animate({
   width: inputWreturn}, 400);
  $('.resize-close').hide();
  $('#sbox').val('');
  doneTyping ();
});
            
          
!
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