css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="container-fluid cFluid">
  <div class="row" id="fstBtn">
    <a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">
      <button class="btn btn-primary btn-lg">
     Visit random Wikipedia Page

<div class="row searchQuery">
  <div class="col-xs-2 col-md-3"></div>
  <div class="col-xs-8 col-md-6">
      <div class="input-group">
         <input type="text" class="form-control" placeholder="Search Wikipedia page here..." id="inputId">
      <span class="input-group-btn">
        <button class="btn btn-default" type="button" id="buttonId">Go!</button>
  <div class="col-xs-2 col-md-3"></div>
  <!-- /input-group -->
  <!-- /.col-lg-6 -->
    <div class="row" id=#>
      <div id="test0"></div>

<div id="test5"></div>
<div class="row">
     <p class="text-center lowP"> written and coded by <br> <span style="color: blue">Yaroslav Paslavskiy </p>
  margin: 5% 0px 10px 0px;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px 0px 10px 0px;
  border-radius: 5%;
  background-color: #eee;
  border-radius: 5px;

              $(document).ready(function() { 
  // Here we check and save input value

   // var inputValue="Lalala";
     var inputValue= $( "#inputId").val();
       //here we add + to input value;
     var res = inputValue.split(" ");
     res = res.join("+");
    // $("#resultId").html(res); /// we have inputValue as arraynow
    // Now we get the JSON
     var myJsonLink ="https://en.wikipedia.org/w/api.php?action=query&format=json&prop=pageimages%7Cpageterms%7Cinfo%7Cextracts&generator=prefixsearch&redirects=1&formatversion=2&piprop=thumbnail&pithumbsize=300&pilimit=10&wbptterms=description&inprop=url&exsentences=3&exlimit=20&exintro=1&explaintext=1&exsectionformat=wiki&gpssearch="+res+"&gpslimit=10&callback=?";
        $.getJSON(myJsonLink, function(json) 
         var  wikiLength = json.query.pages.length;
       // alert("pageId#"+ wikiLength);
            var WikiObj = function(title,description,url,urlImage,extract) 
              this.title = title;
              this.description = description;
              this.url = url;
              this.urlImage= urlImage;
              this.extract = extract;
             var wikiObjArray = [];
         // end ofconstructor
          //making array of usefuldata
          // pages[i].thumbnail.source - doesnt exist
          for(var i=0; i< wikiLength; i++)
            var execTitle = "";
            var execDescription = "";
            var execUrl = "";
            var execUrlImage = "";
            var execExtract = "";
            if (json.query.pages[i].hasOwnProperty("terms") === false) 
              execDescription = "";
            }  else {
              execDescription = json.query.pages[i].terms.description[0];
            if(json.query.pages[i].hasOwnProperty("thumbnail") === false){
               execUrlImage = "No Image";
              if(json.query.pages[i].hasOwnProperty("extract") === false){
               execExtract = "No information yet";
              if(json.query.pages[i].hasOwnProperty("title") === false){
               execTitle = "No Title";
                 execTitle = json.query.pages[i].title;
              execUrl = json.query.pages[i].fullurl;
            wikiObjArray[i] = new WikiObj(execTitle, execDescription, execUrl,execUrlImage, execExtract);
                //alert("znachenie Json ot" + i+ " :" +json.query.pages[i]); 
              if (json.query.pages[i]["terms"] == undefined){  //.description[0]
                wikiObjArray[i] = new WikiObj(json.query.pages[i].title, "", json.query.pages[i].fullurl,json.query.pages[i].thumbnail.source, json.query.pages[i].extract);
              } else if(json.query.pages[i]["thumbnail"]==undefined)
                wikiObjArray[i] = new WikiObj(json.query.pages[i].title, json.query.pages[i].terms.description[0], json.query.pages[i].fullurl,"No Image", json.query.pages[i].extract);
              } else if(json.query.pages[i]["extract"]==undefined)
                wikiObjArray[i] = new WikiObj(json.query.pages[i].title, json.query.pages[i].terms.description[0], json.query.pages[i].fullurl,json.query.pages[i].thumbnail.source, "No information yet");
              else {
             wikiObjArray[i] = new WikiObj(json.query.pages[i].title, json.query.pages[i].terms.description[0], json.query.pages[i].fullurl,json.query.pages[i].thumbnail.source, json.query.pages[i].extract);
            } // for lopp    
         // alert("array fact dlina "+ wikiObjArray.length);
          //finished with array wikiObjArray with useful data
         //transforming Array into HTML content
         var htmlWiki="";
        // htmlWiki += "<div class=\"row\" id=\"rowId\">";
         for (var j=0; j< wikiObjArray.length; j++)
             htmlWiki += "<div class=\"row\" id=\"rowId\">";
            htmlWiki += "<div class=\"col-xs-3 col-md-3\">";
            htmlWiki +="<img class=\"img-responsive imgId\"  src=\"" + wikiObjArray[j].urlImage + "\" alt=\"WikiPhoto\"></div>";
            htmlWiki += "<div class=\"col-xs-9 col-md-9\" id=\"infoD\">";
            htmlWiki +="<h2>"+wikiObjArray[j].title+"</h2>";
            htmlWiki += "<h3>"+ wikiObjArray[j].description +"</h3>";
            htmlWiki +=  "<p>"+ wikiObjArray[j].extract +"</p>";
            htmlWiki += "<div id=\"buttonD\"><a href=\""+ wikiObjArray[j].url+"\" alt=\"\" target=\"_blank\"><button class=\"btn btn-primary\" > Read full story on Wikipedia.org</button> </a></div>";
           htmlWiki += "</div>";
          htmlWiki += "</div>";
        $("#test0").html(htmlWiki); //JSON.stringify(wikiObjArray)
          // finished transforming Array into HTML data
        //  $("#test5").html(JSON.stringify(json)); 
        // alert(myJsonLink);
   // return inputValue;

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