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.

            
              <!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Wikipedia Viewer</title>
        <link rel="stylesheet" type="text/css" href="main.css">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
    </head>
    <body>
        <div class="container">
          <div class="justify-content-center text-center row">
            <div class="col-md-10">
              <h1>Wikipedia Viewer App</h1>
              <br>
              <form>
                <div class="row justify-content-center form-group">
                  <div class="col-md-8">
                    <input id="searchBar" class="form-control" type="search" name="search" placeholder="search">
                  </div>
                  <div class="col-md-4">
                    <button id="searchButton" class="btn btn-primary" type="submit" name="submit">Search</button>
                    <button id="random" type="submit" name="button" class="btn btn-primary">Random Article</button>
                  </div>
                </div>
              </form>

              <div id="group" class="list-group">

                <a   id="list0" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header0" class="mb-1"></h5>
                  </div>
                  <p id="description0" class="mb-1"> </p>

                </a>

                <a   id="list1" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header1" class="mb-1"></h5>
                  </div>
                  <p id="description1" class="mb-1"> </p>

                </a>

                <a   id="list2" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header2" class="mb-1"></h5>
                  </div>
                  <p id="description2" class="mb-1"> </p>

                </a>

                <a   id="list3" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header3" class="mb-1"></h5>
                  </div>
                  <p id="description3" class="mb-1"> </p>

                </a>

                <a   id="list4" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header4" class="mb-1"></h5>
                  </div>
                  <p id="description4" class="mb-1"> </p>

                </a>

                <a   id="list5" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header5" class="mb-1"></h5>
                  </div>
                  <p id="description5" class="mb-1"> </p>

                </a>

                <a   id="list6" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header6" class="mb-1"></h5>
                  </div>
                  <p id="description6" class="mb-1"> </p>

                </a>

                <a   id="list7" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header7" class="mb-1"></h5>
                  </div>
                  <p id="description7" class="mb-1"> </p>

                </a>

                <a   id="list8" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header8" class="mb-1"></h5>
                  </div>
                  <p id="description8" class="mb-1"> </p>
                  <small class="text-muted"></small>
                </a>

                <a   id="list9" class="list-group-item list-group-item-action flex-column align-items-start">
                  <div class="d-flex w-100 justify-content-between">
                    <h5 id="header9" class="mb-1"></h5>
                  </div>
                  <p id="description9" class="mb-1"> </p>
                  <small class="text-muted"></small>
                </a>

              </div>

            </div>
          </div>
        </div>
        <br><br>
        <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script type="text/javascript" src="main.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
    </body>
</html>

            
          
!
            
              body{
  background-image: linear-gradient( 135deg, #FAB2FF 10%, #1904E5 100%);
  min-height: 100vh;
}

.text{
  color: #c3073f;
}

.white{
  color: white;
}
            
          
!
            
              $(document).ready(function() {
    $('#group').hide();
    //random article wikipedia generator
    var randomArticleLink = "https://en.wikipedia.org/wiki/Special:Random";

    //Opens a wikipedia article at random
    $("#random").click(function() {
      //prevents page from reloading
      event.preventDefault();
      window.open(randomArticleLink);
    });

    //loops through the title array
    function titleLoop(array){
        for(var i = 0; i<array[1].length; i++){
            $('#header' + i).html(array[1][i]);
        }
    }

    //loops through the description array
    function descriptionLoop(array){
        for(var i=0; i<array[2].length; i++){
            $('#description' + i).html(array[2][i]);
        }
    }

    //loops through the links array
    function listLoop(array){
        for(var i=0; i<array[3].length; i++){
            $('#list'+i).attr({'href': array[3][i], 'target': '_blank'});
        }
    }


    //retrieves search results on click
    $('#searchButton').click(function(event) {
        //prevents page from reloading
        event.preventDefault();
        //shows results
        $('#group').slideDown();
        //selects data in search bar
        var userInput = $('#searchBar').val();
        //imports user input into api call
        var wikiApi = 'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&requestid=&search='
        + encodeURIComponent(userInput) + '&namespace=&profile=fuzzy&origin=*';
        //gets json data from Wikipedia
        $.getJSON(wikiApi, function(json) {
            titleLoop(json);
            descriptionLoop(json);
            listLoop(json);
        });
    });

});

            
          
!
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