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.

            
              <link href="https://fonts.googleapis.com/css?family=Ultra" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Kalam" rel="stylesheet" type="text/css"> 
<link href=" https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<body>
    
  <form action="#" >
    <div class="container-fluid" id="table">
    <div class="row text-center">
      <div class="col-md-6" id="searchzone">
        <h1>What would you like to know about today?</h1>
        <img id="magnifier" src="http://res.cloudinary.com/dg45lvfuu/image/upload/v1508608886/magnifier_vjpipy.png" onclick="showSearch()">
    
      </div>
    <div class="col-md-6 text-center">
      <h1>Or read a random article:</h1>
      <br>
      <button type="button" onclick="randomArticle()"><i class="fa fa-search"></i>Read an article</button>
    </div>
</div>
</div>
   <DIV id="showSearchResult"></DIV>   
        
  </form>
<h6 class="textcenter">Made by
                <a href="https://www.ionvarsescu.tk" target="_blank">Ion V.</a>
            </h6>


<!--just for tests
 <p id="searchterm"></p>
<p id="searchterm" onclick="testValues()"></p>

-->
</body>
            
          
!
            
              body{
  background-color:#d7c262;
}
input[type=search]{
  margin:5px auto 0 auto;
  width:60%;
  min-width:100px;
  background-color:#66571b;
  border:double;
  border-radius: 15px;
    }
input:hover{
    background-color:#9d1cd8;
  }
input:focus{
  background-color:#f46841;
}
button[type=button] {
  position:relative;
    width:100px;
  margin:auto;
  margin-top:10px;
  padding      : 5px;
  border       : 2px solid #333;
  border-radius: 15px;
  cursor: pointer;
  transition:1s;
}

button:hover,
button:focus {
  color:red;
  width:150px;
  
}
#buttonX{
  position:relative;
  color:black;
  weight: bold;
  font-size:1.5em;
  border:none;
  float:right;
  margin:0px -30px 50px 50px;
  padding:10px;
}
#buttonX:hover,
#buttonX:focus
{
  color:red;
  width:3em;
  font-size:1.7em;
    }
#searcharea {
  position: relative;
  margin:auto;
  width:45%;
  background-color:#d7c262;
  }

input[type=textarea]{
  display: absolute;
  width:50%;
  margin-top:10px;
  padding      : 5px;
  border       : 2px solid #333;
   }

#showSearchResult{
  display:inherit;
  padding:10px;
  background-color:#d7c262;
  position: relative;
  margin:auto;
  width:100%;
   -webkit-columns: 2 200px;
     -moz-columns: 2 200px;
          columns: 2 200px;
  /*best usage of columns :
  http://bengillies.tiddlyspace.com/masonry.css
  */
  }
.newresult{
  padding:20px;
  background-color:#722500;
  width:100%;
   border-radius:20%;
 margin:10px auto 15px auto;
  color:#d7c262;
}

}
.images{
  float: left;
  margin:3px;
  }
a:hover, a:visited, a:link, a:active
{
    text-decoration: none;
}


.ui-autocomplete {
float:right;    position:absolute;
    top: 100%;
    right: 10px;
    z-index: 1000;
    display: block;
    min-width: 160px;   
    padding: 10px 50px;
    margin: 50px;
    list-style-type: square;
    border-color: #ccc;
    border-color: rgba(0, 0, 0, 0.2);
    border-style: solid;
    border-width: 3px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    transition:all 2s ease;
   background: linear-gradient(to right, red 30%, green 60%, blue);
    background-size: 200% 100%;
    background-position:left bottom;
    }
.ui-autocomplete:hover{
  background-position:right bottom;
}

.ui-state-active { 
  color: #ffffff;
    text-decoration: underline;
    
    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
   
  display: inline-block;
  -webkit-background-clip: padding-box;
    -moz-background-clip: padding;
    background-clip: padding-box;
    *border-right-width: 2px;
    *border-bottom-width: 2px;
  
  background: linear-gradient(to left, orange 50%, blue 50%);
   background-size: 200% 100%;
    background-position:right bottom;
  transition:all 2s ease;
}

.ui-state-active:hover{ 
  background-position:left bottom;
    
}

