FreeCodeCamp : Build a Wikipedia Viewer

What is a freecodecamp : build a wikipedia viewer How do you make a freecodecamp : build a wikipedia viewer? This script and codes were developed by Markku Lehmonen on 03 February 2022, Thursday.

How do I make an freecodecamp : build a wikipedia viewer?
  1. FreeCodeCamp : Build a Wikipedia Viewer Previews
  2. FreeCodeCamp : Build a Wikipedia Viewer HTML Codes
  3. FreeCodeCamp : Build a Wikipedia Viewer CSS Codes
  4. FreeCodeCamp : Build a Wikipedia Viewer JS Codes
FreeCodeCamp : Build a Wikipedia Viewer Previews

FreeCodeCamp : Build a Wikipedia Viewer HTML Codes

<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>FreeCodeCamp : Build a Wikipedia Viewer</title>
  
  
  <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300'>

      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>
  <div class="container">
  <div class="row testBorder">
    <div class="col-xs-12 testBorder">
      <h1 class="text-center">Wikipedia Machine</h1>
    </div>
  </div>
  <div class="row testBorder">
    <div class="col-xs-8 col-xs-offset-1 testBorder">
      <div class="input-group">
        <input id="textSearch"  type="text" class="form-control" placeholder="Search...">
        <span class="input-group-btn">
          <button id="buttonSearch" class="btn btn-default" type="button">
            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
          </button>
        </span>
      </div>
    </div>
    <div class="col-xs-1 testBorder">
      <div id="separator" class="center-block"></div>
    </div>
    <div class="col-xs-1 testBorder">
      <button id="buttonRandom" class="btn btn-default dice" type="button">
        <div id="diceLayout">
          <div class="dot dotLeft"></div>
          <div class="dot dotRight"></div>
          <div class="dot dotLeft"></div>
          <div class="dot dotRight"></div>
                    <div class="dot dotLeft"></div>
          <div class="dot dotRight"></div>
        </div>
      </button>
    </div>
  </div>
  <div class="row">
    <div id="output" class="col-xs-12"></div>
  </div>
</div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js'></script>

    <script src="js/index.js"></script>

</body>
</html>

FreeCodeCamp : Build a Wikipedia Viewer CSS Codes

body { min-height:100vh; display:flex; align-items:center; font-family:calibri; color:#444444; }
.testBorder { /*border:1px solid red;*/ }
.container { width:500px; }
.dice {height:34px; width:34px;}
h1 {margin-bottom:35px; font-size:45px; font-weight:lighter; font-family:"Open Sans Condensed", sans-serif; color:#888888; user-select:none; cursor:default; }
span {color:#888888;}
#separator { margin-top:-10px; height:55px; width:0px; border:1px dashed #bbbbbb; }
#output {padding-top:50px;}
h4 {margin-bottom:0px; padding:0px; font-weight:bold;}
p {margin-bottom:25px;}

#diceLayout {position:relative; top:-7px; right:13px; height:34px; width:34px; }
.dot { width:6px; height:6px; border:1px solid #888888; display:block; border-radius:3px; background-color:#888888; }
.dotLeft {margin:5px 5px -2px 6px; float:left;}
.dotRight {margin:5px 6px -2px 5px; float:right;}

FreeCodeCamp : Build a Wikipedia Viewer JS Codes

$(document).ready(function() {
  
  $("#buttonRandom").click(random);
  $("#buttonSearch").click(search);
  $("#textSearch").bind("enterKey", search);
  $("#textSearch").keyup(function(e){
      if(e.keyCode == 13)
      {
          $(this).trigger("enterKey");
      }
  });
  
});


function random() {
  window.open("https://en.wikipedia.org/wiki/Special:Random");
  return false;
}

function search() {
   
  var searchStr = $("#textSearch").val();
  if (searchStr !== "") {
    var url = "https://en.wikipedia.org/w/api.php?";
    var queryData = "action=opensearch&search="+ searchStr +"&format=json&callback=?";

    $.ajax( {
      url: url,
      data: queryData,
      dataType: 'json', // TODO: 'json'
      type: 'POST',
      headers: { 'Api-User-Agent': 'Example/1.0' },
      success: function(data) {

        $("#output").empty();
        $("#textSearch").val("");

        if(data[1].length > 0){
          for(var i = 0; i < data[1].length; i++) {
            $("#output").append("<h4>" + data[1][i] + " <small><a href='" + data[3][i] + "' target='_blank'>Read more</a></small>" + "</h4>");
            $("#output").append("<p>"+ data[2][i]);
          }
        }else {
          $("#output").html("<p class='text-center'>No results were found.</p>");
        }

      }
    });
  }
}
Do you want hide your ip address?Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup.