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.

            
              <head>
  <meta charset=UTF-8>
  <meta name=viewport content="width=device-width,initial-scale=1">
  <meta http-equiv=X-UA-Compatible content="ie=edge">
  <link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel=stylesheet>
  <title>Wikipedia Viewer</title>
  <link href="styles.css" rel="stylesheet">
</head>

<body>
  <div class=flex>
    <header class=site-header>
      <div class=gradient-border> &nbsp; </div>
      <div class="wrapper flex flex--col flex--aligni-center">
        <img src=https://en.wikipedia.org/static/images/project-logos/enwiki.png alt="" class=site-header__logo>
        <nav class="primary-nav flex flex--aligni-center">
          <ul>
            <li>
              <a href=https://en.wikipedia.org/wiki/Main_Page>Main Page</a>
            </li>
            <li>
              <a href=https://en.wikipedia.org/wiki/Portal:Contents>Contents</a>
            </li>
            <li>
              <a href=https://en.wikipedia.org/wiki/Portal:Featured_content>Featured Content</a>
            </li>
            <li>
              <a href=https://en.wikipedia.org/wiki/Portal:Current_events>Current events</a>
            </li>
            <li>
              <a href=https://en.wikipedia.org/wiki/Special:Random>Random Article</a>
            </li>
            <li>
              <a href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en">Donate to Wikipedia</a>
            </li>
            <li>
              <a href=https://shop.wikimedia.org/>Wikipedia store</a>
            </li>
          </ul>
        </nav>
      </div>
    </header>
    <div class="flex flex--col flex--full-width">
      <div class="top-bar flex flex--justify-center flex--aligni-center">
        <form>
          <input class=top-bar__search type=text placeholder="Search Wikipedia">
        </form>
        <a class=button href=https://en.wikipedia.org/wiki/Special:Random target=_blank>Random</a>
        <div class=gradient-border--top> &nbsp; </div>
      </div>
      <div class=main-content>
        <div class=wrapper>
        </div>
      </div>
    </div>
  </div>
</body>
            
          
!
            
              *{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    font-family: 'Lato', sans-serif;
    background-image: linear-gradient(
        to top,
        rgb(242, 242, 242),
        rgb(242, 242, 242) 75%,
        #fff 100%
    );
    background-attachment: fixed;
}

body li {
        list-style: none;
    }

body a {
        text-decoration: none;
        color: black;
    }

form{
    width: 50%;
}

.wrapper{
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 1135px;
}

.flex{
    display: flex;
  }

.flex--justify-center{
    justify-content: center;
  }

.flex--aligni-center{
      align-items: center;
  }

.flex--full-height{
      height: 100%;
  }

.flex--full-width{
    width: 100%;
}

.flex--col{
    flex-direction: column;
}

.site-header{
    position: relative;
    height: 100vh;
    width: 200px;

  }

.site-header__logo{
        max-width: 150px;
        height: auto;
        display: block;
    }

.primary-nav{
    margin-top: 2rem;
    padding-left: 1rem;
}

.gradient-border{
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    background-image: linear-gradient(
        to top,
        #62d1f2,
        #62d1f2 65%,
        #fff 89.5%
    );
    height: inherit;
}

.gradient-border--top{
    position: absolute;
    right: 0;
    bottom: 0;
    height: 2px;
    background-image: linear-gradient(
        to left,
        #62d1f2,
        #62d1f2 85%,
        #fff 100%
    );
    width: 100%;
}

.top-bar{
    position: relative;
    height: 100px;
    width: 100%;
}

.top-bar__search{
    width: 100%;
    padding: .3rem;
    border: 1px solid gray;
    border-radius: 2px;
}

.button{
    padding: .25rem 1rem;
    border-radius: 3px;
    color: #fff;
    background-color: #62d1f2;
    margin-left: 1rem;
    border: 1px solid gray;
    line-height: 16px;
}

.main-content{
    width: 100%;
    padding: 1rem;
    background-color: #fff;
}

.wikipedia-result{
    width: 100%;
    border: 1px solid #62d1f2;
    padding: 1rem;
    background-color: #f3fbf3;
    margin-bottom: 1rem;
}

.wikipedia-result--top{
        width: 100%;
        height: 30px;
        background-color: #d3fbd3;
        line-height: 30px;
        padding: 0 0 0 5px;
        margin-bottom: 1rem;
    }

            
          
!
            
              $(document).ready(function() {
    //Take input from search form and build wiki api url
    $('form').submit(function(e) {
      e.preventDefault();
      var searchString = $('.top-bar__search').val().replace(/ /g, '+');
      console.log(searchString)
      var wikiApiUrl = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&list=&titles=Main+Page%7CFksdlfsdss%7CTalk%3A&generator=search&exsentences=1&exlimit=10&exintro=1&explaintext=1&gsrsearch=" + searchString + "&gsrnamespace=0&gsrlimit=10&callback=?";
      $("div.destory").remove();
    // Get JSON Data
      $.getJSON(wikiApiUrl, function(data){
        var test = "";
   // for loop to append data to html
        for (i = 0; i <= 10; i++) {
          // Object.keys is use since we do not know the page id to access its properties 
          test = Object.keys(data.query.pages)[i];
          //Dont forget about escape characters, maing var = link took FOREVER before I realize I needed escape characters
          var link = "\"http://en.wikipedia.org/wiki?curid=" + data.query.pages[test].pageid + "\"";
          console.log(link);
          $(".main-content .wrapper").append("<div id =" + i + " class = 'destory wikipedia-result'" + "/></a");
          $('#' + i).append("<div class='wikipedia-result--top'><a href=" + link + " target=\_blank\">" + data.query.pages[test].title + "</a></div>");
          $('#' + i).append("<div class='wikipedia-result__main'><p>" + data.query.pages[test].extract + "</p>")
        }
       })
    })
  })


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

Console