/*hide the helper comment of autocomplete without deleting it thus allowing screen readers to use it */
.ui-helper-hidden-accessible {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

.textcenter {
  text-align:center;
}
            
          
!
            
              var searchScreen='<fieldset id="searcharea">\
    <input type="search" placeholder="Type your querry here" results=5 id="searchBox" name="search_Box" autocomplete="off"></input>\
<button type="button" id="buttonX" onclick="closeSearch()" style="position:absolute;top:2px;right:16px;">X</button>\
<button type="button" onclick="myFunction(),getResultsFromWiki()"><i class="fa fa-search"></i>Search</button>\
    <br>\
    <input type="textarea" id="textOut" readonly></input>\
    </fieldset>'

var magnifierImg='<img id="magnifier" src="http://res.cloudinary.com/dg45lvfuu/image/upload/v1508608886/magnifier_vjpipy.png" onclick="showSearch()">'

var showResults='<DIV id="showSearchResult"></DIV>'


function showSearch(){
  $('#searchzone').append(searchScreen);
 // $('#searchterm').append();for tests
  $('#magnifier').remove();
  $('#buttonX').removeClass();
  
 
    
  /*start of autocomplete working*/
$("#searchBox").autocomplete({

	    source: function(request, response) {	        $.ajax({
	            url: "https://en.wikipedia.org/w/api.php",
	            dataType: "jsonp",
	            data: {
	                'action': "opensearch",
	                'format': "json",                                           
	                'search': request.term
	            },
	            success: function(data) {
	                response(data[1]);
	            }
	        });
	    }
	});
  
/*end of autocomplete working  
learned from here:
https://w3lessons.info/2015/03/01/autocomplete-search-using-wikipedia-api-and-jquery-ui/
*/
  
};
function closeSearch(){
  $('#searchzone').append(magnifierImg);
  $('#searcharea').remove();
  $('#showSearchResult').remove();
  //$('#searchterm').remove(); for tests
  $('#table').after(showResults);
};


//start use ENTER to search

document.querySelector('form').onkeydown = function(event){
  if (event.key === "Enter") {
        const keyName = event.key;
    myFunction();
    getResultsFromWiki();
    $(".ui-autocomplete").hide();
  /*alert('keydown event\n\n' + 'key: ' + keyName);*   --> for test*/
    }};

//end use Enter to search


var searchTerm="";
var y="";
function myFunction() {
 searchTerm=document.getElementById("searchBox").value;
    document.getElementById("textOut").placeholder = searchTerm;
  /*document.getElementById("searchterm").innerHTML = searchTerm;       -> for tests*/
  }


function getResultsFromWiki(){
  var searchWord="";
  var definitie=[];
  var titlu=[];
  var total="";
  searchWord=searchTerm;
  
 var urlLink="https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch="+searchWord+"&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max";
  
  
  $.ajax({
  url: urlLink,
  dataType: 'jsonp',
  type:'get',
  headers: { 'Api-User-Agent': 'Nei_V' },  
  success: function (data) {
    var i=0;
    var definitie=data.query.pages;    
    var places=Object.keys(definitie);    
    while (i<places.length){
      var imageLink=definitie[places[i]].thumbnail;      
      console.log(imageLink);
      if (imageLink !== undefined) {
      total+="<a href=https://en.wikipedia.org/?curid="+definitie[places[i]].pageid+" target='_blank'>"+"<P class='newresult'><img src='"+imageLink.source+"' class='images'>"+definitie[places[i]].title+" -  "+definitie[places[i]].extract+"</P></a>";
      }
      else {
      total+="<a href=https://en.wikipedia.org/?curid="+definitie[places[i]].pageid+" target='_blank'>"+"<P class='newresult'><img src='#' class='images'> "+definitie[places[i]].title+" -  "+definitie[places[i]].extract+"</P></a>";
      }
      i++;
        }
         document.getElementById("showSearchResult").innerHTML=total;
  }
    
});
  
}
/*for tests
function testValues(){
  y=searchTerm;
  alert(y);
}
*/
 

function randomArticle() {
  window.open(
  'https://en.wikipedia.org/wiki/Special:Random',
  '_blank');
}

 

            
          
!
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