Created
February 7, 2017 21:15
-
-
Save furball514/e851a6ed6e9ddc05bbc250c926d840d4 to your computer and use it in GitHub Desktop.
Wikipedia Viewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> <meta name="author" content="Karthik"> | |
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Sorts+Mill+Goudy"> | |
</head> | |
<body> | |
<div class="container"> | |
<h1> wikipedia viewer </h1> | |
<a href="https://en.wikipedia.org/wiki/Special:Random" | |
target="_blank"> <button id="gen" class="btn btn-default btn-block"> <span class="fa fa-wikipedia-w"> Generate Random Article </span> </button> </a> | |
<div class="row well jig"> <div class="col-md-8"> <input type="text" class="form-control" placeholder="Search Wikipedia For Articles" id="searchInput"> | |
</div> <div class="col-md-1"> <button type="submit" class="btn" id="searchbtn"> <span class="fa fa-search"> </span> </button> | |
</div> </div> | |
<br> </br> | |
<ul class="fa fa-ul" id="searchOutput"> </ul> | |
</div> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main () { | |
$('#searchbtn').click(function(){ | |
var searchInput = $('#searchInput').val(); | |
var appkey ="https://en.wikipedia.org/w/api.php?action=opensearch&search="+searchInput+ "&format=json&callback=?"; | |
//'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&uselang=user&search='+searchInput ; | |
//alert(searchInput); | |
/* $.getJSON(appkey,function(wiki){ | |
$('#searchOutput').html(''); | |
for (var i=0;i<wiki[1].length;i++) | |
{ $('#searchOutput').prepend("<li>"+ wiki[1][i] + "<p>"+ wiki[2][i] + "</p>" +"<a href= "+ wiki[3][i] +" > Read More </a>" +"</li>");}*/ | |
//alert(appkey); | |
//}); | |
$.ajax({type:"GET", | |
url: appkey, | |
async: false, | |
dataType: "json", | |
success: function(wiki){$('#searchOutput').html(''); | |
for (var i=0;i<wiki[1].length;i++) | |
{ $('#searchOutput').prepend("<li>"+ "<u>" + wiki[1][i] + "</u>" + "<p>"+ wiki[2][i] +"<a href= "+ wiki[3][i] +" > Read More </a>" + "</p>"+ "</li>");}}, | |
error: function(){alert("Unable To Reach :(,try again later");} | |
}); | |
}); | |
} | |
$(document).ready(main); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*{margin:0; | |
padding:0; | |
box-sizing: border-box;} | |
body {background:url("https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1122px-Wikipedia-logo-v2.svg.png") no-repeat center;} | |
h1 {text-transform:uppercase; | |
text-align:center; | |
margin:auto; | |
font-family:'Sorts Mill Goudy',serif; | |
font-size:5.7em;} | |
#gen {font-size:1.7em; | |
background-image:-webkit-linear-gradient(#6B6B6B, #F8F8F8);} | |
/*#search {display:block;}*/ | |
.jig {margin:auto; | |
} | |
#searchbtn {background-image:-webkit-linear-gradient(#6B6B6B, #F8F8F8); | |
font-family:'Sorts Mill Goudy',serif; | |
font-weight: bold; | |
font-size: 1.2em;} | |
#searchOutput {font-size:1.5em; | |
font-family:sans-serif; | |
color:Green} | |
u {color:DarkOrange; | |
font-weight:bold;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment