-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
20 lines (20 loc) · 883 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$(document).ready(function(){
$(document).keypress(function(e) {
if(e.which == 13)
{
var webLink = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch="+document.getElementById("search").value+"&utf8=&format=json";
$.ajax({
url: webLink,
dataType: "jsonp",
success: function(data) {
$("div").remove(".searchResult");
for(i=0;i<data.query.search.length;i++){
var titleForResult = data.query.search[i].title;
var snippetForResult = data.query.search[i].snippet;
$("#searchBox").append("<a href=\"https://en.wikipedia.org/wiki/"+titleForResult+"\" target=\"_blank\"style=\"text-decoration:none\"><div class=\"searchResult\"><span class=\"searchTitle\">"+titleForResult+"</span><span><br />"+snippetForResult+"</span></div></a>");
}
}
});
}
});
});